You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.1KB

  1. VERSION ?= dev
  2. FLAGS += -DVERSION=$(VERSION)
  3. # Generate dependency files alongside the object files
  4. FLAGS += -MMD
  5. # Optimization
  6. FLAGS += -O3 -march=core2 -ffast-math
  7. FLAGS += -g -Wall
  8. CXXFLAGS += -std=c++11
  9. ifeq ($(ARCH), lin)
  10. FLAGS += -DARCH_LIN
  11. endif
  12. ifeq ($(ARCH), mac)
  13. FLAGS += -DARCH_MAC
  14. CXXFLAGS += -stdlib=libc++
  15. LDFLAGS += -stdlib=libc++
  16. MAC_SDK_FLAGS = -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk \
  17. -mmacosx-version-min=10.7
  18. FLAGS += $(MAC_SDK_FLAGS)
  19. LDFLAGS += $(MAC_SDK_FLAGS)
  20. endif
  21. ifeq ($(ARCH), win)
  22. FLAGS += -DARCH_WIN
  23. FLAGS += -D_USE_MATH_DEFINES
  24. endif
  25. OBJECTS += $(patsubst %, build/%.o, $(SOURCES))
  26. DEPS = $(patsubst %, %.d, $(OBJECTS))
  27. # Final targets
  28. $(TARGET): $(OBJECTS)
  29. $(CXX) -o $@ $^ $(LDFLAGS)
  30. # Object targets
  31. -include $(DEPS)
  32. build/%.c.o: %.c
  33. @mkdir -p $(@D)
  34. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<
  35. build/%.cpp.o: %.cpp
  36. @mkdir -p $(@D)
  37. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  38. build/%.cc.o: %.cc
  39. @mkdir -p $(@D)
  40. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  41. build/%.m.o: %.m
  42. @mkdir -p $(@D)
  43. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<