These are the instructions to compile Kiwix.

== GNU/Linux ==

GNU/Linux build uses shared libraries by default.
You will need the following dependencies to compile Kiwix for Linux
Debian/Ubuntu packages: build-essential autoconf automake libtool pkg-config \
libicu-dev libclucene-dev libxapian-dev libmicrohttpd-dev liblzma-dev fastjar \
xulrunner-1.9.2-dev aria2 libsqlite3-dev zlib1g-dev uuid-dev libuuid1 zip subversion
# xapian-tools (debian wheezy)

Fedora (Sugar build) packages: gcc gcc-c++ automake glibc-devel libtool \
c-ares autoconf aria2 libicu-devel xapian-core-devel lzma-libs lzma-devel \
xapian-core-libs xulrunner-devel jpackage-utils expat-devel sqlite-devel \
zlib-devel zlib-static uuid uuid-devel openssl-devel libxml2-devel \
libgnutls-devel libgpg-error-devel libgcrypt-devel c-ares-devel cmake sugar subversion

* ./autogen.sh to generate the ./configure file if not already
done.

* ./configure to prepare the compilation and check if all
  necessary libraries are installed. You may get more information by
  running ./configure --help

* Use ./configure --without-dependences to compile a static version

* make to compile kiwix

* make install to install it on the system

== GNU/Linux (alternative) ==

The new build system (not default) now builds kiwix with shared libraries only.
A static build of Kiwix is a build which packages the dependencies.
Command line tools (indexer, server, etc) are compiled statically.

* ./autogen.sh alt

* ./configure # check --help for options
Most dependencies accept --with-dep=XX and with-static-dep=XX.a
Static version of libraries are used for building static binaries (server, indexer, etc)
Use --with-dep=SELF or --with-static-dep=SELF to trigger fetch and build for the dependency.

* ./configure --enable-compileall --enable-compileall
to fetch and build all dependencies.

* make src/dependencies

* ./configure
To reconfigure with dependencies (Gecko version)

* make

* make diststatic
creates tarbal suitable for distribution (no deps)

== Mac OSX Universal ==

[warning] To build the Mac OS version you will have to install 
proprietary software which are free of charge.
You will also need to build on an Apple Mac computer.

* Install OSX 10.6.5+ (proprietary)
* Install XCode 3.2.5+ (proprietary) - 
  http://developer.apple.com/technologies/xcode.html (requires registration)
  http://download.kiwix.org/dev/xcode_3.2.5_and_ios_sdk_4.2_final.dmg
* Install MacPorts - http://www.macports.org/install.php

* Configure Macports

* Install the following tools and libraries
sudo port install autogen +universal pkgconfig +universal wget +universal gmake +universal coreutils +universal libidl +universal autoconf213 +universal icu +universal

./autogen.sh alt
./configure --enable-compileall
cd src/dependencies && make
./configure --enable-compileall --enable-compileall --disable-dependency-tracking --with-target-arch=i386
make
make distmac
./configure --enable-compileall --enable-compileall --disable-dependency-tracking --with-target-arch=x86_64
make clean
make
make distmac
make universal

== Mac OSX (i386 only for now) ==

Mac OS build is close to the Linux one but it compile everything statically.
[warning] To build the Mac OS version you will have to install 
proprietary software which are free of charge.
You will also need to build on an Apple Mac computer.

* Install OSX 10.6.5+ (proprietary)
* Install XCode 3.2.5+ (proprietary) - 
  http://developer.apple.com/technologies/xcode.html (requires registration)
  http://download.kiwix.org/dev/xcode_3.2.5_and_ios_sdk_4.2_final.dmg
* Install XulRunner
  http://download.kiwix.org/dev/xulrunner-1.9.2.13.en-US.mac-pkg.dmg
* Install MacPorts - http://www.macports.org/install.php

* Configure Macports

* Install the following tools and libraries
sudo port install autogen +universal pkgconfig +universal wget +universal gmake +universal coreutils +universal libidl +universal autoconf213 +universal icu +universal

* short-circuit libtoolize which is a different tool on OSX.
sudo ln -s /opt/local/bin/glibtoolize /opt/local/bin/libtoolize

* set default target architecture by replacing gcc and g++ files
sudo mv /usr/bin/gcc /usr/bin/gcc.default
sudo mv /usr/bin/g++ /usr/bin/g++.default
sudo echo "/usr/bin/gcc-4.2 -arch i386 -m32 \"\$@\"" > /usr/bin/gcc
sudo echo "/usr/bin/g++-4.2 -arch i386 -m32 \"\$@\"" > /usr/bin/g++
sudo chmod +x /usr/bin/g{cc,++}
Alternatively, you can choose to append CC="gcc -arch i386 -m32" 
CXX="g++ -arch i386 -m32" to the configure command.

* ./autogen.sh to generate the ./configure script.

* ./configure --prefix=/opt/local
  to prepare the compilation and check if all
  necessary libraries are installed. You may get more information by
  running ./configure --help
  /opt/local is the path where you installed MacPorts (/opt/local is default)

* make in src/dependences to fetch dependencies.

* re-do ./configure script so it knows about new dependencies.

* make to compile kiwix

* make distmac to generate a complete dmg archive.

* Debugging tips:

- components file type can be either Mach-O dynamically linked shared library
  or Mach-O bundle but above instructions will create dynamic libraries.
- Shared Object (.so files on Linux) have .dylib extension on OSX.
- use dtruss to inspect program execution like strace.

== Windows (Experimental) ==

* Install Windows XP SP2+
* Install Visual Studio Express 2008
* Install 7-zip
* Install MozillaBuild 1.6
* Install ActivePerl
* Install Ruby
* Install NSIS 2.46
* Install nsis_locate
* Install nsis_uac
* Replace installed UAC.dll by new one.

* Install all software in default locations.

* Change your Windows PATH environment variable:
  - 7zip
  - NSIS
  - ruby
  - Perl
  - mozilla-build\msys\bin\

* Get shell from c:\mozilla-build\start-msvc9.bat

* mkdir -p /c/slave/windows-32b
  svn co https://kiwix.svn.sourceforge.net/svnroot/kiwix/moulinkiwix build
  cd build
  ./autogen.sh alt
  ./configure --disable-indexer --enable-jar
  make win
  make windist
  make wininstaller

== Windows ==

* You need now to install the free (as free beer) Microsoft Visual
  Studio express C++ compiler. You can download the installer here:
  "http://download.kiwix.org/dev/vcsetup.exe"

* To install it, run the self installer. Choose none of the optional
  features and install it in the default directory: 
  "c:\Program Files\Microsft Visual Studio 9.0\"

* If installed sucessfuly run one time VS to configure it and maybe
  register it (follow the instructions).

* You have to install a MinGW environnement. You have to download it
  here: "http://download.kiwix.org/dev/MozillaBuildSetup-1.5.1.exe" and
  install it in the default proposed directory "C:\mozilla-build".

* Go to "c:\mozilla-build" with the Windows explorer and start the
  script start-msvc9.bat. You have now an UNIX shell.

* Change the current directory by typing:
  > cd /c/mozilla-build/

* Check out the kiwix client code by typing:
  "svn co https://kiwix.svn.sourceforge.net/svnroot/kiwix/moulinkiwix"

* You need to install Perl. Download it here:
  "http://download.kiwix.org/dev/ActivePerl-5.10.1.1007-MSWin32-x86-291969.msi"
  and install it in the default directory "c:\Perl\"

* You have also to install gcc (for liblzma). You can download it
  here:
  "http://download.kiwix.org/dev/gcc-4.3.0-20080502-mingw32-alpha-bin.7z"
  ... and unzip it (with 7zip) in "c:\mozilla-build\msys"

* You have also to install GNU binutils. Please download it here:
  "http://download.kiwix.org/dev/binutils-2.20.1-2-mingw32-bin.tar.gz"
  ... and detar it in "c:\mozilla-build\msys"

* Now we will download, configurate and compile kiwix. 
  Run the following commands: 
  > cd /c/mozilla-build/moulinkiwix/ 
  > ./autogen.sh
  > ./configure 
  > make win


