build.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. #
  3. # Builds the V3 M2 compiler (step 1: minimal integer pipeline to QBE).
  4. # Requires GNU Modula-2 (gm2 -fiso) and the Coco/R CR binary.
  5. #
  6. # Usage: ./build.sh (from the compiler directory)
  7. #
  8. # All sources live in src/ (grammar, frames, FileIO, SymTab, QbeGen,
  9. # generated scanner/parser/driver). Objects land in the cwd; the
  10. # binary links to ./M2. Generated .ssa goes to gen_ssa/.
  11. #
  12. # Pipeline: src/M2.atg -> src/M2S/M2P/M2 (.mod)
  13. # -> gm2 -fiso -I src -> ./M2
  14. # -> ./M2 tests/foo.mod -> gen_ssa/FOO.ssa -> qbe -> cc
  15. CRBIN="${CRBIN:-/home/eric/Projets/Projets-Modula2/MyWork/CocoGm2/CR}"
  16. echo "=== Regenerating M2S / M2P / M2 from M2.atg ==="
  17. cd src || exit 1
  18. CRFRAMES="$(pwd)" "$CRBIN" -m -C M2.atg || exit 1
  19. cd ..
  20. mkdir -p gen_ssa
  21. echo "=== Compiling ==="
  22. rm -f ./*.o
  23. for m in FileIO AST Lower SymTab QbeGen M2S M2P M2; do
  24. gm2 -fiso -I src -c "src/$m.mod" || exit 1
  25. done
  26. echo "=== Phase 1: generating the module list ==="
  27. gm2 -fiso -I src -fgen-module-list=src/modules.lst -o /dev/null \
  28. M2S.o M2P.o FileIO.o AST.o Lower.o SymTab.o QbeGen.o src/M2.mod || exit 1
  29. echo "=== Phase 2: compiling main module and linking ==="
  30. gm2 -fiso -I src -fuse-list=src/modules.lst -o M2 \
  31. M2S.o M2P.o FileIO.o AST.o Lower.o SymTab.o QbeGen.o src/M2.mod || exit 1
  32. echo "=== M2 built ==="