commiting ccan web pages
[ccan] / Makefile
1 # Hacky makefile to compile everything and run the tests in some kind of sane order.
2 # V=--verbose for verbose tests.
3
4 CFLAGS=-g -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan -I.
5
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))
10
11 libccan.a: $(ALL_LIBS)
12         $(AR) r $@ $^
13
14 check: $(ALL_DIRS:%=test-%)
15
16 distclean: clean
17         rm -f $(ALL_DEPENDS)
18
19 $(ALL_DEPENDS): %/.depends: tools/ccan_depends
20         tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
21
22 $(ALL_LIBS):
23         $(LD) -r -o $@ $^ /dev/null
24
25 test-ccan/%: tools/run_tests ccan/%.o
26         @echo Testing $*...
27         @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
28
29 ccanlint: tools/ccanlint/ccanlint
30
31 clean: tools-clean
32         $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'`  `find . -name _info`
33         $(RM) inter-depends lib-depends test-depends
34
35 inter-depends: $(ALL_DEPENDS)
36         for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),ccan/\1.o,p' < $$f`; done > $@
37
38 test-depends: $(ALL_DEPENDS)
39         for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
40
41 lib-depends: $(foreach D,$(ALL),$(wildcard $D/*.[ch]))
42         for c in $(ALL); do echo ccan/$$c.o: `ls ccan/$$c/*.c | grep -v /_info.c | sed 's/.c$$/.o/'`; done > $@
43
44 include tools/Makefile
45 -include inter-depends
46 -include test-depends
47 -include lib-depends