#!/bin/sh # # Builds the V3 M2 compiler (step 1: minimal integer pipeline to QBE). # Requires GNU Modula-2 (gm2 -fiso) and the Coco/R CR binary. # # Usage: ./build.sh (from the compiler directory) # # All sources live in src/ (grammar, frames, FileIO, SymTab, QbeGen, # generated scanner/parser/driver). Objects land in the cwd; the # binary links to ./M2. Generated .ssa goes to gen_ssa/. # # Pipeline: src/M2.atg -> src/M2S/M2P/M2 (.mod) # -> gm2 -fiso -I src -> ./M2 # -> ./M2 tests/foo.mod -> gen_ssa/FOO.ssa -> qbe -> cc CRBIN="${CRBIN:-/home/eric/Projets/Projets-Modula2/MyWork/CocoGm2/CR}" echo "=== Regenerating M2S / M2P / M2 from M2.atg ===" cd src || exit 1 CRFRAMES="$(pwd)" "$CRBIN" -m -C M2.atg || exit 1 cd .. mkdir -p gen_ssa echo "=== Compiling ===" rm -f ./*.o for m in FileIO SymTab QbeGen M2S M2P M2; do gm2 -fiso -I src -c "src/$m.mod" || exit 1 done echo "=== Phase 1: generating the module list ===" gm2 -fiso -I src -fgen-module-list=src/modules.lst -o /dev/null \ M2S.o M2P.o FileIO.o SymTab.o QbeGen.o src/M2.mod || exit 1 echo "=== Phase 2: compiling main module and linking ===" gm2 -fiso -I src -fuse-list=src/modules.lst -o M2 \ M2S.o M2P.o FileIO.o SymTab.o QbeGen.o src/M2.mod || exit 1 echo "=== M2 built ==="