]> git.localhorst.tv Git - gworm.git/blob - build/gworm.mk
basic gravity calculations
[gworm.git] / build / gworm.mk
1 GWORM_DIRS := $(shell cd $(TOP) && find src -type d)
2 GWORM_SRCS := $(shell cd $(TOP) && find src -type f -name '*.cpp')
3 GWORM_DEPS = $(GWORM_SRCS:%.cpp=%.d)
4 GWORM_OBJS = $(GWORM_SRCS:%.cpp=%.o)
5 GWORM_EXES = gworm
6
7 GWORM_TEST_DIRS := $(shell cd $(TOP) && find tests -type d)
8 GWORM_TEST_SRCS := $(shell cd $(TOP) && find tests -type f -name '*.cpp')
9 GWORM_TEST_DEPS := $(GWORM_TEST_SRCS:%.cpp=%.d)
10 GWORM_TEST_OBJS := $(GWORM_TEST_SRCS:%.cpp=%.o)
11 GWORM_TEST_EXES := test-all
12
13 GWORM_FLAGS = $(strip \
14                 $(SDL_FLAGS) \
15                 )
16 GWORM_LIBS = $(strip \
17                 $(SDL_LIBS) \
18                 )
19
20 GWORM_TEST_FLAGS = $(GWORM_FLAGS) $(CPPUNIT_FLAGS)
21 GWORM_TEST_LIBS = $(GWORM_LIBS) $(CPPUNIT_LIBS)
22
23 -include $(GWORM_DEPS)
24 -include $(GWORM_TEST_DEPS)
25
26 $(GWORM_OBJS): %.o: $(TOP)/%.cpp
27         -@$(MKDIR) "$(@D)"
28         @echo "compile: $@"
29         $(VERBOSE) $(CXX) -c -o "$@" -MMD -MP -MF"$*.d" -MT"$@" "$<" \
30                         $(GWORM_FLAGS) $(CPPFLAGS) $(CXXFLAGS)
31
32 $(GWORM_EXES): $(GWORM_OBJS)
33         -@$(MKDIR) "$(@D)"
34         @echo "link: $@"
35         $(VERBOSE) $(CXX) -o "$@" $^ \
36                         $(GWORM_FLAGS) $(GWORM_LIBS) $(LDFLAGS)
37
38 $(GWORM_TEST_OBJS): %.o: $(TOP)/%.cpp
39         -@$(MKDIR) "$(@D)"
40         @echo "compile: $@"
41         $(VERBOSE) $(CXX) -c -o "$@" -MMD -MP -MF"$*.d" -MT"$@" "$<" \
42                         $(GWORM_TEST_FLAGS) $(CPPFLAGS) $(CXXFLAGS)
43
44 $(GWORM_TEST_EXES): $(GWORM_TEST_OBJS) $(filter-out src/main.o, $(GWORM_OBJS))
45         -@$(MKDIR) "$(@D)"
46         @echo "link: $@"
47         $(VERBOSE) $(CXX) -o "$@" $^ \
48                         $(GWORM_TEST_FLAGS) $(GWORM_TEST_LIBS) $(LDFLAGS)
49
50 gworm-all: $(GWORM_EXES)
51
52 gworm-clean:
53         $(VERBOSE) -$(RM) $(GWORM_DEPS)
54         $(VERBOSE) -$(RM) $(GWORM_OBJS)
55         $(VERBOSE) -$(RM) $(GWORM_EXES)
56         $(VERBOSE) -$(RM) $(GWORM_TEST_DEPS)
57         $(VERBOSE) -$(RM) $(GWORM_TEST_OBJS)
58         $(VERBOSE) -$(RM) $(GWORM_TEST_EXES)
59         $(VERBOSE) -$(RMDIR) $(GWORM_DIRS)
60         $(VERBOSE) -$(RMDIR) $(GWORM_TEST_DIRS)
61
62 gworm-tests: $(GWORM_TEST_EXES)
63
64 gworm-test-all: test-all
65         @echo "test: test-all"
66         $(VERBOSE) ./test-all
67
68 all: gworm-all
69 clean: gworm-clean
70 tests: gworm-tests
71 test: gworm-test-all
72
73 .PHONY: gworm-all gworm-clean gworm-tests gworm-test-all
74
75 -include $(BUILD)gworm-local.mk