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.

64 lines
1.1KB

  1. ifdef VERSION
  2. FLAGS += -DVERSION=$(VERSION)
  3. endif
  4. # Generate dependency files alongside the object files
  5. FLAGS += -MMD
  6. FLAGS += -g
  7. # Optimization
  8. FLAGS += -O3 -march=nocona -ffast-math -fno-finite-math-only
  9. FLAGS += -Wall -Wextra -Wno-unused-parameter
  10. ifneq ($(ARCH), mac)
  11. CXXFLAGS += -Wsuggest-override
  12. endif
  13. CXXFLAGS += -std=c++11
  14. ifeq ($(ARCH), lin)
  15. FLAGS += -DARCH_LIN
  16. endif
  17. ifeq ($(ARCH), mac)
  18. FLAGS += -DARCH_MAC
  19. CXXFLAGS += -stdlib=libc++
  20. LDFLAGS += -stdlib=libc++
  21. MAC_SDK_FLAGS = -mmacosx-version-min=10.7
  22. FLAGS += $(MAC_SDK_FLAGS)
  23. LDFLAGS += $(MAC_SDK_FLAGS)
  24. endif
  25. ifeq ($(ARCH), win)
  26. FLAGS += -DARCH_WIN
  27. FLAGS += -D_USE_MATH_DEFINES
  28. endif
  29. OBJECTS += $(patsubst %, build/%.o, $(SOURCES))
  30. DEPS = $(patsubst %, build/%.d, $(SOURCES))
  31. # Final targets
  32. $(TARGET): $(OBJECTS)
  33. $(CXX) -o $@ $^ $(LDFLAGS)
  34. # Object targets
  35. -include $(DEPS)
  36. build/%.c.o: %.c
  37. @mkdir -p $(@D)
  38. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<
  39. build/%.cpp.o: %.cpp
  40. @mkdir -p $(@D)
  41. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  42. build/%.cc.o: %.cc
  43. @mkdir -p $(@D)
  44. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  45. build/%.m.o: %.m
  46. @mkdir -p $(@D)
  47. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<