ccanlint: --deps-fail-ignore.
[ccan] / Makefile
1 # Hacky makefile to compile everything and run the tests in some kind
2 # of sane order.
3
4 # Main targets:
5
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
12
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
16 default: libccan.a
17
18 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(MODS_NORMAL) $(MODS_EXTERNAL))
19
20 include Makefile-ccan
21
22 fastcheck: $(MODS_NORMAL:%=summary-fastcheck-%)
23
24 check: $(MODS_NORMAL:%=summary-check-%)
25
26 distclean: clean
27         rm -f $(ALL_DEPENDS)
28
29 scores: $(SCOREDIR)/SUMMARY
30
31 $(SCOREDIR)/SUMMARY: $(MODS:%=$(SCOREDIR)/%.score)
32         git describe --always > $@
33         uname -a >> $@
34         $(CC) -v >> $@
35         cat $^ | grep 'Total score:' >> $@
36
37 $(SCOREDIR)/%.score: ccan/%/_info tools/ccanlint/ccanlint $(OBJFILES)
38         mkdir -p `dirname $@`
39         tools/ccanlint/ccanlint -v -s ccan/$* > $@ || true
40
41 $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
42         tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
43
44 # Actual dependencies are created in inter-depends
45 check-%: tools/ccanlint/ccanlint
46         tools/ccanlint/ccanlint ccan/$*
47
48 fastcheck-%: tools/ccanlint/ccanlint
49         tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage ccan/$*
50
51 # Doesn't test dependencies, doesn't print verbose fail results.
52 summary-check-%: tools/ccanlint/ccanlint $(OBJFILES)
53         tools/ccanlint/ccanlint -s ccan/$*
54
55 summary-fastcheck-%: tools/ccanlint/ccanlint $(OBJFILES)
56         tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/$*
57
58 # FIXME: Horrible hacks because % doesn't match /
59 summary-check-antithread/%: tools/ccanlint/ccanlint $(OBJFILES)
60         tools/ccanlint/ccanlint -s ccan/antithread/$*
61
62 summary-fastcheck-antithread/%: tools/ccanlint/ccanlint $(OBJFILES)
63         tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/antithread/$*
64
65 summary-check-tal/%: tools/ccanlint/ccanlint $(OBJFILES)
66         tools/ccanlint/ccanlint -s ccan/tal/$*
67
68 summary-fastcheck-tal/%: tools/ccanlint/ccanlint $(OBJFILES)
69         tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/tal/$*
70
71 ccan/%/info: ccan/%/_info
72         $(CC) $(CCAN_CFLAGS) -o $@ -x c $<
73
74 libccan.a(%.o): ccan/%.o
75         $(AR) r $@ $<
76
77 clean: tools-clean
78         $(RM) `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'`  `find * -name info` `find * -name '*.d'`
79         $(RM) inter-depends lib-depends test-depends ccan/*-Makefile
80
81 # Creates a dependency from the tests to the object files which it needs.
82 inter-depends: $(ALL_DEPENDS) Makefile
83         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 > $@
84
85 # Creates dependencies between tests, so if foo depends on bar, bar is tested
86 # first 
87 test-depends: $(ALL_DEPENDS) Makefile
88         for f in $(ALL_DEPENDS); do echo check-`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check-\1,p' < $$f`; done > $@
89
90 TAGS: FORCE
91         find * -name '*.[ch]' | xargs etags
92
93 FORCE:
94
95 # Ensure we don't end up with empty file if configurator fails!
96 config.h: tools/configurator/configurator Makefile Makefile-ccan
97         tools/configurator/configurator $(CC) $(CCAN_CFLAGS) > $@.tmp && mv $@.tmp $@
98
99 include tools/Makefile
100 -include inter-depends
101 -include test-depends
102 -include Makefile-web