Makefile 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 (or plaform specific)
  18. MODS_EXCLUDE:=altstack generator 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 -f `find * -name '*.o'` `find * -name '.depends'` `find * -name '*.a'` `find * -name info` `find * -name '*.d'` `find ccan -name '*-Makefile'`
  49. rm -f config.h
  50. rm -f inter-depends lib-depends test-depends
  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