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.4KB

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