]> git.ozlabs.org Git - ccan/blob - Makefile
libccan.a: simple way to use all of ccan.
[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 */_info
18         rm -f $(ALL_DEPENDS)
19
20 $(ALL_DEPENDS): $(ALL_DIRS:=/_info)
21
22 $(ALL_DEPENDS): %/.depends: tools/ccan_depends
23         tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
24
25 $(ALL_LIBS):
26         $(LD) -r -o $@ $^ /dev/null
27
28 test-ccan/%: tools/run_tests ccan/%.o
29         @echo Testing $*...
30         @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
31
32 ccanlint: tools/ccanlint/ccanlint
33
34 clean: tools-clean
35         $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'`
36         $(RM) inter-depends lib-depends test-depends
37
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 > $@
40
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 > $@
43
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 > $@
46
47 include tools/Makefile
48 -include inter-depends
49 -include test-depends
50 -include lib-depends