Using Make

All examples use a common Makefile so are built using the same Make commands. (Example-specific values are defined in a file called app.mk, which is included by Makefile.)

Building

The example called name can be built according to the following steps:

  1. Unpack the archive with the command

    tar -xzf name.tar.gz
  2. Change directory to the example directory with the command

    cd name/
  3. Ensure that the environment variable GIRAFFEHOME is the Giraffe Library installation directory and is exported.

    For example, if using Bash, to print its currently exported value, enter the command

    sh -c 'echo ${GIRAFFEHOME}'

    If necessary, to set its value and export it, enter the commands

    GIRAFFEHOME=installdir
    export GIRAFFEHOME

    where installdir is the Giraffe Library installation directory.

  4. To see the build options, enter the command

    make

    This will fail if GIRAFFEHOME is not correctly set as described in the previous step.

  5. To build an executable, enter the command

    make compiler

    where compiler is one of the supported compilers reported in the previous step.

    For example

    make polyml
    make mlton

    Multiple targets can be specified, for example

    make polyml mlton

    The resulting executable is called name-compiler.

Running

To run an executable for the example called name, enter the command

./name-compiler

where compiler is one of the compilers that the example was built with.

For example

./name-polyml
./name-mlton

To test an application based on Gio.Application with different compilers, all running instances of the program should be closed before running the program built with a different compiler.

Unless the Gio.Application object has been been told to ignore uniqueness, it will check for a running instance with the same application identifier when a program is started. If there is already a running instance of the application, a signal is sent to the existing instance and the program will terminate. As MLton and Poly/ML applications are built from the same source, both executables use the same application identifier. Consequently, running e.g. name-polyml while name-mlton is already running would exercise very little of the code in name-polyml because the new instance would be created by name-mlton.

Cleaning

To remove all files built for an example, enter the command

make distclean

To remove intermediate files but not the executables, enter the command

make clean

The following variants of the above commands remove only those files built where the compiler was compiler:

make clean-compiler
make distclean-compiler