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 936B

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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
  19. FLAGS += -D_USE_MATH_DEFINES
  20. endif
  21. OBJECTS += $(patsubst %, build/%.o, $(SOURCES))
  22. DEPS = $(patsubst %, %.d, $(OBJECTS))
  23. # Final targets
  24. $(TARGET): $(OBJECTS)
  25. $(CXX) -o $@ $^ $(LDFLAGS)
  26. # Object targets
  27. -include $(DEPS)
  28. build/%.c.o: %.c
  29. @mkdir -p $(@D)
  30. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<
  31. build/%.cpp.o: %.cpp
  32. @mkdir -p $(@D)
  33. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  34. build/%.cc.o: %.cc
  35. @mkdir -p $(@D)
  36. $(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $<
  37. build/%.m.o: %.m
  38. @mkdir -p $(@D)
  39. $(CC) $(FLAGS) $(CFLAGS) -c -o $@ $<