]> git.ozlabs.org Git - ccan/blob - Makefile
tdb: cleanup: tdb_have_extra_locks() helper
[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 # Trying to build the whole repo is usually a lose; there will be some
14 # dependencies you don't have.
15 EXCLUDE=ccan/wwviaudio ccan/ogg_to_pcm
16
17 # Anything with an _info file is a module.
18 ALL=$(filter-out $(EXCLUDE), $(patsubst ccan/%/_info, %, $(wildcard ccan/*/_info)))
19 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
20 # Not all modules have tests.
21 ALL_TESTS=$(patsubst ccan/%/test/, %, $(foreach dir, $(ALL), $(wildcard ccan/$(dir)/test/)))
22
23 default: libccan.a
24
25 include Makefile-ccan
26
27 check: $(ALL_TESTS:%=summary-check-%)
28
29 distclean: clean
30         rm -f $(ALL_DEPENDS)
31
32 $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
33         @tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
34
35 # Actual dependencies are created in inter-depends
36 check-%: tools/ccanlint/ccanlint
37         @tools/ccanlint/ccanlint -d ccan/$*
38
39 # Doesn't test dependencies, doesn't print verbose fail results.
40 summary-check-%: tools/ccanlint/ccanlint $(OBJFILES)
41         @tools/ccanlint/ccanlint -s -d ccan/$*
42
43 ccan/%/info: ccan/%/_info
44         $(CC) $(CFLAGS) -o $@ -x c $<
45
46 libccan.a(%.o): ccan/%.o
47         $(AR) r $@ $<
48
49 clean: tools-clean
50         $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'`  `find . -name info` `find . -name '*.d'`
51         $(RM) inter-depends lib-depends test-depends ccan/*-Makefile
52
53 # Creates a dependency from the tests to the object files which it needs.
54 inter-depends: $(ALL_DEPENDS) Makefile
55         @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 > $@
56
57 # Creates dependencies between tests, so if foo depends on bar, bar is tested
58 # first 
59 test-depends: $(ALL_DEPENDS) Makefile
60         @for f in $(ALL_DEPENDS); do echo check-`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check-\1,p' < $$f`; done > $@
61
62 include tools/Makefile
63 -include inter-depends
64 -include test-depends
65 -include Makefile-web