-----------------------------------------------------------------------------

COMPILING MERCURY WITH A MINGW / MINGW-W64 CROSS-COMPILER

You can compile Mercury on Linux with a MinGW or MinGW-w64 cross-compiler.
After copying and adjusting some paths, the Mercury installation should be
usable on Windows.  When combined with a native Mercury compiler, it can be
used to cross-compile Mercury applications for Windows.

NOTE: There are problems with 64-bit executables in some low-level C grades,
namely 'asm_fast*' and 'asm_jump*' grades. The 'none*' and 'reg*' grades
do appear to work correctly in our limited testing.

-----------------------------------------------------------------------------

PREREQUISITES

We assume you are on Linux.  You will need a native Mercury installation
installed in the normal way.  The native Mercury version should match the
version of Mercury you intend to cross-compile.

You need a MinGW or MinGW-w64 cross-compiler, and a pthreads implementation.
Many Linux distributions will have packages available, e.g. gcc-mingw32 and
friends on Debian.  Otherwise, you may try <http://mxe.cc/>.

    git clone -b stable https://github.com/mxe/mxe.git
    cd mxe
    make gcc pthreads JOBS=6

-----------------------------------------------------------------------------

INSTALLATION

Ensure that the MinGW cross-compiler i686-pc-mingw-gcc or similar is in your
PATH.  In a fresh copy of the Mercury source tree, run the following in place
of the configure script:

    tools/configure_mingw_cross [--host=HOST] OPTIONS...

If your installation uses a host triplet other than "i686-pc-mingw32" then
you must pass that using the --host= option.  You may pass other options
through to configure as well, e.g.

    tools/configure_mingw_cross \
        --host=x86_64-w64-mingw32 \
        --prefix=/usr/local/mercury-mingw

Then install Mercury as usual:

    mmake install -j6

-----------------------------------------------------------------------------

USING THE CROSS-COMPILER ON LINUX

You can substitute the Windows version of the Mercury compiler binary
(mercury_compile.exe) with a Linux version.  Again, this should be from
the same or similar version of Mercury.

The 'mmc' shell script will have been set up to look for a binary named
'mercury_compile' so you just need to place the Linux binary into the bin
directory, e.g.

    % ln -s /usr/local/mercury/bin/mercury_compile /usr/local/mercury-mingw/bin

Now you can run the 'mmc' script from the cross-compiled installation:

    % /usr/local/mercury-mingw/bin/mmc -m hello --cross-compiling
    Making Mercury/int3s/hello.int3
    Making Mercury/ints/hello.int
    Making Mercury/cs/hello.c
    Making Mercury/os/hello.o
    Making hello.exe

You should definitely pass `--cross-compiling' if mercury_compile was
compiled for 64-bit Linux.  You can add it to the Mercury.config file for the
Windows Mercury installation so you don't forget.

-----------------------------------------------------------------------------
