Makefile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Hacky makefile to compile everything and run the tests in some kind of sane order.
  2. # V=--verbose for verbose tests.
  3. CFLAGS=-g -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan -I.
  4. ALL=$(patsubst ccan/%/test, %, $(wildcard ccan/*/test))
  5. ALL_DIRS=$(patsubst %, ccan/%, $(ALL))
  6. ALL_DEPENDS=$(patsubst %, ccan/%/.depends, $(ALL))
  7. ALL_LIBS=$(patsubst %, ccan/%.o, $(ALL))
  8. libccan.a: $(ALL_LIBS)
  9. $(AR) r $@ $^
  10. check: $(ALL_DIRS:%=test-%)
  11. distclean: clean
  12. rm -f $(ALL_DEPENDS)
  13. $(ALL_DEPENDS): %/.depends: tools/ccan_depends
  14. tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
  15. $(ALL_LIBS):
  16. $(LD) -r -o $@ $^ /dev/null
  17. test-ccan/%: tools/run_tests ccan/%.o
  18. @echo Testing $*...
  19. @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
  20. ccanlint: tools/ccanlint/ccanlint
  21. clean: tools-clean
  22. $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'` `find . -name _info`
  23. $(RM) inter-depends lib-depends test-depends
  24. inter-depends: $(ALL_DEPENDS)
  25. for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),ccan/\1.o,p' < $$f`; done > $@
  26. test-depends: $(ALL_DEPENDS)
  27. for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
  28. lib-depends: $(foreach D,$(ALL),$(wildcard $D/*.[ch]))
  29. for c in $(ALL); do echo ccan/$$c.o: `ls ccan/$$c/*.c | grep -v /_info.c | sed 's/.c$$/.o/'`; done > $@
  30. include tools/Makefile
  31. -include inter-depends
  32. -include test-depends
  33. -include lib-depends