m2make.md 2.1 KB

Building M2make

M2make is a front-end for the M2 Modula-2 compiler or GNU Modula-2 compiler. It's goal is to check the order of compilation of the different files of a project, compiling only what is necessary. It only a main file like this :

M2make toto.mod

I will use a topological sort to figure out the order of compiling, and which file needs to be compiled (if modified).

I needs to compile only what is necessary.

Status (implemented in tools/m2make, GNU Modula-2)

M2make [-n] [-v] [-c m2|gm2] [-I dir] [-o out] [--m2bin path] [--shim path] main.mod

  • Follows IMPORT/FROM imports transitively from the main file, topologically sorts the modules (iterative DFS, cycle reported), skips the build when the output is newer than every source.
  • m2 mode: one session (M2 + qbe + cc), gated on M2's Parsed correctly verdict. gm2 mode: per-file gm2 -fiso -c of stale units + ordered link.
  • One portable core (M2make.mod + M2makeOS.def, ISO Modula-2 importing only FileIO/M2makeOS) compiles with both gm2 -fiso (build_gm2.sh) and the V3 M2 driver (build_m2.sh); the OS layer (stat/system/text input) lives in m2make_os.c with per-compiler bindings (M2makeC.def for gm2, EXTERNAL for M2). See tools/m2make/README.md for the exact portable subset and limitations. tests/run_tests.sh: 18/18 green with both binaries.

I will use a topological sort to figure out the order of compiling, and which file needs to be compiled (if modified).

I needs to compile only what is necessary.