1 # Hacky makefile to compile everything and run the tests in some kind
6 # check: run tests on all ccan modules (use 'make check V=--verbose' for more)
7 # Includes building libccan.a.
8 # libccan.a: A library with all the ccan modules in it.
9 # tools: build useful tools in tools/ dir.
10 # Especially tools/ccanlint/ccanlint and tools/namespacize.
11 # distclean: destroy everything back to pristine state
13 # Trying to build the whole repo is usually a lose; there will be some
14 # dependencies you don't have.
15 EXCLUDE=wwviaudio ogg_to_pcm jmap jbitset nfs
17 # Where make scores puts the results
18 SCOREDIR=scores/$(shell whoami)/$(shell uname -s)-$(shell uname -m)-$(CC)
20 ALL=$(filter-out $(EXCLUDE), $(REALLY_ALL))
22 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(REALLY_ALL))
24 # Not all modules have tests.
25 ALL_TESTS=$(patsubst ccan/%/test/, %, $(foreach dir, $(ALL), $(wildcard ccan/$(dir)/test/)))
27 # Here's my rough logarithmic timeout graph for my laptop:
34 # |Execution Time, seconds /
41 # |----------------- \---
42 # 19 +------------------------------------------------------+--
43 # 0 Timeout (ms, logarithmic) 262144
59 # --+0---------------------------------------------------==+--
60 # 0 Timeout (ms, logarithmic) 262144
62 # On my laptop, this runs 574 tests in 40 seconds, vs. a full check which
63 # runs 676 tests in 260 seconds.
70 fastcheck: $(ALL_TESTS:%=summary-fastcheck-%)
72 check: $(ALL_TESTS:%=summary-check-%)
77 scores: $(SCOREDIR)/SUMMARY
79 $(SCOREDIR)/SUMMARY: $(patsubst ccan/%/_info, $(SCOREDIR)/score-%, $(wildcard ccan/*/_info))
80 git describe --always > $@
83 cat $^ | grep 'Total score:' >> $@
85 $(SCOREDIR)/score-%: ccan/%/_info tools/ccanlint/ccanlint $(OBJFILES)
87 tools/ccanlint/ccanlint -v -s -d ccan/$* > $@ || true
89 $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
90 tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
92 # Actual dependencies are created in inter-depends
93 check-%: tools/ccanlint/ccanlint
94 tools/ccanlint/ccanlint -d ccan/$*
96 fastcheck-%: tools/ccanlint/ccanlint
97 tools/ccanlint/ccanlint -t $(FASTTIMEOUT) -d ccan/$*
99 # Doesn't test dependencies, doesn't print verbose fail results.
100 summary-check-%: tools/ccanlint/ccanlint $(OBJFILES)
101 tools/ccanlint/ccanlint -s -d ccan/$*
103 summary-fastcheck-%: tools/ccanlint/ccanlint $(OBJFILES)
104 tools/ccanlint/ccanlint -t $(FASTTIMEOUT) -s -d ccan/$*
106 ccan/%/info: ccan/%/_info
107 $(CC) $(CCAN_CFLAGS) -o $@ -x c $<
109 libccan.a(%.o): ccan/%.o
113 $(RM) `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'` `find * -name info` `find * -name '*.d'`
114 $(RM) inter-depends lib-depends test-depends ccan/*-Makefile
116 # Creates a dependency from the tests to the object files which it needs.
117 inter-depends: $(ALL_DEPENDS) Makefile
118 for f in $(ALL_DEPENDS); do echo check-$$(basename $$(dirname $$f) ): $$(for dir in $$(cat $$f) $$(dirname $$f); do [ "$$(echo $$dir/*.c)" = "$$dir/*.c" ] || echo ccan/"$$(basename $$dir)".o; done); done > $@
120 # Creates dependencies between tests, so if foo depends on bar, bar is tested
122 test-depends: $(ALL_DEPENDS) Makefile
123 for f in $(ALL_DEPENDS); do echo check-`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check-\1,p' < $$f`; done > $@
125 config.h: tools/configurator/configurator Makefile Makefile-ccan
126 @tools/configurator/configurator $(CC) $(CCAN_CFLAGS) > config.h
128 include tools/Makefile
129 -include inter-depends
130 -include test-depends
131 -include Makefile-web