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.

55 lines
926B

  1. VERSION ?= dev
  2. FLAGS += -DVERSION=$(VERSION)
  3. # Generate dependency files alongside the object files
  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. FLAGS += -DARCH_LIN
  11. endif
  12. ifeq ($(ARCH), mac)
  13. FLAGS += -DARCH_MAC
  14. CXXFLAGS += -stdlib=libc++
  15. LDFLAGS += -stdlib=libc++
  16. endif
  17. ifeq ($(ARCH), win)
  18. FLAGS += -DARCH_WIN -D_USE_MATH_DEFINES
  19. endif
  20. OBJECTS += $(patsubst %, build/%.o, $(SOURCES))
  21. DEPS = $(patsubst %, %.d, $(OBJECTS))
  22. # Final targets
  23. $(TARGET): $(OBJECTS)
  24. $(CXX) -o $@ $^ $(LDFLAGS)
  25. # Object targets
  26. -include $(DEPS)
  27. build/%.c.o: %.c
  28. @mkdir -p $(@D)
  29. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<
  30. build/%.cpp.o: %.cpp
  31. @mkdir -p $(@D)
  32. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  33. build/%.cc.o: %.cc
  34. @mkdir -p $(@D)
  35. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  36. build/%.m.o: %.m
  37. @mkdir -p $(@D)
  38. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<