Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. CCANLINT=tools/ccanlint/ccanlint --deps-fail-ignore
  14. CCANLINT_FAST=$(CCANLINT) -x tests_pass_valgrind -x tests_compile_coverage
  15. default: libccan.a
  16. ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(MODS))
  17. # By default, we skip modules with external deps.
  18. MODS_EXCLUDE:=jmap jset nfs ogg_to_pcm tal/talloc wwviaudio
  19. include Makefile-ccan
  20. fastcheck: $(MODS:%=summary-fastcheck-%)
  21. check: $(MODS:%=summary-check-%)
  22. distclean: clean
  23. rm -f $(ALL_DEPENDS)
  24. scores: $(SCOREDIR)/SUMMARY
  25. $(SCOREDIR)/SUMMARY: $(MODS:%=$(SCOREDIR)/%.score)
  26. git describe --always > $@
  27. uname -a >> $@
  28. $(CC) -v >> $@
  29. cat $^ | grep 'Total score:' >> $@
  30. $(SCOREDIR)/%.score: ccan/%/_info tools/ccanlint/ccanlint $(OBJFILES)
  31. mkdir -p `dirname $@`
  32. $(CCANLINT) -v -s ccan/$* > $@ || true
  33. $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
  34. tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
  35. # Actual dependencies are created in inter-depends
  36. check-%: tools/ccanlint/ccanlint
  37. $(CCANLINT) ccan/$*
  38. fastcheck-%: tools/ccanlint/ccanlint
  39. $(CCANLINT_FAST) ccan/$*
  40. # Doesn't test dependencies, doesn't print verbose fail results.
  41. summary-check-%: tools/ccanlint/ccanlint $(OBJFILES)
  42. $(CCANLINT) -s ccan/$*
  43. summary-fastcheck-%: tools/ccanlint/ccanlint $(OBJFILES)
  44. $(CCANLINT_FAST) -s ccan/$*
  45. # FIXME: Horrible hacks because % doesn't match /
  46. summary-check-antithread/%: tools/ccanlint/ccanlint $(OBJFILES)
  47. $(CCANLINT) -s ccan/antithread/$*
  48. summary-fastcheck-antithread/%: tools/ccanlint/ccanlint $(OBJFILES)
  49. $(CCANLINT_FAST) -s ccan/antithread/$*
  50. summary-check-tal/%: tools/ccanlint/ccanlint $(OBJFILES)
  51. $(CCANLINT) -s ccan/tal/$*
  52. summary-fastcheck-tal/%: tools/ccanlint/ccanlint $(OBJFILES)
  53. $(CCANLINT_FAST) -s ccan/tal/$*
  54. ccan/%/info: ccan/%/_info
  55. $(CC) $(CCAN_CFLAGS) -o $@ -x c $<
  56. clean: tools-clean
  57. $(RM) `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'` `find * -name info` `find * -name '*.d'`
  58. $(RM) inter-depends lib-depends test-depends ccan/*-Makefile
  59. # Creates a dependency from the tests to the object files which it needs.
  60. inter-depends: $(ALL_DEPENDS) Makefile
  61. 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 > $@
  62. # Creates dependencies between tests, so if foo depends on bar, bar is tested
  63. # first
  64. test-depends: $(ALL_DEPENDS) Makefile
  65. for f in $(ALL_DEPENDS); do echo check-`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check-\1,p' < $$f`; done > $@
  66. TAGS: FORCE
  67. find * -name '*.[ch]' | xargs etags
  68. FORCE:
  69. # Ensure we don't end up with empty file if configurator fails!
  70. config.h: tools/configurator/configurator Makefile Makefile-ccan
  71. tools/configurator/configurator $(CC) $(CCAN_CFLAGS) > $@.tmp && mv $@.tmp $@
  72. include tools/Makefile
  73. -include inter-depends
  74. -include test-depends
  75. -include Makefile-web