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
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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
  9. FLAGS += -Wall -Wextra -Wno-unused-parameter
  10. CXXFLAGS += -Wsuggest-override
  11. CXXFLAGS += -std=c++11
  12. ifeq ($(ARCH), lin)
  13. FLAGS += -DARCH_LIN
  14. endif
  15. ifeq ($(ARCH), mac)
  16. FLAGS += -DARCH_MAC
  17. CXXFLAGS += -stdlib=libc++
  18. LDFLAGS += -stdlib=libc++
  19. MAC_SDK_FLAGS = -mmacosx-version-min=10.7
  20. FLAGS += $(MAC_SDK_FLAGS)
  21. LDFLAGS += $(MAC_SDK_FLAGS)
  22. endif
  23. ifeq ($(ARCH), win)
  24. FLAGS += -DARCH_WIN
  25. FLAGS += -D_USE_MATH_DEFINES
  26. endif
  27. OBJECTS += $(patsubst %, build/%.o, $(SOURCES))
  28. DEPS = $(patsubst %, build/%.d, $(SOURCES))
  29. # Final targets
  30. $(TARGET): $(OBJECTS)
  31. $(CXX) -o $@ $^ $(LDFLAGS)
  32. # Object targets
  33. -include $(DEPS)
  34. build/%.c.o: %.c
  35. @mkdir -p $(@D)
  36. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<
  37. build/%.cpp.o: %.cpp
  38. @mkdir -p $(@D)
  39. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  40. build/%.cc.o: %.cc
  41. @mkdir -p $(@D)
  42. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  43. build/%.m.o: %.m
  44. @mkdir -p $(@D)
  45. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<