\chapter{Installation}
\label{app:installation}
\index{installation}

The source code of \ffc{} is portable and should work on any
system with a standard Python installation. Questions, bug reports and patches
concerning the installation should be directed to the
\ffc{} mailing list at the address
\begin{code}
 ffc-dev@fenics.org
\end{code}

\ffc{} must currently be installed directly from source, but effort
is underway to provide precompiled Debian packages of \ffc{} and
other \fenics{} components.

%------------------------------------------------------------------------------
\section{Installing from source}

\subsection{Dependencies and requirements}
\index{dependencies}

\ffc{} depends on a number of libraries that need to be installed on your
system. These libraries include \fiat{} and the Python Numeric module. In
addition, you need to have a working Python installation on your system.

\subsubsection{Installing Python}

\ffc{} is developed for Python 2.4, but might also work with Python 2.3.
To check which version of Python you have installed, issue the command
\texttt{python~-V}:
\begin{code}
 # python -V
 Python 2.4.1
\end{code}

If Python is not installed on your system, it can be downloaded from
\begin{code}
 http://www.python.org/
\end{code}
Follow the installation instructions for Python given on the Python web page.
For Debian users, the package to install is \texttt{python2.4}.

\subsubsection{Installing Numeric}

In addition to Python itself, \ffc{} depends on the Python package Numeric,
which is used by \ffc{} to process multidimensionall arrays (tensors).
Python Numeric can be downloaded from
\begin{code}
 http://www.scipy.org/
\end{code}
For Debian users, the package to install is \texttt{python2.4-numeric}.

\subsubsection{Installing FIAT}

\ffc{} depends on the latest version of \fiat{}, which can be
downloaded from
\begin{code}
 http://www.fenics.org/
\end{code}
\fiat{} is used by \ffc{} to create and evaluate finite element basis
functions and quadrature rules.
The installation instructions for \fiat{} are similar to those for
\ffc{} given in detail below.

In addition, you will need to install the Python package
LinearAlgebra, which may already be included in your installation of
Python Numeric. For Debian users, the package to install is
\texttt{python2.4-numeric-ext}.

% Input section shared with DOLFIN manual
\input{chapters/installation-downloading.tex}

\subsection{Installing the compiler}

\ffc{} follows the standard for Python packages. Enter the source
directory of \ffc{}, and issue the following command:
\begin{code}
 # python setup.py install
\end{code}
This will install the \ffc{} Python package in a subdirectory
called \texttt{ffc} in the default location for user-installed Python
packages (usually in the directory \texttt{/usr/lib/python2.4/site-packages}).
In addition, the compiler executable (a Python script) will be
installed in the default directory for user-installed Python scripts
(usually in \texttt{/usr/bin}).

To see a list of optional parameters to the installation script, type
\begin{code}
 # python setup.py install --help
\end{code}
If you don't have root access to the system you are using, you can
pass the \texttt{--home} option to the installation script to install
\ffc{} in your home directory:
\begin{code}
 # mkdir ~/local
 # python setup.py install --home ~/local
\end{code}
This installs the \ffc{} package in the directory \texttt{\~{}/local/lib/python}
and the \ffc{} executable in \texttt{\~{}/local/bin}. If you use this
option, make sure to set the environment variable \texttt{PYTHONPATH}
to \texttt{\~{}/local/lib/python} and to add \texttt{\~{}/local/bin}
to the \texttt{PATH} environment variable.

\subsection{Compiling the demos}

To test your installation of \ffc{}, enter the subdirectory
\texttt{src/demo} and compile some of the demonstration forms.
With \ffc{} installed on your system, just type
\begin{code}
 # ffc Poisson.form
\end{code}
to compile the bilinear and linear forms for Poisson's equation.
This will generate a C++ header file called \texttt{Poisson.h} that
can be used with \dolfin{} to implement a solver for Poisson's
equation. Adding the flag \texttt{-l latex} generates output in
\LaTeX{} format:
\begin{code}
 # ffc -l latex Poisson.form
 # latex Poisson.tex
 # xdvi Poisson.dvi
\end{code}

It is also possible to compile the forms in \texttt{src/demo} without
needing to install \ffc{} on your system. In that case, you need to
supply the path to the \ffc{} executable:
\begin{code}
 # ../bin/ffc Poisson.form
\end{code}

\subsection{Verifying the generated code}

To verify the output generated by the compiler, run the script
\texttt{verify} from within the \ffc{} source tree:
\begin{code}
 # scripts/verify
\end{code}
This script compiles all forms found in \texttt{src/demo} and compares
the output with previously compiled forms in \texttt{src/reference}.

%------------------------------------------------------------------------------
\section{Debian package}
\index{Debian package}

In preparation.
