Makefile 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. # Trying to build the whole repo is usually a lose; there will be some
  12. # dependencies you don't have.
  13. EXCLUDE=wwviaudio ogg_to_pcm
  14. # Anything with an _info file is a module.
  15. ALL=$(filter-out $(EXCLUDE), $(patsubst ccan/%/_info, %, $(wildcard ccan/*/_info)))
  16. ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
  17. # Not all modules have tests.
  18. ALL_TESTS=$(patsubst ccan/%/test/, %, $(foreach dir, $(ALL), $(wildcard ccan/$(dir)/test/)))
  19. default: libccan.a
  20. include Makefile-ccan
  21. fastcheck: $(ALL_TESTS:%=summary-fastcheck-%)
  22. check: $(ALL_TESTS:%=summary-check-%)
  23. distclean: clean
  24. rm -f $(ALL_DEPENDS)
  25. $(ALL_DEPENDS): %/.depends: %/_info tools/ccan_depends
  26. @tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
  27. # Actual dependencies are created in inter-depends
  28. check-%: tools/ccanlint/ccanlint
  29. @tools/ccanlint/ccanlint -d ccan/$*
  30. fastcheck-%: tools/ccanlint/ccanlint
  31. @tools/ccanlint/ccanlint -t -d ccan/$*
  32. # Doesn't test dependencies, doesn't print verbose fail results.
  33. summary-check-%: tools/ccanlint/ccanlint $(OBJFILES)
  34. @tools/ccanlint/ccanlint -s -d ccan/$*
  35. summary-fastcheck-%: tools/ccanlint/ccanlint $(OBJFILES)
  36. @tools/ccanlint/ccanlint -t -s -d ccan/$*
  37. ccan/%/info: ccan/%/_info
  38. $(CC) $(CFLAGS) -o $@ -x c $<
  39. libccan.a(%.o): ccan/%.o
  40. $(AR) r $@ $<
  41. clean: tools-clean
  42. $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name info` `find . -name '*.d'`
  43. $(RM) inter-depends lib-depends test-depends ccan/*-Makefile
  44. # Creates a dependency from the tests to the object files which it needs.
  45. inter-depends: $(ALL_DEPENDS) Makefile
  46. @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 > $@
  47. # Creates dependencies between tests, so if foo depends on bar, bar is tested
  48. # first
  49. test-depends: $(ALL_DEPENDS) Makefile
  50. @for f in $(ALL_DEPENDS); do echo check-`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),check-\1,p' < $$f`; done > $@
  51. include tools/Makefile
  52. -include inter-depends
  53. -include test-depends
  54. -include Makefile-web