build.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. #
  3. # Builds the M2comp compiler (step 1: Coco/R syntax front end).
  4. # Requires GNU Modula-2 (gm2 -fiso) and the Coco/R CR binary.
  5. #
  6. # Usage: ./build.sh (from the m2comp directory)
  7. #
  8. # All sources live in src/ (grammar, frames, hand modules, generated
  9. # scanner/parser/driver). The binary links to ./M2comp (project root).
  10. #
  11. # Pipeline: src/M2comp.atg -> src/M2compS/M2compP/M2comp (.mod)
  12. # -> gm2 -fiso -> ./M2comp
  13. #
  14. CRBIN="${CRBIN:-/home/eric/Projets/Projets-Modula2/MyWork/CocoGm2/CR}"
  15. echo "=== Regenerating M2compS / M2compP / M2comp from M2comp.atg ==="
  16. cd src || exit 1
  17. CRFRAMES="$(pwd)" "$CRBIN" -m -C M2comp.atg || exit 1
  18. echo "=== Deleting all o files ==="
  19. rm -f ./*.o
  20. echo "=== Compiling the needed modules ==="
  21. for m in FileIO SymTab AST MGen M2compS M2compP M2comp; do
  22. gm2 -fiso -c "$m.mod" || exit 1
  23. done
  24. echo "=== Phase 1: generating the module list ==="
  25. gm2 -fiso -fgen-module-list=modules.lst -o /dev/null \
  26. M2compS.o M2compP.o FileIO.o SymTab.o AST.o MGen.o M2comp.mod || exit 1
  27. echo "=== Phase 2: compiling main module and linking using the module list ==="
  28. gm2 -fiso -fuse-list=modules.lst -o ../M2comp \
  29. M2compS.o M2compP.o FileIO.o SymTab.o AST.o MGen.o M2comp.mod || exit 1
  30. cd ..
  31. echo "=== M2comp built ==="