Makefile-web 3.3 KB

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