Makefile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. echo $(ALL_DIRS)
  16. distclean: clean
  17. rm -f $(ALL_DEPENDS)
  18. # Override implicit attempt to link directory.
  19. $(ALL_DIRS):
  20. @touch $@
  21. $(ALL_DEPENDS): %/.depends: tools/ccan_depends
  22. tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
  23. test-ccan/%: tools/run_tests libccan.a(%.o)
  24. @echo Testing $*...
  25. @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
  26. # Some don't have object files.
  27. test-ccan/%:: tools/run_tests
  28. @echo Testing $*...
  29. @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
  30. clean: tools-clean
  31. $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name _info`
  32. $(RM) inter-depends lib-depends test-depends
  33. # Only list a dependency if there are object files to build.
  34. inter-depends: $(ALL_DEPENDS)
  35. 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 > $@
  36. test-depends: $(ALL_DEPENDS)
  37. for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
  38. include tools/Makefile
  39. -include inter-depends
  40. -include test-depends
  41. -include Makefile-web