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) -DVERSION_$(subst .,_,$(VERSION))
  3. # Generate dependency files alongside the object files
  4. FLAGS += -MMD
  5. # Optimization
  6. FLAGS += -O3 -march=nocona -ffast-math
  7. FLAGS += -Wall
  8. FLAGS += -g
  9. CXXFLAGS += -std=c++11
  10. ifeq ($(ARCH), lin)
  11. FLAGS += -DARCH_LIN
  12. endif
  13. ifeq ($(ARCH), mac)
  14. FLAGS += -DARCH_MAC
  15. CXXFLAGS += -stdlib=libc++
  16. LDFLAGS += -stdlib=libc++
  17. MAC_SDK_FLAGS = -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 %, build/%.d, $(SOURCES))
  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 $@ $<