1 # Hacky makefile to compile everything and run the tests in some kind of sane order.
2 # V=--verbose for verbose tests.
4 CFLAGS=-g -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan -I.
6 ALL=$(patsubst ccan/%/test, %, $(wildcard ccan/*/test))
7 ALL_DIRS=$(patsubst %, ccan/%, $(ALL))
8 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
9 ALL_LIBS=$(patsubst %, ccan/%.o, $(ALL))
11 libccan.a: $(ALL_LIBS)
14 check: $(ALL_DIRS:%=test-%)
20 $(ALL_DEPENDS): $(ALL_DIRS:=/_info)
22 $(ALL_DEPENDS): %/.depends: tools/ccan_depends
23 tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
26 $(LD) -r -o $@ $^ /dev/null
28 test-ccan/%: tools/run_tests ccan/%.o
30 @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
32 ccanlint: tools/ccanlint/ccanlint
35 $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name _info`
36 $(RM) inter-depends lib-depends test-depends
38 inter-depends: $(ALL_DEPENDS)
39 for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),ccan/\1.o,p' < $$f`; done > $@
41 test-depends: $(ALL_DEPENDS)
42 for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
44 lib-depends: $(foreach D,$(ALL),$(wildcard $D/*.[ch]))
45 for c in $(ALL); do echo ccan/$$c.o: `ls ccan/$$c/*.c | grep -v /_info.c | sed 's/.c$$/.o/'`; done > $@
47 include tools/Makefile
48 -include inter-depends