]> git.ozlabs.org Git - ccan/blob - Makefile
rfc822: switch to ccan/tal.
[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-fastcheck-antithread/%: tools/ccanlint/ccanlint $(OBJFILES)
60         tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/antithread/$*
61
62 summary-fastcheck-tal/%: tools/ccanlint/ccanlint $(OBJFILES)
63         tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/tal/$*
64
65 ccan/%/info: ccan/%/_info
66         $(CC) $(CCAN_CFLAGS) -o $@ -x c $<
67
68 libccan.a(%.o): ccan/%.o
69         $(AR) r $@ $<
70
71 clean: tools-clean
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
74
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 > $@
78
79 # Creates dependencies between tests, so if foo depends on bar, bar is tested
80 # first 
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 > $@
83
84 TAGS: FORCE
85         find * -name '*.[ch]' | xargs etags
86
87 FORCE:
88
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 $@
92
93 include tools/Makefile
94 -include inter-depends
95 -include test-depends
96 -include Makefile-web