Compilation of FreeFem++ under unix, MacOs X or cygwin (Windows)
and bamg (mesh generator)
----------------------------------------------------------------

New:  Test version 3.1  F. Hecht & J. Morice 6 oct 2008.
Remark:
     *  the graphique is now base of Open/Glut lib.
     *  IN CASE  of problem under UBUNTU/GLUT  (no graphics window tilte: (march 2009) 
        they are a know bug with compiz package so  try
	To disable/enable it graphically, install the compiz-swith package with synatic. Or try this in command line:
	killall compiz.real && killall compiz && metacity --replace --display :0 & 

     *  to today the ide/cs  version is not  currently available
        nothing in src/ide si compilde.
	you can get a experiental version from http://www.ann.jussieu.fr/~lehyaric/ffcs/index.htm

This part of the software under construction.
F. Hecht.
-


For debian, ubuntu, MacOS, Windows  see the the prerequisite

installed packages before configuration and compilatation.

This file details specific configuration details for FreeFem++. For
a standard installation, please refer to the file named "INSTALL".

annd see the end of this file to have some 
configure example:

Full version 3d need automatic download option
----------------------------------
For a Full 3d  version , some external piece of software
can by usefull, the simplest wait is to add "--enable-download"
to the "./configure" (need of  "wget" or "curl" unix  command). 
The download archive are store in : 
download/pkg/SuiteSparse-2.4.0.tar.gz  # umpack 
download/pkg/arpack96.tar.gz           # arpack
download/pkg/f2c.tar                   # f2c if no fortran 77
download/pkg/fftw-3.2.1.tar.gz         # fft
download/pkg/patch.tar.gz              # arpack
download/pkg/superlu_3.1.tar.gz        # superlu
download/pkg/tetgen1.4.2.tar.gz        # tetgen
download/blas/cblas.tgz                # blas 
if you have not internet access juste copie this files at the same  place.


Debugging and optimization
--------------------------

Without any option, "./configure" selects the best optimization
options for the local machine. To produce optimized binaries that can
be ported to other machines, add the option "--enable-generic".


To produce FreeFem++ programs containing debugging symbols and no
optimization, use "--enable-debug".

If you need to add specific flags to the ones that ./configure
chooses, just define the corresponding automake variable before
running configure. For instance, to add flag "-x" to C++ compilations,
say:

> CXXFLAGS=-x ./configure

Other useful configuration variables include:
- CFLAGS for C compilation
- FFLAGS for Fortran compilation
- LIBS libraries for the linking stage
- LDFLAGS linking flags
- LDADD extra options for the linking stage
- F77  the fortran compile (if not fortran is installed  see section NOFORTRAN)
- CC  the cc compiler
- CXX the c++ compiler


Linear algebra libraries and eigen value problem
-----------------------------------------------
By default, "./configure" looks for the X11, BLAS, ARPACK and UMFPACK, OpenGL, GLUT
libraries on the local system.
ARPACK is use to compute eigenvalue.
and UMFPACK is a new fast sparse linear solver.

 If configure cannot find the libraries
by itself, you can specify the full path to a library file (ending
with ".a") or the options use by the linker (ex: "-L/usr/local/lib -lblas")
with the following options:

--with-blas="blas linker options"  
--with-arpack="arpack linker options"
--with-amd="amd linker options"
--with-umfpack="umfpack linker options"

Or, if the configuration flag "--enable-download" is specified, the
compilation step ("make") will try to download the missing libraries
(from their official websites) and compile them.

Remark, under linux or window the simplest way to get
a not to bad version is
./configure --enable-generic_blas



and reconfigure for example: 
./configure --enable-generic_blas 

Here are the different versions of FreeFem++ produced by one
compilation (some versions may be missing if your system does not
support them):

* FreeFem++: standard version (using X11 graphics on Linux and MacOS
  10, Win32 on Windows and  MacOS X) (located in src/std)

* FreeFem++-nw: without graphics (located in src/nw)

* FreeFem++: graphics based on OpenGL (located in src/nw)
* ffglut: the graphic tools

* FreeFem++-mpi: parallel version, without graphics (located in src/mpi)

The compilation procedure (produced with automake) builds all the
libraries and executables sequentially. Running "make" in a
subdirectory does not rebuild dependencies in other directories.

The compilation has been tested under linux and MacOs/Darwin with g++
version  3.3. 4.0 4.4 It take 30 mn to compile all on
my PowerBook G4 1Mhz 1024MB.

Rebuilding "configure"
------------------------

Developers of FreeFem++ can rebuild the configuration system using
Automake and Autoconf with the command:

> autoreconf
# to reconfigure with the same parameter 
> ./reconfigure 

Extra utilities
---------------

To run an interactive test of FreeFem++:
> make visualcheck

To run a speed test:
> make speedtest

To create the documentation in .ps and .pdf format (in the "DOC" directory):
> make documentation

Examples
--------

All the Examples are in the two directories examples++ and
examples++-tutorial. The suffix is .edp ("equations aux derivees
partielles" in French)

To test all the examples under unix: 

> cd examples++; ../src/std/FreeFem++ all.edp
> cd examples++-tutorial; ../src/std/FreeFem++ all.edp

To try the  dynamic linking loader example: 
remark: some adaptation must be done with the suffix probleme (.dll, .so, .dylib )
and directory  to seach dynamic lib  (shell variable LD_LIBRARY_PATH)
 

warning under  Window XP,  first install the cygwin environnent (see http://www.cygwin.com)
> cd example++-load build a dll file with the following shell script:
> ./ff-c++  myfunction 

to execute the examples try  
  under window xp
 FreeFem++-nw  load.edp 
  or otherwise 
 ../src/nw/FreeFem++-nw load.edp



-- FreeFem++ v1.38 (date Tue Feb 10 12:04:30 CET 2004)
 file : load.edp
 Load: lg_fem  --  no UMFPACK => replace UMFPACK  by LU  
lg_mesh eigenvalue 
 load "myfunction" lood: myfunction 
load: dlopen(./myfunction.so) = 0x84be700

    1 :  mesh Th=square(5,5);
    2 :  fespace Vh(Th,P1);
    3 :  Vh uh=myfunction(); // warning  do not forget () 
    4 :  cout << uh[].min << " " << uh[].max << endl;
    5 : 
    6 : 
    7 :  sizestack + 1024 =1224  ( 200 )
----------CheckPtr:-----init execution ------ NbUndelPtr  996  Alloc: 79131  NbPtr 1011 

   Nb of edges on Mortars  = 0
   Nb of edges on Boundary = 20, neb = 20
 Nb Of Nodes = 36
 Nb of DF = 36
0 0.841471
times: compile 0.01s, execution -2.0837e-19s
----------CheckPtr:-----end execution -- ------ NbUndelPtr  996  Alloc: 79131  NbPtr 1048 
Bien: On a fini Normalement
                CheckPtr:Nb of undelete pointer is 995 last 101
                CheckPtr:Max Memory used     93.672 kbytes  Memory undelete 78619 

Note 1: if this does not work, please check the manual page of dlopen
for your system.


Note 2. Fast fourier exemple ( FFT )  is in dfft.edp  file
need of fftw3 


Some configure flags use to build the current version
-----------------------------------------------------

*  Under Debian: ( 2008)
----------------
  the installed packages + dependance are:   

  gcc g++ g77
  libsuitesparse-dev
  libarpack2-dev
  libx11-dev libxt-dev libxext-dev
  patch
  wget
  freeglut3-dev
 - bluid the parallel version
   openmpi-dev openmpi

 - to rebuild de documentation:  
  imagemagick 
  tetex-base   tetex-bin  tetex-extra 

 ./configure 
  make 
  make check    (to test de version)
  make install  (under root)
   
*  Under Ubuntu (2008)
---------------
  the installed packages + dependance are:   
   gcc g++  g77
   wget 
   m4 bison flex patch
   libx11-dev libxt-dev libxext-dev 
    libxpm4 libxpm4-dbg 
    libsuitesparse-dev libarpack2-devlibarpack2 libarpack2-dev
    libfltk1.1 libfltk1.1-dbg libfltk1.1-dev
    libopenmpi1 libopenmpi-dev
    libopenmpi-dbg libxpm-dev 
    freeglut3 freeglut3-dev
    libx11-dev  libxt-dev  libxext-dev 
    libglut3-dev	
 - bluid the parallel version
    openmpi-dev openmpi
 - to rebuild de documentation:  
    imagemagick 
    tetex-base   tetex-bin  tetex-extra 
 

 ./configure --enable-download  --with-mpi=mpic++
#  utility of parameter:
#  --enable-download :  for fft and tetgen ... 
#  --with-mpi=mpic++ : for mpi version 
  make 
  make check    (to test de version)
  make install  (under root)
  


* Under Red Hat Enterprise Linux AS release 3:
----------------------------------------------
the following rpm:
blas-3.0-20 gcc-3.2.3-53 tetex-1.0.7-67.9 lapack-3.0-20 ImageMagick-5.5.6-15 wget-1.10.2-0.30E curl-7.10.6-7.rhel3
are install
./configure  '--enable-download' '--with-blas=-lblas -llapack'


* Under MacOs: (2008)
-------------
 
 1) intall Apple's Developer Tools from de Apple DVD
 2) TeXLive-teTeX Current Release in http://www.ctan.org/tex-archive/systems/mac/mactex/
 3) find a fortran 77, a simple way is to:
	cd download/f2c
	make install-universal

 ./configure '--enable-download' '--enable-optim' '--with-suffix=G4'

* Under MacOC macIntel 
----------------------
  1) install Apple's Developer Tools
  2) install do the NOFORTRAN section. 
  3) install the TexMac for the documentation:
 http://ctan.org/get/systems/mac/mactex/MacTeX-20071201.dmg

# to build a good freefem for your Mac:

./configure -without-fltk' '--enable-download' '-with-mpi=mpic++' 'F77=fort77' '--with-flib=-L/usr/local/lib -lf2c'

or if you have compile the download/f2c   with : (cd download/f2c;make install)

./configure '-with-suffix' 'MacIntel'  '--enable-download' '-with-mpi=mpic++' '-enable-download' 

# to build universal FreeFem++ of 10.4 macOS (ppc , i386):

/configure '-with-suffix=Universal' '-without-fltk' '--enable-download' '-with-mpi=mpic++' 'F77=/usr/local/bin/fort77' '--with-flib=-L/usr/local/lib -lf2c' 'CXX=g++ -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4' 'CC=gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4' 'FFLAGS=-Wc,-isysroot,/Developer/SDKs/MacOSX10.4u.sdk,-arch,ppc,-arch,i386,-mmacosx-version-min=10.4' 'CXXCPP=g++ -E'


* Under Windows: 
----------------
see the end of README_WINDOW  files 

* NOFORTRAN:
------------
You have not fortran compiler use f2c and the use the  script fort77
by the way just do:
cd  download/f2c
# to build and install fort77,  linf2c.a in download/bin  download/lib
make install
# to install in /usr/local/
make install-sudo

# to build and universal f2c library on MacOS 10.4 and install in /usr/local/bin  /usr/local/lib
# and in download/bin  download/lib download/bin  download/include
#    32/ 64   bits architecture on    intel and ppc
make -n install-10.4 

for the 64 on intel   version 10.5 (SDK)
make -n install-10.5

