\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 Debian
(Ubuntu) packages will be available in the future, for \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 NumPy module. In
addition, you need to have a working Python installation on your system.

\subsubsection{Installing Python}

\ffc{} is developed for Python 2.5, but should also work with Python
2.3 and 2.4.
To check which version of Python you have installed, issue the command
\texttt{python~-V}:
\begin{code}
# python -V
Python 2.5.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 (Ubuntu) users, the package to install is named \texttt{python}.

\subsubsection{Installing NumPy}

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

\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.

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

\subsection{Installing \ffc{}}

\ffc{} follows the standard installation procedure 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 something like
\texttt{/usr/lib/python2.5/site-packages}).  In addition, the compiler
executable \texttt{ffc} (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}
containing UFC~\cite{www:ufc,ufcmanual} code that can be used to assemble
the linear system for Poisson's equation.

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, enter the sub directory
\texttt{src/test/regression} from within the \ffc{} source tree and
run the script \texttt{test.py}
\begin{code}
# python test.py
\end{code}
This script compiles all forms found in \texttt{src/demo} and compares
the output with previously compiled forms in \texttt{src/test/regression/reference}.

%------------------------------------------------------------------------------
\section{Debian (Ubuntu) package}
\index{Debian package}
\index{Ubuntu package}

In preparation.
