Makefile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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: docs
  35. git add docs/output
  36. git commit -m "docs: Automated update $$(date)"
  37. git subtree push --prefix docs/output origin gh-pages
  38. # Tests
  39. test: $(TEST_OUT)
  40. ./$(TEST_OUT)
  41. -include $(TEST_DEPS)
  42. $(TEST_OUT): $(TEST_OBJS)
  43. $(CXX) $(USELDFLAGS) -o$@ $(TEST_OBJS) $(USELDLIBS)
  44. $(TEST_DIR)/%.o: $(TEST_DIR)/%.cpp Makefile
  45. $(CXX) -c $(USECXXFLAGS) -MMD -MF$(@:%.o=%.d) -MT$@ -o$@ $<
  46. # Examples
  47. examples: $(EXAMPLE_OBJS)
  48. @for ex in $(EXAMPLE_OBJS); do echo "> Example '$$ex'"; ./$$ex; done
  49. -include $(EXAMPLE_DEPS)
  50. $(EXAMPLE_DIR)/%.out: $(EXAMPLE_DIR)/%.cpp Makefile
  51. $(CXX) $(USECXXFLAGS) $(USELDFLAGS) -MMD -MF$(<:%.cpp=%.d) -MT$@ -o$@ $< $(USELDLIBS)
  52. # Phony
  53. .PHONY: all clean docs test examples