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