Makefile-web 3.33 KB
Newer Older
1 2 3
default: upload

include Makefile
4
# This can be overridden on cmdline to generate pages elsewhere.
5
WEBDIR=/srv/www/ccodearchive.net
6
PHP=php
7 8 9 10

MODS := $(ALL_MODULES:ccan/%=%)
upload: fastcheck
	git push
11

12 13 14
ALL_PAGES=$(patsubst %, $(WEBDIR)/info/%.html, $(MODS))
DIRECT_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/%.tar.bz2, $(MODS))
DEPEND_TARBALLS=$(patsubst %, $(WEBDIR)/tarballs/with-deps/%.tar.bz2, $(MODS))
15 16 17 18
WEB_SUBDIRS=$(WEBDIR)/tarballs $(WEBDIR)/junkcode $(WEBDIR)/tarballs/with-deps $(WEBDIR)/info
JUNKDIRS=$(wildcard junkcode/*)
JUNKPAGES=$(JUNKDIRS:%=$(WEBDIR)/%.html)
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 30

junkpages: $(WEBDIR)/list.html $(WEBDIR)/junkcode $(JUNKPAGES) $(JUNKBALLS)
$(WEB_SUBDIRS): $(WEBDIR)
31 32
	mkdir -p $@

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 40

$(WEBDIR)/junkcode/%.html: $(WEBDIR)/junkcode/%.tar.bz2
	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 48 49

$(ALL_PAGES): tools/doc_extract web/staticmoduleinfo.php

$(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 56

# cpp inserts gratuitous linebreaks at start of file, makes for php problems.
$(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 63 64

$(WEBDIR)/example-config.h: config.h
	cp $< $@

65 66 67 68 69 70 71
$(WEBDIR)/ccan.png: web/ccan.png
	cp $< $@

$(WEBDIR)/ccan-bg.png: web/ccan-bg.png
	cp $< $@

$(WEBDIR)/ccan.css: web/ccan.css
72 73
	cp $< $@

Rusty Russell's avatar
Rusty Russell committed
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 80
	@mkdir -p `dirname $@`
	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 84
	@mkdir -p `dirname $@`
	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)