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.

66 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. CFLAGS += $(FLAGS)
  30. CXXFLAGS += $(FLAGS)
  31. OBJECTS += $(patsubst %, build/%.o, $(SOURCES))
  32. DEPS = $(patsubst %, build/%.d, $(SOURCES))
  33. # Final targets
  34. $(TARGET): $(OBJECTS)
  35. $(CXX) -o $@ $^ $(LDFLAGS)
  36. -include $(DEPS)
  37. build/%.c.o: %.c
  38. @mkdir -p $(@D)
  39. $(CC) $(CFLAGS) -c -o $@ $<
  40. build/%.cpp.o: %.cpp
  41. @mkdir -p $(@D)
  42. $(CXX) $(CXXFLAGS) -c -o $@ $<
  43. build/%.cc.o: %.cc
  44. @mkdir -p $(@D)
  45. $(CXX) $(CXXFLAGS) -c -o $@ $<
  46. build/%.m.o: %.m
  47. @mkdir -p $(@D)
  48. $(CC) $(CFLAGS) -c -o $@ $<