build_tpshell.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. # build_tpshell.sh -- build tpshell. A thin wrapper; `make` is the build.
  3. #
  4. # This used to be a second, hand-maintained copy of the build recipe, and it
  5. # was wrong in two ways that a copy of a build recipe should never be:
  6. #
  7. # * it ran `gm2 -c Posix.mod`, but Posix is a FOREIGN module written in C
  8. # and built by `cc -c Posix.c` (see Posix.def). gm2 has no Posix.mod, so
  9. # the build died on the third module every time.
  10. # * it printed phase 2's return code and then carried on regardless, so a
  11. # failed link was reported as a successful build as long as some earlier
  12. # `tpshell` happened to be lying around. The Makefile does not have that
  13. # hole, which is part of why it is the one that counts.
  14. #
  15. # Two copies of a build recipe drift, and the copy that is wrong is the one
  16. # nobody runs. So there is now one: the Makefile. This wrapper exists only
  17. # so the old invocation keeps working, and it deliberately has no build
  18. # knowledge of its own beyond that.
  19. #
  20. # The two-phase link itself is the real content of the Makefile:
  21. # phase 1 -fgen-module-list=... generates the import closure
  22. # phase 2 -fuse-list=... links against it
  23. # A single invocation trips gm2's whole-program pass-3 rollup ("too many
  24. # errors in pass 3") on a compiler-sized program. Phase 1 exiting 1 is that
  25. # expected rollup, not a failure -- which is exactly the sort of thing a
  26. # hand-rolled script gets wrong, and is one more reason it is gone.
  27. set -eu
  28. cd "$(dirname "$0")" || exit 9
  29. if command -v make >/dev/null 2>&1; then
  30. exec make "$@"
  31. fi
  32. echo "build_tpshell.sh: make is not installed." >&2
  33. echo " The build recipe now lives in exactly one place, the Makefile," >&2
  34. echo " because a second copy of it was wrong in two ways. Install make," >&2
  35. echo " or read the Makefile and run its four commands by hand:" >&2
  36. echo >&2
  37. sed -n '1,20p' Makefile | sed 's/^/ /' >&2
  38. exit 1