| 123456789101112131415161718192021222324252627282930 |
- #!/bin/sh
- # Builds M2make with the V3 M2 compiler itself.
- # Usage: ./build_m2.sh (from the tools/m2make directory)
- # Output: b_v3/M2make (a V3-built binary)
- #
- # Session: SysShim + FileIO (runtime/syslib) + M2makeOS + M2make,
- # then qbe + cc with the runtime shim and m2make_os.c.
- set -e
- cd "$(dirname "$0")"
- M2=../../compiler/M2
- SYS=../../runtime/syslib
- rm -rf b_v3
- mkdir -p b_v3
- cp M2make.mod M2makeOS.def m2make_os.c b_v3/
- cp M2makeOS_v3.mod b_v3/M2makeOS.mod
- cd b_v3
- mkdir -p gen_ssa
- echo "=== Compiling (M2 session) ==="
- # NB: M2 exits 0 even when it reports "Incorrect source", so gate on
- # the verdict text instead of the exit code.
- "../$M2" \
- "../$SYS/SysShim.def" "../$SYS/SysShim.mod" \
- "../$SYS/FileIO.def" "../$SYS/FileIO.mod" \
- M2makeOS.def M2makeOS.mod M2make.mod \
- 2>&1 | tee m2.log | grep -q Parsed || exit 1
- echo "=== Assembling and linking ==="
- qbe -o gen_ssa/M2make.s gen_ssa/M2make.ssa || exit 1
- cc gen_ssa/M2make.s "../$SYS/shim.c" m2make_os.c \
- -o M2make -lm || exit 1
- echo "=== b_v3/M2make built ==="
|