1 # Hacky makefile to compile everything and run the tests in some kind
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
12 ALL=$(patsubst ccan/%/test, %, $(wildcard ccan/*/test))
13 ALL_DIRS=$(patsubst %, ccan/%, $(ALL))
14 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
18 check: $(ALL_DIRS:%=test-%)
24 # Override implicit attempt to link directory.
28 $(ALL_DEPENDS): %/.depends: tools/ccan_depends
29 tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
31 test-ccan/%: tools/run_tests libccan.a(%.o)
33 @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
35 # Some don't have object files.
36 test-ccan/%:: tools/run_tests
38 @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
41 $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name _info`
42 $(RM) inter-depends lib-depends test-depends
44 # Only list a dependency if there are object files to build.
45 inter-depends: $(ALL_DEPENDS)
46 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 > $@
48 test-depends: $(ALL_DEPENDS)
49 for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
51 include tools/Makefile
52 -include inter-depends