/****************************************************************************
  This file is part of TIDES.
 
 Contributors:
 
 Alberto Abad, Roberto Barrio, Fernando Blesa, Marcos Rodriguez
 Grupo de Mecanica Espacial
 University of Zaragoza
 SPAIN
 
 http://gme.unizar.es/software/tides
 Contact: <tides@unizar.es>

 *****************************************************************************/

                          INSTALLING TIDES
                          ================

TIDES has two different parts (pieces of software): The Mathematica package
MathTIDES and the C library libTIDES.a

The preprocessor MathTIDES writes, automatically, the files containing the
code with the iterative scheme to obtain the taylor series of the variables.
These files, together with the library libTIDES.a, form the Taylor Series
Method integrator (TSM Integrator). The multiple precision version of the
integrator requires the library libmpfr.a.

                          INSTALLING MathTIDES
                          ====================

The preprocessor MathTIDES is written in Mathematica. You need to copy
the folder MathTIDES inside a directory that is in the $Path of Mathematica.
You can do this manually, but to make your task easier we have written a
Mathematica notebook that does the installation process.

Open InstallMathTIDES.nb with Mathematica. It will copy the MathTIDES folder
to $BaseDirectory/Applications.

Once MathTIDES has been installed you can load the package by writing
<<MathTIDES` in a Mathematica Notebook.

                          INSTALLING libTIDES
                          ===================

The libTIDES library can be built to use double precision only or both double
and multiple precision depending on your needs. This means that you have two
different options.

A. MULTIPLE PRECISION

This is the default. The libTIDES library uses GMP and MPFR for the multiple
precision computations, so you need to have both installed.

0. You first need to install GMP and MPFR if your system does not have them.
You can download GMP from http://www.gmplib.org and MPFR from
http://www.mpfr.org. Then uncompress them and run ./configure, make, make check
and make install inside each of its directories.

1. How to compile and install libTIDES.a

First you need to run ./configure. Depending on where you installed GMP
and/or MPFR, you may need to specify its installation directories. For example,
if you put GMP in /usr/local, then you need to do the following:

./configure --with-gmp=/usr/local

If MPFR is also in a non-standard directory, you may have to do the same thing
with it:

./configure --with-gmp=/usr/local --with-mpfr=/usr/local

To build the library, type:

        make

This will create the library with both the double and the multiple
precision objects.

To check the build library (run the test files), type: 

        make check

This will perform some tests for the double and the multiple precision programs.

If you want to check also the minimal fortran version, then you have to add the
following option to configure:

./configure --enable-fortran-tests

If everything went OK, you can install it. Just type:

        sudo make install

By default, the library is installed in /usr/local. If you prefer another
installation directory, you have to specify it by adding the prefix option to
configure.

./configure --prefix=/user/local


B. DOUBLE PRECISION ONLY

If you don't have GMP and/or MPFR installed, or you are not interested in having
multiple precision capacities in your program, you have to pass the following
option to configure:

./configure --disable-multiple-precision

This will create the needed Makefiles to compile a reduced version of libTIDES.a
without the mpfr extensions.

1. How to compile and install libTIDES.a

To build the library, type:

        make

This will create the library with only the double precision objects.

To check the build library (run the test files), type: 

        make check

Here you will make just the tests for the double precision.

If you want to check also the minimal fortran version, then you have to add the
following option to configure:

./configure --enable-fortran-tests


If everything went OK, you can install it. Just type:

        sudo make install

As explained above, by default, the library is installed in /usr/local. If you
prefer another installation directory, you have to specify it by adding the
prefix option to configure.

./configure --disable-multiple-precision --prefix=/user/local

After this installation process, you will end with a library containing the
objects needed for the standard and multiple precision TIDES packages.

If you want to uninstall libTIDES, then you have to run:

        sudo make uninstall

and the library will be removed from the installed directory.

                          TROUBLESHOOTING INSTALLATION
                          ============================

- Working with Mac OS X

Taking into account that Mac OS X is based on a Unix system you can install
LibTIDES on Mac OS X by following all the previous steps from the terminal, and
using the gcc compiler installed on Mac OS X with the Developer tools.

If you prefer to use XCode, instead of working from the terminal, follow the
previous steps except the order sudo make install. Then take the library
libTIDES.a and include it in your XCode project. If you work with multiple
precision do the same with MPFR and GMP libraries.

- Working with Windows

The installation has been tested with MinGW and Msys. The GMP and
MPFR libraries are not installed, so you have to build and install them.
They will be installed at /usr/local, but Msys does not have it in the path,
so you have to use:

./configure --with-gmp=/usr/local --with-mpfr=/usr/local

to correctly create the Makefiles needed for building the liBTIDES library.

- Working with UNIX

If you use a recent distribution of Linux, you should have the MPFR and GMP
libraries already installed. Otherwise download them as indicated above and
install them.