Table of Contents
=================
1 How to compile Pioneer
  1.1 Linux - Autotools
  1.2 Windows - MSVC
  1.3 Windows - Autotools (Linux cross-compile)
  1.4 OS X - Autotools
  1.5 OS X - XCode 4
  1.6 OS X - Homebrew
  1.7 Nix - Autotools
2 pioneer-thirdparty
  2.1 Linux - Autotools
  2.2 Windows - MSVC
  2.3 Windows - Autotools (Linux cross-compile)
  2.4 OSX
3 Building documentation
  3.1 Lua API - Natural Docs
  3.2 C++ source - Doxygen
4 Faster startup
  4.1 precompile models


1 How to compile Pioneer
========================

Pioneer is known to build on the following platforms and build systems:

Linux: GNU Autotools with GCC or Clang
Windows: Microsoft Visual C++ 2015 (Community or Pro)
Windows: GNU Autotools with MXE (MinGW GCC) (cross-compile on Linux)
OS X: XCode 4 or Homebrew or GNU Autotools

The Autotools build system is usually the most up-to-date, and is what is used
to produce the Linux and Windows builds. The others typically lag behind,
depending on the motivation of those using them to keep them up too date with
source file changes.

There is an additional repository called pioneer-thirdparty that contains
various files that may assist with building. If the instructions for your
platforms indicates you may need it, then read the section below for details.

If you're having trouble compiling, please ask in #pioneer on
irc.freenode.net.


1.1 Linux - Autotools
---------------------

1. Install the following libraries (with development headers) for your system.
   If your system is not Debian/Ubuntu based, they may have different names.

    Debian/Ubuntu
    -------------
    g++
    automake
    pkg-config
    libcurl-dev
    libsigc++-dev
    libsigc++-2.0-dev
    libsdl2-dev
    libsdl2-image-dev
    libfreetype6-dev
    libvorbis-dev
    libpng-dev
    libassimp-dev >= 3.2
    mesa-common-dev

   If your platform doesn't have assimp 3.2, you'll need to build it from
   source. It's available in pioneer-thirdparty, see below.

2. Run ./bootstrap to generate your 'configure' file

3. Run ./configure to configure the build. If you're using the
   pioneer-thirdparty repository, pass
   --with-thirdparty=/path/to/pioneer-thirdparty to configure.

4. Run make to build everything


1.2 Windows - MSVC
------------------

1. Get both the pioneer and the pioneer-thirdparty repositories and keep them
   in a directory side by side. Don't rename pioneer-thirdparty because the
   relative path to it is included in the project files.

2. Open the pioneer solution from /win32/vc2015/pioneer.sln

3. Build and run the project or solution.


1.3 Windows - Autotools (Linux cross-compile)
---------------------------------------------

1. First you need a cross-compiling environment. We use MXE (http://mxe.cc).

     git clone git://github.com/mxe/mxe.git

   Now compile GCC and the dependencies needed for Pioneer:

     make gcc freetype sdl2 sdl2_image vorbis libsigc++ assimp curl

2. Now you can build Pioneer. Run ./bootstrap to generate your 'configure'
   file.

4. Run configure to configure the build:

     ./configure --with-mxe=/path/to/mxe

5. Run make to build everything


1.4 OS X - Autotools
--------------------

1. Install XCode (free download from apple). This will install the required
   compilers and other commandline tools.

2. You will need the following libraries installed. The best method I found
   was to install macports (http://www.macports.org/) and install the
   following ports (sudo port install xxxx):

     assimp
     pkgconfig
     freetype
     libsdl2
     libsdl2_image
     libsdl2_sound
     libsigcxx2
     libvorbis
     autoconf
     automake

3. Run ./bootstrap to generate your 'configure' file

4. By default the OpenGL frameworks don't seem to be visible to 'automake'
   way so I did a few tricks to get it working:

   Create a symlink from the OpenGL framework to your /usr/local/include
   directory

     sudo ln -s /System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/ /usr/local/include/GL

5. Instead of running ./configure run it with this command line:

     LDFLAGS="-L/System/Library/Frameworks/OpenGL.framework/Libraries -L/System/Library/Frameworks/GLUT.framework" ./configure

6. Now you can run make as per normal. :)

Note: Compiling from source this way isn't recommended as it doesn't allow you
      to 'install' the application into a different location (pioneer.app
      bundle). It also isn't the 'Apple way', To do that you need to use XCode.


1.5 OS X - XCode 6
------------------

You will need the following libraries installed. The best method I found was to install macports (http://www.macports.org/) and install the following ports (sudo port install xxxx):

     autoconf
     automake
     pkgconfig
     assimp
     freetype
     libsigcxx2
     libsdl2
     libsdl2_image
     libvorbis
     libvorbisfile

Alternatively you can also run the script in the ./osx folder install_ports.sh

The latest XCode project files are located in ./osx. Simply build the
aplication bundle. The XCode project uses the mac port libraries that you
have installed above. Once the pioneer.app bundle is complete you can move it
around where you like (/Applications is a nice place for it).


1.6 OS X - Homebrew
-------------------

1. Install Homebrew package manager (http://brew.sh/) if you don't have one yet.

2. Build and install pioneer. Required dependencies will be installed together.

     brew install homebrew/games/pioneer

   Or you may want to tap homebrew-games first and then install.

     brew tap homebrew/games
     brew install pioneer

   If you want master branch from GitHub, add '--HEAD' option.

     brew install --HEAD pioneer


1.7 Nix - Autotools
-------------------

1. Install the development environment using the included expressions.

    nix-env -i -f nix/env.nix         # build and install the environment
    load-env-pioneer                  # load the environment

2. Run ./bootstrap to generate your 'configure' file

3. Run ./configure to configure the build.

4. Run make to build everything

Executing ./pioneer requires the development environment to be loaded,
executing ./src/pioneer does not.


2 pioneer-thirdparty
====================

The pioneer-thirdparty repository contains:
 - source for dependencies that may be difficult to obtain or build
 - pre-built dependencies for MSVC targets

To get it, clone git://github.com/pioneerspacesim/pioneer-thirdparty.git.


2.1 Linux - Autotools
---------------------

1. After cloning the repo, run autoconf to generate 'configure'.

2. Run ./configure to configure the build

3. Run make <package> to compile and prepare the named package for use with
   Pioneer, or just run make alone to build everything.


2.2 Windows - MSVC
------------------

1. After cloning the repo, move it to a folder called "pioneer-thirdparty"
   alongside your "pioneer" folder.


2.3 Windows - Autotools (Linux cross-compile)
---------------------------------------------

1. After cloning the repo, run autoconf to generate 'configure'.

2. Run ./configure --with-mxe=/path/to/mxe to configure the build.

3. Run make <package> to compile and prepare the named package for use with
   Pioneer, or just run make alone to build everything.


2.4 OSX
-------

- pioneer-thirdparty currently not required.



3 Building documentation
========================

This section describes how to build html-documentation which is stored on disk
for the local pioneer source tree.


3.1 Lua API - Natural Docs
--------------------------

Pioneer is extensible through the Lua scripting language. It is used for
modules such as missions and BBS interaction. See the pioneer wiki for further
details. For up-to-date documentation one can build it locally from the
pioneer source

0. Install dependencies: naturaldocs

1. Run make codedoc

2. The html documentation can be found in the codedoc/ folder


3.2 C++ source - Doxygen
------------------------

To build html-documentation of the pioneer C++ source, doxygen needs to be
installed, as well as the graphviz package, from where dot is used for
visualizing inheritance as graphs. To enable LaTeX output, set GENERATE_LATEX
= YES in the configuration file doxygen/Doxyfile. Same goes for xml, man, rtf.

0. Install dependencies: doxygen and graphviz

1. Run doxygen from the doxygen/ folder.

2. The html documentation will be available from doxygen/html/index.html



4 Faster startup
================

4.1 Precompile model files
--------------------------

Long startup times for pioneer this can be alleviated by precompiling all
models into *.sgm files. This uses the modelcompiler located in src/. From the
pioneer root directory the following will batch compile all models

1. ./src/modelcompiler -b inplace
