####################################################
Building a cross compiler for GCJ/MINGW under Cygwin
####################################################


Get Cygwin installed
####################


Run up the Cygwin "setup" installed and point it to an up-to-date mirror (I chose
mirror.averse.net). Select "unzip" from the "Archive" category and "patch" from the
"Utils" category, then open up the "Devel" category and make sure the following
packages are selected :

        autoconf
        automake
        binutils
        bison
        byacc
        flexx
        gcc
        libtool
        make
        mktemp

        ( I suspect these are not all required but on a fresh install of Cygwin
          this is what finally worked for me )
        
Selecting these packages will also select the packages that these tools depend on,
so you should leave the other package selections on "default" unless you are
adding something.

You can now sit back and wait while it downloads 30Mb+ of Cygwin tools...

Once Cygwin has installed find the "cygwin.bat" file and place the following
line somewhere before the call to "bash" :

        set CYGWIN=check_case:strict

Although this setting seems like a really good idea it does break things in normal
Cygwin use, however it works fine with all the stuff we are going to use now.


Create your build directory
###########################

Start Cygwin
Create a directory for your build
Copy the file attached to this message to this directory
unzip mingwPack.zip


Download the GCJ files
######################

http://sourceforge.net/project/showfiles.php?group_id=2435&release_id=38019

    binutils-2.13.90-20021006-2-src.tar.gz
    gcc-3.2-20020817-1.src.tar.gz
    gcj-3.2-20021210-1.src.diff.gz
    mingw-runtime-2.3.tar.gz
    w32api-2.1.tar.gz
    
http://sourceforge.net/projects/mingwrep/

    regex-0.12-20010123.zip
    
Get the GCJ source code for version 3.2 from any GCC mirror...
(I got mine from http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-3.2/)

    gcc-java-3.2.tar.gz 

    
Place all these files in the build directory you created earlier.

    ( If you download different versions to these you may have to edit
      the envSetup.sh or buildGcj.sh scripts and it may not work anyway ).


    
Extract binutils, gcc & and gcj 
###############################

Now go back into Cygwin and from your build directory do the following :

    tar -zxvf binutils-2.13.90-20021006-2-src.tar.gz
    tar -zxvf gcc-3.2-20020817-1.src.tar.gz
    mv gcc-3.2-20020817-1 gcc-3.2
    tar -zxvf gcc-java-3.2.tar.gz


Apply Ranjit's patches and my patch to the makefile
###################################################

Now the source folders are ready we can apply the patches :

    gunzip gcj-3.2-20021210-1.src.diff.gz
    cd gcc-3.2
    patch -b -p0 < ../gcj-3.2-20021210-1.src.diff
    patch -b -p0 < ../gcj-3.2-20021210-2.src.diff
    cd ..


Do the build !
##############

./buildGcj.sh

This is a wrapper around slightly modified versions of
Rangit's scripts...


Test it
#######

Compile the "HelloWorld" example with :

    xgcc/bin/mingw32-gcj --main=HelloWorld HelloWorld.java -o Hello

And then try running it from a DOS window (to ensure it doesn't pick
anything up from the Cygwin path.
