-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (43 loc) · 1.39 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
# Top level Makefile
include common.mk
# library and test, sources and dependencies
SRCS := $(wildcard *.cxx)
DEPS := $(patsubst %.cxx,.deps/%.d,$(SRCS))
TESTS := $(wildcard tests/test_*.cc)
TEST_DEPS := $(patsubst %.cc,.deps/%.d,$(TESTS))
.PHONY: all tests clean distclean $(patsubst tests/%.cc,%,$(TESTS))
all: libsfcore.so tests
libsfcore.so: $(patsubst %.cxx,%.o,$(SRCS))
$(CXX) $(LDFLAGS) -o $@ $^
tests: $(patsubst %.cc,%,$(TESTS))
@for t in $^; \
do \
$(TEST_RUN_HEADER) $$t; \
LD_LIBRARY_PATH=. $$t --report_level=short; \
done |& $(TEST_RUN_FILTER)
.deps .deps/tests:%:
mkdir -p $@
$(DEPS):.deps/%.d: %.cxx | .deps
$(CXX) $(CXXSTD) -MM $< -MF $@
# do not include when cleaning
ifeq ($(findstring clean,$(MAKECMDGOALS)),)
-include $(DEPS)
endif
$(patsubst %.cxx,%.o,$(SRCS)):%.o: %.cxx
$(CXX) -c $(CXXFLAGS) -o $@ $<
$(TEST_DEPS):.deps/%.d: %.cc | .deps/tests
$(CXX) $(CXXSTD) -I. -MM $< -MF $@
# not empty when target matches test* (condition is true)
ifneq ($(filter test%,$(MAKECMDGOALS)),)
-include $(TEST_DEPS)
endif
$(patsubst %.cc,%,$(TESTS)):%: %.cc libsfcore.so
$(CXX) $(CXXFLAGS) -I. -L. -lsfcore -o $@ $<
$(patsubst tests/%.cc,%,$(TESTS)):%: tests/%
@$(TEST_RUN_HEADER) $<
@LD_LIBRARY_PATH=. $< $(args) --report_level=short |& $(TEST_RUN_FILTER)
clean:
rm -f *.o *.so
rm -f $(patsubst %.cc,%,$(TESTS))
distclean: clean
rm -rf .deps/