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