Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. # libccan.a: A library with all the ccan modules in it.
  8. # tools: build useful tools in tools/ dir.
  9. # Especially tools/ccanlint/ccanlint and tools/namespacize.
  10. # distclean: destroy everything back to pristine state
  11. # Where make scores puts the results
  12. SCOREDIR=scores/$(shell whoami)/$(shell uname -s)-$(shell uname -m)-$(CC)-$(shell git describe --always --dirty)
  13. default: libccan.a
  14. ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(MODS_NORMAL) $(MODS_EXTERNAL))
  15. include Makefile-ccan
  16. fastcheck: $(MODS_NORMAL:%=summary-fastcheck-%)
  17. check: $(MODS_NORMAL:%=summary-check-%)
  18. distclean: clean
  19. rm -f $(ALL_DEPENDS)
  20. scores: $(SCOREDIR)/SUMMARY
  21. $(SCOREDIR)/SUMMARY: $(MODS:%=$(SCOREDIR)/%.score)
  22. git describe --always > $@
  23. uname -a >> $@
  24. $(CC) -v >> $@
  25. cat $^ | grep 'Total score:' >> $@
  26. $(SCOREDIR)/%.score: ccan/%/_info tools/ccanlint/ccanlint $(OBJFILES)
  27. mkdir -p `dirname $@`
  28. tools/ccanlint/ccanlint -v -s ccan/$* > $@ || true
  29. $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
  30. tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
  31. # Actual dependencies are created in inter-depends
  32. check-%: tools/ccanlint/ccanlint
  33. tools/ccanlint/ccanlint ccan/$*
  34. fastcheck-%: tools/ccanlint/ccanlint
  35. tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage ccan/$*
  36. # Doesn't test dependencies, doesn't print verbose fail results.
  37. summary-check-%: tools/ccanlint/ccanlint $(OBJFILES)
  38. tools/ccanlint/ccanlint -s ccan/$*
  39. summary-fastcheck-%: tools/ccanlint/ccanlint $(OBJFILES)
  40. tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/$*
  41. # FIXME: Horrible hacks because % doesn't match /
  42. summary-fastcheck-antithread/%: tools/ccanlint/ccanlint $(OBJFILES)
  43. tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/antithread/$*
  44. summary-fastcheck-tal/%: tools/ccanlint/ccanlint $(OBJFILES)
  45. tools/ccanlint/ccanlint -x tests_pass_valgrind -x tests_compile_coverage -s ccan/tal/$*
  46. ccan/%/info: ccan/%/_info
  47. $(CC) $(CCAN_CFLAGS) -o $@ -x c $<
  48. libccan.a(%.o): ccan/%.o
  49. $(AR) r $@ $<
  50. clean: tools-clean
  51. $(RM) `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'` `find * -name info` `find * -name '*.d'`
  52. $(RM) inter-depends lib-depends test-depends ccan/*-Makefile
  53. # Creates a dependency from the tests to the object files which it needs.
  54. inter-depends: $(ALL_DEPENDS) Makefile
  55. for f in $(ALL_DEPENDS); do echo check-$$(basename $$(dirname $$f) ): $$(for dir in $$(cat $$f) $$(dirname $$f); do [ "$$(echo $$dir/*.c)" = "$$dir/*.c" ] || echo ccan/"$$(basename $$dir)".o; done); done > $@
  56. # Creates dependencies between tests, so if foo depends on bar, bar is tested
  57. # first
  58. test-depends: $(ALL_DEPENDS) Makefile
  59. for f in $(ALL_DEPENDS); do echo check-`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check-\1,p' < $$f`; done > $@
  60. TAGS: FORCE
  61. find * -name '*.[ch]' | xargs etags
  62. FORCE:
  63. # Ensure we don't end up with empty file if configurator fails!
  64. config.h: tools/configurator/configurator Makefile Makefile-ccan
  65. tools/configurator/configurator $(CC) $(CCAN_CFLAGS) > $@.tmp && mv $@.tmp $@
  66. include tools/Makefile
  67. -include inter-depends
  68. -include test-depends
  69. -include Makefile-web