1# ------------------------------------------------------------
2
3# Antoine Le Hyaric - LJLL Paris 6 - lehyaric@ann.jussieu.fr - 13/5/04
4# $Id: configure.ac,v 1.338 2010/05/10 21:35:07 hecht Exp $
5
6# Version numbering: x.xx-pp where "pp" is the package version (when
7# the same FreeFEM version is packaged several times). For
8# coherency, this should have the same value as the top-most package
9# number in debian/changelog.
10
11
12AC_INIT(FreeFEM,4.6,frederic.hecht@sorbonne-universite.fr,FreeFEM)
13dnl : ${CFLAGS=""}
14dnl : ${CXXFLAGS=""}
15dnl : ${FCFLAGS=""}
16dnl : ${FFLAGS=""}
17
18AC_CONFIG_MACRO_DIR([etc/config/m4])
19
20# progg test  exec for windows
21ff_TEST_FFPP="../../src/nw/FreeFem++"
22ff_TEST_FFPP_MPI="../../src/mpi/FreeFem++-mpi"
23ff_uncompile_plugin=""
24ff_unlib_plugin=""
25ff_download_lib=""
26AC_PREREQ(2.63) dnl for AC_LANG_CASE and check stuff
27dnl AC_CONFIG_SRCDIR(src/FreeFem++-CoCoa)
28
29# Automake 1.11 is too old for check ...
30
31# ALH - 10/9/13 - FFCS needs to skip this automake version requirement when compiling on older platforms (eg cygwin or
32# last Ubuntu LTS). So we fix a low hardcoded requirement and test for higher versions when not in FFCS.
33
34AM_INIT_AUTOMAKE(1.11 dist-zip foreign subdir-objects)
35
36if test "$enable_ffcs" != yes
37then
38    if test "$am__api_version" \< 1.13 ;   then
39	AC_MSG_ERROR([Automake version $am__api_version needs to be 1.13 or later to enable "make check"])
40    fi
41fi
42
43AC_CONFIG_HEADERS(config.h)
44AC_PROG_MAKE_SET
45dnl AM_COLOR_TESTS=always
46AC_PROG_RANLIB
47inc_usr_include=""
48ff_where_lib_conf=plugin/seq/WHERE_LIBRARY-config
49dnl search of associad software
50m4_define([AC_FF_ADDWHERELIB],
51  [
52    if test -z "$ff_where_lib_conf_$1"  ; then
53	    echo "$1 LD $2"  >>$ff_where_lib_conf
54	    test -n "$3" && echo "$1 INCLUDE $3 "  >>$ff_where_lib_conf
55            ff_where_lib_conf_$1=1
56	    ff_where_lib_$1="$2"
57	    ff_where_inc_$1="$3"
58	    AC_MSG_NOTICE([    ++ add $1 : $2 ;  $3 in  $ff_where_lib_conf "])
59	else
60	    AC_MSG_NOTICE([    -- do not add $1 : $2 $3 in  $ff_where_lib_conf "])
61        fi
62]) dnl
63m4_define([AC_FF_WHERELIB],
64    [  	if test -z "$ff_where_lib_conf_$1" -a "$enable_download_$1"  != "yes" ; then
65        AC_MSG_CHECKING(check $1)
66	ff_save_libs=$LIBS
67	LIBS="$LIBS $2 $4"
68	AC_LINK_IFELSE([AC_LANG_PROGRAM([m4_if($3,,,[#include <$3>],[#include <stdint.h>],[#include <stdio.h>])],[])], [ff_WHERE=yes],[ff_WHERE=no])
69	if test "$ff_WHERE" = "yes" ; then
70	    echo "$1 LD $2"  >>$ff_where_lib_conf
71	    ff_WHERE_INC=`AS_DIRNAME(["$3"])`
72	    case "$ff_WHERE_INC" in
73		/*) echo "$1 INCLUDE -I$ff_WHERE_INC"  >>$ff_where_lib_conf ;;
74	    esac
75            ff_where_lib_conf_$1=1
76	fi
77	AC_MSG_RESULT($ff_WHERE)
78        ff_$1_ok=$ff_WHERE;
79	LIBS=$ff_save_libs
80	fi
81    ])dnl end m4_define AC_FF_WHERELIB
82define([AC_FF_PETSC_AWK],[awk -F'=' '"$1 "==[$]1 {print [$]2}' $2])
83m4_define([AC_FF_PETSC_WHERELIB],
84	  [
85	    ff_$2=`AC_FF_PETSC_AWK($2,$4)`
86	    ff_$3=`AC_FF_PETSC_AWK($3,$4)`
87	   if test -n "[$]ff_$2"; then
88			    ff_$1_ok=yes;
89			    AC_FF_ADDWHERELIB($1,[$]ff_$2,[$]ff_$3)
90			    AC_SUBST([TOOL_COMPILE_$1],"")
91	  fi
92	  ]
93)dnl end m4_defineAC_FF_PETSC_WHERELIB
94m4_define([AC_FF_PETSC_WHERELIB_BASIC],# PETSC_WITH_EXTERNAL_LIB,PETSC_CC_INCLUDES
95	  [
96	    ff_PETSC_EXTERNAL_LIB_BASIC=`AC_FF_PETSC_AWK(PETSC_EXTERNAL_LIB_BASIC,$2)`
97	    ff_PETSC_LIB_BASIC=`AC_FF_PETSC_AWK(PETSC_LIB_BASIC,$2)`
98	    ff_PETSC_PREFIXDIR=`awk -F' ' '"PREFIXDIR"==[$]1 {print [$]3}' $2`
99	    ff_PETSC_WITH_EXTERNAL_LIB="-Wl,-rpath,[$]ff_PETSC_PREFIXDIR/lib -L[$]ff_PETSC_PREFIXDIR/lib [$]ff_PETSC_LIB_BASIC [$]ff_PETSC_EXTERNAL_LIB_BASIC"
100	    ff_PETSC_CC_INCLUDES=`AC_FF_PETSC_AWK(PETSC_CC_INCLUDES,$2)`
101	   if test -n "[$]ff_PETSC_WITH_EXTERNAL_LIB"; then
102			    ff_$1_ok=yes;
103			    AC_FF_ADDWHERELIB($1,[$]ff_PETSC_WITH_EXTERNAL_LIB,[$]ff_PETSC_CC_INCLUDES)
104			    AC_SUBST([TOOL_COMPILE_$1],"")
105	  fi
106	  ]
107)dnl end m4_defineAC_FF_PETSC_WHERELIB_BASIC
108
109# ALH - this is required by FFCS that needs to deactivate some tools that do not work on all platforms. Some FF users
110# may also find interesting to specify a local version of a tool instead of downloading it.
111
112# m4 macro parameters: $1 = tool name, $2 = dynamic library name, $3 = download directory name if different from $1
113
114m4_define([TOOL_PARAMETERS],
115    [
116	AC_ARG_WITH($1_include,AC_HELP_STRING([--with-$1-include=],[Include directives for $1 instead of automatic download]))
117    AC_ARG_WITH($1_ldflags,AC_HELP_STRING([--with-$1-ldflags=],[Link-time directives for $1 instead of automatic download]))
118	AC_ARG_ENABLE(download-$1,AC_HELP_STRING([--enable-download_$1],[force the download of $1]))
119
120    if test "$with_$1_include" != "" || test "$with_$1_ldflags" != ""
121    then
122
123	# some directives have been specified, use them instead of downloading
124
125	AC_FF_ADDWHERELIB($1,$with_$1_ldflags,$with_$1_include)
126        AC_SUBST([TOOL_COMPILE_$1],"")
127	enable_$1_download=no
128    fi
129   ])
130
131m4_define([TOOL_DISABLE],
132    [AC_ARG_ENABLE($1,AC_HELP_STRING([--disable-$1],[Do not use $1]))
133    if test "$enable_$1" = "no"
134    then
135        AC_SUBST([TOOL_COMPILE_$1],"")
136        AC_SUBST([TOOL_DYLIB_$1],"")
137		ff_uncompile_plugin+=" "$2
138		ff_unlib_plugin+=" $1"
139    elif  test   "$ff_$1_ok" = "yes" ; then
140        AC_SUBST([TOOL_DYLIB_$1],$2)
141        enable_$1_download=no
142    else
143	   if test "$enable_download" != "yes" -a "$enable_download_$1" != "yes" ; then
144	    AC_SUBST([TOOL_COMPILE_$1],"")
145		ff_uncompile_plugin+=" "$2
146		ff_unlib_plugin+=" $1"
147        AC_SUBST([TOOL_DYLIB_$1],"")
148	   else
149        if test "$ff_wget" = yes -a "$enable_download_$1" = "yes" -a "$DOWNLOADCOMPILE" = "" ; then
150            DOWNLOADCOMPILE="compile-pkg install-other"
151        fi
152        AC_SUBST([TOOL_COMPILE_$1],ifelse($3,,$1,$3))
153        AC_SUBST([TOOL_DYLIB_$1],$2)
154		ifelse($4,,[ff_download_lib="$1 $ff_download_lib"])
155	    ifelse($4,,[enable_$1_download=yes])
156	   fi
157     fi
158
159    # Also allow to disable the download of one tool if it is already locally installed
160
161    TOOL_PARAMETERS($1,$2,$3)
162])
163m4_define([TOOL_DISABLE_NO],
164    [
165	AC_ARG_ENABLE($1,AC_HELP_STRING([--disable-$1],[Do not use $1]))
166    if test "$enable_$1" = "no" -o "$enable_$1" = ""
167    then
168	    enable_$1=no
169        AC_SUBST([TOOL_COMPILE_$1],"")
170        AC_SUBST([TOOL_DYLIB_$1],"")
171    elif  test   "$ff_$1_ok" = "yes" ; then
172        AC_SUBST([TOOL_DYLIB_$1],$2)
173        enable_$1_download=no
174    else
175        AC_SUBST([TOOL_COMPILE_$1],ifelse($3,,$1,$3))
176        AC_SUBST([TOOL_DYLIB_$1],$2)
177		ifelse($4,,[ff_download_lib="$1 $ff_download_lib"])
178	    ifelse($4,,[enable_$1_download=yes])
179    fi
180
181    # Also allow to disable the download of one tool if it is already locally installed
182
183    TOOL_PARAMETERS($1,$2,$3)
184])
185
186echo "#  Build with FreeFEM with ./configure " `date`  >$ff_where_lib_conf
187# To allow anonymous CVS version to contain a "./configure" and
188# Makefiles
189
190AM_MAINTAINER_MODE
191
192echo >config_LIB_INFO
193
194# Necessary compilers
195
196AC_PROG_CC
197AC_PROG_CXX
198AC_LANG(C++)
199if test `uname` != Darwin; then
200 ff_ldeg="-Wl,--end-group"
201 ff_ldbg="-Wl,--start-group"
202fi
203
204#  suffix of  dynamic lib ..
205# ---------------------------
206ff_uname=`uname`
207#  flag to build window 32   version   ff_mingw = yes
208# bof bof F. Hecht
209case $ff_uname in
210    CYGWIN*|MINGW*|MSYS_NT*)
211	ff_suffix_dylib="dll"
212	ff_suffix_dylib_a="dll.a";;
213     Darwin)
214	ff_suffix_dylib="dylib"
215	ff_suffix_dylib_a="dylib";;
216    *)
217       ff_suffix_dylib="so";
218       ff_suffix_dylib_a="so";
219esac
220# end suffix ...
221
222
223
224AC_CHECK_PROG(ff_unzip,unzip,yes,no)
225AC_CHECK_PROG(ff_m4,m4,yes,no)
226AC_CHECK_PROG(ff_bison,bison,yes,no)
227AC_CHECK_PROG(ff_flex,flex,yes,no)
228AC_CHECK_PROG(ff_cmake,cmake,yes,no)
229AC_CHECK_PROG(ff_patch,patch,yes,no)
230case "$ff_m4 $ff_bison $ff_patch $ff_flex $ff_unzip"  in
231*no*)
232    AC_MSG_NOTICE([ to install missing package  under debian or ubuntu, try ])
233    test "$ff_unzip" = no && AC_MSG_NOTICE([ sudo apt-get install unzip])
234    test "$ff_m4" = no && AC_MSG_NOTICE([ sudo apt-get install m4])
235    test "$ff_bison" = no && AC_MSG_NOTICE([ sudo apt-get install bison])
236    test "$ff_flex" = no && AC_MSG_NOTICE([ sudo apt-get install flex])
237    test "$ff_patch" = no && AC_MSG_NOTICE([ sudo apt-get install patch])
238    AC_MSG_ERROR([ Sorry missing  unzip,m4,bison,flex,patch command !]);;
239esac
240
241
242if test -z "$CXX"; then
243  AC_MSG_NOTICE( [ fatal error : c++ compiler ! ] );
244  AC_MSG_ERROR([ Sorry no c++ compiler !])
245fi
246
247AC_COMPUTE_INT(ff_size_long,[sizeof(long)])
248AC_COMPUTE_INT(ff_size_int,[sizeof(int)])
249AC_COMPUTE_INT(ff_size_ptr,[sizeof(int*)])
250
251AC_SUBST(SIZEOF_LONG,$ff_size_long)
252AC_SUBST(SIZEOF_INT,$ff_size_int)
253AC_SUBST(SIZEOF_PTR,$ff_size_ptr)
254if test "0$ff_size_ptr" -eq 4  ;then
255 AC_SUBST(SIZEOF_PTRINBIT,32)
256 ff_ptrbit=32
257elif test  "0$ff_size_ptr" -eq 8  ;then
258 AC_SUBST(SIZEOF_PTRINBIT,64)
259 ff_ptrbit=64
260else
261  AC_MSG_NOTICE( [ fatal error : sizeof pointer $ff_size_ptr !  or no c++ compiler: $CXX] );
262  AC_MSG_ERROR([ Sorry  sizeof c++ pointer $ff_size_ptr are not  4 or 8 ])
263fi
264
265# FFCS - build the code for FreeFem++-cs
266AC_ARG_ENABLE(ffcs,AC_HELP_STRING([--enable-ffcs],[build FreeFEM for use by FreeFem++-cs]))
267if test "$enable_ffcs" = yes
268then
269	AC_DEFINE_UNQUOTED(ENABLE_FFCS,$enable_ffcs,[build FreeFEM for use by FreeFem++-cs])
270else
271	enable_ffcs=no
272fi
273AC_SUBST(ENABLE_FFCS,"$enable_ffcs")
274AM_CONDITIONAL([ENABLE_FFCS],[test $enable_ffcs = yes])
275
276# dur dur car sous MacOsX le fortran n'est pas standard.
277ff_AR="ar"
278ff_ARFLAGS="rv"
279ff_RANLIB="ranlib"
280AC_ARG_ENABLE(fortran,AC_HELP_STRING([--disable-fortran],[No Fortran compiler available ( ARPACK need it)]))
281
282ff_g2c_lib="";
283if test "$enable_fortran" != no
284then
285
286    # ALH-FFCS-2/3/10: add gfortran-mp-4.4 for MacPorts on MacOS 10.6
287    # FH add iforr
288    AC_PROG_FC(gfortran  f90  xlf90 g95 ifort gfortran-mp-4.4)
289    AC_PROG_F77(gfortran f90 xlf xlf90 g95 f77 fort77 "$FC" ifort gfortran-mp-4.4)
290
291#	if test -n "$F77"
292#	then
293    ff_flibs=""
294        # modif FH
295    AC_F77_LIBRARY_LDFLAGS
296    dnl	AC_F77_WRAPPERS
297	# correct pb of double def under macos
298    case $F77 in
299	 *fort77)
300	    if test -z "$FLIBS" ; then
301#             FLIBS=`fort77 -v  a.out  2>&1|awk '/a.out/ && /fort77/  { print $(NF-2),$(NF-1)}'`
302#  FH to remove " "
303		FLIBS=`fort77 -v  a.out  2>&1|awk '/a.out/ && /fort77/  { print "echo",$(NF-2),$(NF-1)}'|sh`
304
305		AC_MSG_WARN([  fort77   FLIBS :  $FLIBS ])
306	    fi
307	    ;;
308	*g77)
309	    for i in $FLIBS; do
310		case $i in
311# save last directory of the list
312		    -L*)
313			d=`expr $i : '-L\(.*\)'`;
314			echo " try $d "
315			if test -e "$d/libg2c.so" ; then
316			    ff_flibs="$d/libg2c.so"
317			elif test -e "$d/libg2c.dylib" ; then
318			    ff_flibs="$d/libg2c.dylib"
319			elif test -e "$d/libg2c.a" ; then
320			    ff_flibs="$d/libg2c.a"
321			elif test  -e $d/libg2c.so -o	-e $d/libg2c.a ; then
322			    ff_flibs="$i"
323			fi;;
324		esac
325	    done
326	    if test -e "$ff_flibs"  ;then
327		FLIBS="$ff_flibs"
328	    else
329		FLIBS="$ff_flibs -lg2c"
330	    fi
331	    AC_MSG_WARN([  get dir of -lg2c  FLIBS :  $FLIBS ])
332	    ;;
333# add FH sep 2006 / modif  2009
334        *gfortran)
335	    ff_okkk=0
336            for i in $FLIBS; do
337		case $i in
338		    -L*)
339			d=`expr $i : '-L\(.*\)'`;
340			if test -e "$d/libgfortran.$ff_suffix_dylib_a" -a  -e "$d/libquadmath.$ff_suffix_dylib_a"  ; then
341			   ff_flibs="$d/libgfortran.$ff_suffix_dylib_a $d/libquadmath.$ff_suffix_dylib_a"
342			    ff_okkk=1
343			elif test -e "$d/libgfortran.a"  -a -e "$d/libquadmath.a" ; then
344			   ff_flibs="$d/libgfortran.a $d/libquadmath.a"
345			    ff_okkk=1
346			elif test -e "$d/libgfortran.$ff_suffix_dylib_a"   ; then
347			   ff_flibs="$d/libgfortran.$ff_suffix_dylib_a"
348			    ff_okkk=2
349			elif test -e "$d/libgfortran.a" ; then
350			   ff_flibs="$d/libgfortran.a"
351			    ff_okkk=2
352			fi;;
353		esac
354            done
355	    if test  "$ff_okkk" -ge  1  ;then
356		FLIBS="$ff_flibs"
357	    else
358		FLIBS="$ff_flibs -lgfortran"
359	    fi
360            AC_MSG_WARN([  get dir of -lgfortran  FLIBS :  $FLIBS ])
361            ;;
362    esac
363    AC_ARG_WITH(flib,[  --with-flib= the fortran library ])
364#  correct FH sep 2006 -o -> -a
365    if test "$with_flib" != no -a -n  "$with_flib"
366    then
367	ff_g2c_lib="$with_flib"
368	FLIBS="$with_flib"
369    fi
370# add FH oct 2007 for download f2c
371    if test -z "$F77"  ; then
372	ff_f77=`pwd`/3rdparty/bin/fort77
373	ff_flibs=`pwd`/3rdparty/lib/libf2c.a
374	if test -x $ff_f77  -a -f $ff_flibs ; then
375	    AC_MSG_WARN([ no fortran, but find download f2c/fort]);
376	    F77=$ff_f77
377	    FLIBS=$ff_flibs
378	else
379	    AC_MSG_NOTICE( [ fatal error : no fortran ] );
380	    AC_MSG_NOTICE( [add --disable-fortran  ] );
381	    AC_MSG_NOTICE( [or try to compile f2c in directory 3rdparty/f2c  ] );
382	    AC_MSG_NOTICE( [  just do:  make install ] );
383	    AC_MSG_ERROR([ Fatal error No Fortran compiler . ],1);
384	fi
385    fi
386#  check if the FLIBS is correct
387    ff_libs="$LIBS"
388    LIBS="$ff_libs $FLIBS"
389    AC_TRY_LINK_FUNC(exit,ff_err=,ff_err=ok);
390    if test "$ff_err" = "ok" ; then  AC_MSG_ERROR([ Fatal FLIBS: $FLIBS is incorrect. ],1); fi
391    LIBS="$ff_libs"
392    echo "F77 LD $ff_libs" >config_LIB_INFO
393
394    AC_MSG_CHECKING([ Size of fortran 77 integer ])
395
396
397
398##   AC_LANG(fortran);
399    AC_LANG_PUSH([Fortran 77])
400    AC_RUN_IFELSE([AC_LANG_SOURCE([[
401		program test
402		integer  p,i
403		p=1024*1024
404		i= p*p
405		open(7,file="conftest.out")
406		if (i>0) then
407		    write(7,*) 8
408		else
409         write(7,*) 4
410	 endif
411	 close(7)
412	 end
413 ]])] ,ff_f77intsize=`cat conftest.out`,ff_f77intsize=4,ff_f77intsize=4)
414## AC_LANG(C++)
415    AC_LANG_POP([Fortran 77])
416    AC_MSG_RESULT($ff_f77intsize)
417    AC_F77_WRAPPERS
418
419    ff_cfagsf77=""
420    case $ac_cv_f77_mangling in
421#  "lower case, no underscore, no extra underscore")
422#  "lower case, no underscore, extra underscore")
423# ;;
424	"lower case, underscore, no extra underscore") 	ff_cfagsf77="-DAdd_";;
425	"lower case, underscore, extra underscore")       	ff_cfagsf77="-DAdd__ -Df77IsF2C";;
426	"upper case, no underscore, no extra underscore")     ff_cfagsf77="-DUPPER";;
427	"upper case, no underscore, extra underscore")        ff_cfagsf77="-DUPPER -DAdd__";;
428	"upper case, underscore, no extra underscore")      ff_cfagsf77="-DUPPER -DAdd_";;
429	"upper case, underscore, extra underscore")           ff_cfagsf77="-DUPPER -DAdd__";;
430	*) ;;
431    esac
432    AC_SUBST(CFLAGSF77,$ff_cfagsf77)
433    if test $ff_f77intsize -ne  4
434    then
435	AC_MSG_ERROR([ Fatal Error: Your fortran 77  compiler have by not 4 bytes integer ( $ff_f77intsize bytes) ],1);
436    fi
437    test -f /mingw/bin/libpthread-2.dll && ff_pthread_dll=/mingw/bin/libpthread-2.dll ; \
438    AC_FF_ADDWHERELIB(f77,$FLIBS,$ff_cfagsf77 $ff_pthread_dll)
439    AC_FF_ADDWHERELIB(fc,$FLIBS,$ff_cfagsf77 $ff_pthread_dll)
440fi
441
442#  fin test FORTRAN ..........
443# ----------------------------
444
445AC_ARG_ENABLE(c,AC_HELP_STRING([--disable-c],[No C compiler available (C BLAS need it)]))
446if test "$enable_c" != no
447then
448    AC_PROG_CC
449    AM_PROG_CC_C_O
450else
451
452	# We need to define this otherwise ./configure crashes with
453	# the message "configure: error: conditional "am__fastdepCC"
454	# was never defined".
455
456    am__fastdepCC_TRUE=
457    am__fastdepCC_FALSE='#'
458fi
459
460AM_PROG_LEX
461AC_PROG_YACC
462AC_LANG(C++)
463
464
465# Some useful libraries
466
467AC_CHECK_LIB(pthread,pthread_create,ff_pthread="-lpthread",ff_pthread="")
468AC_CHECK_LIB(iomp5,omp_get_wtime,ff_iomp5="-liomp5",ff_iomp5="")
469AC_CHECK_LIB([rt],[clock_gettime])
470
471if test -n "$ff_pthread"  ; then
472    AC_FF_ADDWHERELIB(pthread,$ff_pthread,)
473fi
474
475# Necessary absolute pathname for local directory when some libraries
476# are used from several different locations (for instance locally in
477# configure.ac and in a subdir).
478curdir=`pwd`
479
480# Configure options
481# -----------------
482
483echo "$PATH" > config.path
484eval for i in $ac_configure_args\; do echo \$i\; done | sed -e "s/$/'/" -e "s/^/'/"   > config.param
485
486# by default the suffix of the  .so lib file is .so
487#      it is .dll   under windows
488#      it is .dylib under macos X
489
490# suffix of dynamic lib
491# Checking wether we can produce a MacIntosh-specific version
492# -----------------------------------------------------------
493AC_MSG_CHECKING(wether we are on a MacIntosh)
494ff_mac=no
495if test `uname` = Darwin;
496then
497	ff_suffix_dylib="dylib"
498	ff_suffix_dylib_a="dylib"
499	ff_mac=yes
500AC_DEFINE_UNQUOTED(FF_PREFIX_DIR_APPLE,"/Applications/FreeFem++.app/Contents/",FreeFem prefix  dir)
501fi
502AC_MSG_RESULT($ff_mac)
503
504AC_MSG_CHECKING(wether we are on  SunOS)
505ff_sunos=no
506if test `uname -s` = SunOS;
507then
508	ff_sunos=yes
509fi
510AC_MSG_RESULT($ff_sunos)
511
512# glut ------------
513# ----------------
514ff_glut=""
515ff_glut_ok=""
516AC_ARG_WITH(glut,[  --with-glut  glutlib and include  ])
517if test "$with_glut" != no -a  -n "$with_glut" ; then
518    ff_libs_save="$LIBS"
519    LIBS="$LIBS"
520dnl not works .... so no check .... FH
521      ff_glut="$with_glut";ff_glut_ok=yes
522dnl     AC_SEARCH_LIBS(abort,[$with_glut],[ff_glut="$with_glut";ff_glut_ok=yes],[ff_glut="";ff_glut_ok="no"])
523    LIBS="$ff_libs_save"
524dnl     AC_MSG_ERROR([ Sorry  bad --with-glut :  $with_glut !])
525elif test "$with_glut" = no ; then
526    ff_glut_ok="no"
527fi
528
529# Checking wether we can produce a Microsoft Windows-specific version
530# -------------------------------------------------------------------
531
532AC_ARG_ENABLE(cygwindll,[  --enable-cygwindll	Forces the use of the Cygwin DLL (not recommended)])
533AC_ARG_ENABLE(mingw64,[  --enable-mingw64	Uses mingw64 compilers on Cygwin])
534AC_MSG_CHECKING(wether we are on Microsoft Windows)
535ff_uname=`uname`
536#  flag to build window 32   version   ff_mingw = yes
537ff_mingw=no
538ff_fpic=yes
539case $ff_uname in
540    CYGWIN*)
541	ff_fpic=no
542	#    ff_nocygwin=-mno-cygwin
543	AC_SUBST(GCCNOCYGWIN,$ff_nocygwin);;
544    MINGW*|MSYS_NT*)
545        enable_cygwindll=no;;
546
547
548esac
549ff_PURE_WIN32=0
550case $ff_uname in
551CYGWIN*|MINGW*|MSYS_NT*)
552	ff_fpic=no
553	ff_suffix_dylib="dll";
554	ff_suffix_dylib_a="dll.a";
555        ff_win32=yes;
556    # echo "ff win 32 --------------------------------------------"
557	# FFCS - 8/3/12 - remove -D_MSC_VER under MinGW64 because it forces system calls to be compiled into any object
558	# (which creates thousands of duplicate definitions for sytem calls like time()).
559
560
561	# We need Mingw to avoid Cygwin's extra DLLs
562	if test "$enable_cygwindll" != yes
563	then
564# 	        CHECK_COMPILE_FLAG(C++,-mwindows,CXXFLAGS)
565
566		# FFCS: on Windows, FF crashes when compiling GL/glut.h and the option "--disable-opengl" is not
567		# operational because ff_glut_ok is forced to yes here.
568		if test $enable_ffcs = yes
569		then
570	            ff_glut_ok=no
571		    ff_glut=""
572		    enable_opengl=no
573		fi
574
575                ff_mingw=yes
576                enable_cygwindll=no;
577		ff_pthread="-mthreads"
578
579		# FFCS does not use the Cygwin MinGW compilers any more
580		if test $enable_ffcs = no
581		then
582		    CXXFLAGS="$CXXFLAGS $ff_nocygwin -I/usr/include/mingw"
583		    FFLAGS="$FFLAGS $ff_nocygwin"
584		    CFLAGS="$CFLAGS $ff_nocygwin -I/usr/include/mingw"
585                    AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a;])],[],
586			[ff_nocygwin="";
587			    AC_MSG_NOTICE([Sorry $ff_nocygwin optio is wrong try whitout , but try with gcc-3.3])
588			    ])
589		    CXXFLAGS="$CXXFLAGS $ff_nocygwin -I/usr/include/mingw"
590		    FFLAGS="$FFLAGS $ff_nocygwin"
591		    CFLAGS="$CFLAGS $ff_nocygwin -I/usr/include/mingw"
592		    CNOFLAGS="$CNOFLAGS $ff_nocygwin -I/usr/include/mingw"
593		fi
594
595		LIBS="$LIBS $ff_nocygwin -mthreads -lws2_32 -lcomdlg32"
596		LIBSNOCONSOLE="-mwindows"
597
598		# FFCS uses a specific compiler, so we specify its libraries explicitely
599		if test $enable_ffcs = no
600		then
601		    export PATH="$PATH:`cygpath $MSMPI_BIN`"
602		    test -z "$MPIRUN" &&  MPIRUN=`which mpiexe.exe`
603		    if test "$enable_fortran" != no  -o  "$with_flib" != no ;   then
604			case "$F77" in
605	 		    *gfortran) FLIBS="$ff_nocygwin -lgfortran -lquadmath";;
606	 		    *g77) FLIBS="$ff_nocygwin -lg2c";;
607			    *)   AC_MSG_ERROR([ Sorry no known FLIBS with this $F77  !]) ;;
608			esac
609		    fi
610		fi
611
612		if test -z "$ff_glut" -a  "$ff_glut_ok" != "no" ; then
613                    ff_glutname="glut32"
614		#  check abort a existing function just to find in glut32.dll exist in the path
615		#  because glutInit is not the real symbol on win32 dur dur FH !!!!!!!!!
616		    AC_CHECK_LIB(glut32,abort,ff_glut="-l$ff_glutname -mthreads -lglu32 -lopengl32",ff_glut="")
617		    if test -z "$ff_glut" ; then
618			ff_glutname="freeglut"
619			if test -x  /usr/bin/pkg-config.exe ; then
620			ff_glut="-lglu32 "`/usr/bin/pkg-config.exe --libs freeglut`
621			else
622			ff_glut="-l$ff_glutname -mthreads -lglu32 -lopengl32"
623			fi
624			AC_CHECK_LIB(freeglut,abort,ff_glut_ok=yes,ff_glut="")
625		    fi
626		fi
627         	# Resources for FreeFem++-cs in Microsoft Windows format
628	        AC_SUBST(FFGLUTNAME,$ff_glutname)
629	        AC_SUBST(WINDRESOBJ,windres.o)
630	        AC_SUBST(LIBSNOCONSOLE,$LIBSNOCONSOLE)
631            AC_SUBST(WIN32DLLTARGET,win32-dll-target)
632		    ff_TEST_FFPP="../../src/bin-win32/FreeFem++.exe"
633		    ff_TEST_FFPP_MPI="../../src/bin-win32/FreeFem++-mpi.exe"
634
635            AC_DEFINE(PURE_WIN32,1,A pure windows applications no cygwin dll)
636		ff_PURE_WIN32=1
637		ff_dynload=yes
638	fi
639
640
641	;;
642*) ff_win32=no;;
643esac
644AC_MSG_RESULT($ff_win32)
645
646if test "$ff_win32" = no
647then
648	enable_cygwindll=no
649fi
650
651# FreeFem++-specific version information
652# --------------------------------------
653
654# Version numbering, converted to a floating point value
655ff_numver="`echo $VERSION|sed 's/-\(.*\)/+\1.0*0.000001/'`"
656AC_DEFINE_UNQUOTED(VersionFreeFem,$ff_numver,FreeFEM version as a float)
657
658# Since src/fflib/strversionnumber.cpp is recreated at each build, this
659# date is only useful for config-version.h
660
661test "$prefix" = NONE && prefix="$ac_default_prefix"
662ff_prefix_dir="${prefix}/lib/ff++/$VERSION"
663AC_MSG_CHECKING(prefix dir freefem++  )
664AC_MSG_RESULT($ff_prefix_dir)
665
666FF_DATE=`date`
667AC_DEFINE_UNQUOTED(VersionFreeFemDate,"$FF_DATE",FreeFEM build date)
668AC_DEFINE_UNQUOTED(FF_PREFIX_DIR,"${ff_prefix_dir}",FreeFem prefix  dir)
669AC_SUBST(ff_prefix_dir,$ff_prefix_dir)
670
671ff_prefix_dir_lib="$ff_prefix_dir/lib"
672ff_prefix_dir_data="$datadir/$PACKAGE_NAME"
673
674ff_prefix_dir_include="$ff_prefix_dir/include"
675ff_prefix_dir_etc="$ff_prefix_dir/etc"
676ff_prefix_dir_lib_mpi="$ff_prefix_dir/lib/mpi"
677ff_prefix_dir_example="${prefix}/share/examples/freefem++"
678AC_SUBST(ff_prefix_dir_lib,$ff_prefix_dir_lib)
679AC_SUBST(ff_prefix_dir_include,$ff_prefix_dir_include)
680AC_SUBST(ff_prefix_dir_etc,$ff_prefix_dir_etc)
681AC_SUBST(ff_prefix_dir_lib_mpi,$ff_prefix_dir_lib_mpi)
682AC_SUBST(ff_prefix_dir_example,$ff_prefix_dir_example)
683
684# Separate configuration header file for version information, included
685# in config-macos9.h
686
687cat << EOF > config-version.h
688/* FreeFEM version information for MacOS 9 configuration */
689/* File generated by configure.ac */
690
691/* Define to the full name and version of this package. */
692#define PACKAGE_STRING "$PACKAGE_STRING"
693
694/* Define to the one symbol short name of this package. */
695#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
696
697/* Define to the version of this package. */
698#define PACKAGE_VERSION "$PACKAGE_VERSION"
699
700/* Version number of package */
701#define VERSION "$VERSION"
702
703/* FreeFEM build date */
704#define VersionFreeFemDate "$FF_DATE"
705
706/* FreeFEM version as a float */
707#define VersionFreeFem ($ff_numver)
708EOF
709
710# Checking wether to produce a debug version
711# ------------------------------------------
712
713# Generic or hardware-dependant optimization
714m4_include(etc/config/m4/acmacros.m4)
715m4_include(etc/config/m4/acoptim.m4)
716
717# [[file:ax_lib_hdf5.m4]]
718m4_include(etc/config/m4/ax_lib_hdf5.m4)
719
720# [[file:ax_lib_gsl.m4]]
721m4_include(etc/config/m4/ax_lib_gsl.m4)
722
723# Checking c++11 for HashMatix (Madatory now)
724# F.Hecht:
725# do not compile all with c++11 version to much
726# probleme to day (frev 2015) with g++ 4.8.1
727ff_cxx_save=$CXXFLAGS
728CHECK_COMPILE_FLAG(C++,[-std=c++11],CXXFLAGS,ff_cxx11)
729dnl CXXFLAGS="$CXX11FLAGS $CXXFLAGS"
730dnlff_cxx11="no"
731dnl if test -n "$CXX11FLAGS" ; then ff_cxx11="yes" ; fi
732if test "$ff_cxx11" = yes ; then
733    CXX11FLAGS="-std=c++11";
734##	CXXFLAGS="$CXXFLAGS -std=c++11"
735    AC_FF_ADDWHERELIB(cxx11,$CXX11FLAGS,$CXX11FLAGS)
736else
737  AC_MSG_NOTICE( [ fatal error : c++ compiler ! ] );
738  AC_MSG_ERROR([ Sorry no c++ compiler !])
739  AC_MSG_ERROR([ Fatal error c++11  ],1);
740fi
741##CXXFLAGS="$ff_cxx_save"
742AC_SUBST(WITH_CXX11,$ff_cxx11)
743AC_SUBST(CXX11FLAGS,$CXX11FLAGS)
744#end Checking  c++11
745# ------------------------------
746# compilation flags of FreeFem++
747# ------------------------------
748#  -DDRAWING  bamg active some drawing facility in bamg (inquire mesh)
749#  -DBAMG_LONG_LONG active the use of  long long in bamg
750#  -DDEBUG active the  checking in bamg
751#  -DNCHECKPTR remove check pointer facility
752#  -DCHECK_KN active subscripting of some array
753#  -DWITHCHECK of the dynamic type ckecking of the langague (very slow)
754#  -DEIGENVALUE  to compile the eigen value part
755#  ------------------------------------------------
756
757# FreeFrem++-specific optimizations -fpascal-strings
758
759
760if test "$enable_debug" = yes;
761then
762	CXXFLAGS="$CXXFLAGS  -DBAMG_LONG_LONG -DCHECK_KN"
763	if test "$ff_mac" = yes;
764	then
765		CXXFLAGS="$CXXFLAGS -fno-inline  -fexceptions"
766	fi
767else
768	CXXFLAGS="$CXXFLAGS -DBAMG_LONG_LONG  -DNCHECKPTR"
769	if test "$ff_mac" = yes;
770	then
771		CXXFLAGS="$CXXFLAGS "
772	fi
773fi
774
775#whether or not to add a suffix to the package name
776#--------------------------------------------------
777
778AC_ARG_WITH(suffix,[  --with-suffix=[G3/G4/G4,P4,..] or --without-suffix (default no suffix to package name)])
779
780AC_MSG_CHECKING(suffix to add to package name)
781ff_suffix=
782if test "$with_suffix" = yes -o "$with_suffix" = no -o "$with_suffix" = ""
783then
784  AC_MSG_RESULT(none)
785else
786  ff_suffix="-$with_suffix"
787  AC_MSG_RESULT($ff_suffix)
788fi
789AC_SUBST(ADD_PACKAGE_NAME,$ff_suffix)
790
791
792
793
794# Checking that OpenGL is accessible
795# ----------------------------------
796
797ff_gl_ok=no
798ff_glx_ok=no
799
800ff_libs="$LIBS"
801AC_ARG_WITH(flib,[  --with-flib= the fortran library ])
802AC_ARG_ENABLE([opengl],AS_HELP_STRING([--enable-opengl],
803                                      [Enable/disable support for OpenGL]))
804
805# echo "  .... LIBS = $LIBS .... "
806if test x$enable_opengl != xno; then
807# GL libraries seem to depend on some dlopen capabilities
808if test "$enable_static" != yes -a "$ff_glut_ok" != yes
809then
810	# If we cannot find gl.h, no OpenGL version can be produced
811    AC_CHECK_HEADERS(OpenGL/gl.h,
812        ff_gl_ok=yes
813        ,
814        ff_gl_ok=no
815        )
816
817
818    if test "$ff_gl_ok" = no
819    then
820	AC_CHECK_HEADERS(GL/gl.h,
821	    ff_gl_ok=yes
822	    ,
823	    ff_gl_ok=no
824	    )
825    fi
826    AC_CHECK_HEADERS(GLUT/glut.h,
827        ff_glut_ok=yes,
828        ff_glut_ok=no)
829
830    if test "$ff_glut_ok" = no
831    then
832	AC_CHECK_HEADERS(GL/glut.h,
833	    ff_glut_ok=yes,
834	    ff_glut_ok=no)
835    fi
836
837# GLUT .....
838    if test "$ff_glut_ok" =	yes
839    then
840	for glut in \
841	    "-framework GLUT -framework OpenGL -framework Cocoa" \
842	    "-lglut -lGLU -lGL"
843	do
844	    ff_glut="$glut"
845	    ff_libs1="$LIBS"
846     	    LIBS="$LIBS $ff_glut"
847	    AC_TRY_LINK_FUNC(glutInit,
848		ff_glut_ok=yes
849	        LIBS="$ff_libs1"
850		break,
851		ff_glut_ok=next);
852	    LIBS="$ff_libs1"
853	done
854    fi
855
856
857fi
858fi
859AC_SUBST(LIBSPTHREAD,$ff_pthread)
860
861# ALH - 16/9/13 - at the moment the requirements for medit (glut) are not compatible with FFCS so medit is
862# only compiled with FF.
863
864if test $enable_ffcs = no
865then
866    if test "$ff_glut_ok" = yes
867    then
868	AC_SUBST(LIBSGLUT,$ff_glut)
869	if test -n  "$ff_pthread" ; then
870	    ff_ffglutprog="ffglut${EXEEXT}"
871	    AC_DEFINE_UNQUOTED(PROG_FFGLUT,"$ff_ffglutprog", the ffglut application for the new graphics )
872	fi
873	ff_meditprog="ffmedit${EXEEXT}"
874    fi
875fi
876
877AC_ARG_WITH(suffix,[  --with-suffix=[G3/G4/G4,P4,..] or --without-suffix (default no suffix package name)])
878if test "$with_suffix" = yes
879then
880  with_suffix=""
881elif test "$with_suffix" = no -o -z "$with_suffix"
882then
883  with_suffix=""
884else
885  with_suffix="-$with_suffix"
886fi
887  AC_MSG_CHECKING(add suffix $with_suffix )
888  AC_SUBST(ADD_PACKAGE_NAME,$with_suffix)
889  AC_MSG_RESULT(yes)
890
891
892# Checking wether we can produce a parallel version
893# -------------------------------------------------
894
895if test $enable_ffcs = no
896then
897    # FF case
898    m4_include(etc/config/m4/acmpi.m4)
899else
900    # FFCS - use the same MPI configuration choices as FFCS
901    if test -z "$MPICXX"
902    then
903	ff_mpi=no
904    else
905	ff_mpi=yes
906	AC_SUBST(MPICXX,$MPICXX)
907	AC_SUBST(MPICC,$MPICC)
908	AC_SUBST(MPIF77,$MPIF77)
909	AC_SUBST(MPIFC,$MPIFC)
910	AC_SUBST(MPIPROG,"FreeFem++-mpi${EXEEXT}")
911	AC_SUBST(MPI_INCLUDE,"-I $MPI_INC_DIR")
912	AC_SUBST(MPI_INC_DIR,$MPI_INC_DIR)
913	AC_SUBST(MPI_LIB_DIRS,"")
914	AC_SUBST(MPI_LIB,$MPI_LIB)
915	AC_SUBST(MPI_LIBC,"")
916	AC_SUBST(MPI_LIBFC,"")
917
918        # these values should not be empty otherwise
919        # plugin/seq/ff-get-dep will think that they are not
920        # defined
921	AC_FF_ADDWHERELIB(mpi,-DDUMMY,-I$MPI_INC_DIR)
922
923        # mpifc and mpif77 libraries should always be specified
924        # because FF never calls the Fortran MPI compiler. It always
925        # uses mpicxx in [[file:plugin/seq/ff-c++]]. The
926        # resulting Fortran libraries (eg Mumps) would compile even
927        # without the proper Fortran libs, but they would not load
928        # properly.
929
930        # under Win32, libmpi_f77.a is not the right name and FFCS
931        # mingw/mpicxx adds the right libraries by itself
932
933        # With mpich2 Debian wheezy 32 bits, libmpi_f77.a is not available (request from Cico, 14/10/13)
934
935	if test -f /usr/lib/openmpi/lib/libmpi_f77.a
936	then
937            AC_FF_ADDWHERELIB(mpifc,-lmpi_f77,)
938    	    AC_FF_ADDWHERELIB(mpif77,-lmpi_f77,)
939	else
940            AC_FF_ADDWHERELIB(mpifc,-DDUMMY,)
941    	    AC_FF_ADDWHERELIB(mpif77,-DDUMMY,)
942	fi
943
944        # FFCS - MPI_DOUBLE_COMPLEX kept from original FF configure script
945	AC_MSG_CHECKING( MPI_DOUBLE_COMPLEX)
946	AC_COMPILE_IFELSE(
947	    [AC_LANG_SOURCE([
948#include <mpi.h>
949			MPI_Datatype xxxx=MPI_DOUBLE_COMPLEX;
950			])],
951	    ff_mpi_double_complex=yes,
952	    ff_mpi_double_complex=no)
953	AC_MSG_RESULT($ff_mpi_double_complex)
954	if test "$ff_mpi_double_complex" = yes  ; then
955	    AC_DEFINE(HAVE_MPI_DOUBLE_COMPLEX,1, mpi_double_complex)
956	fi
957    fi
958fi
959
960# FFCS needs to change some of the FF makefiles to compile without MPI
961AM_CONDITIONAL([FFCS_MPIOK],[test $ff_mpi = yes])
962
963# Looking for useful configuration utilities
964# ------------------------------------------
965
966AC_ARG_ENABLE(summary,AC_HELP_STRING([--enable-summary],[Display activated libraries list at the end of the configure process]))
967
968AC_ARG_ENABLE(download,AC_HELP_STRING([--enable-download],[Download missing libraries (BLAS,ARPACK,UMFPACK,...)]))
969## PETSc
970AC_ARG_WITH(petsc,[ --with-petsc=/usr/local/petsc/conf/petscvariables --without-petsc])
971AC_ARG_WITH(prefix_petsc,[ --prefix_petsc=directory where all PETSc/SLEPc will be installed if you download ])
972if test -z "${prefix_petsc}"; then prefix_petsc="${prefix}/ff-petsc/"; fi
973AC_SUBST([FF_prefix_petsc],"$prefix_petsc")
974AC_SUBST([FF_prefix_petsc_real],"$prefix_petsc_real")
975AC_SUBST([FF_prefix_petsc_complex],"$prefix_petsc_complex")
976AC_SUBST([FF_generic_petsc],"$enable_generic")
977# /usr/local/petsc/conf/petscvariables
978#/usr/local/ff++/petsc/lib/petsc/conf/petscvariables
979ff_petsc_ok=no
980ff_slepc_ok=no
981if test "$with_petsc" != no -a $ff_mpi = yes; then
982    for d in "$with_petsc" "${prefix_petsc}/real/lib" "${prefix_petsc}/r/lib" /usr/local/ff++/petsc/lib  /usr /usr/local /opt/usr  /opt/local ;do
983	for dd in "" "/petsc/conf/petscvariables" "/lib/petsc-conf/petscvariables" ; do
984	    ffconfpetsc="$d$dd"
985		ffconfslepc="$d/slepc/conf/slepcvariables"
986
987		 echo " petsc ... $ffconfpetsc"
988	    if test -f "$ffconfpetsc" ; then
989		if test  "$ff_petsc_ok" = no ; then
990		    PETSC_PREFIXDIR=`awk -F' *= *' '"PREFIXDIR"==$1 {print $2}' "$ffconfpetsc"`
991		    PETSC_SCALAR=`awk -F' *= *' '"PETSC_SCALAR"==$1 {print $2}' "$ffconfpetsc"`
992		    PETSC_MPIRUN=`awk -F' *= *' '"MPIEXEC"==$1 {print $2}' "$ffconfpetsc"`
993		    PETSC_MPIRUN=`echo "$PETSC_MPIRUN" | awk '{gsub(" --oversubscribe", ""); print}'`	#remove --oversubscribe
994		    AC_MSG_NOTICE([ find real ( $PETSC_SCALAR )  petsc in $ffconfpetsc]);
995                    WPETSC_MPIRUN=`which "$PETSC_MPIRUN"`
996                    WMPIRUN=`which "$MPIRUN"`
997		    test  "$PETSC_SCALAR" = "real" && test "$ff_win32" = yes -o  "$PETSC_MPIRUN" = "$MPIRUN" ||  cmp -s "$WPETSC_MPIRUN" "$WMPIRUN"
998		    if test "$?"  -eq 0 ; then
999	                AC_SUBST([FF_conf_petsc_real],"$ffconfpetsc")
1000		        AC_SUBST([FF_prefix_petsc_real],"$PETSC_PREFIXDIR")
1001		        AC_FF_PETSC_WHERELIB_BASIC(petsc,$ffconfpetsc)
1002		        AC_FF_PETSC_WHERELIB(parmetis,PARMETIS_LIB,PARMETIS_INCLUDE,$ffconfpetsc)
1003		        AC_FF_PETSC_WHERELIB(metis,METIS_LIB,METIS_INCLUDE,$ffconfpetsc)
1004		        AC_FF_PETSC_WHERELIB(ptscotch,PTSCOTCH_LIB,PTSCOTCH_INCLUDE,$ffconfpetsc)
1005                        ff_SCOTCH_INCLUDE=$ff_PTSCOTCH_INCLUDE
1006                        ff_SCOTCH_LIB=`echo $ff_PTSCOTCH_LIB | sed -e 's/@<:@^ @:>@*ptscotch@<:@^ @:>@*//g' | sed -e 's/@<:@^ @:>@*ptes@<:@^ @:>@*//g'`
1007                        if test -n "$ff_SCOTCH_LIB"; then
1008                          ff_scotch_ok=yes;
1009                          AC_FF_ADDWHERELIB(scotch,$ff_SCOTCH_LIB,$ff_SCOTCH_INCLUDE)
1010                          AC_SUBST([TOOL_COMPILE_scotch],"")
1011                        fi
1012		        AC_FF_PETSC_WHERELIB(mumps,MUMPS_LIB,MUMPS_INCLUDE,$ffconfpetsc)
1013                        AC_FF_PETSC_WHERELIB(tetgen,TETGEN_LIB,TETGEN_INCLUDE,$ffconfpetsc)
1014                        AC_FF_PETSC_WHERELIB(hpddm,HPDDM_LIB,HPDDM_INCLUDE,$ffconfpetsc)
1015                        AC_FF_PETSC_WHERELIB(superlu,SUPERLU_LIB,SUPERLU_INCLUDE,$ffconfpetsc)
1016		        AC_FF_PETSC_WHERELIB(scalapack,SCALAPACK_LIB,SCALAPACK_INCLUDE,$ffconfpetsc)
1017  		        AC_FF_PETSC_WHERELIB(suitesparse,SUITESPARSE_LIB,SUITESPARSE_INCLUDE,$ffconfpetsc)
1018			AC_FF_PETSC_WHERELIB(blaslapack,BLASLAPACK_LIB,BLASLAPACK_INCLUDE,$ffconfpetsc)
1019                        if test -f $d/libslepc.$ff_suffix_dylib -o -f $d/libslepc.a ; then
1020			   ff_slepc_ok=yes
1021                           ff_SLEPC_LIB="-Wl,-rpath,$d -L$d -lslepc"
1022			   AC_FF_ADDWHERELIB(slepc,$ff_SLEPC_LIB,$ff_where_inc_petsc)
1023		        fi
1024            if test "$ff_slepc_ok" != yes ;   then
1025                AC_ARG_WITH(slepc_include,AC_HELP_STRING([--with-slepc-include=],[Include directives for slepc instead of automatic download]))
1026                AC_ARG_WITH(slepc_ldflags,AC_HELP_STRING([--with-slepc-ldflags=],[Link-time directives for slepc instead of automatic download]))
1027                if test "$with_slepc_include" != "" || test "$with_slepc_ldflags" != ""
1028                then
1029                    # some directives have been specified, use them instead of downloading
1030                    AC_FF_ADDWHERELIB(slepc,$with_slepc_ldflags,$with_slepc_include)
1031                    ff_slepc_ok=yes
1032                fi
1033            fi
1034		    else
1035			 AC_MSG_NOTICE([" Warning PETSC MPI and FF++ MPI not the same: $PETSC_MPIRUN != $MPIRUN or $PETSC_SCALAR != real ." ]);
1036		    fi
1037		fi
1038	    else
1039		ffconfpetsc="";
1040	    fi
1041	done
1042    done
1043fi
1044
1045if test "$ff_petsc_ok" != no ;   then
1046    AC_MSG_NOTICE([ with petsc  $ff_petsc_ok,  with slepc $ff_slepc_ok ])
1047else
1048    AC_MSG_NOTICE([ without petsc, slepc  ***** ])
1049fi
1050
1051## PETSc complex
1052AC_ARG_WITH(petsc_complex,[  --with-petsc_complex=/usr/local/petsc/conf/petscvariables   --without-petsc_complex  ])
1053ff_petsccomplex_ok=no
1054ff_slepccomplex_ok=no
1055if test "$with_petsc_complex" != no -a  $ff_mpi = yes; then
1056    for d in "$with_petsc_complex" "${prefix_petsc}/complex/lib" "${prefix_petsc}/c/lib" /usr/local/ff++/petsc-complex/lib ;do
1057	for dd in ""  "/petsc/conf/petscvariables" "/lib/petsc-conf/petscvariables" ; do
1058	    ffconfpetscc="$d$dd"
1059	    if test -f "$ffconfpetscc" -a  "$ff_petsccomplex_ok" = no ; then
1060		    PETSC_COMPLEX_SCALAR=`awk -F' *= *' '"PETSC_SCALAR"==$1 {print $2}' "$ffconfpetscc"`
1061		    PETSC_COMPLEX_MPIRUN=`awk -F' *= *' '"MPIEXEC"==$1 {print $2}' "$ffconfpetscc"`
1062		    PETSC_COMPLEX_PREFIXDIR=`awk -F' *= *' '"PREFIXDIR"==$1 {print $2}' "$ffconfpetscc"`
1063
1064			PETSC_COMPLEX_MPIRUN=`echo "$PETSC_COMPLEX_MPIRUN" | awk '{print $1}'`	#remove --oversubscribe
1065			AC_MSG_NOTICE([ find complex ($PETSC_COMPLEX_SCALAR) petsc in $ffconfpetscc]);
1066		    test  "$PETSC_COMPLEX_SCALAR" = "complex" &&  test  "$ff_win32" = yes -o  "$PETSC_COMPLEX_MPIRUN" = "$MPIRUN" ||  cmp -s `which "$PETSC_COMPLEX_MPIRUN"` `which "$MPIRUN"`
1067		   	if test "$?"  -eq 0 ; then
1068            AC_SUBST([FF_prefix_petsc_complex],"$PETSC_COMPLEX_PREFIXDIR")
1069            AC_SUBST([FF_conf_petsc_complex],"$ffconfpetscc")
1070
1071            AC_FF_PETSC_WHERELIB_BASIC(petsccomplex,$ffconfpetscc)
1072            AC_FF_PETSC_WHERELIB(parmetis,PARMETIS_LIB,PARMETIS_INCLUDE,$ffconfpetscc)
1073            AC_FF_PETSC_WHERELIB(metis,METIS_LIB,METIS_INCLUDE,$ffconfpetscc)
1074            AC_FF_PETSC_WHERELIB(ptscotch,PTSCOTCH_LIB,PTSCOTCH_INCLUDE,$ffconfpetscc)
1075            ff_SCOTCH_INCLUDE=$ff_PTSCOTCH_INCLUDE
1076            ff_SCOTCH_LIB=`echo $ff_PTSCOTCH_LIB | sed -e 's/@<:@^ @:>@*ptscotch@<:@^ @:>@*//g' | sed -e 's/@<:@^ @:>@*ptes@<:@^ @:>@*//g'`
1077            if test -n "$ff_SCOTCH_LIB"; then
1078                ff_scotch_ok=yes;
1079                AC_FF_ADDWHERELIB(scotch,$ff_SCOTCH_LIB,$ff_SCOTCH_INCLUDE)
1080                AC_SUBST([TOOL_COMPILE_scotch],"")
1081            fi
1082            AC_FF_PETSC_WHERELIB(mumps,MUMPS_LIB,MUMPS_INCLUDE,$ffconfpetscc)
1083            AC_FF_PETSC_WHERELIB(tetgen,TETGEN_LIB,TETGEN_INCLUDE,$ffconfpetscc)
1084            AC_FF_PETSC_WHERELIB(hpddm,HPDDM_LIB,HPDDM_INCLUDE,$ffconfpetscc)
1085            AC_FF_PETSC_WHERELIB(superlu,SUPERLU_LIB,SUPERLU_INCLUDE,$ffconfpetscc)
1086            AC_FF_PETSC_WHERELIB(scalapack,SCALAPACK_LIB,SCALAPACK_INCLUDE,$ffconfpetscc)
1087            AC_FF_PETSC_WHERELIB(suitesparse,SUITESPARSE_LIB,SUITESPARSE_INCLUDE,$ffconfpetscc)
1088            AC_FF_PETSC_WHERELIB(blaslapack,BLASLAPACK_LIB,BLASLAPACK_INCLUDE,$ffconfpetscc)
1089            if test -f $d/libslepc.$ff_suffix_dylib -o -f $d/libslepc.a ; then
1090				   ff_slepccomplex_ok=yes
1091                   ff_SLEPCCOMPLEX_LIB="-Wl,-rpath,$d -L$d -lslepc"
1092			       AC_FF_ADDWHERELIB(slepccomplex,$ff_SLEPCCOMPLEX_LIB,$ff_where_inc_petsccomplex)
1093			fi
1094            if test "$ff_slepccomplex_ok" != yes ;   then
1095                AC_ARG_WITH(slepccomplex_include,AC_HELP_STRING([--with-slepccomplex-include=],[Include directives for slepccomplex instead of automatic download]))
1096                AC_ARG_WITH(slepccomplex_ldflags,AC_HELP_STRING([--with-slepccomplex-ldflags=],[Link-time directives for slepccomplex instead of automatic download]))
1097                if test "$with_slepccomplex_include" != "" || test "$with_slepccomplex_ldflags" != ""
1098                then
1099                    # some directives have been specified, use them instead of downloading
1100                    AC_FF_ADDWHERELIB(slepccomplex,$with_slepccomplex_ldflags,$with_slepccomplex_include)
1101                    ff_slepccomplex_ok=yes
1102                fi
1103            fi
1104			else
1105			 AC_MSG_NOTICE([" Warning PETSC complex MPI and FF++ MPI not the same: $PETSC_COMPLEX_MPIRUN != $MPIRUN or $PETSC_COMPLEX_SCALAR != complex ." ]);
1106		    fi
1107		fi
1108	done
1109    done
1110fi
1111
1112
1113if test "$ff_petsccomplex_ok" != no ;   then
1114    AC_MSG_NOTICE([ with petsc complex  $ff_petsccomplex_ok, with slepc complex $ff_slepccomplex_ok ])
1115else
1116    AC_MSG_NOTICE([ without petsc complex ***** ])
1117fi
1118##  slepc
1119
1120### end petsc ....
1121
1122#replacing wget with another command
1123ff_wget_command="wget --no-check-certificate"
1124ff_wget=no
1125
1126AC_ARG_WITH(wget,
1127	[  --with-wget=command	Replace "wget" with another command. Implies --enable-download],
1128	   enable_download=yes
1129	   ff_wget=yes
1130	   ff_wget_command="${withval}")
1131
1132ff_MKL_libpath=yes
1133AC_ARG_WITH(mkl,
1134	[  --with-mkl= the  MKL LIBPATH : (ie. /opt/intel/mkl/RR.r.y.xxx/lib/<arch>)],
1135	   ff_mkl_libpath="${withval}")
1136
1137# if enabling downloads find wget or curl to do download
1138# ------------------------------------------------------
1139
1140if test  "$ff_wget" =  no
1141then
1142	ff_wget=""
1143	AC_CHECK_PROG(ff_wget,wget --no-check-certificate,yes,no)
1144fi
1145if test  "$ff_wget" = no
1146then
1147        ff_wget_command="curl --fail -O "
1148  	ff_curl=""
1149	AC_CHECK_PROG(ff_curl,curl -O,yes,no)
1150	ff_wget="$ff_curl"
1151fi
1152
1153# for automatique compilation of
1154# lib in download
1155if test  "$ff_wget" != yes  -a "$enable_download"  = "yes"  ; then
1156  enable_download=no
1157  AC_MSG_ERROR([   enable-download and no wget or curl. ],1);
1158fi
1159if test "$enable_download"  = "yes" ; then
1160DOWNLOADCOMPILE="compile-pkg install-other"
1161else
1162DOWNLOADCOMPILE=
1163enable_download=no
1164fi
1165if test "$enable_download"  = "yes"  ; then
1166 AC_CHECK_PROG(ff_git,git,yes,no)
1167 case "$ff_git"  in
1168 *no*)
1169     AC_MSG_NOTICE([ to install missing package  under debian or ubuntu, try ])
1170     test "$ff_git" = no && AC_MSG_NOTICE([ sudo apt-get install git])
1171     AC_MSG_ERROR([ Sorry missing  git command !]);;
1172 esac
1173fi
1174
1175AC_SUBST(WGET,$ff_wget_command)
1176
1177#  modif FH -----
1178#  -- looking for cadna
1179#  the round-off error propagation
1180# the web site http://www-anp.lip6.fr/cadna/
1181#  --------------------
1182AC_ARG_WITH(cadna,[  --with-cadna= cadna library --without-cadna  ])
1183if test "$with_cadna" != no -o -n  "$with_cadna"
1184    then
1185    ff_cadna="$with_cadna"
1186fi
1187ff_cadna_ok=no
1188if test "$with_cadna" != no
1189    then
1190    ff_libs_old="$LIBS"
1191    ff_ldflags_old="$LDFLAGS"
1192    ff_cadna_dir="${curdir}/3rdparty/cadna"
1193    LDFLAGS="$LDFLAGS -L$ff_cadna_dir"
1194    AC_CHECK_LIB(cadnafree,arit_zero,
1195	ff_cadna_ok=yes)
1196    AC_CHECK_HEADERS(${ff_cadna_dir}/cadnafree.h,
1197	ff_cadna_h=yes, ff_cadna_h=no)
1198
1199    LIBS="$ff_libs_old"
1200    LDFLAGS="$ff_ldflags_old"
1201
1202    if test "$ff_cadna_ok" = yes  -a "$ff_cadna_h" = yes
1203	then
1204	AC_DEFINE(HAVE_CADNA,1, freecadna is use to evalute the round-off error propagation )
1205	CPPFLAGS="$CPPFLAGS -I$ff_cadna_dir"
1206	LIBS=" -L$ff_cadna_dir -lcadnafree $ff_libs_old"
1207    else
1208	AC_MSG_NOTICE([ without cadna ***** ])
1209    fi
1210else
1211    AC_MSG_NOTICE([ without cadna ***** ])
1212fi
1213
1214# Looking for FFTW
1215# ----------------
1216
1217# ALH - 18/9/13 - deactivates FFTW detection for testing purposes
1218AC_ARG_ENABLE(system_fftw,AC_HELP_STRING([--disable-system-fftw],[Disable the automatic detection of FFTW]))
1219if test "$enable_system_fftw" != no
1220then
1221
1222    # ALH - 4/9/13 - avoid recompiling FFTW if a copy was found on the system (request from Helmut Jarausch, 1/8/13)
1223
1224    AC_CHECK_LIB(fftw3,fftw_execute,ff_fftw_ok=yes)
1225    AC_CHECK_HEADERS(fftw3.h,ff_fftw_h=yes, ff_fftw_h=no)
1226fi
1227
1228if test "$ff_fftw_ok" = yes -a "$ff_fftw_h" = yes
1229then
1230    AC_FF_ADDWHERELIB(fftw3,-lfftw3,)
1231    fftw_download=
1232else
1233    if test "$enable_download" = yes
1234    then
1235        ff_DOWNLOAD_FFTW=fftw
1236    fi
1237fi
1238
1239# used in [[file:3rdparty/fftw/Makefile.am::DOWNLOAD_FFTW]]
1240
1241AC_SUBST(DOWNLOAD_FFTW,$ff_DOWNLOAD_FFTW)
1242
1243
1244dnl ---------------------------
1245dnl   Looking for the tetgen
1246dnl --------------------------
1247dnl AC_CHECK_LIB(tet,tetrahedralize,ff_fftet_ok=yes)
1248dnl AC_CHECK_HEADERS(tetgen.h,ff_tet_h=yes, ff_tet_h=no)
1249dnl if test "$ff_tet_ok" = yes -a "$ff_tet_h" = yes
1250dnl then
1251dnl    AC_SUBST([TOOL_COMPILE_tetgen],"")
1252dnl AC_FF_ADDWHERELIB(tetgen,-ltet,)
1253dnl    AC_DEFINE(HAVE_TETGEN,1, tetgen is compute tetrahedralize volume of an enclosed surface)
1254dnl fi
1255
1256# Looking for the BLAS
1257# --------------------
1258
1259ff_blas_ok=no
1260ff_blas_inc=""
1261
1262# ALH - 18/9/13 - give the option to deactivate system blas for testing purposes
1263AC_ARG_ENABLE(system-blas,AC_HELP_STRING([--disable-system-blas],[Disable the search for a system-wide BLAS library]))
1264if test "$ff_where_lib_conf_blaslapack" = 1  ; then
1265  echo " use BLAS/Lapack of petsc "
1266#  echo "  lib: $ff_where_lib_blaslapack inc: $ff_where_inc_blaslapack"
1267	    ff_blas_ok=yes
1268	    ff_lapack_ok=yes
1269	    ff_blas_libs="$ff_where_lib_blaslapack"
1270	    ff_lapack_lib=
1271	    ff_blas_inc="$ff_where_inc_blaslapack"
1272       AC_FF_ADDWHERELIB(lapack,$ff_mkl_lapack,$ff_blas_inc)
1273	   AC_FF_ADDWHERELIB(blas,$ff_blas_libs,$ff_blas_inc)
1274	   AC_MSG_NOTICE([ BLAS and LAPACK  from  petsc ***** ])
1275	   if  echo  "$ff_where_lib_blaslapack"| grep -q  " -lmkl"  ; then
1276	     	AC_MSG_NOTICE([ MKL  from  petsc ***** ])
1277	        AC_FF_ADDWHERELIB(mkl,$ff_blas_libs,$ff_blas_inc)
1278            ff_mkl_ok=yes
1279			ff_mkl=yes
1280dnl            AC_DEFINE(HAVE_MKL,1, the MKL intel lib is present for BLAS and LAPACK  )
1281	   fi
1282
1283fi
1284
1285if test "$enable_system_blas" != no -a "$ff_blas_ok" = no
1286then
1287
1288    # User-specified location
1289    # add MKL  seach dec 2010  FH ....
1290
1291    ff_mkl_flags=""
1292    if test "$ff_mkl_libpath" != "not" ; then
1293	ff_CFLAGS="$CFLAGS"
1294	CHECK_COMPILE_FLAG(C,-mkl,CFLAGS)
1295	if test  "$ff_CFLAGS" != "$CFLAGS" ; then
1296	    ff_ff_mkl_flags="-mkl"
1297	fi
1298	CFLAGS="$ff_CFLAGS"
1299    fi
1300
1301    AC_MSG_CHECKING(for MKL)
1302    ff_mkl_root=""
1303    if test "$ff_mkl_libpath" != "not" -a -z "$ff_mkl_flags" ; then
1304
1305	if test "$ff_mkl_libpath"  = "yes"  ; then
1306	    ff_IFS="$IFS"
1307	    IFS=":"
1308	    for i in $LD_LIBRARY_PATH:$LIBRARY_PATH ; do
1309		case $i in
1310		    */mkl/*) ff_mkl_libpath=$i;;
1311		esac ;
1312	    done;
1313	    IFS="$ff_IFS"
1314#	else
1315#	    ff_mkl_libpath=no
1316	fi
1317
1318	if test "$ff_mkl_libpath" != "no" -a -d "$ff_mkl_libpath" ; then
1319	    ff_mkl_root=`expr "//$ff_mkl_libpath" : '//\(.*\)/lib.*'`
1320	    ff_mkl_arch=`expr "//$ff_mkl_libpath" : '//.*/lib/\(.*\)'`
1321            ff_mkl_lp=_lp64
1322            case "$ff_mkl_arch" in
1323		*64*)  ff_mkl_lp=_lp64
1324	    esac
1325            case $F77 in
1326		*ifort*) ff_mkl_cc=intel;;
1327		*) ff_mkl_cc=gf;;
1328            esac
1329            # bof bof ....
1330	    case "$MPIRUN" in
1331		*/sgi/*)         ff_mkl_mpi=_sgimpt;;
1332		*/intel/*)         ff_mkl_mpi=_intelmpi;;
1333		*)        ff_mkl_mpi=_openmpi;;
1334	    esac
1335#            echo ................  ff_mkl_root = $ff_mkl_root  .. $ff_mkl_arch
1336	    if test ! -d "$ff_mkl_libpath" ; then
1337		ff_mkl_libpath="$ff_mkl_root/lib/$ff_mkl_arch"
1338	    fi
1339		mkl_l="-Wl,-rpath,$ff_mkl_libpath -L$ff_mkl_libpath"
1340		mkl_piomp5=$(realpath $ff_mkl_libpath/../../compiler/lib/)
1341		ff_mkl_inc=$(realpath $ff_mkl_libpath/../include)
1342		ff_blas_inc="-I$ff_mkl_inc"
1343
1344		if test -d "$mkl_piomp5" ; then mkl_l="$mkl_l -Wl,-rpath,$mkl_piomp5 -L$mkl_piomp5" ; fi
1345#		echo " ################### $mkl_l $ff_blas_inc "
1346	    if test  -f "$ff_mkl_libpath/libmkl_rt.$ff_suffix_dylib" ; then
1347		 mkl_blas=rt
1348		 mkl_lapack=rt
1349		 ff_mkl_mlt="$mkl_l -lmkl_rt -lmkl_intel_thread -lmkl_core  $ff_iomp5 $ff_pthread"
1350		 ff_mkl_blas="$mkl_l -lmkl_rt -lmkl_sequential -lmkl_core   $ff_iomp5 $ff_pthread"
1351		 ff_mkl_lapack="$ff_mkl_blas"
1352	    elif test -f "$ff_mkl_libpath/libmkl_lapack.$ff_suffix_dylib" ; then
1353		 ff_mkl_mlt="$mkl_l -lmkl_${ff_mkl_cc}${ff_mkl_lp} -lmkl_lapack -lmkl_intel${ff_mkl_lp} -lmkl_intel_thread  -lmkl_core -lguide  -lm -lpthread"
1354		 ff_mkl_blas="$mkl_l -lmkl_${ff_mkl_cc}${ff_mkl_lp} -lmkl_lapack -lmkl_intel${ff_mkl_lp} -lmkl_sequential -lmkl_core -lguide -lm -lpthread"
1355		 ff_mkl_lapack="$mkl_l -lmkl_lapack"
1356	    else
1357		 ff_mkl_mlt="$ff_ldbg $mkl_l  -lmkl_${ff_mkl_cc}${ff_mkl_lp}  -lmkl_intel${ff_mkl_lp}  -lmkl_intel_thread  -lmkl_core -lmkl_intel_thread $ff_iomp5  $ff_ldeg  -lm $ff_pthread"
1358		 ff_mkl_blas="$ff_ldbg $mkl_l -lmkl_${ff_mkl_cc}${ff_mkl_lp}  -lmkl_intel${ff_mkl_lp} -lmkl_sequential -lmkl_core  -lmkl_sequential $ff_ldeg   -lm $ff_pthread"
1359		 ff_mkl_lapack="$ff_mkl_blas"
1360	    fi
1361	    if test -f "-L$ff_mkl_libpathmkl_scalapack${ff_mkl_lp}" ; then
1362            ff_mkl_scalapack="$mkl_l -lmkl_blacs${ff_mkl_mpi}${ff_mkl_lp} -lmkl_scalapack${ff_mkl_lp} "
1363            ff_mkl_blacs="$mkl_l -lmkl_blacs${ff_mkl_mpi}${ff_mkl_lp} -lmkl_scalapack${ff_mkl_lp}"
1364	    fi
1365	    ff_blas_ok=yes
1366	    ff_lapack_ok=yes
1367
1368	    # <<enable_mkl_mlt>> ALH - 6/11/13 - request from Atsushi Suzuki - the default MKL library must be able to
1369	    # handle threads when FF is connected to AS' solver. So we need an option to configure FF with the
1370	    # multithreaded MKL by default.
1371
1372	    AC_ARG_ENABLE(mkl_mlt,AC_HELP_STRING([--enable-mkl-mlt],[Link with the multithreaded instead of the monothreaded version of the MKL]))
1373
1374	    if test "$enable_mkl_mlt" = yes
1375	    then
1376		ff_blas_libs="$ff_mkl_mlt"
1377	    else
1378		ff_blas_libs="$ff_mkl_blas"
1379	    fi
1380
1381	    ff_blas_inc="-I$ff_mkl_root/include"
1382	    dnl  scalapack, and blacs do not not work with mlk and sgi
1383	    if test "$ff_mkl_mpi" = "_intelmpi" ; then
1384		AC_FF_ADDWHERELIB(scalapack,$ff_mkl_scalapack,$ff_blas_inc)
1385		AC_FF_ADDWHERELIB(blacs,$ff_mkl_blacs,$ff_blas_inc)
1386	    else
1387		ff_warm=" (We do not use MKL scalapack and blacs with sgi MPI),  "
1388	    fi
1389	    AC_FF_ADDWHERELIB(lapack,$ff_mkl_lapack,$ff_blas_inc)
1390	    AC_FF_ADDWHERELIB(mkl,$ff_mkl_mlt,$ff_blas_inc)
1391		ff_mkl_ok=yes
1392		ff_mkl=yes
1393dnl            AC_DEFINE(HAVE_MKL,1, the MKL intel lib is present for BLAS and LAPACK  )
1394
1395	else
1396	    ff_mkl_libpath=no
1397	fi
1398    fi
1399
1400
1401    AC_MSG_RESULT( [ $ff_warm  root: $ff_mkl_root , arch: $ff_mkl_arch , $ff_mkl_lp ...  ])
1402
1403    AC_ARG_WITH(blas,
1404	AC_HELP_STRING([--with-blas=library],[Use a specific version of the Blas]),
1405	ff_blas_ok=yes
1406	ff_blas_libs="${withval}")
1407
1408    # Specific BLAS library location for FreeBSD
1409    ff_freebsd_blas="-lf2c -lf77blas -latlas -lgslcblas"
1410    ff_dll_blas=`which  libopenblas.dll`
1411    if test -z "$ff_dll_blas" ; then  ff_dll_blas="no"; fi
1412        #  zmach is in lapack
1413    # Trying  blas library
1414    # echo "LIBS =  $LIBS blas --- $ff_blas_ok"
1415    for iblas in "$ff_dll_blas" \
1416	"-framework Accelerate" "$ff_mkl_blas" "-lblas"  "-L/usr/lib/atlas -lblas" \
1417	$ff_freebsd_blas
1418    do
1419	if test "$ff_blas_ok" = no -a "$iblas" != "no"
1420	then
1421            AC_MSG_CHECKING(for daxpy_ in $iblas)
1422            ff_save_libs="$LIBS"
1423            LIBS="$LIBS $iblas"
1424            AC_LINK_IFELSE(
1425		[AC_LANG_CALL(,daxpy_)],
1426		ff_blas_ok=yes
1427		ff_blas_libs="$iblas",)
1428            LIBS="$ff_save_libs"
1429            AC_MSG_RESULT($ff_blas_ok)
1430	fi
1431    done
1432
1433    #cblas_zdotu_sub
1434    #echo "LIBS = " $LIBS
1435    ff_cblas_libs=no
1436    if test "$ff_blas_ok" = yes
1437    then
1438	AC_MSG_CHECKING(for blas_zdotu_sub in $ff_blas_libs)
1439	ff_save_libs="$LIBS"
1440	LIBS="$LIBS $ff_blas_libs $FLIBS"
1441	AC_LINK_IFELSE(
1442            [AC_LANG_CALL(,cblas_zdotu_sub)],
1443            ff_cblas_libs=yes)
1444	AC_MSG_RESULT($ff_cblas_libs)
1445	LIBS="$ff_save_libs"
1446    fi
1447fi
1448
1449# <<OpenBLAS>> ALH - 18/9/13 - option to compile the OpenBLAS moved from the FFCS tree to FF tree
1450
1451AC_ARG_ENABLE(openblas,AC_HELP_STRING([--disable-openblas],[Disable the automatic download of OpenBLAS]))
1452if  test "$ff_blas_ok" = no && test "$enable_openblas" != no && test "$enable_download" = yes
1453then
1454    AC_CHECK_PROG(ff_git,git,yes,no)
1455    AC_MSG_CHECKING([Activating the OpenBLAS (deactivate with --disable-openblas)])
1456    if test $ff_git = no
1457    then
1458	AC_MSG_RESULT([git not found])
1459    else
1460	ff_download_blas=openblas
1461
1462	# it is necessary to split the library path into -L and -l otherwise ff/upstream/plugin/seq/ff-c++ will place -lgfortran in
1463	# LIBS, .../libgoto___.lib in OTHER, and call the compiler with $LIBS before $OTHER, which will fail. But libopenblas.a is placed in
1464	# the standard directory 3rdparty/lib so the -L option is not required anymore.
1465
1466	ff_blas_libs="-L${curdir}/3rdparty/lib -lopenblas $LIBS $ff_pthread"
1467	ff_blas_inc="-I${curdir}/3rdparty/include"
1468
1469        # skip generic blas compilation and activate OpenBLAS (see [[file:3rdparty/blas/Makefile.am::OpenBLAS]])
1470	AC_SUBST(DOWNLOADED_BLAS,"")
1471	AC_SUBST(COMPILE_OPENBLAS,openblas)
1472
1473	ff_blas_ok=yes
1474	ff_cblas_h=yes
1475	ff_cblas_libs=yes
1476
1477	AC_MSG_RESULT([ok])
1478    fi
1479fi
1480
1481# If all else fails, download a generic version
1482
1483if test "$ff_blas_ok" = no -a "$enable_download" = yes -a "$enable_fortran" != no -a "$enable_c" != no
1484then
1485    AC_CHECK_PROG(ff_unzip,unzip,yes,no)
1486
1487    AC_MSG_CHECKING(for BLAS version to download)
1488
1489    # Do not update $LIBS, but create an extra LIB variable, because this lib does not exist yet, and this could make
1490    # the following tests fail.
1491
1492    # When compiling a generic version, we do not need an optimized version of the BLAS.
1493
1494    ff_download_blas=generic
1495    ff_blas_libs="-L${curdir}/3rdparty/blas -lcblas -lf77blas"
1496    ff_blas_inc="-I${curdir}/3rdparty/blas/CBLAS/src"
1497
1498    AC_SUBST(DOWNLOADED_BLAS,"libf77blas.a libcblas.a")
1499    AC_SUBST(DOWNLOADED_BLAS_BUILT_SOURCES,'BLAS CBLAS $(F77BLAS_SRC) $(CBLAS_SRC)')
1500
1501    AC_MSG_RESULT($ff_download_blas)
1502    ff_blas_ok=yes
1503    ff_cblas_h=yes
1504    ff_cblas_libs=yes
1505fi
1506
1507AC_SUBST(BLASLIBS,$ff_blas_libs)
1508AC_SUBST(BLASINC,$ff_blas_inc)
1509
1510#looking for cblas.h  FH
1511
1512if test "$ff_blas_ok" = yes -a -z "$ff_download_blas"; then
1513  AC_CHECK_HEADERS(cblas.h,
1514    ff_cblas_h=yes,
1515    ff_cblas_h=no)
1516  AC_CHECK_HEADERS(Accelerate/cblas.h,
1517    ff_cblas_h=yes,
1518    ff_cblas_h=no)
1519  AC_CHECK_HEADERS(atlas/cblas.h,
1520    ff_cblas_h=yes,
1521    ff_cblas_h=no)
1522  AC_CHECK_LIB([cblas], [cblas_zdotu_sub], [LIBS+=-lcblas])
1523fi
1524
1525# ALH - 18/9/13 - [[file:3rdparty/blas/Makefile.am]] does not update the WHERE mechanism so it always needs to be set up
1526# here even in the case of a downloaded blas library.
1527
1528AC_FF_ADDWHERELIB(blas,$ff_blas_libs,)
1529
1530# end of BLAS -------------------
1531
1532# Looking for ARPACK
1533# ------------------
1534
1535# We need the following g77 libraries to connect to the Fortran 77
1536# Arpack.
1537
1538if test "$ff_blas_ok" = yes;
1539then
1540  ff_g2c_lib="$FLIBS"
1541       if test  -n "$ff_g2c_lib"
1542       then
1543           LIBS="$LIBS $ff_g2c_lib"
1544       else
1545	  ff_g2c_ok=no
1546	  AC_CHECK_LIB(g2c,G77_second_0,
1547		LIBS="$LIBS -lg2c"
1548		ff_g2c_lib="-lg2c"
1549		ff_g2c_ok=yes)
1550
1551	  if test "$ff_g2c_ok" = no;
1552	     then
1553	        AC_MSG_CHECKING(for G77_second_0 in /sw/lib/libg2c.a)
1554		ff_save_libs="$LIBS"
1555		LIBS="$LIBS -L/sw/lib -lg2c"
1556		AC_LINK_IFELSE(
1557			[AC_LANG_CALL(,G77_second_0)],
1558			ff_g2c_lib="-L/sw/lib -lg2c"
1559			ff_g2c_ok=yes,
1560			LIBS="$ff_save_libs")
1561		AC_MSG_RESULT($ff_g2c_ok)
1562	  fi
1563	fi
1564fi
1565
1566# Copy the result of g2c investigations into a separate variable
1567# because BLAS compilation will need it.
1568
1569AC_SUBST(G2CLIB,$ff_g2c_lib)
1570#looking of  lapack if no compile the arpack lapack
1571# warning $$ because the make eat one
1572ff_lapack_ok=no;
1573ff_lapack_lib=
1574AC_MSG_CHECKING([for lapack in $LIBS, $ff_blas_libs and -llapack] )
1575    if test "$ff_blas_ok" = yes ; then
1576        AC_LINK_IFELSE( [AC_LANG_CALL(,dgeqr2_)], ff_lapack_ok=yes)
1577	if test "$ff_lapack_ok" = no ; then
1578	    ff_save_libs=$LIBS
1579	    LIBS="$ff_save_libs $ff_blas_libs"
1580            AC_LINK_IFELSE( [AC_LANG_CALL(,dgeqr2_)], [ff_lapack_ok=yes;ff_lapack_lib="$ff_blas_libs"])
1581	    if test "$ff_lapack_ok" = no ; then
1582	    LIBS="$ff_save_libs -llapack $ff_blas_libs"
1583            AC_LINK_IFELSE( [AC_LANG_CALL(,dgeqr2_)], [ff_lapack_ok=yes
1584	    ff_lapack_lib="-llapack"] )
1585	    fi
1586	    LIBS="$ff_save_libs"
1587	fi
1588    fi
1589
1590if test "$ff_lapack_ok" = no; then
1591    AC_ARG_WITH(lapack,
1592	AC_HELP_STRING([--with-lapack=library],[Use a specific version of Lapack]),
1593	ff_lapack_ok=yes
1594	ff_lapack_lib="${withval}"
1595	LIBS="$ff_lapack_lib $LIBS")
1596fi
1597AC_MSG_RESULT($ff_lapack_ok)
1598if test "$ff_lapack_ok" != no ; then
1599AC_SUBST(LAPACKLIBS,$ff_lapack_lib)
1600fi
1601
1602# Lapack configuration for Arpack
1603
1604ff_lapackdir='$$(LAPACKdir)'
1605if test "$ff_lapack_ok" = yes
1606then
1607    # no compilation of lapack in arpack
1608    ff_lapackdir=
1609else
1610    ff_lapack_lib="-L${curdir}/3rdparty/lib -llapack"
1611fi
1612
1613# Arpack itself
1614AC_ARG_ENABLE(download-arpack,AC_HELP_STRING([--enable-download_arpack],[force the use  download of arpack]))
1615#echo "****** enable_download_arpack=$enable_download_arpack"
1616
1617ff_arpack_ok=no
1618ff_save_libs="$LIBS"
1619ff_arpack_libs=
1620if test "$ff_blas_ok" = yes ;
1621then
1622    if test "$enable_download_arpack" != yes ; then
1623	# User-specified location
1624	AC_ARG_WITH(arpack,
1625	[  --with-arpack=library	Use a specific version of Arpack],
1626	ff_arpack_ok=yes
1627	ff_arpack_libs="${withval}")
1628
1629	# Default locations
1630	if test "$ff_arpack_ok" = no;
1631	then
1632	    AC_CHECK_LIB(arpack,dsaupd_,
1633		ff_arpack_libs="-larpack -llapack"
1634		ff_arpack_ok=yes,,
1635		-llapack)
1636	fi
1637
1638   # Trying to "locate" Arpack
1639	if test "$ff_arpack_ok" = no -a "$enable_download" != yes ;
1640	then
1641            AC_MSG_CHECKING(for libarpack with locate)
1642            ff_lib_arpack=`locate libarpack|grep  'libarpack.*.a$'|head -1`
1643	    LIBS="$ff_lib_arpack $LIBS"
1644            AC_LINK_IFELSE(
1645		[AC_LANG_CALL(,dsaupd_)],
1646		ff_arpack_ok=yes
1647		ff_arpack_libs="$ff_lib_arpack")
1648            AC_MSG_RESULT($ff_arpack_ok)
1649	fi
1650	if test "$ff_arpack_ok" = yes
1651	then
1652	    AC_FF_ADDWHERELIB(arpack,$ff_arpack_libs,)
1653	fi
1654    fi
1655    # If all else fails, download!
1656    if test "$ff_arpack_ok" = no -a "$enable_download" = yes -o "$enable_download_arpack" = yes  -a "$enable_fortran" != no
1657    then
1658	ff_arpack_download=yes
1659	AC_MSG_NOTICE(using downloaded Arpack)
1660
1661		# ALH - 6/11/13 - this install goal is the standard goal for all downloaded packages in
1662		# [[file:3rdparty/common.mak::install]]
1663
1664	AC_SUBST(DOWNLOAD_ARPACK,install)
1665
1666	AC_SUBST(FF_LAPACKdir,$ff_lapackdir)
1667	AC_SUBST(ARPACKLIB,${curdir}/3rdparty/lib/libarpack.a)
1668	AC_SUBST(LAPACK_arpack_LIB,${curdir}/3rdparty/lib/liblapack.a)
1669
1670		# Do not update $LIBS, but create an extra LIB variable, because this lib does not exist yet, and this
1671		# could make the following tests fail.
1672
1673		# ALH - 30/9/13 - do not use the "-L ${curdir}/3rdparty/lib" directive because it would allow other
1674		# following -l directives (eg -lumfpack) to pick an old locally compiled library instead of the system
1675		# ones.
1676
1677	ff_arpack_libs="${curdir}/3rdparty/lib/libarpack.a $ff_lapack_lib"
1678	ff_arpack_ok=yes
1679    fi
1680fi
1681if test  "$ff_arpack_ok" != yes
1682 then
1683	    AC_MSG_NOTICE([-- NO ARPACK --  enable_download : $enable_download , wget: $ff_wget ])
1684fi
1685
1686# Do not insert ARPACK libs in $LIBS yet, because they may not exist
1687# yet, and this could make the following tests fail.
1688
1689LIBS="$ff_save_libs"
1690
1691if test "$ff_arpack_ok" = yes;
1692then
1693        AC_SUBST(ARPACKLIBS,$ff_arpack_libs)
1694	EIGENOBJ='eigenvalue.$(OBJEXT)'
1695	AC_DEFINE(HAVE_LIBARPACK,1,Arpack is used for eigenvalue computation)
1696
1697	# Determines whether to run the eigenvalue tests
1698else
1699# all eigen test fails
1700	AC_SUBST([SKIP_TESTS_EIGEN],[yes])
1701fi
1702AM_CONDITIONAL([ENABLE_EIGEN], [test "$ff_arpack_ok" = "yes"])
1703
1704AC_SUBST([EIGENOBJ])
1705
1706# ALH - 25/9/13 - <<WHERE_lapack>> always run the WHERE LD statement for lapack because some libraries in
1707# plugin/seq require it (eg [[file:plugin/seq/Element_Mixte.cpp::lapack]]). Request from Fred.
1708
1709AC_FF_ADDWHERELIB(lapack,$ff_lapack_lib,)
1710
1711# Looking for UMFPACK
1712# -------------------
1713UMFPACK_CPPFLAGS="";
1714ff_umfpack_incs=""
1715ff_amd_ok=no
1716ff_umfpack_ok=no
1717# echo @@@@@@@@@ ff_where_lib_conf_suitesparse == $ff_where_lib_conf_suitesparse  @@@@
1718if test "$ff_where_lib_conf_suitesparse" = "1"  ; then
1719    echo "amd/umfpack/suitesparse  of petsc"
1720    echo "    lib: $ff_where_lib_suitesparse inc: $ff_where_inc_suitesparse"
1721    ff_amd_ok=yes
1722    ff_umfpack_ok=yes
1723    enable_system_umfpack=no
1724    ff_umfpack_libs="$ff_where_lib_suitesparse"
1725    ff_umfpack_incs="$ff_where_inc_suitesparse"
1726    AC_DEFINE(HAVE_LIBUMFPACK,1,Umfpack is used for sparse matrices computations)
1727    AC_DEFINE(HAVE_LIBCHOLMOD,1,Cholmod  is used for sparse matrices computations)
1728    UMFPACK_CPPFLAGS="$ff_where_inc_suitesparse"
1729    dnl   AC_SUBST([UMFPACK_CPPFLAGS],[$ff_where_inc_suitesparse])
1730    AC_DEFINE(HAVE_UMFPACK_H,1,If umfpack.h is located in UMFPACK subdir)
1731fi
1732#echo "@@@@@@@"
1733ff_save_libs="$LIBS"
1734AC_ARG_ENABLE(system_umfpack,AC_HELP_STRING([--disable-system-umfpack],[Disable the automatic detection of umfpack, colmod, amd, ....]))
1735if test "$ff_umfpack_ok"  = no -a "$enable_system_umfpack" != no -a  "$ff_blas_ok" = yes;
1736then
1737#    echo "@@@@@@@qqqq"
1738    # User-specified location
1739    AC_ARG_WITH(amd,
1740	AC_HELP_STRING([--with-amd=library],[Use a specific version of AMD]),
1741        ff_amd_ok=yes
1742	ff_umfpack_libs="${withval}")
1743
1744    AC_ARG_WITH(umfpack,
1745        AC_HELP_STRING([--with-umfpack=library],[Use a specific version of Umfpack]),
1746        ff_umfpack_ok=yes
1747        ff_umfpack_libs="${withval} $ff_umfpack_libs")
1748
1749    if test "${with_umfpack_include+set}" = set; then
1750      	CPPFLAGS="$CPPFLAGS $with_umfpack_include"
1751    fi
1752
1753    AC_CHECK_HEADERS(umfpack.h umfpack/umfpack.h ufsparse/umfpack.h suitesparse/umfpack.h,
1754	[ff_umfpack_header=yes
1755	    ff_umfpack_dir=`dirname $ac_header`
1756	    break])
1757
1758    # Somes systems like FreeBSD hide umfpack.h in a directory called UMFPACK (all capitals). This breaks the
1759    # standard #define produced by autoconf in config.h.in.
1760
1761    LIBS="$ff_blas_libs $LIBS"
1762    if test "$ff_umfpack_header" != yes;
1763    then
1764	AC_CHECK_HEADER(UMFPACK/umfpack.h,
1765	    ff_umfpack_header=yes
1766	    ff_umfpack_dir=UMFPACK
1767	    AC_DEFINE(HAVE_BIG_UMFPACK_UMFPACK_H,1,If umfpack.h is located in UMFPACK subdir))
1768    fi
1769
1770    if test "$ff_amd_ok" = no;
1771    then
1772	AC_CHECK_LIB(amd,amd_info,
1773	    ff_umfpack_libs="$ff_umfpack_libs -lamd"
1774	    ff_amd_ok=yes)
1775    fi
1776
1777    if test "$ff_umfpack_ok" = no -a "$ff_amd_ok" = yes;
1778    then
1779
1780        # ALH - 30/9/13 - other libraries required by Umfpack
1781
1782	AC_CHECK_LIB(cholmod,cholmod_add,ff_umfpack_libs="$ff_umfpack_libs -lcholmod")
1783	AC_CHECK_LIB(colamd,colamd_set_defaults,ff_umfpack_libs="$ff_umfpack_libs -lcolamd")
1784
1785	AC_CHECK_LIB(umfpack,umf_i_malloc,
1786	    ff_umfpack_libs="-lumfpack $ff_umfpack_libs"
1787	    ff_umfpack_ok=yes,,$ff_umfpack_libs)
1788    fi
1789
1790    if test "$ff_umfpack_header" != yes -o "$ff_umfpack_ok" != yes; then
1791        ff_umfpack_ok=no
1792	AC_MSG_WARN([Sorry, we could not find the UMFPACK lib or the UMFPACK headers])
1793	ff_umfpack_incs=""
1794	UMFPACK_CPPFLAGS=""
1795    fi
1796
1797    if test "$ff_umfpack_ok" = yes -a "$ff_amd_ok" = yes; then
1798	 if test -n "$ff_umfpack_incs" ; then
1799	  UMFPACK_CPPFLAGS="$ff_umfpack_incs"
1800	 fi
1801dnl    AC_SUBST([UMFPACK_CPPFLAGS],[$ff_umfpack_incs])
1802	  AC_DEFINE(HAVE_LIBUMFPACK,1,Umfpack is used for sparse matrices computations)
1803    fi
1804fi
1805
1806LIBS="$ff_save_libs"
1807#echo "@@@@22@@@"
1808# If all else fails, download!
1809#  attention no /usr/include in WHERE
1810if test "$ff_umfpack_ok" = yes -a -n "$ff_umfpack_dir" -a -z "$ff_umfpack_incs"
1811then
1812	ff_umfpack_incs="-I/usr/include/$ff_umfpack_dir"
1813	UMFPACK_CPPFLAGS="$ff_umfpack_incs"
1814fi
1815if test "$ff_umfpack_ok" = no -a "$enable_download" = yes
1816then
1817    AC_MSG_NOTICE(using downloaded UMFPACK)
1818    AC_SUBST(DOWNLOAD_UMFPACK,"umfpack")
1819    ff_umfpack_download=yes
1820
1821    # Do not update $LIBS, but create an extra LIB variable, because this lib does not exist yet, and this could make
1822    # the following tests fail.
1823
1824    ff_umfpack_libs="-L${curdir}/3rdparty/lib -lumfpack -lcholmod -lcolamd -lamd -lsuitesparseconfig"
1825    ff_umfpack_incs="-I${curdir}/3rdparty/include"
1826	UMFPACK_CPPFLAGS="$ff_umfpack_incs"
1827    AC_DEFINE(HAVE_LIBUMFPACK,1,UMFPACK)
1828    if test "$ff_win32" = yes; then
1829  	AC_SUBST(FF_UMFPACK_CONFIG,-DCBLAS)
1830    fi
1831    ff_umfpack_ok=yes
1832fi
1833AC_SUBST([UMFPACK_CPPFLAGS],[$UMFPACK_CPPFLAGS])
1834
1835# ALH - 17/9/13 - moved UMFPACK configuration settings in wherelib to _after_ configuring the download version because
1836# [[file:3rdparty/umfpack/Makefile.am]] does not set the WHERE mechanism. Also removed -I/usr/include/$ff_umfpack_dir
1837# from include options for FFCS because it breaks the MingW64 compilation process.
1838
1839if test "$ff_umfpack_ok" = yes
1840then
1841    if test $enable_ffcs = no
1842    then
1843	AC_FF_ADDWHERELIB(amd,$ff_umfpack_libs,$ff_umfpack_incs)
1844	AC_FF_ADDWHERELIB(umfpack,$ff_umfpack_libs,$ff_umfpack_incs)
1845    else
1846	AC_FF_ADDWHERELIB(amd,$ff_umfpack_libs,)
1847	AC_FF_ADDWHERELIB(umfpack,$ff_umfpack_libs,)
1848    fi
1849
1850else
1851#echo "@@@@33@@@@"
1852    AC_MSG_NOTICE([ -- NO UMFPACK (ff_wget = $ff_wget)])
1853fi
1854
1855AC_SUBST(UMFPACKLIBS,$ff_umfpack_libs)
1856
1857# If times() and sysconf() are not here, UMFPACK should know
1858
1859if test "$ff_umfpack_ok" = yes
1860then
1861    AC_CHECK_FUNCS(times sysconf,
1862	ff_umfpack_posix_ok=yes,
1863	ff_umfpack_posix_ok=no)
1864
1865    if test "$ff_umfpack_posix_ok" = no
1866    then
1867	AC_SUBST(FF_UMFPACK_CONFIG,"-DCBLAS -DNPOSIX")
1868    fi
1869fi
1870
1871# Checking for some functions that may not appear everywhere
1872# ----------------------------------------------------------
1873AC_CHECK_HEADERS(cstddef)
1874AC_CHECK_HEADERS(stddef.h)
1875AC_CHECK_HEADERS(semaphore.h,ff_sem=1,ff_sem=0)
1876AC_CHECK_HEADERS(sys/mman.h,ff_mmap=1,ff_mmap=0)
1877
1878
1879if test "$ff_sem" -eq  1 -a  "$ff_mmap" -eq  1 ; then
1880BIN_ffmaster=ffmaster
1881else
1882enable_MMAP=no
1883BIN_ffmaster=
1884fi
1885
1886AC_CHECK_HEADERS(regex.h,ff_regex_h=1, ff_regex_h=0)
1887AC_SUBST(FF_HAVE_REGEX_H,$ff_regex_h)
1888
1889AC_CHECK_HEADERS([unistd.h])
1890# asinh acosh atanh are not in Mingw yet gettimeofday
1891ff_malloc_h=""
1892AC_HEADER_TIME
1893AC_CHECK_HEADERS(malloc.h,ff_malloc_h=1)
1894AC_SUBST(FF_MALLOC_H,$ff_malloc_h)
1895
1896AC_CHECK_FUNCS(asinh acosh atanh getenv jn erfc tgamma gettimeofday mallinfo mstats)
1897AC_CHECK_FUNCS(srandomdev)
1898
1899
1900AC_CHECK_FUNCS(second_,ff_second="",ff_second=second.o)
1901AC_SUBST(FF_SECOND,"$ff_second")
1902
1903# Enable static linking (no shared libraries)
1904# -------------------------------------------
1905AC_CHECK_PROG(ff_libtool,libtool,yes,no)
1906if test  "$ff_mac" = "yes"  -a "$ff_libtool" = yes ; then
1907  ff_AR="libtool"
1908  ff_ARFLAGS="-static -o"
1909  ff_RANLIB="echo"
1910fi
1911
1912AC_ARG_ENABLE(static,
1913	[  --enable-static	Build binaries with no shared library dependencies])
1914if test "$enable_static" = yes
1915then
1916	AC_CHECK_PROG(ff_libtool,libtool,yes,no)
1917	if test "$ff_libtool" = yes
1918	then
1919		LDFLAGS="$LDFLAGS -all-static"
1920		AC_SUBST(STATICTOOL,libtool)
1921	else
1922		AC_MSG_ERROR(libtool not found)
1923	fi
1924fi
1925#  for compiation of  arpack  use libtool to bluid universal library on MacOs.
1926AC_SUBST(AR,$ff_AR)
1927AC_SUBST(ARFLAGS,$ff_ARFLAGS)
1928AC_SUBST(RANLIN,$ff_RANLIB)
1929
1930
1931# Dynamic loading of compiled functions
1932# -------------------------------------
1933
1934# Not if we don't want shared libraries (non FH  modif FH juin 2005)
1935if test "$ff_PURE_WIN32" -ne 1 ; then
1936ff_dynload=no
1937if test "$enable_static" != yes
1938then
1939
1940	# Availability of dlopen(). Use AC_COMPILE rather than
1941	# AC_CHECK_HEADERS because the latter has problems seeing it (in
1942	# Cygwin) when it does not compile (in Mingw).
1943
1944	AC_MSG_CHECKING(for dlfcn.h)
1945	AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <dlfcn.h>]])],
1946		ff_dynload=yes,
1947		ff_dynload=no)
1948	AC_MSG_RESULT($ff_dynload)
1949fi
1950
1951# FFCS - -lm missing for ffmedit link stage on Debian Testing
1952AC_CHECK_LIB(m,sin)
1953
1954# Checks that we also have the corresponding library
1955if test "$ff_dynload" = yes
1956then
1957	AC_CHECK_LIB(dl,dlinfo)
1958
1959	# Checks that everythings works ok
1960	AC_MSG_CHECKING(whether dlopen links ok)
1961	AC_LINK_IFELSE(
1962[AC_LANG_SOURCE([[#include <dlfcn.h>
1963int main(int argc,char **argv){
1964  dlopen("",RTLD_LAZY);
1965  return 0;
1966}]])],
1967	ff_dynload=yes,
1968	ff_dynload=no)
1969	AC_MSG_RESULT($ff_dynload)
1970fi
1971if test "$ff_dynload" = yes
1972then
1973	AC_DEFINE(HAVE_DLFCN_H,1,Dynamic loading - not mandatory)
1974fi
1975fi  # endif ff_PURE_WIN32 != 1
1976#  the -rdynamic don't exist on macos and sunOS
1977if test "$ff_dynload" = yes
1978then
1979	# Activate dynamic loading tests (see plugin/seq/Makefile.am)
1980	AC_SUBST(LOAD_TESTS,../regtests.sh)
1981	AC_SUBST(LOAD_COMPILE,load_compile)
1982
1983	# gcc on MacOS does not produce an error with "-rdynamic" but
1984	# still complains about it.
1985	if test "$ff_mac" = "no" -a "$ff_win32"  = "no" -a "$ff_sunos"  = "no" ;
1986	then
1987		CHECK_COMPILE_FLAG(C++,-rdynamic,LDFLAGS)
1988dnl		CHECK_COMPILE_FLAG(C,-rdynamic,CNOFLAGS)
1989dnl		CHECK_COMPILE_FLAG(C,-rdynamic,CFLAGS)
1990	fi
1991	if test "$ff_fpic" != "no" ; then
1992	CHECK_COMPILE_FLAG(C++,-fPIC,CXXFLAGS)
1993	CHECK_COMPILE_FLAG(C,-fPIC,CFLAGS)
1994	CHECK_COMPILE_FLAG(C,-fPIC,CNOFLAGS)
1995	fi
1996	if test "$enable_fortran" != no ;  then
1997	if test "$ff_fpic" != "no" ; then
1998	 CHECK_COMPILE_FLAG(Fortran,-fPIC,FFLAGS)
1999	 CHECK_COMPILE_FLAG(Fortran,-fPIC,FNOFLAGS)
2000	 CHECK_COMPILE_FLAG(Fortran,-fPIC,FCFLAGS)
2001	 CHECK_COMPILE_FLAG(Fortran,-fPIC,FCNOFLAGS)
2002	 fi
2003dnl	 CHECK_COMPILE_FLAG(Fortran,-rdynamic,FNOFLAGS)
2004dnl	 CHECK_COMPILE_FLAG(Fortran,-rdynamic,FFLAGS)
2005
2006	fi
2007fi
2008AC_SUBST(DYLIB_SUFFIX,$ff_suffix_dylib)
2009#  the doc is now in https://github.com/FreeFem/FreeFem-doc-pdf/blob/master/freefem%2B%2Bdoc.pdf
2010# Checking wether we can generate some documentation
2011# --------------------------------------------------
2012dnl
2013dnl AC_CHECK_PROG(ff_latex,latex,yes,no)
2014dnl AC_CHECK_PROG(ff_makeindex,makeindex,yes,no)
2015dnl AC_CHECK_PROG(ff_dvips,dvips,yes,no)
2016dnl # to translate the figure
2017dnl AC_CHECK_PROG(ff_pdf2ps,pdf2ps,yes,no)
2018dnl AC_CHECK_PROGS(EPSTOPDF,[epstopdf pstopdf],[false])
2019dnl AC_CHECK_PROG(ff_convert,convert,yes,no)
2020dnl if test "$ff_latex" = yes -a "$ff_makeindex" = yes -a "$ff_dvips" = yes -a $ff_pdf2ps = yes -a $ff_convert = yes;
2021dnl then
2022dnl 	AC_SUBST(DOCPS,"freefem++doc.ps")
2023dnl
2024dnl 	AC_CHECK_PROG(ff_gzip,gzip,yes,no)
2025dnl 	if test "$ff_gzip" = yes;
2026dnl 	then
2027dnl 		AC_SUBST(DOCPSGZ,"freefem++doc.ps.gz")
2028dnl 	fi
2029dnl fi
2030
2031# PDF documentation building sometimes poses problems because of pdfsync.sty. So we need to be able to disable it.
2032# FFCS - 9/4/14 - need to disable PDF also during FFCS build (which does not use the resulting PDF).
2033
2034dnl AC_ARG_ENABLE(pdf,[  --disable-pdf	Disable PDF documentation building])
2035dnl if test "$enable_pdf" != no
2036dnl then
2037dnl    AC_CHECK_PROG(ff_pdflatex,pdflatex,yes,no)
2038dnl    if test "$ff_pdflatex" = yes -a $EPSTOPDF != false -a $ff_convert = yes;
2039dnl    then
2040dnl 	AC_SUBST(DOCPDF,"freefem++doc.pdf")
2041dnl    fi
2042dnl fi
2043
2044# Choosing compilation options for the standard version (in src/std)
2045# ------------------------------------------------------------------
2046
2047# The "standard" configured version can use win32 (mingw)
2048
2049if test "$ff_mingw" = yes
2050then
2051
2052    # FFCS does not use FreeFem++-std, and Pcrgraph.cpp does not compile under mingwin64
2053    if test $enable_ffcs = no
2054    then
2055	ff_stdprog="FreeFem++-std${EXEEXT}"
2056	ff_std_graph_obj=Pcrgraph.$OBJEXT
2057    fi
2058
2059    # ALH - FFCS - 30/11/8 - I need to get the output from FF for FFCS regression tests
2060    if test $enable_ffcs = yes
2061    then
2062	ff_std_ldflags="-mconsole -mwindows"
2063    else
2064	ff_std_ldflags=-mwindows
2065    fi
2066
2067	ff_std_libs=
2068fi
2069AC_SUBST(STD_GRAPH_OBJ,$ff_std_graph_obj)
2070AC_SUBST(STD_LDFLAGS,$ff_std_ldflags)
2071
2072AC_SUBST(STD_LIBS,$ff_std_libs)
2073
2074# Allow some downloaded tools not to be compiled
2075# ----------------------------------------------
2076
2077
2078##  try to see pakage is hon computer  if the FH ZZZZ
2079## FH to find gsl ...
2080AX_PATH_GSL(1.15, ff_with_gsl=yes, ff_with_gsl=no)
2081if test "$ff_with_gsl" = "yes"; then
2082  AC_FF_ADDWHERELIB(gsl,$GSL_LIBS,$GSL_CFLAGS)
2083fi
2084
2085m4_map([AC_FF_WHERELIB],[
2086	[[mumps],[-ldmumps -lzmumps  -lmumps_common  -lpord],[dmumps_c.h],[]],
2087	[[mumps_seq],[$ff_blas_libs $ff_lapack_lib -ldmumps_seq -lzmumps_seq  -lmumps_common_seq  -lpord_seq -lmpiseq_seq],[dmumps_c.h],[]],
2088	[[libseq],[-lmpiseq_seq],[${inc_usr_include}mumps_seq/mpi.h]],
2089	[[mumps_ptscotch],[-lpord_ptscotch -lmumps_common_ptscotch -ldmumps_ptscotch -lzmumps_ptscotch -lpord_ptscotch],[dmumps_c.h]],
2090	[[mumps_scotch],[-lpord_scotch -lmumps_common_scotch -ldmumps_scotch -lzmumps_scotch -lpord_scotch],[dmumps_c.h]],
2091	[[fftw3],[-lfftw3],[${inc_usr_include}fftw3.h],[]],
2092	[[superlu],[-lsuperlu],[${inc_usr_include}superlu/superlu_enum_consts.h],[]],
2093        [[blacs],[ -lblacsCinit$ff_with_mpi	-lblacsF77init$ff_with_mpi	-lblacs$ff_with_mpi],[]],
2094        [[scalapack],[-lscalapack$ff_with_mpi],[]],
2095        [[scotch],[-lscotch -lscotcherr], [scotch.h]],
2096        [[ptscotch],[-lscotch -lscotcherr -lptscotch -lptscotcherr],[ptscotch.h]],
2097	[[metis],[-lmetis],[${inc_usr_include}metis/metis.h],[]],
2098	[[metis],[-lmetis],[metis.h],[]],
2099	[[parmetis],[-lparmetis -lmetis],[],[]],
2100	[[freeyams],[-lfreeyams],[freeyamslib.h],[]],
2101	[[mmg3d],[-lmmg3d-v4],[libmmg3d.h],[]],
2102        [[mmg],[-lmmg],[libmmg.h],[]],
2103        [[parmmg],[-lparmmg],[libparmmg.h],[]],
2104	[[mshmet],[-lmshmet],[mshmetlib.h],[]],
2105dnl	[[gsl],[-lgsl -lgslcblas -lm],[gsl/gsl_sf.h],[]],
2106	[[tetgen],[-ltet],[tetgen.h],[]],
2107	[[ipopt],[ -lipopt],[${inc_usr_include}coin/IpTNLP.hpp],[]],
2108	[[nlopt],[ -lnlopt],[nlopt.hpp],[]]
2109    ]
2110    )
2111## before try
2112
2113TOOL_DISABLE(tetgen,tetgen.$DYLIB_SUFFIX)
2114TOOL_DISABLE(ipopt,ff-Ipopt.$DYLIB_SUFFIX)
2115TOOL_DISABLE(lapack,"lapack.$DYLIB_SUFFIX fflapack.$DYLIB_SUFFIX")
2116TOOL_DISABLE(metis,metis.$DYLIB_SUFFIX)
2117TOOL_DISABLE(parmetis,parmetis.$DYLIB_SUFFIX)
2118TOOL_DISABLE(mmg3d,mmg3d-v4.0.$DYLIB_SUFFIX)
2119if test "$ff_cmake" = yes; then
2120     TOOL_DISABLE(mmg,mmg.$DYLIB_SUFFIX)
2121     TOOL_DISABLE(parmmg,parmmg.$DYLIB_SUFFIX)
2122fi
2123TOOL_DISABLE(mshmet,"mshmet.$DYLIB_SUFFIX aniso.$DYLIB_SUFFIX")
2124TOOL_DISABLE(gmm,ilut.$DYLIB_SUFFIX,,enable_gmm=no)
2125TOOL_DISABLE(scalapack,"MUMPS.$DYLIB_SUFFIX MUMPS_mpi.$DYLIB_SUFFIX")
2126TOOL_DISABLE(mumps,"MUMPS.$DYLIB_SUFFIX MUMPS_mpi.$DYLIB_SUFFIX")
2127TOOL_DISABLE(mumps_seq,"MUMPS_seq.$DYLIB_SUFFIX MUMPS.$DYLIB_SUFFIX",mumps-seq)
2128TOOL_DISABLE(nlopt,ff-NLopt.$DYLIB_SUFFIX)
2129
2130TOOL_DISABLE(scotch,scotch.$DYLIB_SUFFIX)
2131TOOL_DISABLE(superlu,SuperLu.$DYLIB_SUFFIX)
2132TOOL_DISABLE(umfpack,UMFPACK64.$DYLIB_SUFFIX)
2133TOOL_DISABLE(yams,freeyams.$DYLIB_SUFFIX)
2134TOOL_DISABLE(pipe,pipe.$DYLIB_SUFFIX,,nodownload)
2135AC_SUBST([BIN_ffmaster],"$BIN_ffmaster")
2136TOOL_DISABLE(MMAP,ff-mmap-semaphore.$DYLIB_SUFFIX,,nodownload)
2137
2138# FFCS - MUMPS_seq has a different Win32 compiler setup from FFCS, so we need to add some extra parameters
2139
2140if test "$OS" = Windows_NT
2141then
2142    CFLAGS="$CFLAGS -DWITHOUT_PTHREAD -DAdd_"
2143
2144    # we also need to satisfy ff-c++ that the pthread are not a blocking point
2145    if test -n "$ff_pthread"  ; then
2146       AC_FF_ADDWHERELIB(pthread,"",)
2147    fi
2148# ALH  MPI  "-fno-range-check" on Windows, but this options fails on MacOS 10.8.  Add no-range-check for Windows
2149# for hexadecimal parameter constants like:
2150# [[file:c:/cygwin/home/alh/ffcs/rel/mingw/mpif.h::PARAMETER MPI_SHORT_INT z 8c000003]]
2151#
2152    AC_SUBST(NO_RANGE_CHECK,-fno-range-check)
2153fi
2154
2155
2156# ALH - 4/9/13 - request from Helmut Jarausch - allow to change Scotch include path
2157if test "$with_scotch_include" = ""
2158then
2159    with_scotch_include=$ac_pwd/3rdparty/include/scotch
2160fi
2161AC_SUBST(SCOTCH_INCLUDE,$with_scotch_include)
2162
2163# Find out kernel and libc versions
2164# ---------------------------------
2165
2166if test "$ff_win32" != yes -a "$ff_mac" != yes
2167then
2168	AC_MSG_CHECKING(kernel version)
2169	ff_kernel_version=`cat /proc/version|perl -e '<STDIN>=~/(\d+\.\d+\.\d+)/;print $1;'`
2170	AC_MSG_RESULT($ff_kernel_version)
2171	AC_SUBST(KERNEL_VERSION,$ff_kernel_version)
2172
2173	AC_MSG_CHECKING(libc version)
2174	ff_libc_version=`ldd /bin/sh | awk '/libc/{print $3}' | xargs readlink | sed -e 's/\.so$//'`
2175	AC_MSG_RESULT($ff_libc_version)
2176	AC_SUBST(LIBC_VERSION,$ff_libc_version)
2177fi
2178#  def variable pour les makefiles
2179
2180# creating all makefiles
2181# ----------------------
2182
2183ff_bamgprog="bamg${EXEEXT} cvmsh2${EXEEXT}"
2184
2185AC_SUBST(CNOFLAGS,$CNOFLAGS) dnl for superludist CFLAGS without optim  ...
2186AC_SUBST(FNOFLAGS,$FNOFLAGS) dnl for blacs CFLAGS without optim  ...
2187
2188# The final list of executable programs
2189
2190AC_SUBST(MEDITPROG,$ff_meditprog)
2191AC_SUBST(FFGLUTPROG,$ff_ffglutprog)
2192AC_SUBST(BAMGPROG,$ff_bamgprog)
2193AC_SUBST(STDPROG,$ff_stdprog)
2194ff_progs="FreeFem++-nw $ff_bamgprog  $ff_mpiprog $ff_meditprog $ff_ffglutprog"
2195
2196AC_SUBST(TEST_FFPP,$ff_TEST_FFPP)
2197AC_SUBST(TEST_FFPP_MPI,$ff_TEST_FFPP_MPI)
2198AC_SUBST(TEST_FFPPMPI,"../../src/mpi/ff-mpirun")
2199
2200ff_with_mpi=-openmpi;
2201
2202ff_blacs="-lblacsCinit$ff_with_mpi     -lblacsF77init$ff_with_mpi      -lblacs$ff_with_mpi"
2203ff_scalapack=-lscalapack
2204
2205# change MKL interface ...
2206test -n "$ff_mkl_blacs" && ff_blacs="$ff_mkl_blacs"
2207test -n "$ff_mkl_scalapack" && ff_scalapack="$ff_mkl_scalapack"
2208test -n "$ff_mkl_root" && ff_winc="$ff_mkl_root/include/mkl_blas.h"
2209
2210# FFCS - 27/10/11 - Some extra conditionals for things that do not work on certain systems (eg MPI libraries under
2211# Windows)
2212
2213##  search of HDF5 ....
2214AX_LIB_HDF5()
2215if test "$with_hdf5" = "yes"; then
2216  ff_save_cppflags="$CPPFLAGS";
2217  CPPFLAGS="$CPPFLAGS $HDF5_CPPFLAGS"
2218  AC_CHECK_HEADER([H5Cpp.h],[],[with_hdf=no])
2219  CPPFLAGS="$ff_save_cppflags"
2220  #if test "$with_hdf5" = "yes"; then
2221  AC_FF_ADDWHERELIB(hdf5,$HDF5_LDFLAGS  $HDF5_LIBS,$HDF5_CPPFLAGS)
2222  LIBS="$LIBS $HDF5_LDFLAGS  $HDF5_LIBS"
2223  # hack, if enable_download=no
2224  AC_SUBST([TOOL_COMPILE_iohdf5],ifelse(,,iohdf5,))
2225  AC_SUBST([TOOL_DYLIB_iohdf5],iohdf5.$DYLIB_SUFFIX)
2226  ifelse(nodownload,,[ff_download_lib="iohdf5 $ff_download_lib"])
2227  ifelse(nodownload,,[enable_iohdf5_download=yes])
2228  #fi
2229else
2230  enable_iohdf5=no
2231fi
2232#TOOL_DISABLE(iohdf5,iohdf5.$DYLIB_SUFFIX,,nodownload)
2233
2234
2235AM_CONDITIONAL([FFCS_WINDOWS],[test "$OS" = Windows_NT])
2236
2237#  remove gsl if not find ... FH
2238# correction FH .. 18/12/2013.
2239# ALH - 7/1/14 - not able to compile gsl with FFCS on Windows
2240if test "$enable_ffcs" != yes
2241then
2242    if test  "$ff_where_lib_conf_gsl" = 1  -a  "$enable_gsl" != "no" ; then enable_gsl=yes; fi;
2243fi
2244
2245# hack, if enable_download=no
2246if test "$ff_with_gsl" = "yes"; then
2247  AC_SUBST([TOOL_COMPILE_gsl],ifelse(,,gsl,))
2248  AC_SUBST([TOOL_DYLIB_gsl],gsl.$DYLIB_SUFFIX)
2249  ifelse(nodownload,,[ff_download_lib="gsl $ff_download_lib"])
2250  ifelse(nodownload,,[enable_gsl_download=yes])
2251else
2252  enable_gsl=no
2253fi
2254
2255TOOL_DISABLE(NewSolver,"NewSolver.$DYLIB_SUFFIX",,nodownload)
2256TOOL_DISABLE(mkl,"PARDISO.$DYLIB_SUFFIX",,nodownload)
2257
2258# echo "debug cxxx11: $ff_cxx11 mpi: $ff_mpi petsc: $ff_petsc_ok "
2259test "$enable_download" != "yes" -a "$enable_download_hpddm" != "yes" -a \( "$enable_hpddm" != "yes" -o "$ff_hpddm_ok" != "yes" \) && enable_hpddm=no
2260test "$enable_download" != "yes" -a "$enable_htool" != yes && enable_htool=no
2261
2262test "$enable_download" != "yes" -a "$enable_bemtool" != yes && enable_bemtool=no
2263test "$enable_download" != "yes" -a "$enable_boost" != yes && enable_boost=no
2264
2265test \( \( "$enable_download" = "yes" -o "$enable_download_hpddm" = "yes" \) -a "$enable_hpddm" != "no" \) -o "$ff_hpddm_ok" = "yes" && enable_hpddm=yes
2266test "$enable_download" = yes -a "$enable_htool" != no && enable_htool=yes
2267
2268test "$enable_download" = yes  -a "$enable_bemtool" != no && enable_bemtool=yes
2269test "$enable_download" = yes -a "$enable_boost" != no && enable_boost=yes
2270
2271test "$ff_cxx11" != yes -o  "$ff_mpi" != yes  -o \( "$ff_umfpack_ok" != "yes" -a "$ff_mumps_ok" != "yes" \) &&  enable_hpddm=no
2272test "$ff_cxx11" != yes -o  "$ff_mpi" != yes   &&  enable_htool=no
2273test "$ff_cxx11" != yes -o  "$ff_mpi" != yes  -o \( "$enable_bemtool" != "yes" -a "$enable_boost" != "yes" \) &&  enable_bemtool=no
2274
2275FF_PETSC_DYLIB=""
2276if test "$ff_petsc_ok" != no ;   then
2277FF_PETSC_DYLIB="PETSc.$DYLIB_SUFFIX"
2278fi
2279if test "$ff_petsccomplex_ok" != no ;   then
2280FF_PETSC_DYLIB="$FF_PETSC_DYLIB PETSc-complex.$DYLIB_SUFFIX"
2281fi
2282if test "$ff_slepccomplex_ok" != no ;   then
2283FF_PETSC_DYLIB="$FF_PETSC_DYLIB SLEPc-complex.$DYLIB_SUFFIX"
2284fi
2285if test "$ff_slepc_ok" != no ;   then
2286FF_PETSC_DYLIB="$FF_PETSC_DYLIB SLEPc.$DYLIB_SUFFIX"
2287fi
2288
2289##echo @@@@@@@@@@@@ $ff_petsc_ok @@ "hpddm.$DYLIB_SUFFIX $FF_PETCS_DYLIB"
2290TOOL_DISABLE(hpddm,["hpddm.$DYLIB_SUFFIX hpddm_substructuring.$DYLIB_SUFFIX $FF_PETSC_DYLIB"])
2291TOOL_DISABLE(bem,["bem.$DYLIB_SUFFIX"])
2292
2293##
2294if test "$ff_mkl_ok" = yes ; then
2295    AC_DEFINE(HAVE_MKL,1, the MKL intel lib is present for BLAS and LAPACK  )
2296fi
2297
2298## Condtional for check
2299test "$ff_fftw_ok" = yes -o -n "$ff_DOWNLOAD_FFTW" && ff_fftw_=yes || ff_fftw_=no
2300test "$ff_ipopt_ok" = yes -o -n "$TOOL_COMPILE_ipopt" && ff_ipopt_=yes || ff_ipopt_=no
2301test "$ff_metis_ok" = yes -o -n "$TOOL_COMPILE_metis" && ff_metis_=yes || ff_metis_=no
2302test "$ff_mmg_ok" = yes -o -n "$TOOL_COMPILE_mmg" && ff_mmg_=yes || ff_mmg_=no
2303test "$ff_mshmet_ok" = yes -o -n "$TOOL_COMPILE_mshmet" && ff_mshmet_=yes || ff_mshmet_=no
2304test "$ff_mumps_ok" = yes -o -n "$TOOL_COMPILE_mumps" && ff_mumps_=yes || ff_mumps_=no
2305test "$ff_mumps_seq_ok" = yes -o -n "$TOOL_COMPILE_mumps_seq" && ff_mumps_seq_=yes || ff_mumps_seq_=no
2306test "$ff_parmetis_ok" = yes -o -n "$TOOL_COMPILE_parmetis" && ff_parmetis_=yes || ff_parmetis_=no
2307test "$ff_scotch_ok" = yes -o -n "$TOOL_COMPILE_scotch" && ff_scotch_=yes || ff_scotch_=no
2308test "$ff_tetgen_ok" = yes -o -n "$TOOL_COMPILE_tetgen" && ff_tetgen_=yes || ff_tetgen_=no
2309test "$ff_umfpack_ok" = yes -o -n "$TOOL_COMPILE_umfpack"  && ff_umfpack_=yes || ff_umfpack_=no
2310test "$ff_parmmg_ok" = yes -o -n "$TOOL_COMPILE_parmmg"  && ff_parmmg_=yes || ff_parmmg_=no
2311
2312AC_SUBST(DOWNLOADCOMPILE,$DOWNLOADCOMPILE)
2313AM_CONDITIONAL([DOWNLOAD], [test "$enable_download" = yes])
2314AM_CONDITIONAL([ARPACK], [test "$ff_arpack_ok" = yes])
2315AM_CONDITIONAL([BLACS], [test "$ff_blacs_ok" = yes])
2316AM_CONDITIONAL([BEMTOOL], [test "$enable_bemtool" = yes])
2317AM_CONDITIONAL([BOOST], [test "$enable_boost" = yes])
2318AM_CONDITIONAL([FFTW3], [test "$ff_fftw_" = yes])
2319AM_CONDITIONAL([FORTRAN], [test "$enable_fortran" != no ])
2320AM_CONDITIONAL([FREEYAMS], [test "$ff_freeyams_ok" = yes -o -n "$TOOL_COMPILE_yams"])
2321AM_CONDITIONAL([GMM], [test "$enable_gmm" = yes -o -n "$TOOL_COMPILE_gmm"])
2322AM_CONDITIONAL([GSL], [test "$ff_with_gsl" = yes])
2323AM_CONDITIONAL([HDF5], [test "$with_hdf5" = yes])
2324AM_CONDITIONAL([HTOOL], [test "$enable_htool" = yes])
2325AM_CONDITIONAL([HPDDM], [test "$enable_hpddm" = yes])
2326AM_CONDITIONAL([IPOPT], [test "$ff_ipopt_" = yes])
2327AM_CONDITIONAL([LIBSEQ], [test "$ff_libseq_ok" = yes])
2328AM_CONDITIONAL([METIS], [test "$ff_metis_" = yes])
2329AM_CONDITIONAL([MKL], [test "$ff_mkl" = yes])
2330AM_CONDITIONAL([MMG3D], [test "$ff_mmg3d_ok" = yes -o -n "$TOOL_COMPILE_mmg3d"])
2331AM_CONDITIONAL([MMG], [test "$ff_mmg_" = yes])
2332AM_CONDITIONAL([PARMMG], [test "$ff_parmmg_" = yes])
2333AM_CONDITIONAL([MPI], [test "$ff_mpi" = yes])
2334AM_CONDITIONAL([MSHMET], [test "$ff_mshmet_" = yes])
2335AM_CONDITIONAL([MUMPS], [test "$ff_mumps_" = yes])
2336AM_CONDITIONAL([MUMPS_ptscotch], [test "$ff_mumps_ptscotch_ok" = yes])
2337AM_CONDITIONAL([MUMPS_scotch], [test "$ff_mumps_scotch_ok" = yes])
2338AM_CONDITIONAL([MUMPS_seq], [test "$ff_mumps_seq_" = yes])
2339AM_CONDITIONAL([NLOPT], [test "$ff_nlopt_ok" = yes -o -n "$TOOL_COMPILE_nlopt"])
2340AM_CONDITIONAL([PARMETIS], [test "$ff_parmetis_" = yes])
2341AM_CONDITIONAL([PETSC], [test "$ff_petsc_ok" = yes])
2342AM_CONDITIONAL([PETSCCOMPLEX], [test "$ff_petsccomplex_ok" = yes])
2343AM_CONDITIONAL([PIPE], [test -n "$TOOL_COMPILE_pipe"])
2344AM_CONDITIONAL([PTHREAD], [test -n "$ff_pthread"])
2345AM_CONDITIONAL([PTSCOTCH], [test "$ff_ptscotch_ok" = yes])
2346AM_CONDITIONAL([SCALAPACK], [test "$ff_scalapack_ok" = yes])
2347AM_CONDITIONAL([SCOTCH], [test "$ff_scotch_" = yes])
2348AM_CONDITIONAL([SLEPC], [test "$ff_slepc_ok" = yes])
2349AM_CONDITIONAL([SLEPCCOMPLEX], [test "$ff_slepccomplex_ok" = yes])
2350AM_CONDITIONAL([SUPERLU], [test "$ff_superlu_ok" = yes])
2351AM_CONDITIONAL([TETGEN], [test "$ff_tetgen_" = yes])
2352AM_CONDITIONAL([UMFPACK], [test "$ff_umfpack_" = yes])
2353
2354##
2355# All makefiles
2356AC_OUTPUT(
2357    Makefile
2358    3rdparty/Makefile
2359    3rdparty/blas/Makefile
2360    3rdparty/arpack/Makefile
2361    3rdparty/umfpack/Makefile
2362    3rdparty/fftw/Makefile
2363    src/Makefile
2364    src/bamglib/Makefile
2365    src/Graphics/Makefile
2366    src/femlib/Makefile
2367    src/Algo/Makefile
2368    src/lglib/Makefile
2369    src/ffgraphics/Makefile
2370    src/ffgraphics/server/Makefile
2371    src/ffgraphics/client/Makefile
2372    src/fflib/Makefile
2373    src/nw/Makefile
2374    src/mpi/Makefile
2375    src/bamg/Makefile
2376    src/libMesh/Makefile
2377    src/medit/Makefile
2378    src/bin-win32/Makefile
2379    plugin/Makefile
2380    plugin/seq/Makefile
2381    plugin/mpi/Makefile
2382    examples/Makefile
2383    examples/plugin/Makefile
2384    examples/tutorial/Makefile
2385    examples/misc/Makefile
2386    examples/mpi/Makefile
2387    examples/hpddm/Makefile
2388    examples/ffddm/Makefile
2389    examples/eigen/Makefile
2390    examples/examples/Makefile
2391    examples/bug/Makefile
2392    examples/3d/Makefile
2393    examples/3dSurf/Makefile
2394    examples/3dCurve/Makefile
2395)
2396
2397AC_MSG_NOTICE([  FreeFEM used download: $enable_download ])
2398AC_MSG_NOTICE([  --  Dynamic load facility: $ff_dynload ])
2399AC_MSG_NOTICE([  --  ARPACK (eigen value): $ff_arpack_ok ])
2400AC_MSG_NOTICE([  --  UMFPACK (sparse solver): $ff_umfpack_ok ])
2401AC_MSG_NOTICE([  --  BLAS: $ff_blas_ok ])
2402AC_MSG_NOTICE([  --  with MPI:     $ff_mpi])
2403AC_MSG_NOTICE([    --  with PETSc: $ff_petsc_ok / PETSc complex: $ff_petsccomplex_ok ]);
2404AC_MSG_NOTICE([    --  with SLEPc: $ff_slepc_ok / SLEPc complex: $ff_slepccomplex_ok ]);
2405AC_MSG_NOTICE([    --  with hpddm: $enable_hpddm ]);
2406AC_MSG_NOTICE([    --  with htool: $enable_htool ]);
2407AC_MSG_NOTICE([    --  with bemtool: $enable_bemtool (need boost: $enable_boost and htool: $enable_htool) ]);
2408AC_MSG_NOTICE([  --  without libs: $ff_unlib_plugin ]);
2409AC_MSG_NOTICE([  --  without plugins: $ff_uncompile_plugin ]);
2410
2411
2412AC_MSG_NOTICE([    progs: $ff_progs ])
2413if test  "$ff_umfpack_download" = yes -a  -n "$TOOL_COMPILE_umfpack" ;then
2414    AC_MSG_NOTICE([      use of download UMFPACK see  3rdparty/umfpack/SuiteSparse/UMFPACK/README.txt for the License])
2415fi
2416if test "$ff_arpack_download" = yes -a  -n "$TOOL_COMPILE_arpack"  ; then
2417    AC_MSG_NOTICE([      use of download ARPACK see  3rdparty/arpack/ARPACK/README  no License ])
2418fi
2419
2420if test "$enable_download" = yes; then
2421  if test -n "$ff_DOWNLOAD_FFTW"; then
2422    AC_MSG_NOTICE([      use of download fftw   see  3rdparty/fftw/fftw-3.2/COPYRIGHT ])
2423  fi
2424  if test -n "$TOOL_COMPILE_tetgen"; then
2425    AC_MSG_NOTICE([      use of download tetgen  see 3rdparty/tetgen/tetgen1.5.1-beta/LICENSE ])
2426  fi
2427  if test -n "$TOOL_COMPILE_yams"; then
2428    AC_MSG_NOTICE([      use of download freeyams  see 3rdparty/yams/freeyams.2011.02.22 (suface mesh adaptation)  ])
2429  fi
2430  if test -n "$TOOL_COMPILE_mmg3d"; then
2431    AC_MSG_NOTICE([      use of download mmg3d (v4)   see 3rdparty/mmg3d/mmg3d4/LICENCE.txt  ])
2432  fi
2433  if test -n "$TOOL_COMPILE_mmg"; then
2434    AC_MSG_NOTICE([      use of download mmg  see 3rdparty/mmg/mmg-sources/LICENSE ])
2435  fi
2436  if test -n "$TOOL_COMPILE_parmmg"; then
2437    AC_MSG_NOTICE([      use of download parmmg  see 3rdparty/parmmg/parmmg-sources/LICENSE ])
2438  fi
2439  if test -n "$TOOL_COMPILE_parmetis"; then
2440    AC_MSG_NOTICE([      use of download parmetis])
2441  fi
2442
2443  # ALH - some tools may be activated but not downloaded if a local version is specified (see
2444  # [[TOOL_PARAMETERS]])
2445
2446  if test "$enable_superlu_download" = yes; then
2447    AC_MSG_NOTICE([      use of download superlu])
2448  fi
2449
2450  if test -n "$MPICC"; then
2451    AC_MSG_NOTICE([      try to download: $ff_download_lib])
2452  fi
2453
2454  if test "$enable_boost" = yes; then
2455    AC_MSG_NOTICE([      use of download boost        see 3rdparty/boost/LICENSE_1_0.txt  ])
2456  fi
2457
2458  if test "$ff_download_blas" = "generic"; then
2459    AC_MSG_NOTICE([      use of download generic blas and cblas freefem may be slow  ])
2460    AC_MSG_NOTICE([      you can try to use the  Kazushige Goto s BLAS at http://www.cs.utexas.edu/users/flame/goto/  ])
2461    AC_MSG_NOTICE([          or at  http://www.tacc.utexas.edu/~kgoto/ for the best BLAS .])
2462    AC_MSG_NOTICE([      or try to 3rdparty/compile the altas blas .])
2463  fi
2464
2465  # ALH - 30/10/13 - (request from FH) all downloads are now part of a separate script ([[file:3rdparty/getall]])
2466  # which needs to be run before make for the user to specify whether he is ok with each of the package licences.
2467
2468  AC_MSG_NOTICE([      Please run "3rdparty/getall" to download all necessary packages before running make])
2469fi
2470
2471# FFCS does not use glut, so remove this message because it could make the user think that something is broken
2472
2473if test $enable_ffcs = no
2474then
2475    if test "$ff_glut_ok" != yes  ; then
2476	AC_MSG_NOTICE([     *********************************************** ])
2477	AC_MSG_NOTICE([     WARNING: you do not have the new grachics tools ])
2478	AC_MSG_NOTICE([         because the configure do not find OpenGL, GLUT or pthread  developer stuff ])
2479	AC_MSG_NOTICE([         read the README to find missing package  ])
2480	AC_MSG_NOTICE([         F. Hecht  ])
2481	AC_MSG_NOTICE([ to install missing package  under debian or ubuntu, try: sudo apt-get install freeglut3-dev ])
2482	AC_MSG_NOTICE([     *********************************************** ])
2483    fi
2484fi
2485
2486if test "$enable_summary" = yes; then
2487  if test "$enable_fortran" != yes; then
2488    enable_fortran=no
2489  fi
2490  if test "$enable_gmm" != yes; then
2491    enable_gmm=no
2492  fi
2493  if test "$ff_mkl" != yes; then
2494    ff_mkl=no
2495  fi
2496  if test -n "$ff_pthread"; then
2497    ff_pthread_ok=yes
2498  else
2499    ff_pthread_ok=no
2500  fi
2501
2502
2503  AC_MSG_NOTICE([ Activated libraries ])
2504  AC_MSG_NOTICE([ - ARPACK: $ff_arpack_ok])
2505  AC_MSG_NOTICE([ - BLACS: $ff_blacs_ok])
2506  AC_MSG_NOTICE([ - BEMTOOL: $enable_bemtool])
2507  AC_MSG_NOTICE([ - BOOST: $enable_boost])
2508  AC_MSG_NOTICE([ - FFTW3: $ff_fftw_])
2509  AC_MSG_NOTICE([ - FORTRAN: $enable_fortran])
2510  AC_MSG_NOTICE([ - FREEYAMS: $ff_freeyams_ok])
2511  AC_MSG_NOTICE([ - GMM: $enable_gmm])
2512  AC_MSG_NOTICE([ - GSL: $ff_with_gsl])
2513  AC_MSG_NOTICE([ - HDF5: $with_hdf5])
2514  AC_MSG_NOTICE([ - HTOOL: $enable_htool])
2515  AC_MSG_NOTICE([ - HPDDM: $enable_hpddm])
2516  AC_MSG_NOTICE([ - IPOPT: $ff_ipopt_])
2517  AC_MSG_NOTICE([ - LIBSEQ: $ff_libseq_ok])
2518  AC_MSG_NOTICE([ - METIS: $ff_metis_])
2519  AC_MSG_NOTICE([ - MKL: $ff_mkl])
2520  AC_MSG_NOTICE([ - MMG3D: $ff_mmg3d_ok])
2521  AC_MSG_NOTICE([ - MMG: $ff_mmg_])
2522  AC_MSG_NOTICE([ - PARMMG: $ff_parmmg_])
2523  AC_MSG_NOTICE([ - MPI: $ff_mpi])
2524  AC_MSG_NOTICE([ - MSHMET: $ff_mshmet_])
2525  AC_MSG_NOTICE([ - MUMPS: $ff_mumps_])
2526  AC_MSG_NOTICE([ - MUMPS_ptscotch: $ff_mumps_ptscotch_ok])
2527  AC_MSG_NOTICE([ - MUMPS_scotch: $ff_mumps_scotch_ok])
2528  AC_MSG_NOTICE([ - MUMPS_seq: $ff_mumps_seq_])
2529  AC_MSG_NOTICE([ - NLOPT: $ff_nlopt_ok])
2530  AC_MSG_NOTICE([ - PARMETIS: $ff_parmetis_])
2531  AC_MSG_NOTICE([ - PETSC: $ff_petsc_ok])
2532  AC_MSG_NOTICE([ - PETSCCOMPLEX: $ff_petsccomplex_ok])
2533  AC_MSG_NOTICE([ - PTHREAD: $ff_pthread_ok])
2534  AC_MSG_NOTICE([ - PTSCOTCH: $ff_ptscotch_ok])
2535  AC_MSG_NOTICE([ - SCALAPACK: $ff_scalapack_ok])
2536  AC_MSG_NOTICE([ - SCOTCH: $ff_scotch_])
2537  AC_MSG_NOTICE([ - SLEPC: $ff_slepc_ok])
2538  AC_MSG_NOTICE([ - SLEPCCOMPLEX: $ff_slepccomplex_ok])
2539  AC_MSG_NOTICE([ - SUPERLU: $ff_superlu_ok])
2540  AC_MSG_NOTICE([ - TETGEN: $ff_tetgen_])
2541  AC_MSG_NOTICE([ - UMFPACK: $ff_umfpack_])
2542fi
2543if test "${prefix_petsc}" != no -a   ! \( -d "${prefix_petsc}/real/lib"  -o  -d "${prefix_petsc}/r/lib" \) ; then
2544  AC_MSG_NOTICE([ PETSc directories do not exist, to build do:])
2545  AC_MSG_NOTICE([cd 3rdparty/ff-petsc && make])
2546fi
2547