Makefile 3.0 KB

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