Makefile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Utilities
  2. RM = rm -rf
  3. CHDIR = cd
  4. EXEC = exec
  5. # Test artifacts
  6. TEST_DIR := tests
  7. TEST_OUT := $(TEST_DIR)/all
  8. TEST_SRCS := all.cpp auxiliary.cpp types.cpp stack.cpp functions.cpp usertypes.cpp
  9. TEST_DEPS := $(TEST_SRCS:%.cpp=$(TEST_DIR)/%.d)
  10. TEST_OBJS := $(TEST_SRCS:%.cpp=$(TEST_DIR)/%.o)
  11. # Example artifacts
  12. EXAMPLE_DIR := examples
  13. EXAMPLE_SRCS := types.cpp stack.cpp functions.cpp usertypes.cpp state.cpp
  14. EXAMPLE_DEPS := $(EXAMPLE_SRCS:%.cpp=$(EXAMPLE_DIR)/%.d)
  15. EXAMPLE_OBJS := $(EXAMPLE_SRCS:%.cpp=$(EXAMPLE_DIR)/%.out)
  16. # Lua-specific
  17. LUA_INCDIR = /usr/include
  18. LUA_LIBDIR = /usr/lib
  19. LUA_LIBNAME = lua
  20. # Compiler
  21. CXX ?= clang++
  22. USECXXFLAGS += $(CXXFLAGS) -std=c++11 -O0 -g -DDEBUG -fmessage-length=0 -Wall -Wextra \
  23. -pedantic -D_GLIBCXX_USE_C99 -Ilib -I$(LUA_INCDIR) -Ideps/catch/include
  24. USELDFLAGS += $(LDFLAGS) -L$(LUA_LIBDIR)
  25. USELDLIBS += $(LDLIBS) -lm -l$(LUA_LIBNAME) -ldl
  26. # Default targets
  27. all: test examples
  28. clean:
  29. $(RM) $(EXAMPLE_OBJS) $(EXAMPLE_DEPS) $(TEST_OUT) $(TEST_OBJS) $(TEST_DEPS)
  30. # Documentation
  31. docs:
  32. mkdocs build --clean
  33. doxygen
  34. push-gh-pages:
  35. git subtree push --prefix docs/output origin gh-pages
  36. # Tests
  37. test: $(TEST_OUT)
  38. ./$(TEST_OUT)
  39. -include $(TEST_DEPS)
  40. $(TEST_OUT): $(TEST_OBJS)
  41. $(CXX) $(USELDFLAGS) -o$@ $(TEST_OBJS) $(USELDLIBS)
  42. $(TEST_DIR)/%.o: $(TEST_DIR)/%.cpp Makefile
  43. $(CXX) -c $(USECXXFLAGS) -MMD -MF$(@:%.o=%.d) -MT$@ -o$@ $<
  44. # Examples
  45. examples: $(EXAMPLE_OBJS)
  46. @for ex in $(EXAMPLE_OBJS); do echo "> Example '$$ex'"; ./$$ex; done
  47. -include $(EXAMPLE_DEPS)
  48. $(EXAMPLE_DIR)/%.out: $(EXAMPLE_DIR)/%.cpp Makefile
  49. $(CXX) $(USECXXFLAGS) $(USELDFLAGS) -MMD -MF$(<:%.cpp=%.d) -MT$@ -o$@ $< $(USELDLIBS)
  50. # Phony
  51. .PHONY: all clean docs test examples