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)
18 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(MODS_NORMAL) $(MODS_EXTERNAL))
22 fastcheck: $(MODS_NORMAL:%=summary-fastcheck-%)
24 check: $(MODS_NORMAL:%=summary-check-%)
29 scores: $(SCOREDIR)/SUMMARY
31 $(SCOREDIR)/SUMMARY: $(MODS:%=$(SCOREDIR)/score-%)
32 git describe --always > $@
35 cat $^ | grep 'Total score:' >> $@
37 $(SCOREDIR)/score-%: ccan/%/_info tools/ccanlint/ccanlint $(OBJFILES)
39 tools/ccanlint/ccanlint -v -s ccan/$* > $@ || true
41 $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
42 tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
44 # Actual dependencies are created in inter-depends
45 check-%: tools/ccanlint/ccanlint
46 tools/ccanlint/ccanlint ccan/$*
48 fastcheck-%: tools/ccanlint/ccanlint
49 tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage ccan/$*
51 # Doesn't test dependencies, doesn't print verbose fail results.
52 summary-check-%: tools/ccanlint/ccanlint $(OBJFILES)
53 tools/ccanlint/ccanlint -s ccan/$*
55 summary-fastcheck-%: tools/ccanlint/ccanlint $(OBJFILES)
56 tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/$*
58 # FIXME: Horrible hacks because % doesn't match /
59 summary-fastcheck-antithread/%: tools/ccanlint/ccanlint $(OBJFILES)
60 tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/antithread/$*
62 summary-fastcheck-tal/%: tools/ccanlint/ccanlint $(OBJFILES)
63 tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/tal/$*
65 ccan/%/info: ccan/%/_info
66 $(CC) $(CCAN_CFLAGS) -o $@ -x c $<
68 libccan.a(%.o): ccan/%.o
72 $(RM) `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'` `find * -name info` `find * -name '*.d'`
73 $(RM) inter-depends lib-depends test-depends ccan/*-Makefile
75 # Creates a dependency from the tests to the object files which it needs.
76 inter-depends: $(ALL_DEPENDS) Makefile
77 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 > $@
79 # Creates dependencies between tests, so if foo depends on bar, bar is tested
81 test-depends: $(ALL_DEPENDS) Makefile
82 for f in $(ALL_DEPENDS); do echo check-`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check-\1,p' < $$f`; done > $@
85 find * -name '*.[ch]' | xargs etags
89 # Ensure we don't end up with empty file if configurator fails!
90 config.h: tools/configurator/configurator Makefile Makefile-ccan
91 tools/configurator/configurator $(CC) $(CCAN_CFLAGS) > $@.tmp && mv $@.tmp $@
93 include tools/Makefile
94 -include inter-depends