]> git.ozlabs.org Git - ccan/blob - Makefile-web
tools/configurator: Better argument handling, particularly unknown arguments.
[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
22 clean-tree:
23         [ "$(WEBDEV)" ] || ! git status --porcelain | grep .
24
25 webpages: clean-tree webpages-unchecked
26
27 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
28
29 junkpages: $(WEBDIR)/list.html $(WEBDIR)/junkcode $(JUNKPAGES) $(JUNKBALLS)
30 $(WEB_SUBDIRS): $(WEBDIR)
31         mkdir -p $@
32
33 $(PRETTIFY):
34         git clone --depth=1 https://github.com/google/code-prettify.git $(WEBDIR)/prettify
35
36 $(WEBDIR)/junkcode/%.tar.bz2: junkcode/% $(WEBDIR)/junkcode
37         git ls-files -z $< | xargs -0 -x tar cvfj $@ 
38
39 $(WEBDIR)/junkcode/%.html: $(WEBDIR)/junkcode/%.tar.bz2
40         cd $(WEBDIR) && tar xfj junkcode/$*.tar.bz2
41         URLPREFIX=../ $(PHP) web/staticjunkcode.php junkcode/$* $* > $@
42
43 # We want tarball to contain ccan/; we put junkcode in, but don't depend on it.
44 $(WEBDIR)/ccan.tar.bz2: config.h Makefile $(shell git ls-files ccan tools licenses)
45         DIR=`pwd` && cd /tmp && ln -sf "$$DIR" ccan && tar cvfj $@ `for f in $^; do echo ccan/$$f; done` ccan/junkcode && rm ccan
46
47 $(ALL_PAGES): tools/doc_extract web/staticmoduleinfo.php
48
49 $(WEBDIR)/list.html: web/staticall.php tools/doc_extract $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(JUNKBALLS)
50         $(PHP) web/staticall.php ccan/ junkcode/ $(WEBDIR) $(MODS) > $@
51
52 $(WEBDIR)/upload.html: web/staticupload.php
53         $(PHP) web/staticupload.php > $@
54
55 # cpp inserts gratuitous linebreaks at start of file, makes for php problems.
56 $(WEBDIR)/uploader.php: web/uploader.php.cpp
57         cpp -w -C -P $< | grep . > $@
58
59 $(WEBDIR)/index.html: web/staticindex.php
60         $(PHP) web/staticindex.php > $@
61
62 $(WEBDIR)/example-config.h: config.h
63         cp $< $@
64
65 $(WEBDIR)/ccan.png: web/ccan.png
66         cp $< $@
67
68 $(WEBDIR)/ccan-bg.png: web/ccan-bg.png
69         cp $< $@
70
71 $(WEBDIR)/ccan.css: web/ccan.css
72         cp $< $@
73
74 $(WEBDIR)/info/%.html: $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2
75         @mkdir -p `dirname $@`
76         URLPREFIX=../`echo $* | tr -dc '/' | sed s',/,../,g'` $(PHP) web/staticmoduleinfo.php `pwd`/ccan/$* $* > $@
77
78 $(WEBDIR)/tarballs/%.tar.bz2: ccan/%/_info clean-tree
79         @mkdir -p `dirname $@`
80         FILES=$$(tools/list_files.sh ccan/$*) && tar -c -j -f $@ $$FILES $$(echo $$FILES | xargs -n1 -r readlink | sed 's,^\(../\)*,,' | sort -u)
81
82 $(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/%/_info tools/ccan_depends clean-tree
83         @mkdir -p `dirname $@`
84         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)
85
86 distclean: distclean-web
87
88 distclean-web:
89         rm -rf $(WEBDIR)