Makefile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 */_info
  13. rm -f $(ALL_DEPENDS)
  14. $(ALL_DEPENDS): $(ALL_DIRS:=/_info)
  15. $(ALL_DEPENDS): %/.depends: tools/ccan_depends
  16. tools/ccan_depends $* > $@ || ( rm -f $@; exit 1 )
  17. $(ALL_LIBS):
  18. $(LD) -r -o $@ $^ /dev/null
  19. test-ccan/%: tools/run_tests ccan/%.o
  20. @echo Testing $*...
  21. @if tools/run_tests $(V) ccan/$* | grep ^'not ok'; then exit 1; else exit 0; fi
  22. ccanlint: tools/ccanlint/ccanlint
  23. clean: tools-clean
  24. $(RM) `find . -name '*.o'` `find . -name '.depends'` `find . -name '*.a'`
  25. $(RM) inter-depends lib-depends test-depends
  26. inter-depends: $(ALL_DEPENDS)
  27. for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),ccan/\1.o,p' < $$f`; done > $@
  28. test-depends: $(ALL_DEPENDS)
  29. for f in $(ALL_DEPENDS); do echo test-ccan/`basename \`dirname $$f\``: `sed -n 's,ccan/\(.*\),test-ccan/\1,p' < $$f`; done > $@
  30. lib-depends: $(foreach D,$(ALL),$(wildcard $D/*.[ch]))
  31. for c in $(ALL); do echo ccan/$$c.o: `ls ccan/$$c/*.c | grep -v /_info.c | sed 's/.c$$/.o/'`; done > $@
  32. include tools/Makefile
  33. -include inter-depends
  34. -include test-depends
  35. -include lib-depends