-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
78 lines (59 loc) · 1.74 KB
/
makefile
File metadata and controls
78 lines (59 loc) · 1.74 KB
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
68
69
70
71
72
73
74
75
76
77
# ==============================================================================
# Basic building and testing.
#
# author: Markus Saers <masaers@gmail.com>
# ==============================================================================
#
# Settings
#
CXXFLAGS+=-Wall -pedantic -std=c++11 -g -O3
LDFLAGS=
PROG_NAMES=
TEST_NAMES=pointer_union_test polyset_test
#
# Derived settings
#
# List of binaries that needs to be built
BIN_NAMES=$(PROG_NAMES) $(TEST_NAMES)
# Object files are c++ sources that do not result in stand alone binaries
OBJECTS=$((filter-out $(BIN_NAMES:%=%.cpp),$(wildcard *.cpp)):%.cpp=build/obj/%.o)
#
# Targets
#
# Clear default suffix rules
.SUFFIXES :
# Keep STAMPs and dependencies between calls
.PRECIOUS : %/.STAMP build/dep/%.d build/obj/%.o
all : binaries
binaries : $(BIN_NAMES:%=build/bin/%)
test : $(TEST_NAMES:%=build/test/%.out)
@if [ -s build/test/.ERROR ]; then \
( cat build/test/.ERROR; rm build/test/.ERROR ) \
else echo "\n[ALL TESTS PASSED]\n"; \
fi
build/bin/% : build/obj/%.o $(OBJECTS) build/bin/.STAMP
$(CXX) $(LDFLAGS) $< $(OBJECTS) -o $@
build/obj/%.o : %.cpp build/obj/.STAMP build/dep/.STAMP
$(CXX) $(CXXFLAGS) -MM -MT '$@' $< > $(@:build/obj/%.o=build/dep/%.d)
$(CXX) $(CXXFLAGS) -c $< -o $@
build/test/%.out : build/bin/% build/test/.STAMP
@if [ -e $@ ]; then \
( cp $@ $@.old; \
$< &> $@; \
diff $@ $@.old >> build/test/.ERROR \
|| echo "REGRESSION TEST FAILED: $<" >> build/test/.ERROR \
; \
rm $@.old ) \
else \
( $< &> $@; \
echo "WARNING: No regression test: $<" >> build/test/.ERROR ) \
fi
%/.STAMP :
@mkdir -pv $(@D)
@touch $@
clean :
@rm -rf build/dep build/obj build/bin
@rm -f *~
cleaner : clean
@rm -rf build
-include $(wildcard build/dep/*.d)