Makefile 3.3 KB

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