Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. # tools: build useful tools in tools/ dir.
  8. # Especially tools/ccanlint/ccanlint and tools/namespacize.
  9. # distclean: destroy everything back to pristine state
  10. ALL=$(patsubst ccan/%/test, %, $(wildcard ccan/*/test))
  11. ALL_DIRS=$(patsubst %, ccan/%, $(ALL))
  12. ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
  13. include Makefile-ccan
  14. check: $(ALL_DIRS:%=test-%)
  15. distclean: clean
  16. rm -f $(ALL_DEPENDS)
  17. # Override implicit attempt to link directory.
  18. $(ALL_DIRS):
  19. @touch $@
  20. $(ALL_DEPENDS): %/.depends: tools/ccan_depends
  21. tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
  22. test-ccan/%: tools/run_tests libccan.a(%.o)
  23. @echo Testing $*...
  24. @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
  25. # Some don't have object files.
  26. test-ccan/%:: tools/run_tests
  27. @echo Testing $*...
  28. @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
  29. clean: tools-clean
  30. $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name _info`
  31. $(RM) inter-depends lib-depends test-depends
  32. # Only list a dependency if there are object files to build.
  33. inter-depends: $(ALL_DEPENDS)
  34. for f in $(ALL_DEPENDS); do echo test-ccan/$$(basename $$(dirname $$f) ): $$(for dir in $$(cat $$f); do [ "$$(echo $$dir/[a-z]*.c)" = "$$dir/[a-z]*.c" ] || echo libccan.a\("$$(basename $$dir)".o\); done); done > $@
  35. test-depends: $(ALL_DEPENDS)
  36. for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
  37. include tools/Makefile
  38. -include inter-depends
  39. -include test-depends
  40. -include Makefile-web