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.

58 lines
971B

  1. # Generate dependency files build/*.d
  2. FLAGS += -MMD
  3. # Optimization
  4. FLAGS += -O3 -march=core2 -ffast-math
  5. FLAGS += -g -Wall
  6. CXXFLAGS += -std=c++11
  7. ifeq ($(ARCH), lin)
  8. CC ?= gcc
  9. CXX ?= g++
  10. FLAGS += -DARCH_LIN
  11. endif
  12. ifeq ($(ARCH), mac)
  13. CC ?= clang
  14. CXX ?= clang++
  15. FLAGS += -DARCH_MAC
  16. CXXFLAGS += -stdlib=libc++
  17. LDFLAGS += -stdlib=libc++
  18. endif
  19. ifeq ($(ARCH), win)
  20. CC ?= x86_64-w64-mingw32-gcc
  21. CXX ?= x86_64-w64-mingw32-g++
  22. FLAGS += -DARCH_WIN -D_USE_MATH_DEFINES
  23. endif
  24. OBJECTS += $(patsubst %, build/%.o, $(SOURCES))
  25. DEPS = $(patsubst %, build/%.d, $(SOURCES))
  26. # Final targets
  27. $(TARGET): $(OBJECTS)
  28. $(CXX) -o $@ $^ $(LDFLAGS)
  29. # Object targets
  30. -include $(DEPS)
  31. build/%.c.o: %.c
  32. @mkdir -p $(@D)
  33. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<
  34. build/%.cpp.o: %.cpp
  35. @mkdir -p $(@D)
  36. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  37. build/%.cc.o: %.cc
  38. @mkdir -p $(@D)
  39. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  40. build/%.m.o: %.m
  41. @mkdir -p $(@D)
  42. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<