NOTE: This document isn't finished at all. This contains the first
instructions to build gtk-gnutella for win32.

This document describes how to setup gtk-gnutella for cross-compiling on a
Linux system, using xmingw to compile as a windows program.

As my Linux distribution is based on gentoo, I'll describe the steps involved
to setup xmingw, the necessary libraries and finally how to build
gtk-gnutella.

I have made the assumption that your xmingw installation will be under
/opt/xmingw and all extra installed libraries, include files etc. will be
installed in /opt/xmingw/local.

First, the xmingw cross-compile environment needs to setup. Under gentoo this
is as easy as:

$ emerge xmingw-binutils xmingw-gcc xmingw-w32api xmingw-runtime

By the way, if you also want a C++ compiler under your xmingw, you need to
emerge xmingw-gcc twice. gtk-gnutella doesn't need one though.

Next thing we need is the gtk+ devel packages for mingw. You could either
compile all needed packages by hand, or take the easy road and grab them from
the gaim project:

  http://prdownloads.sourceforge.net/gaim/gtk-dev-2.6.9-rev-a.tar.gz

  (from http://gaim.sourceforge.net/win32/build.php)

extract the sources, and move everything from the gtk_2_0 directory to
/opt/xmingw/local:

$ tar -zxvf gtk-dev-2.6.9-rev-a.tar.gz
$ mv -- gtk_2_0/* /opt/xmingw/local/

You should now have something like this:

$ ls /opt/xmingw/local/
bin
build.sh
include
lib
version.sh

$ ls /opt/xmingw/local/lib/
asprintf.lib
atk-1.0.lib
charset.lib
fontconfig.def
fontconfig.lib
freetype.def
gdk-win32-2.0.def
gdk-win32-2.0.lib
gdk_pixbuf-2.0.def
gdk_pixbuf-2.0.lib
gettextpo.lib
glib-2.0
glib-2.0.def
glib-2.0.lib
gmodule-2.0.def
gmodule-2.0.lib
gobject-2.0.def
gobject-2.0.lib
gthread-2.0.def
gthread-2.0.lib
gtk-2.0
gtk-win32-2.0.def
gtk-win32-2.0.lib
iconv.lib
intl.lib
jpeg62.def
libatk-1.0.dll.a
libfontconfig.dll.a
libfreetype-bcc.lib
libfreetype.a
libfreetype.dll.a
libfreetype.lib
libgdk-win32-2.0.dll.a
libgdk_pixbuf-2.0.dll.a
libglib-2.0.dll.a
libgmodule-2.0.dll.a
libgobject-2.0.dll.a
libgthread-2.0.dll.a
libgtk-win32-2.0.dll.a
libiconv.a
libintl.a
libjpeg-bcc.lib
libjpeg.a
libjpeg.dll.a
libjpeg.lib
libpango-1.0.dll.a
libpangoft2-1.0.dll.a
libpangowin32-1.0.dll.a
libpng.a
libpng.dll.a
libpng.lib
libpng13.a
libpng13.dll.a
libregex.a
libtiff-bcc.lib
libtiff.a
libtiff.dll.a
libtiff.lib
libtiff3.def
libz-bcc.lib
libz.a
libz.dll.a
libz.lib
pango-1.0.def
pango-1.0.lib
pangoft2-1.0.def
pangoft2-1.0.lib
pangowin32-1.0.def
pangowin32-1.0.lib
pkgconfig
zlib-bcc.lib
zlib.def
zlib.lib

As gtk-gnutella has a dependency on regex. Grab regex from

  ftp://ftp.gnu.org/gnu/regex

extract it and compile it as follows:

$ PATH=/opt/xmingw/bin:$PATH \
  CC=i386-mingw32msvc-gcc \
  ./configure \
    --host=i386-mingw32msvc \
    --prefix=/usr/local/

$ PATH=/opt/xmingw/bin:$PATH \
  make -k

ignore any build errors regarding tex like:
"make[1]: tex: Command not found"

and last, build a library:

$ /opt/xmingw/i386-mingw32msvc/bin/ar ru libregex.a regex.o

Now copy libregex.a to /opt/xmingw/local/lib and copy regex.h to
/opt/xmingw/local/include:

$ cp libregex.a /opt/xmingw/local/lib
$ cp regex.h /opt/xmingw/local/include

Compiling gtk-gnutella

As Configure currently doesn't handle cross-compiling very well, there is a
template config.sh available, named config.sh.xmingw.  Copy the
config.sh.xmingw as being the correct config.sh:

$ cp config.sh.xmingw config.sh

Remember, the config.sh assumes the layout in /opt/xmingw and
/opt/xmingw/local as described above. Next tell Configure to read the
config.sh and recreate the makefiles:

$ ./Configure -S && make depend

The final step is of course to build gtk-gnutella:

$ export PATH=/opt/xmingw/bin:$PATH
$ make

I was unsuccessful with the win32 packages, that's why I choose to
cross-compile the package myself. First we need to compile the package:

$ PATH=/opt/xmingw/bin:$PATH \
  LDFLAGS=-L/opt/xmingw/local/lib \
  CPPFLAGS=-I/opt/xmingw/local/include \
 ./configure \
   --host=i386-mingw32msvc \
   --target=i386-mingw32msvc \
   --without-python \
   --without-readline \
   --prefix=/opt/xmingw/local/

What we are doing here is set the PATH to start with the xmingw binary
directory. This is where the cross-compiler lives and must be found. As I took
the non-standard route to place my own packages in /opt/xmingw/local I needed
to setup the LDFLAGS and CPPFLAGS to point them in the right direction.
--host and --target tell configure for which host we are going to build. Note
that we are _not_ using the --build flag, as we are building on the machine
which configure can detect itself.  Neither do we use python, nor readline.

$ PATH=/opt/xmingw/bin:$PATH make
$ PATH=/opt/xmingw/bin:$PATH make install

/* Author: Jeroen Asselman */
/* Last-Edited: $Id$ */
/*i vi: set tw=78: */
