1 | CXX = g++
|
---|
2 | CXXFLAGS ?= -g -Wall -W -ansi # -pedantic
|
---|
3 | LDFLAGS ?=
|
---|
4 | SED = sed
|
---|
5 | MV = mv
|
---|
6 | RM = rm
|
---|
7 |
|
---|
8 | .SUFFIXES: .o .cpp
|
---|
9 |
|
---|
10 | lib = libUnitTest++.a
|
---|
11 | test = TestUnitTest++
|
---|
12 |
|
---|
13 | src = src/AssertException.cpp \
|
---|
14 | src/Test.cpp \
|
---|
15 | src/Checks.cpp \
|
---|
16 | src/TestRunner.cpp \
|
---|
17 | src/TestResults.cpp \
|
---|
18 | src/TestReporter.cpp \
|
---|
19 | src/TestReporterStdout.cpp \
|
---|
20 | src/ReportAssert.cpp \
|
---|
21 | src/TestList.cpp \
|
---|
22 | src/TimeConstraint.cpp \
|
---|
23 | src/TestDetails.cpp \
|
---|
24 | src/MemoryOutStream.cpp \
|
---|
25 | src/DeferredTestReporter.cpp \
|
---|
26 | src/DeferredTestResult.cpp \
|
---|
27 | src/XmlTestReporter.cpp \
|
---|
28 | src/CurrentTest.cpp
|
---|
29 |
|
---|
30 | ifeq ($(MSYSTEM), MINGW32)
|
---|
31 | src += src/Win32/TimeHelpers.cpp
|
---|
32 | else
|
---|
33 | src += src/Posix/SignalTranslator.cpp \
|
---|
34 | src/Posix/TimeHelpers.cpp
|
---|
35 | endif
|
---|
36 |
|
---|
37 | test_src = src/tests/Main.cpp \
|
---|
38 | src/tests/TestAssertHandler.cpp \
|
---|
39 | src/tests/TestChecks.cpp \
|
---|
40 | src/tests/TestUnitTest++.cpp \
|
---|
41 | src/tests/TestTest.cpp \
|
---|
42 | src/tests/TestTestResults.cpp \
|
---|
43 | src/tests/TestTestRunner.cpp \
|
---|
44 | src/tests/TestCheckMacros.cpp \
|
---|
45 | src/tests/TestTestList.cpp \
|
---|
46 | src/tests/TestTestMacros.cpp \
|
---|
47 | src/tests/TestTimeConstraint.cpp \
|
---|
48 | src/tests/TestTimeConstraintMacro.cpp \
|
---|
49 | src/tests/TestMemoryOutStream.cpp \
|
---|
50 | src/tests/TestDeferredTestReporter.cpp \
|
---|
51 | src/tests/TestXmlTestReporter.cpp \
|
---|
52 | src/tests/TestCurrentTest.cpp
|
---|
53 |
|
---|
54 | objects = $(patsubst %.cpp, %.o, $(src))
|
---|
55 | test_objects = $(patsubst %.cpp, %.o, $(test_src))
|
---|
56 | dependencies = $(subst .o,.d,$(objects))
|
---|
57 | test_dependencies = $(subst .o,.d,$(test_objects))
|
---|
58 |
|
---|
59 | define make-depend
|
---|
60 | $(CXX) $(CXXFLAGS) -M $1 | \
|
---|
61 | $(SED) -e 's,\($(notdir $2)\) *:,$(dir $2)\1: ,' > $3.tmp
|
---|
62 | $(SED) -e 's/#.*//' \
|
---|
63 | -e 's/^[^:]*: *//' \
|
---|
64 | -e 's/ *\\$$//' \
|
---|
65 | -e '/^$$/ d' \
|
---|
66 | -e 's/$$/ :/' $3.tmp >> $3.tmp
|
---|
67 | $(MV) $3.tmp $3
|
---|
68 | endef
|
---|
69 |
|
---|
70 |
|
---|
71 | all: $(lib)
|
---|
72 |
|
---|
73 |
|
---|
74 | $(lib): $(objects)
|
---|
75 | @echo Creating $(lib) library...
|
---|
76 | @ar cr $(lib) $(objects)
|
---|
77 |
|
---|
78 | $(test): $(lib) $(test_objects)
|
---|
79 | @echo Linking $(test)...
|
---|
80 | @$(CXX) $(LDFLAGS) -o $(test) $(test_objects) $(lib)
|
---|
81 | @echo Running unit tests...
|
---|
82 | @./$(test)
|
---|
83 |
|
---|
84 | clean:
|
---|
85 | -@$(RM) $(objects) $(test_objects) $(dependencies) $(test_dependencies) $(test) $(lib) 2> /dev/null
|
---|
86 |
|
---|
87 | %.o : %.cpp
|
---|
88 | @echo $<
|
---|
89 | @$(call make-depend,$<,$@,$(subst .o,.d,$@))
|
---|
90 | @$(CXX) $(CXXFLAGS) -c $< -o $(patsubst %.cpp, %.o, $<)
|
---|
91 |
|
---|
92 |
|
---|
93 | ifneq "$(MAKECMDGOALS)" "clean"
|
---|
94 | -include $(dependencies)
|
---|
95 | -include $(test_dependencies)
|
---|
96 | endif
|
---|