build.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh
  2. #
  3. # Builds the M2c compiler (step 2: scalars + MC64 backend).
  4. # Requires GNU Modula-2 (gm2) and the Coco/R CR binary.
  5. #
  6. # Usage: ./build.sh (from the project root)
  7. #
  8. # All sources live in src/ (grammar, frames, hand modules, generated
  9. # scanner/parser/driver). Build objects (.o) stay in the project root
  10. # (gm2 -I src drops them in the cwd); the binary links to ./M2c.
  11. #
  12. # Pipeline: src/M2c.atg -> src/M2cS/M2cP/M2c (.mod)
  13. # -> gm2 -fiso -I src -> ./M2c
  14. #
  15. CRBIN="${CRBIN:-/home/eric/Projets/Projets-Modula2/MyWork/CocoGm2/CR}"
  16. echo "=== Regenerating M2cS / M2cP / M2c from M2c.atg ==="
  17. cd src || exit 1
  18. CRFRAMES="$(pwd)" "$CRBIN" -m -C M2c.atg || exit 1
  19. cd ..
  20. echo "=== Deleting all o files ==="
  21. rm -f ./*.o
  22. echo "=== Compiling the needed modules ==="
  23. for m in FileIO SymTab MGen M2cS M2cP M2c; 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. M2cS.o M2cP.o FileIO.o SymTab.o MGen.o src/M2c.mod || exit 1
  29. echo "=== Phase 2: compiling main module and linking using the module list ==="
  30. gm2 -fiso -I src -fuse-list=src/modules.lst -o M2c \
  31. M2cS.o M2cP.o FileIO.o SymTab.o MGen.o src/M2c.mod || exit 1
  32. echo "=== M2c built ==="