]> git.ozlabs.org Git - ccan/blob - Makefile-web
Makefile: fix random pattern hack.
[ccan] / Makefile-web
1 # This can be overridden on cmdline to generate pages elsewhere.
2 WEBDIR=/srv/www/ccodearchive.net
3
4 ALL_PAGES=$(patsubst %, $(WEBDIR)/info/%.html, $(MODS))
5 DIRECT_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/%.tar.bz2, $(MODS))
6 DEPEND_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/with-deps/%.tar.bz2, $(MODS))
7 WEB_SUBDIRS=$(WEBDIR)/tarballs $(WEBDIR)/junkcode $(WEBDIR)/tarballs/with-deps $(WEBDIR)/info
8 JUNKDIRS=$(wildcard junkcode/*)
9 JUNKPAGES=$(JUNKDIRS:%=$(WEBDIR)/%.html)
10 JUNKBALLS=$(JUNKDIRS:%=$(WEBDIR)/%.tar.bz2)
11 PRETTIFY=$(WEBDIR)/prettify/src/run_prettify.js $(WEBDIR)/prettify/src/prettify.css
12
13 upload: fastcheck modcheck
14         git push
15
16 # Check MODS list in Makefile-ccan matches modules we find.
17 modcheck:
18         @FOUND=$$(echo $$(find ccan -name _info | sed 's,ccan/\(.*\)/_info,\1,' | sort) ); LISTED=$$(echo $$(echo $(MODS) | tr ' ' '\012' | sort) ); if [ "$$FOUND" = "$$LISTED" ]; then exit 0; fi; while true; do a="$${FOUND%% *}"; b="$${LISTED%% *}"; if [ "$$a" != "$$b" ]; then echo "'$$a' found but '$$b' in MOD" >&2; exit 1; fi; FOUND="$${FOUND#* }"; LISTED="$${LISTED#* }"; done
19
20 clean-tree:
21         [ "$(WEBDEV)" ] || ! git status --porcelain | grep .
22
23 webpages: modcheck clean-tree webpages-unchecked
24
25 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 $(WEBDIR)/Makefile-ccan $(ALL_PAGES) junkpages
26
27 junkpages: $(WEBDIR)/list.html $(WEBDIR)/junkcode $(JUNKPAGES) $(JUNKBALLS)
28 $(WEB_SUBDIRS): $(WEBDIR)
29         mkdir -p $@
30
31 $(PRETTIFY):
32         git clone --depth=1 https://github.com/google/code-prettify.git $(WEBDIR)/prettify
33
34 $(WEBDIR)/junkcode/%.tar.bz2: junkcode/% $(WEBDIR)/junkcode
35         git ls-files -z $< | xargs -0 -x tar cvfj $@ 
36
37 $(WEBDIR)/junkcode/%.html: $(WEBDIR)/junkcode/%.tar.bz2
38         cd $(WEBDIR) && tar xfj junkcode/$*.tar.bz2
39         URLPREFIX=../ php5 web/staticjunkcode.php junkcode/$* $* > $@
40
41 # We want tarball to contain ccan/; we put junkcode in, but don't depend on it.
42 $(WEBDIR)/ccan.tar.bz2: config.h Makefile Makefile-ccan $(shell git ls-files ccan tools licenses)
43         DIR=`pwd` && cd /tmp && ln -sf "$$DIR" ccan && tar cvfj $@ `for f in $^; do echo ccan/$$f; done` ccan/junkcode && rm 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) $(MODS) > $@
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.png: web/ccan.png
67         cp $< $@
68
69 $(WEBDIR)/ccan-bg.png: web/ccan-bg.png
70         cp $< $@
71
72 $(WEBDIR)/ccan.css: web/ccan.css
73         cp $< $@
74
75 $(WEBDIR)/info/%.html: $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2
76         @mkdir -p `dirname $@`
77         URLPREFIX=../`echo $* | tr -dc '/' | sed s',/,../,g'` php5 web/staticmoduleinfo.php `pwd`/ccan/$* $* > $@
78
79 $(WEBDIR)/tarballs/%.tar.bz2: ccan/%/_info clean-tree
80         @mkdir -p `dirname $@`
81         FILES=$$(tools/list_files.sh ccan/$*) && tar -c -j -f $@ $$FILES $$(echo $$FILES | xargs -n1 -r readlink | sed 's,^\(../\)*,,' | sort -u)
82
83 $(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/%/_info tools/ccan_depends clean-tree
84         @mkdir -p `dirname $@`
85         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)
86
87 distclean: distclean-web
88
89 distclean-web:
90         rm -rf $(WEBDIR)