Makefile 3.2 KB

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