The Makefile of MinCaml Compiler

Once you have downloaded the MinCaml compiler, please take a look at its Makefile. It describes how to compile MinCaml itself.

The Makefile of MinCaml uses a convenient tool called OCamlMakefile (the line include OCamlMakefile on the bottom). Just by listing the files needed for MinCaml in the line SOURCES = ..., you can generate the byte-code executable min-caml by running the command "make byte-code". Similarly, you can get the native-code min-caml.opt by "make native-code". Furthermore, "make top" creates an OCaml top-level interactive environment min-caml.top where the modules of MinCaml are loaded by default. It is convenient for debugging and experiments.

MinCaml's Makefile also has the functionality of automatic testing. Put ML code "program-name.ml" under directory test, write the program name at the line TESTS = ..., and run "make do_test". Then, the OCaml-produced result (program-name.ans) and the result (program-name.res) of MinCaml-generated assembly (program-name.s) are automatically compared, and their difference is output to "program-name.cmp". Usually, it is empty because there should be no difference as long as the compilation and execution have succeeded.

You need a SPARC environment with the compiler gcc and assembler as to execute the compiled program. However, it is not necessary for just generating the SPARC assembly.

Next