Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # Hacky makefile to compile everything and run the tests in some kind
  2. # of sane order.
  3. # Main targets:
  4. #
  5. # check: run tests on all ccan modules (use 'make check V=--verbose' for more)
  6. # Includes building libccan.a.
  7. # tools: build useful tools in tools/ dir.
  8. # Especially tools/ccanlint/ccanlint and tools/namespacize.
  9. # distclean: destroy everything back to pristine state
  10. # This can be overridden on cmdline to generate pages elsewhere.
  11. WEBDIR=~/www/html/ccan/
  12. ALL=$(patsubst ccan/%/test, %, $(wildcard ccan/*/test))
  13. ALL_DIRS=$(patsubst %, ccan/%, $(ALL))
  14. ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
  15. ALL_PAGES=$(patsubst ccan/%, $(WEBDIR)/info/%.html, $(ALL_DIRS))
  16. DIRECT_TARBALLS=$(patsubst ccan/%, $(WEBDIR)/tarballs/%.tar.bz2, $(ALL_DIRS))
  17. DEPEND_TARBALLS=$(patsubst ccan/%, $(WEBDIR)/tarballs/with-deps/%.tar.bz2, $(ALL_DIRS))
  18. WEB_SUBDIRS=$(WEBDIR)/tarballs $(WEBDIR)/junkcode $(WEBDIR)/tarballs/with-deps $(WEBDIR)/info
  19. JUNKDIRS=$(wildcard junkcode/*)
  20. JUNKPAGES=$(JUNKDIRS:%=$(WEBDIR)/%.html)
  21. JUNKBALLS=$(JUNKDIRS:%=$(WEBDIR)/%.tar.bz2)
  22. include Makefile-ccan
  23. check: $(ALL_DIRS:%=test-%)
  24. echo $(ALL_DIRS)
  25. distclean: clean
  26. rm -f $(ALL_DEPENDS)
  27. rm -rf $(WEBDIR)
  28. webpages: $(WEB_SUBDIRS) $(WEBDIR)/junkcode $(ALL_PAGES) $(WEBDIR)/list.html $(WEBDIR)/index.html $(WEBDIR)/upload.html $(WEBDIR)/uploader.php $(WEBDIR)/example-config.h $(WEBDIR)/ccan.jpg $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(WEBDIR)/Makefile-ccan $(JUNKPAGES) $(JUNKBALLS)
  29. $(WEB_SUBDIRS):
  30. mkdir -p $@
  31. $(WEBDIR)/junkcode/%.tar.bz2: junkcode/% $(WEBDIR)/junkcode
  32. tar cvfj $@ `bzr ls --versioned --kind=file $<`
  33. $(WEBDIR)/junkcode/%.html: $(WEBDIR)/junkcode/%.tar.bz2
  34. cd $(WEBDIR) && tar xfj junkcode/$*.tar.bz2
  35. php5 web/staticjunkcode.php junkcode/$* $* > $@
  36. # Override implicit attempt to link directory.
  37. $(ALL_DIRS):
  38. @touch $@
  39. $(WEBDIR)/ccan.tar.bz2: config.h Makefile Makefile-ccan $(shell bzr ls --versioned --kind=file ccan) $(shell bzr ls --versioned --kind=file tools)
  40. tar cvfj $@ $^
  41. $(ALL_PAGES): tools/doc_extract web/staticmoduleinfo.php
  42. $(WEBDIR)/list.html: web/staticall.php tools/doc_extract $(DIRECT_TARBALLS) $(DEPEND_TARBALLS) $(WEBDIR)/ccan.tar.bz2 $(JUNKBALLS)
  43. php5 web/staticall.php ccan/ junkcode/ $(WEBDIR) > $@
  44. $(WEBDIR)/upload.html: web/staticupload.php
  45. php5 web/staticupload.php > $@
  46. # cpp inserts gratuitous linebreaks at start of file, makes for php problems.
  47. $(WEBDIR)/uploader.php: web/uploader.php.cpp
  48. cpp -w -C -P $< | grep . > $@
  49. $(WEBDIR)/index.html: web/staticindex.php
  50. php5 web/staticindex.php > $@
  51. $(WEBDIR)/example-config.h: config.h
  52. cp $< $@
  53. $(WEBDIR)/Makefile-ccan: Makefile-ccan
  54. cp $< $@
  55. $(WEBDIR)/ccan.jpg: web/ccan.jpg
  56. cp $< $@
  57. $(WEBDIR)/info/%.html: ccan/% ccan/%/test $(WEBDIR)/tarballs/%.tar.bz2 $(WEBDIR)/tarballs/with-deps/%.tar.bz2
  58. URLPREFIX=../ php5 web/staticmoduleinfo.php ccan/$* > $@
  59. $(WEBDIR)/tarballs/%.tar.bz2: ccan/% ccan/%/test
  60. tar -c -v -j -f $@ `bzr ls --versioned --kind=file ccan/$*`
  61. $(WEBDIR)/tarballs/with-deps/%.tar.bz2: ccan/% ccan/%/test tools/ccan_depends
  62. tar cvfj $@ $$(echo ccan/$* $$(tools/ccan_depends ccan/$*) | xargs -n 1 bzr ls --versioned --kind=file)
  63. $(ALL_DEPENDS): %/.depends: tools/ccan_depends
  64. tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
  65. test-ccan/%: tools/run_tests libccan.a(%.o)
  66. @echo Testing $*...
  67. @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
  68. # Some don't have object files.
  69. test-ccan/%:: tools/run_tests
  70. @echo Testing $*...
  71. @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
  72. clean: tools-clean
  73. $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name _info`
  74. $(RM) inter-depends lib-depends test-depends
  75. # Only list a dependency if there are object files to build.
  76. inter-depends: $(ALL_DEPENDS)
  77. for f in $(ALL_DEPENDS); do echo test-ccan/$$(basename $$(dirname $$f) ): $$(for dir in $$(cat $$f); do [ "$$(echo $$dir/[a-z]*.c)" = "$$dir/[a-z]*.c" ] || echo libccan.a\("$$(basename $$dir)".o\); done); done > $@
  78. test-depends: $(ALL_DEPENDS)
  79. for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
  80. include tools/Makefile
  81. -include inter-depends
  82. -include test-depends