Modifying an Example
This section describes how to update the build files when modifying an example from the.
The build files provided with an example have the following properties:
Building is managed.
A target is provided for all supported compilers.
For Poly/ML, compilation is incremental in two stages: the library dependencies are loaded in the first stage and the application source code is loaded in the second stage. The library dependencies are not reloaded if only the application source code changes which substantially reduces build times.
In addition to the SML source code, an example contains the following build files that may need to be updated:
and the following files for building with Make that do not need to be changed:
Note that mlton-main.sml should not be changed because Makefile expects the main function to be called main for Poly/ML.
Changing the application name
Before changing the application name, make distclean should be performed.
The application executable name is defined in app.mk by the Make variables
TARGET_MLTON for MLton and
TARGET_POLYML for Poly/ML
These variables should be updated to the desired application names. To retain the MLton and Poly/ML application names of the form NAME-mlton and NAME-polyml, respectively, only the variable NAME needs to be updated in app.mk.
Changing application source files
After adding, removing or renaming an application source file, the application source file names should be updated in:
mlton.mlb for MLton
polyml-app.sml for Poly/ML
The source file dependencies are defined in app.mk by the Make variables
SRC_MLTON for MLton and
SRC_POLYML for Poly/ML
These are derived automatically so do not need to be updated.
Changing library dependencies
If the application source code introduces or removes dependence on an SML structure Namespace for a namespace Namespace-Version, the library dependency (with the indicated form) should be added or removed, respectively, in:
app.mk, in the Make variable LIB_NAMES (namespace-version)
mlton.mlb for MLton ($(GIRAFFE_SML_LIB)/namespace-version/mlton.mlb)
polyml-libs.sml for Poly/ML ($(GIRAFFE_SML_LIB)/namespace-version/polyml.sml)
The file polyml-libs.sml also includes library dependencies of the library dependencies, i.e. the transitive closure of the library dependencies. Therefore, after adding a dependency, it may be necessary to add other dependencies and, after removing a dependency, it may be possible to remove other dependencies.
Note that the variable LIB_NAMES in app.mk should include namespace-version if and only if the file mlton.mlb includes $(GIRAFFE_SML_LIB)/namespace-version/mlton.mlb.