tal: add tal_dup_or_null and tal_dup_talarr helpers.
[ccan] / Makefile-web
1 default: upload
2
3 include Makefile
4 # This can be overridden on cmdline to generate pages elsewhere.
5 WEBDIR=/srv/www/ccodearchive.net
6 PHP=php
7
8 MODS := $(ALL_MODULES:ccan/%=%)
9 upload: fastcheck
10         git push
11
12 ALL_PAGES=$(patsubst %, $(WEBDIR)/info/%.html, $(MODS))
13 DIRECT_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/%.tar.bz2, $(MODS))
14 DEPEND_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/with-deps/%.tar.bz2, $(MODS))
15 WEB_SUBDIRS=$(WEBDIR)/tarballs $(WEBDIR)/junkcode $(WEBDIR)/tarballs/with-deps $(WEBDIR)/info
16 JUNKDIRS=$(wildcard junkcode/*)
17 JUNKPAGES=$(JUNKDIRS:%=$(WEBDIR)/%.html)
18 JUNKBALLS=$(JUNKDIRS:%=$(WEBDIR)/%.tar.bz2)
19 PRETTIFY=$(WEBDIR)/prettify/src/run_prettify.js $(WEBDIR)/prettify/src/prettify.css
20
21 VERSION_NUM := $(shell git describe | cut -d- -f2)
22
23 clean-tree:
24         [ "$(WEBDEV)" ] || ! git status --porcelain | grep .
25
26 webpages: clean-tree webpages-unchecked
27
28 webpages-unchecked: $(WEB_SUBDIRS) $(PRETTIFY) $(WEBDIR)/index.html $(WEBDIR)/upload.html $(WEBDIR)/uploader.php $(WEBDIR)/example-config.h $(WEBDIR)/ccan.png $(WEBDIR)/ccan-bg.png $(WEBDIR)/ccan.css $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(ALL_PAGES) junkpages
29
30 junkpages: $(WEBDIR)/list.html $(WEBDIR)/junkcode $(JUNKPAGES) $(JUNKBALLS)
31 $(WEB_SUBDIRS): $(WEBDIR)
32         mkdir -p $@
33
34 $(PRETTIFY):
35         git clone --depth=1 https://github.com/google/code-prettify.git $(WEBDIR)/prettify
36
37 $(WEBDIR)/junkcode/%.tar.bz2: junkcode/% $(WEBDIR)/junkcode
38         git ls-files -z $< | xargs -0 -x tar cvfj $@ 
39
40 $(WEBDIR)/junkcode/%.html: $(WEBDIR)/junkcode/%.tar.bz2
41         cd $(WEBDIR) && tar xfj junkcode/$*.tar.bz2
42         URLPREFIX=../ $(PHP) web/staticjunkcode.php junkcode/$* $* > $@
43
44 $(WEBDIR)/ccan.tar.bz2: $(WEBDIR)/ccan-$(VERSION_NUM).tar.bz2
45         ln -sf ccan-$(VERSION_NUM).tar.bz2 ccan.tar.bz2
46
47 # We want tarball to contain ccan/; we put junkcode in, but don't depend on it.
48 $(WEBDIR)/ccan-$(VERSION_NUM).tar.bz2: config.h Makefile $(shell git ls-files ccan tools licenses)
49         DIR=`pwd` && cd /tmp && ln -sf "$$DIR" ccan && tar cvfj $@ `for f in $^; do echo ccan/$$f; done` ccan/junkcode && rm ccan
50
51 $(ALL_PAGES): tools/doc_extract web/staticmoduleinfo.php
52
53 $(WEBDIR)/list.html: web/staticall.php tools/doc_extract $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(JUNKBALLS)
54         $(PHP) web/staticall.php ccan/ junkcode/ $(WEBDIR) ccan-$(VERSION_NUM).tar.bz2 $(MODS) > $@
55
56 $(WEBDIR)/upload.html: web/staticupload.php
57         $(PHP) web/staticupload.php > $@
58
59 # cpp inserts gratuitous linebreaks at start of file, makes for php problems.
60 $(WEBDIR)/uploader.php: web/uploader.php.cpp
61         cpp -w -C -P $< | grep . > $@
62
63 $(WEBDIR)/index.html: web/staticindex.php
64         $(PHP) web/staticindex.php ccan-$(VERSION_NUM).tar.bz2 > $@
65
66 $(WEBDIR)/example-config.h: config.h
67         cp $< $@
68
69 $(WEBDIR)/ccan.png: web/ccan.png
70         cp $< $@
71
72 $(WEBDIR)/ccan-bg.png: web/ccan-bg.png
73         cp $< $@
74
75 $(WEBDIR)/ccan.css: web/ccan.css
76         cp $< $@
77
78 $(WEBDIR)/info/%.html: $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2
79         @mkdir -p `dirname $@`
80         URLPREFIX=../`echo $* | tr -dc '/' | sed s',/,../,g'` $(PHP) web/staticmoduleinfo.php `pwd`/ccan/$* $* > $@
81
82 $(WEBDIR)/tarballs/%.tar.bz2: ccan/%/_info clean-tree
83         @mkdir -p `dirname $@`
84         FILES=$$(tools/list_files.sh ccan/$*) && tar -c -j -f $@ $$FILES $$(echo $$FILES | xargs -n1 -r readlink | sed 's,^\(../\)*,,' | sort -u)
85
86 $(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/%/_info tools/ccan_depends clean-tree
87         @mkdir -p `dirname $@`
88         FILES=$$(tools/list_files.sh ccan/$* $$(tools/ccan_depends ccan/$*) ) && tar -c -j -f $@ $$FILES $$(echo $$FILES | xargs -n1 -r readlink | sed 's,^\(../\)*,,' | sort -u)
89
90 distclean: distclean-web
91
92 distclean-web:
93         rm -rf $(WEBDIR)