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)
15 CCANLINT=tools/ccanlint/ccanlint --deps-fail-ignore
16 CCANLINT_FAST=$(CCANLINT) -x tests_pass_valgrind -x tests_compile_coverage
18 default: all_info libccan.a
20 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(MODS))
22 # By default, we skip modules with external deps (or plaform specific)
23 MODS_EXCLUDE:=altstack generator jmap jset nfs ogg_to_pcm tal/talloc wwviaudio
24 # This randomly fails, and reliably fails under Jenkins :(
26 MODS_RELIABLE=$(filter-out $(MODS_FLAKY),$(MODS))
30 fastcheck: $(MODS_RELIABLE:%=summary-fastcheck/%)
32 check: $(MODS_RELIABLE:%=summary-check/%)
37 scores: $(SCOREDIR)/SUMMARY
39 $(SCOREDIR)/SUMMARY: $(MODS:%=$(SCOREDIR)/%.score)
40 git describe --always > $@
43 cat $^ | grep 'Total score:' >> $@
45 $(SCOREDIR)/%.score: ccan/%/_info tools/ccanlint/ccanlint $(OBJFILES)
47 $(CCANLINT) -v -s ccan/$* > $@ || true
49 $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
50 tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
52 # Actual dependencies are created in inter-depends
53 check/%: tools/ccanlint/ccanlint
56 fastcheck/%: tools/ccanlint/ccanlint
57 $(CCANLINT_FAST) ccan/$*
59 # Doesn't test dependencies, doesn't print verbose fail results.
60 summary-check/%: tools/ccanlint/ccanlint $(OBJFILES)
61 $(CCANLINT) -s ccan/$*
63 summary-fastcheck/%: tools/ccanlint/ccanlint $(OBJFILES)
64 $(CCANLINT_FAST) -s ccan/$*
66 ccan/%/info: ccan/%/_info config.h
67 $(CC) $(CCAN_CFLAGS) -I. -o $@ -x c $<
69 all_info: $(MODS:%=ccan/%/info)
72 rm -f `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'` `find * -name info` `find * -name '*.d'` `find ccan -name '*-Makefile'`
74 rm -f inter-depends lib-depends test-depends
76 # Creates a dependency from the tests to the object files which it needs.
77 inter-depends: $(ALL_DEPENDS) Makefile
78 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 > $@
80 # Creates dependencies between tests, so if foo depends on bar, bar is tested
82 test-depends: $(ALL_DEPENDS) Makefile
83 for f in $(ALL_DEPENDS); do echo check/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check/\1,p' < $$f`; done > $@
86 find * -name '*.[ch]' | xargs etags
90 # Ensure we don't end up with empty file if configurator fails!
91 config.h: tools/configurator/configurator Makefile Makefile-ccan
92 tools/configurator/configurator $(CC) $(CCAN_CFLAGS) > $@.tmp && mv $@.tmp $@
94 include tools/Makefile
95 -include inter-depends