Planeshift Guide To Compiling with MinGW32
==========================================

MinGW32 is an free, open source compiler with an associated toolset that
can be used for compiling Win32 executables. In conjunction with other 
free or open source software the majority of Planeshift can be compiled
under Windows without having to purchase any compiler or other licences.

This guide lists the steps necessary to download all the tools and
compile Planeshift.

1. Tools Download
=================

A) Download MinGW32 and MSYS from http://www.mingw.org
------------------------------------------------------

The MinGW package contains the compiler, header and lib files. The MSYS 
package contains the shell and make utility.

Go to the download page on the website and download the packages:
>> MinGW [bin] MinGW-2.0.0-3.exe
>> MSYS [bin] MSYS-1.0.8.exe

Run the two exe files to install the compiler and make utility. The
installation program should also add an icon for MSYS to your start menu.
Click the icon and it should open up a shell window. Type "exit" to close
the shell window again.

B) Download WinCVS from http://www.wincvs.org
---------------------------------------------

WinCVS is a free version control system that links to the source files 
for Planeshift and it's libraries at Sourceforge.com and allows you to 
easily download and update the current version of all source code files.

Go to the download page on the wincvs website and click
>> WinCvs 1.2 *STABLE* The x86 version 1.2
This will link to Sourceforge, where you need to download the file labelled
>> WinCvs 1.2.. WinCvs120.zip

For now, dont bother downloading any of the optional files.

Unpack the zip file to create an install directory for WinCVS. Run the
setup program to install the file. The setup program will create a WinCVS
folder in your startup menu. Click the WinCVS to run the program.

2. Libraries Download
=====================

A) Configure WinCVS
-------------------
The first step is to create a directory structure for the library files.
Create a root directory for the project (eg. D:\cvssrc\), and create 
subdirectories called "CS", "CEL", and "Planeshift".

Run WinCVS. Click Admin.. Preferences from the menu if the preferences
window is not already open. Enter the following information in the dialog
box:

(On the General Tab)
[Enter the CVSROOT]
:pserver:anonymous@cvs.crystal.sourceforge.net:/cvsroot/crystal

[Authentication]
"passwd" file on the cvs server

[Use Version]
cvs 1.10 (Standard)

(On the WinCVS tab)
[HOME folder (where cvs stores your passwords)]
d:\cvssrc

Click OK. Select View.. Browse Location.. Change from the menu and select
the d:\cvssrc directory. Click OK, then select View.. Browse Location..
Save Settings to save this default. You should now see your empty directory
structure on the left hand window:

cvssrc
   - cel
   - cs
   - planeshift

B) Use WinCVS to download the Crystal Space (CS) sourcecode
-----------------------------------------------------------

Right-click on the CS subdirectory and select "Update Selection" from the 
menu. This will then log into the sourcecode server and download all the 
sourcecode for Crystal Space.

C) Use WinCVS to download the Crystal Entity Layer (CEL) sourcecode
-------------------------------------------------------------------

Go back to Admin.. Preferences and change the [Enter the CVSROOT] to
:pserver:anonymous@cvs.cel.sourceforge.net:/cvsroot/cel

Right-click on the CEL subdirectory and select "Update Selection" again.

D) Use WinCVS to download the Planeshift sourcecode
---------------------------------------------------

Go back to Admin.. Preferences and change the [Enter the CVSROOT] to
:pserver:anonymous@cvs.planeshift.sourceforge.net:/cvsroot/planeshift

Right-click on the planeshift subdirectory and select "Update Selection" 
again.

After this process you should now have the three subdirectories full of
source code and support files. Check that appears to have been downloaded
correctly. I have occasionally had WinCVS throw a fit and refuse to update.
Normally if you close the program and open it again it will start work.

E) Download CSMINGWLIBS
-----------------------
This library is needed for compatibility between Crystal Space and MinGW.
Go to the following FTP site and download and install the latest version 
of the csmingwlibs_xxx.exe file (you dont need the cs_mingw_xxx.exe file)

ftp://ftp.sunsite.dk/projects/crystal/support/mingw32

F) Download MYSQL
-----------------
Downlaod the MySQL binary (it contains the library and header files too).

http://www.mysql.com

Select the downloads tab and click on MySQL 4.0 (release) and select the 
windows build to download.
>>Windows 95/98/NT/2000/XP/2003   4.0.13   18.1M

Run the setup program and install MySQL.

G) Download REIMP
-----------------
This tool is needed to create MinGW compatible libraries from the standard
Microsoft compatible libraries that ship with MySQL. Read the FAQ for 
mingw32 under the section "How can an MSVC program call a MinGW DLL, and 
vice versa?"

http://www.mingw.org/mingwfaq.shtml

Download the follwing file and unzip it in your mingw/bin directory.

http://mywebpage.netscape.com/yongweiwu/reimp_new.zip

Now open a DOS prompt, cd to the mysql/lib/opt directory and type

reimp libmysql.lib

This will create a libmysql.a file. Do the same in mysql/lib/debug.

3. Compiling
============

A) Set the environment variables
--------------------------------

The makefiles will use environment variables to find the location of the
libraries. Set all these environment variables in the Windows system
environment. Also note that all slashes must be forward slashes (not the
backslashes that are more commonly used in windows directory names).

CEL=d:/cvssrc/cel
CPATH=d:/cvssrc/cs/include;d:/cvssrc/cs/libs
CRYSTAL=d:/cvssrc/cs
CSCONFPATH=d:/cvssrc/cel

You may also need the following

INCLUDE=d:\cvssrc\cs\include;d:\mysql\include
LIB=d:\cvssrc\cs\libs;d:\mysql\lib\debug

B) Use MSYS to compile Crystal Space
------------------------------------

Run MSYS from the start menu to open the shell. Type

cd /d/cvssrc/cs

to change directory to where the Crystal Space sourcecode is stored. Type

./configure
make all

This will build the whole of Crystal Space with the associated libraries
and demo applications. You may need to run make several times to ensure
that all the dependencies are resolved. When everything has compiled, 
try running some of the demo applications to check that everything is OK.

C) Use MSYS to compile CEL
--------------------------

CEL uses the JAMFILE utility instead of Make, so the compiling procedure
here is a little different:

cd /d/cvssrc/cel
./configure
jam

Again, this should compile the test application celtst.exe. Run the 
application to check everything is working. I strongly suggest that you
change the follwing line in celtest.cpp from 1 to 0 before you compile.
This will enable the full testing code.

#define MINIMAL 0

D) Use MSYS to compile Planeshift
---------------------------------

cd /d/cvssrc/planeshift
./configure
jam

This should compile planeshift, but there are still some issues that
remain unresolved, so you may not be able to compile the whole set of
executables and libraries.

E) Compiling Debug Versions
---------------------------

Given that the libraries are in a constant state of flux, you will probably
want to compile a debug version of Planeshift. To do this, you will need
to remake all the libraries. To do this, re-run the configure command but
use the following switch.

./configure --enable-debug

Then use the make / jam utilities to rebuild each library (following the
instructions above). Remember that by default, a debug version of 
Planeshift will expect to have debug versions of all the libraries 
available, so you will need to recompile CS, CEL and make sure you have 
the /mysql/lib/debug/mysqllib.a file created.

4. Getting Help
===============

If you have trouble getting any of this to work, please feel free to 
contact me and I will do my best to help.

Email: steve.cook1@excite.com
ICQ: 39784019

Steve



