]> git.ozlabs.org Git - ccan/blob - Makefile
Endianness module.
[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 # tools: build useful tools in tools/ dir.
9 #        Especially tools/ccanlint/ccanlint and tools/namespacize.
10 # distclean: destroy everything back to pristine state
11
12 ALL=$(patsubst ccan/%/test, %, $(wildcard ccan/*/test))
13 ALL_DIRS=$(patsubst %, ccan/%, $(ALL))
14 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
15
16 include Makefile-ccan
17
18 check: $(ALL_DIRS:%=test-%)
19
20 distclean: clean
21         rm -f $(ALL_DEPENDS)
22
23 # Override implicit attempt to link directory.
24 $(ALL_DIRS):
25         @touch $@
26
27 $(ALL_DEPENDS): %/.depends: tools/ccan_depends
28         tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
29
30 test-ccan/%: tools/run_tests libccan.a(%.o)
31         @echo Testing $*...
32         @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
33
34 # Some don't have object files.
35 test-ccan/%:: tools/run_tests
36         @echo Testing $*...
37         @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
38
39 clean: tools-clean
40         $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'`  `find . -name _info`
41         $(RM) inter-depends lib-depends test-depends
42
43 # Only list a dependency if there are object files to build.
44 inter-depends: $(ALL_DEPENDS)
45         for f in $(ALL_DEPENDS); do echo test-ccan/$$(basename $$(dirname $$f) ): $$(for dir in $$(cat $$f); do [ "$$(echo $$dir/[a-z]*.c)" = "$$dir/[a-z]*.c" ] || echo libccan.a\("$$(basename $$dir)".o\); done); done > $@
46
47 test-depends: $(ALL_DEPENDS)
48         for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
49
50 include tools/Makefile
51 -include inter-depends
52 -include test-depends
53 -include Makefile-web