Makefile-web 3.8 KB

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