]> git.ozlabs.org Git - ccan/blob - Makefile
Build info files
[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: all_info libccan.a
19
20 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(MODS))
21
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 :(
25 MODS_FLAKY:=altstack
26 MODS_RELIABLE=$(filter-out $(MODS_FLAKY),$(MODS))
27
28 include Makefile-ccan
29
30 fastcheck: $(MODS_RELIABLE:%=summary-fastcheck/%)
31
32 check: $(MODS_RELIABLE:%=summary-check/%)
33
34 distclean: clean
35         rm -f $(ALL_DEPENDS)
36
37 scores: $(SCOREDIR)/SUMMARY
38
39 $(SCOREDIR)/SUMMARY: $(MODS:%=$(SCOREDIR)/%.score)
40         git describe --always > $@
41         uname -a >> $@
42         $(CC) -v >> $@
43         cat $^ | grep 'Total score:' >> $@
44
45 $(SCOREDIR)/%.score: ccan/%/_info tools/ccanlint/ccanlint $(OBJFILES)
46         mkdir -p `dirname $@`
47         $(CCANLINT) -v -s ccan/$* > $@ || true
48
49 $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
50         tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
51
52 # Actual dependencies are created in inter-depends
53 check/%: tools/ccanlint/ccanlint
54         $(CCANLINT) ccan/$*
55
56 fastcheck/%: tools/ccanlint/ccanlint
57         $(CCANLINT_FAST) ccan/$*
58
59 # Doesn't test dependencies, doesn't print verbose fail results.
60 summary-check/%: tools/ccanlint/ccanlint $(OBJFILES)
61         $(CCANLINT) -s ccan/$*
62
63 summary-fastcheck/%: tools/ccanlint/ccanlint $(OBJFILES)
64         $(CCANLINT_FAST) -s ccan/$*
65
66 ccan/%/info: ccan/%/_info config.h
67         $(CC) $(CCAN_CFLAGS) -I. -o $@ -x c $<
68
69 all_info: $(MODS:%=ccan/%/info)
70
71 clean: tools-clean
72         rm -f `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'`  `find * -name info` `find * -name '*.d'` `find ccan -name '*-Makefile'`
73         rm -f config.h
74         rm -f inter-depends lib-depends test-depends
75
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 > $@
79
80 # Creates dependencies between tests, so if foo depends on bar, bar is tested
81 # first 
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 > $@
84
85 TAGS: FORCE
86         find * -name '*.[ch]' | xargs etags
87
88 FORCE:
89
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 $@
93
94 include tools/Makefile
95 -include inter-depends
96 -include test-depends
97 -include Makefile-web