Makefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. TESTS = \
  2. tests/lexer/test-lexer.sh \
  3. tests/parser/test-parser.sh \
  4. tests/interpreter/test-interpreter.sh \
  5. tests/generator/test-generator.sh \
  6. tests/vm/test-vm.sh \
  7. $(EMPTY)
  8. PROGS = \
  9. lexer \
  10. parser \
  11. interpreter \
  12. generator \
  13. vm \
  14. $(EMPTY)
  15. all: $(PROGS)
  16. V ?= 0
  17. _AT_1 =
  18. _AT_0 = @
  19. _AT = $(_AT_$(V))
  20. _IMG_1 =
  21. _IMG_0 = @echo " IMG " $@;
  22. _IMG = $(_IMG_$(V))
  23. no_redefines = sed 's/redefined [^ ]*\( with [^ ]*\)\? *//g'
  24. _P_COUNT = 0
  25. ifndef _P_TOTAL
  26. _P_MARK := ++progress-mark++
  27. _P_TOTAL := $(shell $(MAKE) -n _P_TOTAL=$(_P_MARK) $(MAKECMDGOALS) | grep --count -F -- $(_P_MARK))
  28. endif
  29. PROGRESS_PERCENT ?= yes
  30. ifeq ($(PROGRESS_PERCENT),yes)
  31. _P = $(eval _P_COUNT = $(shell expr $(_P_COUNT) + 1)) printf "[%3d%%] " `expr \( $(_P_COUNT) \* 100 \) \/ $(_P_TOTAL)`
  32. else
  33. _P_WIDTH := $(shell printf "$(_P_TOTAL)" | wc -c)
  34. _P = $(eval _P_COUNT = $(shell expr $(_P_COUNT) + 1)) printf "[%$(_P_WIDTH)d/$(_P_TOTAL)] " $(_P_COUNT);
  35. endif
  36. # Image generation in gforthmi manipulates temporary files whose names
  37. # are not unique, so we cannot build images in parallel.
  38. .NOTPARALLEL:
  39. $(PROGS): %: %.fs
  40. @$(_P)
  41. $(_IMG)gforthmi $@ $< 3>&1 1>/dev/null 2>&3 3>&1 | $(no_redefines) >&2
  42. check: $(TESTS) $(PROGS)
  43. $(_AT)srcdir=`pwd`; \
  44. for t in $(TESTS); do \
  45. printf "%40s : " $$t; \
  46. srcdir=$$srcdir $$t; \
  47. case $$? in \
  48. 0) printf "\033[32mPASS\033[0m\n" ;; \
  49. 77) printf "\033[34mSKIP\033[0m\n" ;; \
  50. *) printf "\033[31mFAIL\033[0m\n" ;; \
  51. esac; \
  52. done
  53. clean:
  54. rm -f test-*.tmp test-*.log $(PROGS)