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 # Where make scores puts the results
14 SCOREDIR=scores/$(shell whoami)/$(shell uname -s)-$(shell uname -m)-$(CC)-$(shell git describe --always --dirty)
16 # Here's my rough logarithmic timeout graph for my laptop:
23 # |Execution Time, seconds /
30 # |----------------- \---
31 # 19 +------------------------------------------------------+--
32 # 0 Timeout (ms, logarithmic) 262144
48 # --+0---------------------------------------------------==+--
49 # 0 Timeout (ms, logarithmic) 262144
51 # On my laptop, this runs 574 tests in 40 seconds, vs. a full check which
52 # runs 676 tests in 260 seconds.
57 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(MODS_NORMAL) $(MODS_EXTERNAL))
61 fastcheck: $(MODS_NORMAL:%=summary-fastcheck-%)
63 check: $(MODS_NORMAL:%=summary-check-%)
68 scores: $(SCOREDIR)/SUMMARY
70 $(SCOREDIR)/SUMMARY: $(MODS:%=$(SCOREDIR)/score-%)
71 git describe --always > $@
74 cat $^ | grep 'Total score:' >> $@
76 $(SCOREDIR)/score-%: ccan/%/_info tools/ccanlint/ccanlint $(OBJFILES)
78 tools/ccanlint/ccanlint -v -s ccan/$* > $@ || true
80 $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
81 tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
83 # Actual dependencies are created in inter-depends
84 check-%: tools/ccanlint/ccanlint
85 tools/ccanlint/ccanlint ccan/$*
87 fastcheck-%: tools/ccanlint/ccanlint
88 tools/ccanlint/ccanlint --timeout $(FASTTIMEOUT) ccan/$*
90 # Doesn't test dependencies, doesn't print verbose fail results.
91 summary-check-%: tools/ccanlint/ccanlint $(OBJFILES)
92 tools/ccanlint/ccanlint -s ccan/$*
94 summary-fastcheck-%: tools/ccanlint/ccanlint $(OBJFILES)
95 tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/$*
97 ccan/%/info: ccan/%/_info
98 $(CC) $(CCAN_CFLAGS) -o $@ -x c $<
100 libccan.a(%.o): ccan/%.o
104 $(RM) `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'` `find * -name info` `find * -name '*.d'`
105 $(RM) inter-depends lib-depends test-depends ccan/*-Makefile
107 # Creates a dependency from the tests to the object files which it needs.
108 inter-depends: $(ALL_DEPENDS) Makefile
109 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 > $@
111 # Creates dependencies between tests, so if foo depends on bar, bar is tested
113 test-depends: $(ALL_DEPENDS) Makefile
114 for f in $(ALL_DEPENDS); do echo check-`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check-\1,p' < $$f`; done > $@
117 find * -name '*.[ch]' | xargs etags
121 # Ensure we don't end up with empty file if configurator fails!
122 config.h: tools/configurator/configurator Makefile Makefile-ccan
123 tools/configurator/configurator $(CC) $(CCAN_CFLAGS) > $@.tmp && mv $@.tmp $@
125 include tools/Makefile
126 -include inter-depends
127 -include test-depends
128 -include Makefile-web