Makefile 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. ccan/%/info: ccan/%/_info
  46. $(CC) $(CCAN_CFLAGS) -o $@ -x c $<
  47. clean: tools-clean
  48. $(RM) `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'` `find * -name info` `find * -name '*.d'`
  49. $(RM) inter-depends lib-depends test-depends ccan/*-Makefile
  50. # Creates a dependency from the tests to the object files which it needs.
  51. inter-depends: $(ALL_DEPENDS) Makefile
  52. 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 > $@
  53. # Creates dependencies between tests, so if foo depends on bar, bar is tested
  54. # first
  55. test-depends: $(ALL_DEPENDS) Makefile
  56. for f in $(ALL_DEPENDS); do echo check/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check/\1,p' < $$f`; done > $@
  57. TAGS: FORCE
  58. find * -name '*.[ch]' | xargs etags
  59. FORCE:
  60. # Ensure we don't end up with empty file if configurator fails!
  61. config.h: tools/configurator/configurator Makefile Makefile-ccan
  62. tools/configurator/configurator $(CC) $(CCAN_CFLAGS) > $@.tmp && mv $@.tmp $@
  63. include tools/Makefile
  64. -include inter-depends
  65. -include test-depends
  66. -include Makefile-web