5ebdd7dbbd0ca9bdbc28b3a5e1c96d4da6b6aeb1
[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)/tarballs/with-deps $(WEBDIR)/info
14
15 include Makefile-ccan
16
17 check: $(ALL_DIRS:%=test-%)
18
19 distclean: clean
20         rm -f $(ALL_DEPENDS)
21         rm -rf $(WEBDIR)
22
23 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
24
25 $(WEB_SUBDIRS):
26         mkdir -p $@
27
28 $(WEBDIR)/junkcode:
29         cp -a junkcode $@
30
31 # Override implicit attempt to link directory.
32 $(ALL_DIRS):
33         @touch $@
34
35 $(WEBDIR)/ccan.tar.bz2:
36         tar cvfj $@ `bzr ls --versioned --kind=file ccan`
37
38 $(ALL_PAGES): tools/doc_extract web/staticmoduleinfo.php
39
40 $(WEBDIR)/list.html: web/staticall.php tools/doc_extract $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2
41         php5 web/staticall.php ccan/ $(WEBDIR) > $@
42
43 $(WEBDIR)/upload.html: web/staticupload.php
44         php5 web/staticupload.php > $@
45
46 # cpp inserts gratuitous linebreaks at start of file, makes for php problems.
47 $(WEBDIR)/uploader.php: web/uploader.php.cpp
48         cpp -w -C -P $< | grep . > $@
49
50 $(WEBDIR)/index.html: web/staticindex.php
51         php5 web/staticindex.php > $@
52
53 $(WEBDIR)/example-config.h: config.h
54         cp $< $@
55
56 $(WEBDIR)/Makefile-ccan: Makefile-ccan
57         cp $< $@
58
59 $(WEBDIR)/ccan.jpg: web/ccan.jpg
60         cp $< $@
61
62 $(WEBDIR)/info/%.html: ccan/% ccan/%/test $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2
63         URLPREFIX=../ php5 web/staticmoduleinfo.php ccan/$* > $@
64
65 $(WEBDIR)/tarballs/%.tar.bz2: ccan/% ccan/%/test
66         tar -c -v -j -f $@ `bzr ls --versioned --kind=file ccan/$*`
67
68 $(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/% ccan/%/test tools/ccan_depends
69         tar cvfj $@ $$(echo ccan/$* $$(tools/ccan_depends ccan/$*) | xargs -n 1 bzr ls --versioned --kind=file)
70
71 $(ALL_DEPENDS): %/.depends: tools/ccan_depends
72         tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
73
74 test-ccan/%: tools/run_tests ccan/%.o
75         @echo Testing $*...
76         @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
77
78 ccanlint: tools/ccanlint/ccanlint
79
80 clean: tools-clean
81         $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'`  `find . -name _info`
82         $(RM) inter-depends lib-depends test-depends
83
84 inter-depends: $(ALL_DEPENDS)
85         for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),ccan/\1.o,p' < $$f`; done > $@
86
87 test-depends: $(ALL_DEPENDS)
88         for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
89
90 include tools/Makefile
91 -include inter-depends
92 -include test-depends