GNUmakefile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/this/is/make
  2. #
  3. # This makefile compiles SQLTester test files into something
  4. # we can readily import into JavaScript.
  5. all:
  6. SHELL := $(shell which bash 2>/dev/null)
  7. MAKEFILE := $(lastword $(MAKEFILE_LIST))
  8. CLEAN_FILES :=
  9. DISTCLEAN_FILES := ./--dummy-- *~
  10. test-list.mjs := test-list.mjs
  11. test-list.mjs.gz := $(test-list.mjs).gz
  12. CLEAN_FILES += $(test-list.mjs)
  13. tests.dir := $(firstword $(wildcard tests ../../jni/src/tests))
  14. $(info test script dir=$(tests.dir))
  15. tests.all := $(wildcard $(tests.dir)/*.test)
  16. bin.touint8array := ./touint8array
  17. $(bin.touint8array): $(bin.touint8array).c $(MAKEFILE)
  18. $(CC) -o $@ $<
  19. CLEAN_FILES += $(bin.touint8array)
  20. ifneq (,$(tests.all))
  21. $(test-list.mjs): $(bin.touint8array) $(tests.all) $(MAKEFILE)
  22. @{\
  23. echo 'export default ['; \
  24. sep=''; \
  25. for f in $(sort $(tests.all)); do \
  26. echo -en $$sep'{"name": "'$${f##*/}'", "content":'; \
  27. $(bin.touint8array) < $$f; \
  28. echo -n '}'; \
  29. sep=',\n'; \
  30. done; \
  31. echo '];'; \
  32. } > $@
  33. @echo "Created $@"
  34. $(test-list.mjs.gz): $(test-list.mjs)
  35. gzip -c $< > $@
  36. CLEAN_FILES += $(test-list.mjs.gz)
  37. all: $(test-list.mjs.gz)
  38. else
  39. @echo "Cannot build $(test-list.mjs) for lack of input test files."; \
  40. echo "Symlink ./tests to a directory containing SQLTester-format "; \
  41. echo "test scripts named *.test, then try again"; \
  42. exit 1
  43. endif
  44. .PHONY: clean distclean
  45. clean:
  46. -rm -f $(CLEAN_FILES)
  47. distclean: clean
  48. -rm -f $(DISTCLEAN_FILES)