
Building jigdo-file and jigdo under Windows
===========================================

Building the jigdo GUI application on Windows is not straightforward
at the moment. Here are some pointers to get you started - I assume
you want to build under Windows rather than cross-compile.

- Download Cygwin from <http://www.cygwin.com/>, install in C:\cygwin.
- Download MinGW32 (minimal GNU for Windows) from
  <http://www.mingw.org/>. MinGW is similar to Cygwin, but creates
  binaries that do not depend on the huge Cygwin DLL. Create directory
  C:\mingw, unpack MinGW-x.y.tar.gz there.
  Cygwin actually includes mingw as one of the installable components.
  I have never tried that, though it probably works... better don't
  use Cygwin's toolchain with the -mno-cygwin switch, apparently this
  causes problems sometimes.
- Download GTK+ for Windows from
  <http://www.gimp.org/~tml/gimp/win32/>. You need libiconv,
  libiconv-dev, libintl, glib, glib-dev, gtk+, gtk+-dev and zlib.
  Unpack in C:\mingw\local - this should create new directories
  C:\mingw\local\bin, C:\mingw\local\lib, C:\mingw\local\include etc.
- For the mingw binaries, C:\mingw is accessible as /mingw. For Cygwin
  binaries, that is not the case ("/" in Cygwin is mapped to
  C:\cygwin). To fix this, execute from within Cygwin:
  ln -s /cygdrive/c/mingw /mingw
- Make the mingw compiler available from within Cygwin; add /mingw/bin
  to the front of PATH. You may also want to add to PATH any
  directories in /mingw/local that contain DLLs, because at runtime
  PATH is searched for any DLLs which are not in the same directory as
  the executable.
- Should you experience weird problems during compilation later on,
  remove or rename the mingw version of make, e.g. with
  mv /mingw/bin/make.exe /mingw/bin/make-mingw.exe
  In other words, use the Cygwin version. I have encountered a number
  of bizarre problems with the mingw make when compiling libwww.
- Install libwww. The easy way to do this is to get a binary package
  from the jigdo homepage <http://atterer.net/jigdo/> and to unpack it
  in /mingw/local.
  Alternatively, get the sources from
  <http://www.w3.org/Library/Distribution/> and compile it yourself.
  As of version 5.4.0, my patch for mingw support was included, so it
  should compile cleanly. Configure libwww as follows:
  ./configure i586-pc-mingw32 --prefix=/mingw/local --with-zlib=/mingw/local/lib/libz.a --without-regex --without-ssl --without-expat
- Edit the gtk-config and libwww-config scripts (probably in
  /mingw/local/bin) and adjust the paths, library versions etc. to
  match those of your installation. (In practice, you'll want to try
  compiling jigdo first, then whenever any header or lib isn't found
  adjust the scripts and rerun jigdo's configure script.) If no
  gtk-config script comes with the GTK+ release, use the one supplied
  with my binary libwww package or get it from the jigdo homepage.
- Set some environment vars:
  CC=gcc -mcpu=pentium -fnative-struct
  CXX=c++ -mcpu=pentium -fnative-struct
  MACHTYPE=i586-pc-mingw32
  For GCC 3.1, the -fnative-struct switch was renamed to -mms-bitfields
- configure jigdo --without-libdb

In the future, jigdo on Win might use the NSIS installer from
<http://www.nullsoft.com/free/nsis/>.

For debugging, the gdb supplied with mingw is useful, and so is Dr.
MinGW:
<http://mefriss1.swan.ac.uk/~jfonseca/gnu-win32/software/drmingw/index.html>

In case you want to install software in a different location than
/mingw/local and want to set LIBRARY_PATH, C_INCLUDE_PATH or
CPLUS_INCLUDE_PATH, note that with mingw, the path separator is not
':', but ';'


The following script may be useful to you. I put it in my .bashrc
under Cygwin, then just entering "mingw" will set up all environment
variables ready for mingw compilation, and "nomingw" will switch back
to Cygwin.

function mingw() {
if test -z "$old_PS1"; then
    dirs=/mingw/local/*
    old_PS1="$PS1"
    old_PATH="$PATH"
    PS1='\[\033[33m\w\033[0m\]
MinGW> '
    export CC='gcc -mcpu=pentium -fnative-struct'
    export CXX='c++ -mcpu=pentium -fnative-struct'
    export MACHTYPE="i586-pc-mingw32"
    for dir in $dirs; do
        C_INCLUDE_PATH="$C_INCLUDE_PATH;/mingw/local/$dir/include"
        CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH;/mingw/local/$dir/include"
        LIBRARY_PATH="$LIBRARY_PATH;/mingw/local/$dir/lib"
        PATH="$PATH:/mingw/local/$dir/bin:/mingw/local/$dir/lib"
    done
    unset dir dirs
    export PATH="/mingw/bin:$PATH"
    export C_INCLUDE_PATH="${C_INCLUDE_PATH#;}"
    export CPLUS_INCLUDE_PATH="${CPLUS_INCLUDE_PATH#;}"
    export LIBRARY_PATH="${LIBRARY_PATH#;}"
fi
}
function nomingw() {
    if test "$old_PS1"; then
        export PS1="$old_PS1"
        export PATH="$old_PATH"
        unset old_PS1 CC CXX LIBRARY_PATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH
        unset old_PATH
    fi
}

Contact me at <mailto:jigdo@atterer.net> in case of problems.

Richard Atterer
