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.

compile.mk 1.1KB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. -include $(DEPS)
  35. build/%.c.o: %.c
  36. @mkdir -p $(@D)
  37. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<
  38. build/%.cpp.o: %.cpp
  39. @mkdir -p $(@D)
  40. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  41. build/%.cc.o: %.cc
  42. @mkdir -p $(@D)
  43. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  44. build/%.m.o: %.m
  45. @mkdir -p $(@D)
  46. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<