Cross-compiling RegLookup to Windows with MinGW
===============================================

MinGW can be used to compile Windows binaries from UNIX environments.
The following instructions outline the steps required to build
reglookup.exe and reglookup-recover.exe.  This process is experimental
and Windows binaries have not been well tested.  You have been warned.

Prerequisites
-------------

- Before you start, ensure you have MinGW installed.  Under Debian,
  install the `mingw32' package.

- Download pre-compiled libiconv packages from here:
   http://gnuwin32.sourceforge.net/packages/libiconv.htm

  You will need to download the "Binaries" and "Developer files"
  packages, whose files are named libiconv-VERSION-bin.zip and
  libiconv-VERSION-lib.zip respectively.

- Unpack both zip files into a designated top-level directory.
  Suggested commands:
  $ mkdir /usr/local/src/libiconv-VERSION-bin /usr/local/src/libiconv-VERSION-lib
  $ cd /usr/local/src/libiconv-VERSION-bin
  $ unzip .../path/to/libiconv-VERSION-bin.zip
  $ cd /usr/local/src/libiconv-VERSION-lib
  $ unzip .../path/to/libiconv-VERSION-lib.zip
  

Building
--------

Review the top level RegLookup Makefile to ensure the settings match
your environment.  Find the conditional block which looks like:

################################################################################
# MinGW cross-compiling build settings
ifdef BUILD_MINGW

## These may need to be changed
CC=i586-mingw32msvc-cc
LIBICONV_PATH=/usr/local/src/libiconv-1.9.2-1-lib

## These probably do not need to be changed
BIN_EXT=.exe
INC:=$(INC) -I$(LIBICONV_PATH)/include
EXTRA_OBJ=$(LIBICONV_PATH)/lib/libiconv.dll.a

endif
################################################################################


If either the CC or LIBICONV_PATH settings are incorrect for your
system, either update the Makefile, or override these options at build
time when you run make.  For instance, the above settings in the
Makefile are correct, you can execute the build by running:

$ make BUILD_MINGW=1

Alternatively, you may override the variables above with:

$ make BUILD_MINGW=1 CC=my-mingw-binary LIBICONV_PATH=.../path/to/libiconv-VERSION-lib

Once the build is complete, you'll find the .exe files under the
build/bin directory.


Installation
------------
Naturally, there is no install Makefile target for the MinGW build
process, since we aren't installing on the local system.  To install
these binaries on a Windows machine, simply copy over the reglookup.exe
and reglookup-recover.exe files from the build/bin directory to the
desired host.  In addition, you will need to install the libiconv2.dll
file on that host (either in the same directory as the reglookup
executables, or somewhere in the DLL search path).  This file is
available in the libiconv-VERSION-bin.zip file you downloaded earlier,
under the `bin' subdirectory.

