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.

76 lines
1.4KB

  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))
  38. DEPENDENCIES := $(patsubst %, build/%.d, $(SOURCES))
  39. # Final targets
  40. $(TARGET): $(OBJECTS)
  41. $(CXX) -o $@ $(OBJECTS) $(LDFLAGS)
  42. -include $(DEPENDENCIES)
  43. build/%.c.o: %.c | dep
  44. @mkdir -p $(@D)
  45. $(CC) $(CFLAGS) -c -o $@ $<
  46. build/%.cpp.o: %.cpp | dep
  47. @mkdir -p $(@D)
  48. $(CXX) $(CXXFLAGS) -c -o $@ $<
  49. build/%.cc.o: %.cc | dep
  50. @mkdir -p $(@D)
  51. $(CXX) $(CXXFLAGS) -c -o $@ $<
  52. build/%.m.o: %.m | dep
  53. @mkdir -p $(@D)
  54. $(CC) $(CFLAGS) -c -o $@ $<
  55. # Do nothing by default
  56. dep:
  57. .PHONY: dep