GARLI COMPILATION/INSTALLATION INSTRUCTIONS:

NOTE: For Windows and Mac OS X machines you should not need to 
compile the program manually, and it is recommended that you 
download one of the pre-compiled binaries.

(If after reviewing this document you still have unsolved compilation
problems, please email garli.support@gmail.com)
------

EXTRA EASY COMPILATION INSTRUCTIONS (USE OF THIS IS RECOMMENDED!):
If this is a version with the NCL source code bundled (there
will be an ncl-2.1.xx.tar.gz file in the same directory as this
file), then you should be able to very easily do a default
compilation and static linking to NCL by typing this in the
same directory as this file:

./build_garli.sh

This will do all of the necessary building of the NCL library, 
and you should eventually end up with a working Garli-#.#
executable in the bin directory within the current directory.
You are done.  See the QuickStart.txt file, manual or support
website for details on running the program.

->If you are doing an MPI build, use the Advanced instructions
below.

->If you have a newer version of NCL that you want to use, just
put the ncl-xxxx.tar.gz archive within this directory and the
build_garli script will find and use it.

->If you want to check out the newest version of NCL (which could
have bug fixes) from Sourceforge and build GARLI with it, do this:

./build_garli.sh --ncl-svn

->If you know what you are doing and want to use a different compiler
(such as the intel icc compiler) instead of gcc you can invoke the 
build_garli.sh script like this:

env CC=icc CXX=icpc ./build_garli.sh

->If you want to pass other arguments to GARLI's configure script, 
(you have no particular reason to do so) list them at the end, e.g.

./build_garli.sh [--ncl-svn] --enable-asserts

------
MANUAL/ADVANCED COMPILATION INSTRUCTIONS:
(use this if the above simplified build script does work for you
or doesn't meet your needs)

####BUILDING NCL####
To make and install GARLI, you first need to have a compiled
copy of the Nexus Class Library version 2.1 by Paul Lewis and Mark Holder.

The newest version of NCL 2.1 is available here:
http://github.com/mtholder/ncl
and can be checked out via anonymous svn or git:
svn co https://github.com/mtholder/ncl
or
git clone https://github.com/mtholder/ncl

Use of the trunk github version of NCL is recommended, but a slightly older
version is also available here:
http://sourceforge.net/projects/ncl/files/NCL/

VERY IMPORTANT:
-NCL version 2.1 or better is required to compile GARLI.
-You MUST run NCL's configure script with NCL_CONST_FUNCS defined.  
See below for how to do this
------

You can choose to compile GARLI with the NCL library either statically
or dynamically linked in.  Note that whether GARLI will link 
it statically or dynamically depends on how NCL itself is 
configured when it is built.

TWO OPTIONS:
-To STATICALLY link:
Do this if you are compiling GARLI for your own use but are not a system
administrator, or if want the GARLI executable to run on another machine 
of the same type.  It will not require the NCL library to remain on the 
system after compilation of GARLI.  
Configure and build NCL like this (the shared NCL library will not
be made):
(from the NCL source root directory)
env CPPFLAGS=-DNCL_CONST_FUNCS ./configure --prefix=<install directory> --disable-shared
make
make install

-To DYNAMICALLY link:
You only really want to do this if you are an admin on the machine
and are going to install NCL globally (e.g. in /usr/local/),
or if you want to install it elsewhere and are the only one that will 
be using it on that machine.  In those cases, configure and build as 
shown below (you can omit the prefix if you want to
just install globally into the normal location at /usr/local/):
(from the NCL source root directory)
env CPPFLAGS=-DNCL_CONST_FUNCS ./configure --prefix=<install directory>
make
make install

####BUILDING GARLI####
Now that NCL is built, it is time to configure and build GARLI . 
You will call GARLI's configure script as follows: 
(if you installed NCL globally at /usr/local, you can leave off the --with-ncl= argument):
(from GARLI's source root directory)
./configure --prefix=<install directory> --with-ncl=<ncl install directory>
make
make install

To run the program once you've compiled the executable, you'll need to use
a configuration file.  Sample files and test datasets are provided in the 
example directory.
------

Other configuration notes:
To use a compiler different from the default (for example the Intel icc
compiler), call configure like this:

env CC=icc CXX=icpc ./configure ... etc

You can similarly pass extra CXXFLAGS or LDFLAGS:

env CXXFLAGS=<your flags> LDFLAGS=<your flags> ./configure ... etc
------

Making an OS X Universal binary (this may not work with newer versions of OS X):
To do this you first need to build the NCL static library with multiple architectures.
Configure NCL like this (all on one line):

env CXXFLAGS="-arch ppc -arch i386 -DNCL_CONST_FUNCS" LDFLAGS="-arch ppc -arch i386" \
	./configure --prefix=<install directory> --disable-dependency-tracking --disable-shared

Then configure GARLI like this (all on one line):

env CXXFLAGS="-arch ppc -arch i386" LDFLAGS="-arch ppc -arch i386" \
	./configure --prefix=<install directory> --disable-dependency-tracking \
	--with-ncl=<ncl install directory>
---

Other options that can be passed to configure:
--enable-openmp
(build the multithreaded openMP version - available with the proprietary Intel compiler,
(CC=icc and CXX=icpc), or newer versions of gcc

--enable-mpi
(build the MPI run distributing version.  It should automatically determine
the correct MPI compiler script name (e.g. mpiCC) but if the underlying compiler
is not gcc (try "mpiCC --version" to check) you should also set CC and CXX to the
corresponding compiler type (e.g., CC=icc and CXX=icpc) to get the right compilation flags) 

--help
(list other options of the configure script)
