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