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

New:  Test version 3.  F. Hecht & J. Morice 6 oct 2008.
remark the graphique is now base of Open/Glut lib.
so to today the ide/cs  version is not  currently available
nothing in src/ide si compilde.
This part of the software under construction.
F. Hecht.
---------------------------


remark: 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:

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
libraries on the local system.
ARPACK is use to compute eigenvalue.
and UMFPACK is a new fast sparce 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
or without ide 
./configure --enable-generic_blas --without-fltk 


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



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++-glx: graphics based on OpenGL (located in src/glx)

* FreeFem++-agl: graphics based on MacOS X CoCoa (located in src/agl)

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

* FreeFem++-cs: integrated development environment (located in src/ide)

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 2.95.2, 2.95.3, 3.01 3.1 3.3. 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

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:
> ./mkdll-ff.sh -win32  myfunction 
or under other achitecture
> g++  ./mkdll-ff.sh   myfunction
g++ -c -I../src/fflib -I../src/femlib -I../src/Graphics myfunction.cpp

to execute the examples try  
  under window xp
 ../FreeFem++-nw loadwin32.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: on MacOSX, link problems occur because of some incompatibility
between RTTI, templates and the apple c++ version (2.95.2). But this
is now working with the new g++3 compiler (default compiler in MacOs
10.2) and also with g++-3.3.

Note 3. Fast fourier exemple ( FFT )  is in dfft.edp  file


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

 - 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	
 - to rebuild de documentation:  
  imagemagick 
  tetex-base   tetex-bin  tetex-extra 


 ./configure 
  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' '-without-fltk' '--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 build and universal f2c library on MacOS 10.4 and install in /usr/local/bin  /usr/loaal/lib
make -n install-universal

