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.

59 lines
1.0KB

  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 = -mmacosx-version-min=10.7
  17. FLAGS += $(MAC_SDK_FLAGS)
  18. LDFLAGS += $(MAC_SDK_FLAGS)
  19. endif
  20. ifeq ($(ARCH), win)
  21. FLAGS += -DARCH_WIN
  22. FLAGS += -D_USE_MATH_DEFINES
  23. endif
  24. OBJECTS += $(patsubst %, build/%.o, $(SOURCES))
  25. DEPS = $(patsubst %.o, %.d, $(OBJECTS))
  26. # Final targets
  27. $(TARGET): $(OBJECTS)
  28. $(CXX) -o $@ $^ $(LDFLAGS)
  29. # Object targets
  30. -include $(DEPS)
  31. build/%.c.o: %.c
  32. @mkdir -p $(@D)
  33. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<
  34. build/%.cpp.o: %.cpp
  35. @mkdir -p $(@D)
  36. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  37. build/%.cc.o: %.cc
  38. @mkdir -p $(@D)
  39. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  40. build/%.m.o: %.m
  41. @mkdir -p $(@D)
  42. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<