Remove compile warnings of tests under Ubuntu (return value ignored)
[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 # This can be overridden on cmdline to generate pages elsewhere.
5 WEBDIR=~/www/html/ccan/
6
7 ALL=$(patsubst ccan/%/test, %, $(wildcard ccan/*/test))
8 ALL_DIRS=$(patsubst %, ccan/%, $(ALL))
9 ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
10 ALL_PAGES=$(patsubst ccan/%, $(WEBDIR)/info/%.html, $(ALL_DIRS))
11 DIRECT_TARBALLS=$(patsubst ccan/%, $(WEBDIR)/tarballs/%.tar.bz2, $(ALL_DIRS))
12 DEPEND_TARBALLS=$(patsubst ccan/%, $(WEBDIR)/tarballs/with-deps/%.tar.bz2, $(ALL_DIRS))
13 WEB_SUBDIRS=$(WEBDIR)/tarballs $(WEBDIR)/junkcode $(WEBDIR)/tarballs/with-deps $(WEBDIR)/info
14 JUNKDIRS=$(wildcard junkcode/*)
15 JUNKPAGES=$(JUNKDIRS:%=$(WEBDIR)/%.html)
16 JUNKBALLS=$(JUNKDIRS:%=$(WEBDIR)/%.tar.bz2)
17
18 include Makefile-ccan
19
20 check: $(ALL_DIRS:%=test-%)
21
22 distclean: clean
23         rm -f $(ALL_DEPENDS)
24         rm -rf $(WEBDIR)
25
26 webpages: $(WEB_SUBDIRS) $(WEBDIR)/junkcode $(ALL_PAGES) $(WEBDIR)/list.html $(WEBDIR)/index.html $(WEBDIR)/upload.html $(WEBDIR)/uploader.php $(WEBDIR)/example-config.h $(WEBDIR)/ccan.jpg $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(WEBDIR)/Makefile-ccan $(JUNKPAGES) $(JUNKBALLS)
27
28 $(WEB_SUBDIRS):
29         mkdir -p $@
30
31 $(WEBDIR)/junkcode/%.tar.bz2: junkcode/% $(WEBDIR)/junkcode
32         tar cvfj $@ `bzr ls --versioned --kind=file $<`
33
34 $(WEBDIR)/junkcode/%.html: $(WEBDIR)/junkcode/%.tar.bz2
35         cd $(WEBDIR) && tar xfj junkcode/$*.tar.bz2
36         php5 web/staticjunkcode.php junkcode/$* $* > $@
37
38 # Override implicit attempt to link directory.
39 $(ALL_DIRS):
40         @touch $@
41
42 $(WEBDIR)/ccan.tar.bz2:
43         tar cvfj $@ `bzr ls --versioned --kind=file ccan`
44
45 $(ALL_PAGES): tools/doc_extract web/staticmoduleinfo.php
46
47 $(WEBDIR)/list.html: web/staticall.php tools/doc_extract $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(JUNKBALLS)
48         php5 web/staticall.php ccan/ junkcode/ $(WEBDIR) > $@
49
50 $(WEBDIR)/upload.html: web/staticupload.php
51         php5 web/staticupload.php > $@
52
53 # cpp inserts gratuitous linebreaks at start of file, makes for php problems.
54 $(WEBDIR)/uploader.php: web/uploader.php.cpp
55         cpp -w -C -P $< | grep . > $@
56
57 $(WEBDIR)/index.html: web/staticindex.php
58         php5 web/staticindex.php > $@
59
60 $(WEBDIR)/example-config.h: config.h
61         cp $< $@
62
63 $(WEBDIR)/Makefile-ccan: Makefile-ccan
64         cp $< $@
65
66 $(WEBDIR)/ccan.jpg: web/ccan.jpg
67         cp $< $@
68
69 $(WEBDIR)/info/%.html: ccan/% ccan/%/test $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2
70         URLPREFIX=../ php5 web/staticmoduleinfo.php ccan/$* > $@
71
72 $(WEBDIR)/tarballs/%.tar.bz2: ccan/% ccan/%/test
73         tar -c -v -j -f $@ `bzr ls --versioned --kind=file ccan/$*`
74
75 $(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/% ccan/%/test tools/ccan_depends
76         tar cvfj $@ $$(echo ccan/$* $$(tools/ccan_depends ccan/$*) | xargs -n 1 bzr ls --versioned --kind=file)
77
78 $(ALL_DEPENDS): %/.depends: tools/ccan_depends
79         tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
80
81 test-ccan/%: tools/run_tests libccan.a(%.o)
82         @echo Testing $*...
83         @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
84
85 ccanlint: tools/ccanlint/ccanlint
86
87 clean: tools-clean
88         $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'`  `find . -name _info`
89         $(RM) inter-depends lib-depends test-depends
90
91 # Only list a dependency if there are object files to build.
92 inter-depends: $(ALL_DEPENDS)
93         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 > $@
94
95 test-depends: $(ALL_DEPENDS)
96         for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
97
98 include tools/Makefile
99 -include inter-depends
100 -include test-depends