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.

61 lines
1017B

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