1# Process this file with reconfigure.sh to update configure script.
2# See also config/config.*.
3
4
5# General Configurations
6
7AC_INIT(lis, 2.0.30, devel@ssisc.org)
8AC_CONFIG_SRCDIR([src/fortran/lisf_matrix.c])
9AC_CONFIG_AUX_DIR(config)
10AC_CONFIG_MACRO_DIR([m4])
11
12AC_CANONICAL_SYSTEM
13AM_INIT_AUTOMAKE
14AM_CONFIG_HEADER(include/lis_config.h)
15
16AM_MAINTAINER_MODE
17
18AC_ARG_VAR(MPICC,[MPI C compiler])
19AC_ARG_VAR(MPIF77,[MPI Fortran compiler])
20AC_ARG_VAR(MPIRUN,[command to execute MPI programs])
21AC_ARG_VAR(OMPFLAG,[OpenMP flags])
22AC_ARG_VAR(MPFLAG,[floating point precision flags])
23AC_ARG_VAR(TARGET,[system architecture])
24
25
26# Build Options
27
28AC_ARG_ENABLE(fortran, AC_HELP_STRING(--enable-fortran, [enable FORTRAN 77 compatible interfaces [[default=no]]]))
29AC_ARG_ENABLE(f90, AC_HELP_STRING(--enable-f90, [enable Fortran 90 compatible interface [[default=no]]]))
30AC_ARG_ENABLE(saamg, AC_HELP_STRING(--enable-saamg, [enable SA-AMG preconditioner [[default=no]]]))
31AC_ARG_ENABLE(mpi, AC_HELP_STRING(--enable-mpi, [build with MPI library [[default=no]]]))
32AC_ARG_ENABLE(omp, AC_HELP_STRING(--enable-omp, [build with OpenMP library [[default=no]]]))
33AC_ARG_ENABLE(quad, AC_HELP_STRING(--enable-quad, [enable quadruple precision operations [[default=no]]]))
34AC_ARG_ENABLE(sse2, AC_HELP_STRING(--enable-sse2, [use Intel Streaming SIMD Extensions [[default=yes]]]),[],enable_sse2=yes)
35AC_ARG_ENABLE(fma, AC_HELP_STRING(--enable-fma, [use fused multiply add [[default=no]]]))
36AC_ARG_ENABLE(debug, AC_HELP_STRING(--enable-debug, [enable debugging [[default=no]]]))
37AC_ARG_ENABLE(gprof, AC_HELP_STRING(--enable-gprof, [enable profiling [[default=no]]]))
38AC_ARG_ENABLE(64bit, AC_HELP_STRING(--enable-64bit, [build 64bit binary on AIX and Solaris x86 [[default=no]]]))
39AC_ARG_ENABLE(32bit, AC_HELP_STRING(--enable-32bit, [build 32bit binary on Mac OS X [[default=no]]]))
40AC_ARG_ENABLE(longlong, AC_HELP_STRING(--enable-longlong, [enable long long int support [[default=no]]]))
41AC_ARG_ENABLE(longdouble, AC_HELP_STRING(--enable-longdouble, [enable long double support [[default=no]]]))
42AC_ARG_ENABLE(complex, AC_HELP_STRING(--enable-complex, [enable complex scalar support [[default=no]]]))
43AC_ARG_ENABLE(test, AC_HELP_STRING(--enable-test, [enable test programs [[default=yes]]]))
44
45AC_MSG_CHECKING([for a library suffix to use])
46AC_ARG_WITH(library-suffix,
47	[  --with-library-suffix=LIBSUFFIX    tag a suffix to the library names [[default=]]],
48	[LIBSUFFIX="${withval}"],
49	[LIBSUFFIX=])
50AC_SUBST(LIBSUFFIX)
51
52
53# Configurations for Some Specific Systems
54
55if test "$TARGET" != ""; then
56	case "$TARGET" in
57# Cray XT3 Cross Compiler
58	  cray_xt3_cross) CC="cc"
59                    F77="ftn"
60                    FC="ftn"
61                    MPICC="$CC"
62                    MPIF77="$F77"
63                    MPIFC="$FC"
64                    MPIRUN="yod"
65                    CFLAGS="-O3 -B -fastsse -tp k8-64"
66                    FFLAGS="-O3 -fastsse -tp k8-64 -Mpreprocess"
67                    FCFLAGS="-O3 -fastsse -tp k8-64 -Mpreprocess"
68                    FCLDFLAGS="-Mnomain"
69                    enable_mpi="yes"
70                    ac_cv_sizeof_void_p=8
71                    cross_compiling="yes"
72                    ax_f77_mangling="lower case, underscore, no extra underscore"
73	  ;;
74# Fujitsu Compiler for PRIMERGY
75	  fujitsu_pg) CC="fcc"
76                    F77="frt"
77                    FC="frt"
78                    MPICC="mpifcc"
79                    MPIF77="mpifrt"
80                    MPIFC="mpifrt"
81                    CFLAGS="-Kfast,ocl,preex -w"
82                    FFLAGS="-Kfast,ocl,preex -Cpp -fs"
83                    FCFLAGS="-Kfast,ocl,preex -Cpp -Am -fs"
84                    FCLDFLAGS=""
85                    ac_cv_sizeof_void_p=8
86                    ax_f77_mangling="lower case, underscore, no extra underscore"
87                    ax_cv_c_compiler_vendor="fujitsu"
88                    ax_cv_f77_compiler_vendor="fujitsu"
89                    cross_compiling="yes"
90                    MPIRUN="mpiexec"
91                    MPINP="-n"
92                    OMPFLAG="-KOMP"
93                    AMDEFS="-PG"
94	  ;;
95# Fujitsu Compiler for PRIMEQUEST
96	  fujitsu_pq) CC="fcc"
97                    F77="frt"
98                    FC="frt"
99                    MPICC="mpifcc"
100                    MPIF77="mpifrt"
101                    MPIFC="mpifrt"
102                    CFLAGS="-Kfast,ocl,preex -w"
103                    FFLAGS="-Kfast,ocl,preex -Cpp -fs"
104                    FCFLAGS="-Kfast,ocl,preex -Cpp -Am -fs"
105                    FCLDFLAGS=""
106                    ac_cv_sizeof_void_p=8
107                    ax_f77_mangling="lower case, underscore, no extra underscore"
108                    ax_cv_c_compiler_vendor="fujitsu"
109                    ax_cv_f77_compiler_vendor="fujitsu"
110                    MPIRUN="mpiexec"
111                    MPINP="-n"
112                    OMPFLAG="-KOMP"
113	  ;;
114# Fujitsu Technical Computing Suite (for FX and PRIMERGY)
115          fujitsu_tcs) CC="fcc"
116                    F77="frt"
117                    FC="frt"
118                    MPICC="mpifcc"
119                    MPIF77="mpifrt"
120                    MPIFC="mpifrt"
121                    CFLAGS="-Kfast,ocl,preex -w"
122                    FFLAGS="-Kfast,ocl,preex -Cpp -fs"
123                    FCFLAGS="-Kfast,ocl,preex -Cpp -fs"
124                    FCLDFLAGS=""
125                    ac_cv_sizeof_void_p=8
126                    ax_f77_mangling="lower case, underscore, no extra underscore"
127                    ax_cv_c_compiler_vendor="fujitsu"
128                    ax_cv_f77_compiler_vendor="fujitsu"
129                    MPIRUN="mpiexec"
130                    MPINP="-n"
131                    OMPFLAG="-Kopenmp"
132          ;;
133# Fujitsu Cross Compiler for FX10
134          fujitsu_fx10_cross) CC="fccpx"
135                    F77="frtpx"
136                    FC="frtpx"
137                    MPICC="mpifccpx"
138                    MPIF77="mpifrtpx"
139                    MPIFC="mpifrtpx"
140                    CFLAGS="-Kfast,ocl,preex -w"
141                    FFLAGS="-Kfast,ocl,preex -Cpp -fs"
142                    FCFLAGS="-Kfast,ocl,preex -Cpp -fs"
143                    FCLDFLAGS="-mlcmain=main"
144                    ac_cv_sizeof_void_p=8
145                    cross_compiling="yes"
146		    enable_sse2="no"
147		    target="s64fx"
148                    ax_f77_mangling="lower case, underscore, no extra underscore"
149                    ax_cv_c_compiler_vendor="fujitsu"
150                    ax_cv_f77_compiler_vendor="fujitsu"
151                    MPIRUN="mpiexec"
152                    MPINP="-n"
153                    OMPFLAG="-Kopenmp"
154          ;;
155# Fujitsu Compiler for K
156          K_shared) CC="fcc"
157                    F77="frt"
158                    FC="frt"
159                    MPICC="mpifcc"
160                    MPIF77="mpifrt"
161                    MPIFC="mpifrt"
162                    CFLAGS="-Kfast,ocl,preex,noeval -w"
163                    FFLAGS="-Kfast,ocl,preex,noeval -Cpp -fs -KPIC"
164                    FCFLAGS="-Kfast,ocl,preex,noeval -Cpp -fs -KPIC"
165                    FCLDFLAGS=""
166                    ac_cv_sizeof_void_p=8
167                    ax_f77_mangling="lower case, underscore, no extra underscore"
168                    ax_cv_c_compiler_vendor="fujitsu"
169                    ax_cv_f77_compiler_vendor="fujitsu"
170                    OMPFLAG="-Kopenmp"
171          ;;
172# Fujitsu Compiler for K
173          K_mpi_shared) CC="fcc"
174                    F77="mpifrt"
175                    FC="mpifrt"
176                    MPICC="mpifcc"
177                    MPIF77="mpifrt"
178                    MPIFC="mpifrt"
179                    CFLAGS="-Kfast,ocl,preex,noeval -w"
180                    FFLAGS="-Kfast,ocl,preex,noeval -Cpp -fs -KPIC"
181                    FCFLAGS="-Kfast,ocl,preex,noeval -Cpp -fs -KPIC"
182                    FCLDFLAGS=""
183                    ac_cv_sizeof_void_p=8
184                    ax_f77_mangling="lower case, underscore, no extra underscore"
185                    ax_cv_c_compiler_vendor="fujitsu"
186                    ax_cv_f77_compiler_vendor="fujitsu"
187                    MPIRUN="mpiexec"
188                    MPINP="-n"
189                    OMPFLAG="-Kopenmp"
190          ;;
191# Fujitsu Technical Computing Suite (for PRIMEHPC FX1000/FX700)
192          fujitsu_arm) CC="fcc"
193                    F77="frt"
194                    FC="frt"
195                    MPICC="mpifcc"
196                    MPIF77="mpifrt"
197                    MPIFC="mpifrt"
198                    CFLAGS="-Kfast,ocl,preex -w"
199                    FFLAGS="-Kfast,ocl,preex -Cpp -fs"
200                    FCFLAGS="-Kfast,ocl,preex -Cpp -fs"
201                    FCLDFLAGS=""
202                    ac_cv_sizeof_void_p=8
203                    ax_f77_mangling="lower case, underscore, no extra underscore"
204                    ax_cv_c_compiler_vendor="fujitsu"
205                    ax_cv_f77_compiler_vendor="fujitsu"
206                    MPIRUN="mpiexec"
207                    MPINP="-n"
208                    OMPFLAG="-Kopenmp -Nlibomp"
209          ;;
210# Hitachi Optimizing Compiler for SR16000
211          hitachi_sr16k) CC="cc"
212                    F77="f90"
213                    FC="f90"
214                    MPICC="mpicc"
215                    MPIF77="mpif90"
216                    MPIFC="mpif90"
217                    CFLAGS="-Os -64 -nolimit"
218                    FFLAGS="-Oss -64 -nolimit -cpp"
219                    FCFLAGS="-Oss -64 -nolimit -cpp -c"
220                    FCLDFLAGS="-lf90s"
221                    ac_cv_sizeof_void_p=8
222                    ax_f77_mangling="lower case, underscore, no extra underscore"
223                    ax_cv_c_compiler_vendor="hitachi"
224                    ax_cv_f77_compiler_vendor="hitachi"
225                    MPIRUN="mpirun"
226                    MPINP="-np"
227                    OMPFLAG="-parallel -omp"
228          ;;
229# Hitachi Optimizing Compiler for HA8000
230          hitachi_ha8k) CC="cc"
231                    F77="f90"
232                    FC="f90"
233                    MPICC="mpicc"
234                    MPIF77="mpif90"
235                    MPIFC="mpif90"
236                    CFLAGS="-Os -64 -nolimit"
237                    FFLAGS="-Oss -64 -nolimit -cpp"
238                    FCFLAGS="-Oss -64 -nolimit -cpp -c"
239                    FCLDFLAGS="-lf90s"
240                    ac_cv_sizeof_void_p=8
241                    ax_f77_mangling="lower case, underscore, no extra underscore"
242                    ax_cv_c_compiler_vendor="hitachi"
243                    ax_cv_f77_compiler_vendor="hitachi"
244                    MPIRUN="mpirun"
245                    MPINP="-np"
246                    OMPFLAG="-parallel -omp"
247          ;;
248# IBM XL Compiler for Blue Gene Solution
249	  ibm_bgl_cross) CC="blrts_xlc"
250                    F77="blrts_xlf90"
251                    FC="blrts_xlf90"
252                    MPICC="$CC"
253                    MPIF77="$F77"
254                    MPIFC="$FC"
255                    CFLAGS="-O3 -qarch=440d -qtune=440 -qstrict -I/bgl/BlueLight/ppcfloor/bglsys/include"
256                    FFLAGS="-O3 -qarch=440d -qtune=440 -qsuffix=cpp=F -qfixed=72 -w -I/bgl/BlueLight/ppcfloor/bglsys/include"
257                    FCFLAGS="-O3 -qarch=440d -qtune=440 -qsuffix=cpp=F90 -w -I/bgl/BlueLight/ppcfloor/bglsys/include"
258                    MPILIBS="-L/bgl/BlueLight/ppcfloor/bglsys/lib -lmpich.rts -lmsglayer.rts -lrts.rts -ldevices.rts"
259                    enable_mpi="yes"
260                    ac_cv_sizeof_void_p=8
261                    cross_compiling="yes"
262                    ax_cv_f77_compiler_vendor="ibm"
263                    ax_cv_c_compiler_vendor="ibm"
264                    ax_f77_mangling="lower case, no underscore, no extra underscore"
265	  ;;
266# NEC Compiler for SX-6i
267	  nec_sx6i) CC="c++"
268	            F77="f90"
269                    FC="f90"
270                    RANLIB="true"
271                    CFLAGS=""
272                    FFLAGS=""
273                    FCFLAGS=""
274                    FCLDFLAGS=""
275                    ac_cv_sizeof_void_p=8
276                    ax_f77_mangling="lower case, no underscore, extra underscore"
277                    ax_vector_machine="yes"
278	  ;;
279# NEC Cross Compiler for SX-6i
280	  nec_sx6i_cross) CC="sxc++"
281	            F77="sxf90"
282                    FC="sxf90"
283                    AR="sxar"
284                    RANLIB="true"
285                    STRIP="sxstrip"
286                    CFLAGS=""
287                    FFLAGS=""
288                    FCFLAGS=""
289                    FCLDFLAGS=""
290                    ac_cv_sizeof_void_p=8
291                    cross_compiling="yes"
292                    ax_f77_mangling="lower case, no underscore, extra underscore"
293                    ax_vector_machine="yes"
294	  ;;
295# NEC Cross Compiler for Earth Simulator
296	  nec_es_cross) CC="esmpic++"
297	            F77="esmpif90"
298                    FC="esmpif90"
299                    MPICC="$CC"
300                    MPIF77="$F77"
301                    MPIFC="$FC"
302                    AR="esar"
303                    RANLIB="true"
304                    CFLAGS=""
305                    FFLAGS=""
306                    FCFLAGS=""
307                    FCLDFLAGS=""
308                    LDFLAGS=""
309                    enable_mpi="yes"
310                    enable_omp="yes"
311                    ac_cv_sizeof_void_p=8
312                    cross_compiling="yes"
313                    ax_f77_mangling="lower case, no underscore, extra underscore"
314                    ax_vector_machine="yes"
315                    OMPFLAG="-Popenmp"
316	  ;;
317# NEC Compiler for SX-9
318          nec_sx9)  CC="sxmpic++"
319                    F77="sxmpif90"
320                    FC="sxmpif90"
321                    MPICC="$CC"
322                    MPIF77="$F77"
323                    MPIFC="$FC"
324                    AR="ar"
325                    RANLIB="true"
326                    CFLAGS=""
327                    FFLAGS=""
328                    FCFLAGS=""
329                    FCLDFLAGS=""
330                    LDFLAGS=""
331                    ac_cv_sizeof_void_p=8
332                    ax_f77_mangling="lower case, no underscore, extra underscore"
333                    ax_vector_machine="yes"
334                    OMPFLAG="-Popenmp"
335          ;;
336# NEC Cross Compiler for SX-9
337          nec_sx9_cross) CC="sxmpic++"
338                    F77="sxmpif90"
339                    FC="sxmpif90"
340                    MPICC="$CC"
341                    MPIF77="$F77"
342                    MPIFC="$FC"
343                    AR="sxar"
344                    RANLIB="true"
345                    CFLAGS=""
346                    FFLAGS=""
347                    FCFLAGS=""
348                    FCLDFLAGS=""
349                    LDFLAGS=""
350                    ac_cv_sizeof_void_p=8
351                    cross_compiling="yes"
352                    ax_f77_mangling="lower case, no underscore, extra underscore"
353                    ax_vector_machine="yes"
354                    OMPFLAG="-Popenmp"
355          ;;
356# NEC Compiler for SX-Aurora
357          nec_sxaurora)  CC="ncc"
358                    F77="nfort"
359                    FC="nfort"
360                    MPICC="mpincc"
361                    MPIF77="mpinfort"
362                    MPIFC="mpinfort"
363                    AR="ar"
364                    RANLIB="true"
365                    CFLAGS=""
366                    FFLAGS=""
367                    FCFLAGS=""
368                    FCLDFLAGS=""
369                    LDFLAGS=""
370                    ac_cv_sizeof_void_p=8
371                    ax_f77_mangling="lower case, no underscore, extra underscore"
372                    ax_vector_machine="yes"
373                    OMPFLAG="-fopenmp"
374          ;;
375# Intel Compiler for MIC
376          intel_mic) CC="icc"
377                    F77="ifort"
378                    FC="ifort"
379                    MPICC="mpiicc"
380                    MPIF77="mpiifort"
381                    MPIFC="mpiifort"
382                    CFLAGS="-mmic"
383                    FFLAGS="-mmic"
384                    FCFLAGS="-mmic"
385                    FCLDFLAGS="-mmic"
386                    LDFLAGS="-mmic"
387                    ax_cv_c_compiler_vendor="intel"
388                    ax_cv_f77_compiler_vendor="intel"
389	            OMPFLAG="-openmp"
390          ;;
391# Intel Cross Compiler for MIC
392          intel_mic_cross) CC="icc"
393                    F77="ifort"
394                    FC="ifort"
395                    MPICC="mpiicc"
396                    MPIF77="mpiifort"
397                    MPIFC="mpiifort"
398                    CFLAGS="-mmic"
399                    FFLAGS="-mmic"
400                    FCFLAGS="-mmic"
401                    FCLDFLAGS="-mmic"
402                    LDFLAGS="-mmic"
403                    cross_compiling="yes"
404		    host="x86_64-pc-linux-gnu"
405		    host_alias="x86_64-linux-gnu"
406		    host_cpu="x86_64"
407		    host_os="linux-gnu"
408		    host_vendor="pc"
409		    target="k1om-mpss-linux-gnu"
410		    target_alias="k1om-mpss-linux"
411		    target_cpu="k1om"
412		    target_os="linux-gnu"
413		    target_vendor="mpss"
414                    ax_cv_c_compiler_vendor="intel"
415                    ax_cv_f77_compiler_vendor="intel"
416		    OMPFLAG="-openmp"
417          ;;
418	  *)  echo 'TARGET' $TARGET 'cannot be specified.'
419              exit 1
420          ;;
421	esac
422fi
423
424# GNU Compiler for Apple Mac OS X
425if test "$build_vendor" = "apple"; then
426   if test -z "$CC"; then
427      CC="gcc"
428   fi
429   if test -z "$FC"; then
430      FC="gfortran"
431   fi
432   if test "$enable_32bit" = "yes"; then
433      CFLAGS="$CFLAGS -m32"
434      FCFLAGS="$FCFLAGS -m32"
435   else
436      CFLAGS="$CFLAGS -m64"
437      FCFLAGS="$FCFLAGS -m64"
438   fi
439   if test "$enable_omp" = "yes"; then
440      if $CC --version 2>&1 | grep clang > /dev/null ; then
441      	 OMPFLAG="-Xclang -fopenmp"
442       	 LDFLAGS="$LDFLAGS -lomp"
443      fi
444   fi
445fi
446
447enable_dependency_tracking="no"
448
449
450# Configurations for C and Fortran Compilers
451
452########## Check C Compilers ##########
453cflags_save="$CFLAGS"
454AC_PROG_CC([icc ecc xlc_r xlc fcc pgcc pathcc cc gcc clang])
455CFLAGS="$cflags_save"
456if test "$TARGET" = ""; then
457  if test "$CC" = "fcc"; then
458    CFLAGS="-O3 -w"
459    FFLAGS="-O3 -Cpp -fs"
460    FCFLAGS="-O3 -Cpp -Am -fs"
461    ax_f77_mangling="lower case, underscore, no extra underscore"
462    MPIRUN="mpiexec"
463    MPINP="-n"
464  fi
465fi
466
467if test "$TARGET" = ""; then
468	if test "$enable_mpi" = "yes"; then
469		AC_CHECK_PROGS(MPICC, $MPICC mpicc mpifcc hcc mpcc_r mpcc mpxlc cmpicc blrts_xlc esmpic++, $CC)
470		save_cc="$CC"
471		CC="$MPICC"
472		if test x = x"$MPILIBS"; then
473			AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])
474		fi
475		if test x = x"$MPILIBS"; then
476			AC_CHECK_LIB(mpi, MPI_Init, [MPILIBS="-lmpi"])
477		fi
478		if test x = x"$MPILIBS"; then
479			AC_CHECK_LIB(mpich, MPI_Init, [MPILIBS="-lmpich"])
480		fi
481		if test x != x"$MPILIBS"; then
482			AC_MSG_CHECKING([for mpi.h])
483			AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
484			AC_MSG_RESULT(no)])
485	        else
486	        	enable_mpi="not found"
487		fi
488		CC="$save_cc"
489		CC=$MPICC
490	fi
491
492########## Check C Flags ##########
493	for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI pathscale:__PATHCC__,__PATHSCALE__; do
494	    vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
495	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
496	#if !($vencpp)
497	      thisisanerror;
498	#endif
499	])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
500	done
501	AC_MSG_CHECKING([for C compiler vendor])
502	AC_MSG_RESULT($[ax_cv_]_AC_LANG_ABBREV[_compiler_vendor])
503	  case $ax_cv_c_compiler_vendor in
504	    dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host $CFLAGS" ;;
505	    gnu) CFLAGS="-O3 -fomit-frame-pointer $CFLAGS" ;;
506	    intel) CFLAGS="-ansi_alias $CFLAGS" ;;
507	    portland) CFLAGS="-O3 -B -fastsse $CFLAGS" ;;
508	    pathscale) CFLAGS="-O3 $CFLAGS" ;;
509	    ibm) CFLAGS="-O3 -qansialias -w -qarch=auto -qtune=auto $CFLAGS"
510                 AR="ar -X any"
511		 ;;
512	    sun) case `(uname -m) 2>/dev/null` in
513	           "i86pc") CFLAGS="-xtarget=native -xO5 -dalign $CFLAGS"
514                            LDFLAGS="-xtarget=native -xO5"
515			    ;;
516	                 *) CFLAGS="-xtarget=native64 -xO5 -dalign $CFLAGS"
517                            LDFLAGS="-xtarget=native64 -xO5"
518                            ;;
519          	 esac
520                 ;;
521	    hp)  CFLAGS="+Oall +Optrs_ansi +DSnative $CFLAGS" ;;
522	  esac
523
524	AC_DEFUN([_AX_PROG_FC_V_OUTPUT],
525	[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
526
527	# Compile and link our simple test program by passing a flag (argument
528	# 1 to this macro) to the Fortran compiler in order to get
529	# "verbose" output that we can then parse for the Fortran linker
530	# flags.
531	ac_save_CFLAGS=$CFLAGS
532	CFLAGS="$CFLAGS m4_default([$1], [$ac_cv_prog_[]_AC_LANG_ABBREV[]_v])"
533	(eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD
534	ac_[]_AC_LANG_ABBREV[]_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`
535	echo "$ac_[]_AC_LANG_ABBREV[]_v_output" >&AS_MESSAGE_LOG_FD
536	CFLAGS=$ac_save_CFLAGS
537
538	rm -f conftest*
539
540	# On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
541	# /foo, /bar, and /baz are search directories for the Fortran linker.
542	# Here, we change these into -L/foo -L/bar -L/baz (and put it first):
543	ac_[]_AC_LANG_ABBREV[]_v_output="`echo $ac_[]_AC_LANG_ABBREV[]_v_output |        grep 'LPATH is:' |        sed 's,.*LPATH is\(: *[[^ ]]*\).*,\1,;s,: */, -L/,g'` $ac_[]_AC_LANG_ABBREV[]_v_output"
544
545	case $ac_[]_AC_LANG_ABBREV[]_v_output in
546	  # If we are using xlf then replace all the commas with spaces.
547	  *xlcentry*)
548	    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/,/ /g'` ;;
549
550	  # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
551	  # $LIBS confuse us, and the libraries appear later in the output anyway).
552	  *mGLOB_options_string*)
553	    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/\"-mGLOB[[^\"]]*\"/ /g'` ;;
554
555	esac
556	])
557
558	AC_DEFUN([_AX_PROG_FC_V],
559	[AC_CACHE_CHECK([how to get verbose linking output from C],
560	                [ac_cv_prog_[]_AC_LANG_ABBREV[]_v],
561	[AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
562	[ac_cv_prog_[]_AC_LANG_ABBREV[]_v=
563	# Try some options frequently used verbose output
564	for ac_verb in -v -verbose --verbose -V -\#\#\#; do
565	  _AX_PROG_FC_V_OUTPUT($ac_verb)
566	  # look for -l* and *.a constructs in the output
567	  for ac_arg in $ac_[]_AC_LANG_ABBREV[]_v_output; do
568	     case $ac_arg in
569	        [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*)
570	          ac_cv_prog_[]_AC_LANG_ABBREV[]_v=$ac_verb
571	          break 2 ;;
572	     esac
573	  done
574	done
575	if test -z "$ac_cv_prog_[]_AC_LANG_ABBREV[]_v"; then
576	   AC_MSG_WARN([cannot determine how to obtain linking information from C])
577	fi],
578	                  [AC_MSG_WARN([compilation failed])])
579	])])
580
581
582	_AX_PROG_FC_V
583	AC_CACHE_CHECK([for C libraries], ac_cv_[]_AC_LANG_ABBREV[]_libs,
584	[if test "x$[]_AC_LANG_PREFIX[]LIBS" != "x"; then
585	  ac_cv_[]_AC_LANG_ABBREV[]_libs="$[]_AC_LANG_PREFIX[]LIBS" # Let the user override the test.
586	else
587
588	_AX_PROG_FC_V_OUTPUT
589
590	ac_cv_[]_AC_LANG_ABBREV[]_libs=
591
592	# Save positional arguments (if any)
593	ac_save_positional="$[@]"
594
595	set X $ac_[]_AC_LANG_ABBREV[]_v_output
596	while test $[@%:@] != 1; do
597	  shift
598	  ac_arg=$[1]
599	  case $ac_arg in
600	        [[\\/]]*.a | ?:[[\\/]]*.a)
601	          _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
602	              ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
603	          ;;
604	        -bI:*)
605	          _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
606	             [_AC_LINKER_OPTION([$ac_arg], ac_cv_[]_AC_LANG_ABBREV[]_libs)])
607	          ;;
608	          # Ignore these flags.
609	        -lang* | -lcrt[[01]].o | -lcrtbegin.o | -lc | -lgcc | -libmil | -LANG:=*)
610	          ;;
611	        -lkernel32)
612	          test x"$CYGWIN" != xyes && ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg"
613	          ;;
614	        -[[LRuY]])
615	          # These flags, when seen by themselves, take an argument.
616	          # We remove the space between option and argument and re-iterate
617	          # unless we find an empty arg or a new option (starting with -)
618	          case $[2] in
619	             "" | -*);;
620	             *)
621	                ac_arg="$ac_arg$[2]"
622	                shift; shift
623	                set X $ac_arg "$[@]"
624	                ;;
625	          esac
626	          ;;
627	        -YP,*)
628	          for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
629	            _AC_LIST_MEMBER_IF($ac_j, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
630	                               [ac_arg="$ac_arg $ac_j"
631	                               ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_j"])
632	          done
633	          ;;
634	        -[[lLR]]*)
635	          _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
636	                             ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
637	          ;;
638	          # Ignore everything else.
639	  esac
640	done
641	# restore positional arguments
642	set X $ac_save_positional; shift
643
644	# We only consider "LD_RUN_PATH" on Solaris systems.  If this is seen,
645	# then we insist that the "run path" must be an absolute path (i.e. it
646	# must begin with a "/").
647	case `(uname -sr) 2>/dev/null` in
648	   "SunOS 5"*)
649	      ac_ld_run_path=`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
650	                        sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`
651	      test "x$ac_ld_run_path" != x &&
652	        _AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_[]_AC_LANG_ABBREV[]_libs)
653	      ;;
654	esac
655	fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
656	])
657	[]_AC_LANG_PREFIX[]LIBS="$ac_cv_[]_AC_LANG_ABBREV[]_libs"
658	AC_SUBST([]_AC_LANG_PREFIX[]LIBS)
659fi
660
661########## Check Fortran Compilers ##########
662if test "$enable_fortran" = "yes" || test "$enable_f90" = "yes" || test "$enable_saamg" = "yes"; then
663  if test -z "$F77"; then
664    F77=$FC
665  fi
666  AC_LANG_PUSH(Fortran 77)
667  fflags_save="$FFLAGS"
668  AC_PROG_F77([ifort ifc efc xlf95_r xlf90_r xlf_r xlf95 xlf90 xlf ftn frt pgf95 pgf90 pathf95 pathf90 epcf90 f95 fort lf95 gfortran f90 g77])
669  FFLAGS="$fflags_save"
670  if test "$TARGET" = ""; then
671    if test "$enable_mpi" = "yes"; then
672      AC_CHECK_PROGS(MPIF77, mpxlf95_r mpxlf90_r mpxlf95 mpxlf90 mpifrt cmpifc cmpif90c mpf90 mpif90 hf77 mpxlf_r mpxlf mpf77 mpif77, $F77)
673      F77=$MPIF77
674    fi
675  fi
676  AC_LANG_POP(Fortran 77)
677  if test -n "$F77"; then
678    FC=$F77
679    MPIFC=$MPIF77
680  fi
681fi
682
683if test "$enable_f90" = "yes" || test "$enable_saamg" = "yes"; then
684  AC_LANG_PUSH(Fortran)
685  fcflags_save="$FCFLAGS"
686  AC_PROG_FC([ifort ifc efc xlf95_r xlf90_r xlf_r xlf95 xlf90 xlf ftn frt pgf95 pgf90 pathf95 pathf90 epcf90 f95 fort lf95 gfortran f90])
687  FCFLAGS="$fcflags_save"
688  if test "$TARGET" = ""; then
689    if test "$enable_mpi" = "yes"; then
690      AC_CHECK_PROGS(MPIFC, mpxlf95_r mpxlf90_r mpxlf95 mpxlf90 mpifrt cmpifc cmpif90c mpf90 mpif90 hf77, $F77)
691      FC=$MPIFC
692    fi
693  fi
694# AC_FC_SRCEXT(F90)
695  AC_LANG_POP(Fortran)
696fi
697
698########## Check Fortran Flags ##########
699if test "$TARGET" = ""; then
700  AC_LANG_PUSH(Fortran 77)
701  ac_ext=F
702  for ventest in intel:__INTEL_COMPILER ibm:__IBMC__ gnu:__GNUC__ sun:__SUNPRO_F77,__SUNPRO_F90,__SUNPRO_F95 portland:__PGI pathscale:__PATHCC__,__PATHSCALE__; do
703    vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
704    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
705#if !($vencpp)
706      thisisanerror;
707#endif
708])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
709  done
710  AC_MSG_CHECKING([for Fortran compiler vendor])
711  AC_MSG_RESULT($[ax_cv_]_AC_LANG_ABBREV[_compiler_vendor])
712  AC_LANG_POP(Fortran 77)
713  case $ax_cv_f77_compiler_vendor in
714    gnu) FFLAGS="-O3 -fomit-frame-pointer $FFLAGS"
715         FCFLAGS="-O3 -fomit-frame-pointer $FCFLAGS" ;;
716    intel) FFLAGS="-fpp $FFLAGS"
717         FCFLAGS="-fpp $FCFLAGS"
718         LDFLAGS="-Vaxlib"
719         FCLDFLAGS="-nofor_main" ;;
720    portland) FFLAGS="-O3 -fastsse -Mpreprocess $FFLAGS"
721         FCFLAGS="-O3 -fastsse -Mpreprocess $FCFLAGS"
722         FCLDFLAGS="-Mnomain" ;;
723    pathscale) FFLAGS="-O3 $FFLAGS" ;;
724    ibm) FFLAGS="-O3 -qsuffix=cpp=F -qfixed=72 -w -qarch=auto -qtune=auto $FFLAGS"
725         FCFLAGS="-O3 -qsuffix=cpp=F90 -w -qarch=auto -qtune=auto $FCFLAGS" ;;
726    sun) case `(uname -m) 2>/dev/null` in
727	   "i86pc") FFLAGS="-fpp -xtarget=native -xO5 -dalign $FFLAGS"
728		    FCFLAGS="-fpp -xtarget=native -xO5 -dalign $FCFLAGS"
729                    FCLDFLAGS="-xO5" ;;
730	         *) FFLAGS="-fpp -xtarget=native64 -xO5 -dalign $FFLAGS"
731                    FCFLAGS="-fpp -xtarget=native64 -xO5 -dalign $FCFLAGS"
732		    FCLDFLAGS="-xO5" ;;
733   	 esac
734	 ;;
735  esac
736
737  if test x$ax_cv_c_compiler_vendor = x$ax_cv_f77_compiler_vendor; then
738    CLIBS=""
739  fi
740fi
741
742if test "$enable_fortran" = "yes" || test "$enable_f90" = "yes" || test "$enable_saamg" = "yes"; then
743  AC_LANG_PUSH(Fortran 77)
744  if test "$ax_cv_f77_compiler_vendor" = "sun"; then
745    ax_f77_mangling="lower case, underscore, no extra underscore"
746  fi
747  if test -z "$ax_f77_mangling"; then
748    AC_F77_WRAPPERS
749    AC_F77_DUMMY_MAIN
750  else
751    case $ax_f77_mangling in
752      "lower case, no underscore, no extra underscore")
753        AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name])
754        AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name])
755      ;;
756      "lower case, no underscore, extra underscore")
757        AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name])
758        AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _])
759      ;;
760      "lower case, underscore, no extra underscore")
761        AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _])
762        AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _])
763      ;;
764      "lower case, underscore, extra underscore")
765        AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _])
766        AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## __])
767      ;;
768      "upper case, no underscore, no extra underscore")
769        AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME])
770        AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME])
771      ;;
772      "upper case, no underscore, extra underscore")
773        AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME])
774        AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _])
775      ;;
776      "upper case, underscore, no extra underscore")
777        AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _])
778        AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _])
779      ;;
780      "upper case, underscore, extra underscore")
781        AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _])
782        AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## __])
783      ;;
784    esac
785  fi
786  AC_LANG_POP(Fortran 77)
787fi
788
789
790# Configurations for Build Options
791
792######### Enable Fortran Interface ##########
793if test "$enable_fortran" = "yes"; then
794  AC_DEFINE([USE_FORTRAN], [1], [Define to 1 to enable Fortran subroutines.])
795else
796  enable_fortran="no"
797  if test "$enable_f90" = "yes"; then
798    AC_DEFINE([USE_FORTRAN], [1], [Define to 1 to enable Fortran subroutines.])
799    enable_fortran="yes"
800  else
801    enable_f90="no"
802  fi
803fi
804if test "$enable_fortran" = "yes"; then
805  if test "$CC" = "fcc"; then
806    AC_DEFINE([USE_MAIN__], [1], [Use MAIN__ macro with Fortran.])
807  else
808    if test "$CC" = "mpifcc"; then
809      AC_DEFINE([USE_MAIN__], [1], [Use MAIN__ macro with Fortran.])
810    fi
811  fi
812fi
813
814######### Enable SA-AMG Preconditioner ##########
815if test "$enable_saamg" = "yes"; then
816  AC_DEFINE([USE_FORTRAN], [1], [Define to 1 to enable Fortran subroutines.])
817  AC_DEFINE([USE_SAAMG], [1], [Define to 1 to enable SA-AMG preconditioner.])
818  case $ax_cv_f77_compiler_vendor in
819    ibm) FCFLAGS="$FCFLAGS -WF,-DZERO_ORIGIN=1" ;;
820    gnu) FCFLAGS="$FCFLAGS -Wp,-DZERO_ORIGIN=1" ;;
821    hitachi) FCFLAGS="$FCFLAGS" ;;
822    *)   FCFLAGS="$FCFLAGS -DZERO_ORIGIN=1" ;;
823  esac
824else
825  enable_saamg="no"
826fi
827if test "$enable_fortran" = "yes"; then
828  if test "$CC" = "fcc"; then
829    AC_DEFINE([USE_MAIN__], [1], [Use MAIN__ macro with Fortran.])
830  else
831    if test "$CC" = "mpifcc"; then
832      AC_DEFINE([USE_MAIN__], [1], [Use MAIN__ macro with Fortran.])
833    fi
834  fi
835else
836  if test "$enable_saamg" = "yes"; then
837    if test "$CC" = "fcc"; then
838      AC_DEFINE([USE_MAIN__], [1], [Use MAIN__ macro with Fortran.])
839    else
840      if test "$CC" = "mpifcc"; then
841        AC_DEFINE([USE_MAIN__], [1], [Use MAIN__ macro with Fortran.])
842      fi
843    fi
844  fi
845fi
846
847########## Enable MPI and OpenMP Directives ##########
848if test "$TARGET" = ""; then
849  if test -z "$enable_mpi"; then
850    enable_mpi="no"
851    MPIRUN=""
852  else
853    if test -z "$MPIRUN"; then
854      AC_CHECK_PROGS(MPIRUN, mpirun mpiexec, mpirun)
855    fi
856    if test -z "$MPINP"; then
857      if test "$MPIRUN" = "mpiexec"; then
858        MPINP="-n"
859      else
860        MPINP="-np"
861      fi
862    fi
863  fi
864  if test "$enable_omp" = "yes"; then
865    save_cflags="$CFLAGS"
866    openmp_flags="-openmp -qopenmp -qsmp=omp -xopenmp -fopenmp -KOMP -mp -omp -Popenmp none"
867    for ompf in $openmp_flags; do
868      AC_MSG_CHECKING([for OpenMP flag $ompf])
869      case $ompf in
870        none) CFLAGS=$save_cflags ;;
871           *) CFLAGS="$save_cflags $ompf" ;;
872      esac
873      AC_TRY_LINK([#include <omp.h>], [
874        #pragma omp parallel
875        omp_set_num_threads(1)
876      ], [OMPFLAG=$ompf;    AC_MSG_RESULT(yes); break])
877      AC_MSG_RESULT(no)
878    done
879    CFLAGS=$save_cflags
880    if test "$OMPFLAG" = ""; then
881      enable_omp="not found"
882    else
883      if test "$OMPFLAG" = "none"; then
884        OMPFLAG=""
885      fi
886    fi
887  else
888    case $ax_cv_c_compiler_vendor in
889        hitachi) OMPFLAG="-noparallel" ;;
890    esac
891    case $ax_cv_f77_compiler_vendor in
892        hitachi) OMPFLAG="-noparallel" ;;
893    esac
894    enable_omp="no"
895
896  fi
897fi
898
899if test "$enable_mpi" = "yes"; then
900  CC=$MPICC
901  F77=$MPIF77
902  FC=$MPIFC
903  CFLAGS="$CFLAGS -DUSE_MPI"
904  case $ax_cv_f77_compiler_vendor in
905    ibm) FCFLAGS="$FCFLAGS -WF,-DUSE_MPI"
906         FFLAGS="$FFLAGS -WF,-DUSE_MPI"
907         ;;
908    gnu) FCFLAGS="$FCFLAGS -Wp,-DUSE_MPI"
909         FFLAGS="$FFLAGS -Wp,-DUSE_MPI"
910         ;;
911    *)   FCFLAGS="$FCFLAGS -DUSE_MPI"
912         FFLAGS="$FFLAGS -DUSE_MPI"
913         ;;
914  esac
915else
916  enable_mpi="no"
917fi
918
919if test "$enable_omp" = "yes"; then
920  if test "$OMPFLAG" != ""; then
921    CFLAGS="$CFLAGS $OMPFLAG"
922    FFLAGS="$FFLAGS $OMPFLAG"
923    FCFLAGS="$FCFLAGS $OMPFLAG"
924    LDFLAGS="$LDFLAGS $OMPFLAG"
925  fi
926fi
927
928########## Enable x87 FPUs ##########
929  AC_MSG_CHECKING([for x87 FPU])
930  case $target in
931    i*86-* | x86*) AC_MSG_RESULT(yes)
932         AC_DEFINE([HAS_X87_FPU], [1], [Define to 1 to enable x87 FPU.])
933         ;;
934    *)   AC_MSG_RESULT(no) ;;
935  esac
936#  enable_sse2="no"
937
938if test "$enable_quad" = "yes"; then
939
940########## Enable Intel Streaming SIMD Extensions ##########
941#  enable_sse2="yes"
942if test "$enable_sse2" = "yes"; then
943  AC_MSG_CHECKING([for SSE2])
944  AC_TRY_COMPILE([#include <emmintrin.h>],[
945    __m128d xs;
946    double hi;
947    xs  = _mm_set_pd(1.0,1.0);
948    _mm_store_sd(&hi,xs);
949  ],[AC_MSG_RESULT(yes)
950  AC_DEFINE([USE_SSE2], [1], [Define to 1 to enable quad precision operations using SSE2.])
951  AC_DEFINE([USE_FMA2_SSE2], [1], [Define to 1 to enable quad precision operations using FMA and SSE2.])
952  ], [enable_sse2="no"; AC_MSG_RESULT(no)])
953fi
954  if test "$TARGET" = ""; then
955    if test "$enable_sse2" != "yes"; then
956      save_cflags="$CFLAGS"
957      case $ax_cv_c_compiler_vendor in
958        intel) quad_flags="-mp" ;;
959        ibm)   quad_flags="-qstrict none" ;;
960        sun)   quad_flags="-fsimple=0 none" ;;
961        *)   quad_flags="none" ;;
962      esac
963      if test "$MPFLAG" != ""; then
964        quad_flags="$MPFLAG $quad_flags"
965      fi
966      for mpf in $quad_flags; do
967        case $ax_cv_c_compiler_vendor in
968          sun) mpf="$mpf -fns=no" ;;
969        esac
970        case $mpf in
971          none) CFLAGS=$save_cflags ;;
972             *) CFLAGS="$save_cflags $mpf" ;;
973        esac
974        AC_MSG_CHECKING([for mp flag $mpf])
975        AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>],[[double r,e;
976  		double a=1.0;
977		double b=1.1e-16;
978		r=a+b;
979		e=b-(r-a);
980                printf("r=%e e=%e ",r,e);
981		if(e==0.0) return 1;
982        ]])],
983        [MPFLAG=$mpf;    AC_MSG_RESULT(yes); break],
984        AC_MSG_RESULT(no))
985      done
986      CFLAGS=$save_cflags
987      if test "$MPFLAG" = ""; then
988        enable_quad="not found"
989      else
990        if test "$MPFLAG" = "none"; then
991          MPFLAG=""
992        fi
993      fi
994    fi
995  fi
996  if test "$enable_quad" = "yes"; then
997    AC_DEFINE([USE_QUAD_PRECISION], [1], [Define to 1 to enable quad precision operations.])
998    AC_DEFINE([USE_FAST_QUAD_ADD], [1], [Define to 1 to enable quad precision operations using fast quad add.])
999    if test "$enable_sse2" = "yes"; then
1000	  case $ax_cv_c_compiler_vendor in
1001	    gnu) MPFLAG="-msse2" ;;
1002	  esac
1003    fi
1004  fi
1005else
1006  enable_quad="no"
1007fi
1008
1009########## Enable SIMD Optimization for Intel Fused Multiply and Add ##########
1010if test "$enable_fma" = "yes"; then
1011  AC_DEFINE([HAS_FMA], [1], [Define to 1 to enable quad precision operations using FMA.])
1012  case $ax_cv_c_compiler_vendor in
1013    intel) MPFLAG="$MPFLAG -fma" ;;
1014  esac
1015else
1016  enable_fma="no"
1017fi
1018
1019########## Enable Vectorization for NEC SX Series ##########
1020if test "$ax_vector_machine" = "yes"; then
1021  AC_DEFINE([USE_VEC_COMP], [1], [Define to 1 to use vectorization.])
1022else
1023  ax_vector_machine="no"
1024fi
1025
1026########## Enable Debugging ###########
1027if test "$enable_debug" = "yes"; then
1028  CFLAGS="$CFLAGS -g -D_DEBUG"
1029  if test "$enable_fortran" = "yes"; then
1030    FFLAGS="$FFLAGS -g -DDEBUG"
1031    case $ax_cv_f77_compiler_vendor in
1032      ibm) FCFLAGS="$FCFLAGS -g -WF,-DDEBUG" ;;
1033      gnu) FCFLAGS="$FCFLAGS -g -Wp,-DDEBUG" ;;
1034      *)   FCFLAGS="$FCFLAGS -g -DDEBUG" ;;
1035    esac
1036  fi
1037else
1038  enable_debug="no"
1039fi
1040
1041########## Enable Profiling ##########
1042if test "$enable_gprof" = "yes"; then
1043  case $ax_cv_c_compiler_vendor in
1044    sun)     CFLAGS="$CFLAGS -xpg"
1045             FFLAGS="$FFLAGS -xpg"
1046             FCFLAGS="$FCFLAGS -xpg"
1047             LDFLAGS="$LDFLAGS -xpg"
1048             ;;
1049    fujitsu) CFLAGS="$CFLAGS -p"
1050             FFLAGS="$FFLAGS -p"
1051             FCFLAGS="$FCFLAGS -p"
1052             LDFLAGS="$LDFLAGS -p"
1053             ;;
1054    hp)      CFLAGS="$CFLAGS -p"
1055             FFLAGS="$FFLAGS -p"
1056             FCFLAGS="$FCFLAGS -p"
1057             LDFLAGS="$LDFLAGS -p"
1058             ;;
1059    gnu)     CFLAGS="$CFLAGS -fno-omit-frame-pointer -pg"
1060             FFLAGS="$FFLAGS -fno-omit-frame-pointer -pg"
1061             FCFLAGS="$FCFLAGS -fno-omit-frame-pointer -pg"
1062             LDFLAGS="$LDFLAGS -fno-omit-frame-pointer -pg"
1063             ;;
1064    *)       CFLAGS="$CFLAGS -pg"
1065             FFLAGS="$FFLAGS -pg"
1066             FCFLAGS="$FCFLAGS -pg"
1067             LDFLAGS="$LDFLAGS -pg"
1068             ;;
1069  esac
1070else
1071  enable_gprof="no"
1072fi
1073
1074########## Enable 64bit Binary Executables ##########
1075if test "$enable_64bit" = "yes"; then
1076  case $ax_cv_c_compiler_vendor in
1077    sun)     CFLAGS="$CFLAGS -m64"
1078             FFLAGS="$FFLAGS -m64"
1079             FCFLAGS="$FCFLAGS -m64"
1080             LDFLAGS="$LDFLAGS -m64"
1081             ;;
1082    ibm)     CFLAGS="$CFLAGS -q64"
1083             FFLAGS="$FFLAGS -q64"
1084             FCFLAGS="$FCFLAGS -q64"
1085             LDFLAGS="$LDFLAGS -q64"
1086             ;;
1087  esac
1088else
1089  enable_64bit="no"
1090fi
1091
1092########## Enable 64bit Integer ##########
1093if test "$enable_longlong" = "yes"; then
1094
1095  case $ax_cv_c_compiler_vendor in
1096    sun)     CFLAGS="$CFLAGS -m64"
1097             FFLAGS="$FFLAGS -m64"
1098             FCFLAGS="$FCFLAGS -m64"
1099             LDFLAGS="$LDFLAGS -m64"
1100             ;;
1101    ibm)     CFLAGS="$CFLAGS -q64"
1102             FFLAGS="$FFLAGS -q64"
1103             FCFLAGS="$FCFLAGS -q64"
1104             LDFLAGS="$LDFLAGS -q64"
1105             ;;
1106  esac
1107  CFLAGS="$CFLAGS -D_LONG__LONG"
1108
1109  case $ax_cv_f77_compiler_vendor in
1110    intel) FFLAGS="$FFLAGS -DLONG__LONG -integer-size 64"
1111         FCFLAGS="$FCFLAGS -DLONG__LONG -integer-size 64"
1112	 ;;
1113    ibm) FFLAGS="$FFLAGS -WF,-DLONG__LONG -qintsize=8"
1114         FCFLAGS="$FCFLAGS -WF,-DLONG__LONG -qintsize=8"
1115	 ;;
1116    fujitsu) FFLAGS="$FFLAGS -DLONG__LONG -CcdII8"
1117         FCFLAGS="$FCFLAGS -DLONG__LONG -CcdII8"
1118         ;;
1119    gnu) FFLAGS="$FFLAGS -Wp,-DLONG__LONG -fdefault-integer-8"
1120         FCFLAGS="$FCFLAGS -Wp,-DLONG__LONG -fdefault-integer-8"
1121         ;;
1122    *)   FFLAGS="$FFLAGS -DLONG__LONG"
1123	 FCFLAGS="$FCFLAGS -DLONG__LONG"
1124	 ;;
1125  esac
1126else
1127  enable_longlong="no"
1128fi
1129
1130########## Enable Long Double (Quadruple) Precision Operations ##########
1131if test "$enable_longdouble" = "yes"; then
1132
1133  case $ax_cv_c_compiler_vendor in
1134    ibm)     CFLAGS="$CFLAGS -qldbl128"
1135             ;;
1136  esac
1137  CFLAGS="$CFLAGS -D_LONG__DOUBLE"
1138
1139  case $ax_cv_f77_compiler_vendor in
1140    intel) FFLAGS="$FFLAGS -DLONG__DOUBLE -real-size 128"
1141         FCFLAGS="$FCFLAGS -DLONG__DOUBLE -real-size 128"
1142	 ;;
1143    *)   FFLAGS="$FFLAGS -DLONG__DOUBLE"
1144	 FCFLAGS="$FCFLAGS -DLONG__DOUBLE"
1145	 ;;
1146  esac
1147else
1148  enable_longdouble="no"
1149fi
1150
1151
1152########## Enable Complex Scalar Operations ##########
1153AC_CHECK_HEADERS([complex.h])
1154if test "$enable_complex" = "yes"; then
1155  AC_DEFINE([USE_COMPLEX], [1], [Define to 1 to enable complex scalar operations.])
1156  if test -z "$HAVE_COMPLEX_H"; then
1157    CFLAGS="$CFLAGS -D_COMPLEX"
1158    FFLAGS="$FFLAGS -DCOMPLEX"
1159    FCFLAGS="$FCFLAGS -DCOMPLEX"
1160  else
1161    AC_MSG_WARN([no complex.h])
1162    enable_complex="no"
1163  fi
1164else
1165  enable_complex="no"
1166fi
1167
1168
1169########## Enable Quadmath Operations ##########
1170AC_CHECK_HEADERS([quadmath.h])
1171if test "$enable_longdouble" = "yes"; then
1172  if test -z "$HAVE_QUADMATH_H"; then
1173    CFLAGS="$CFLAGS -lquadmath"
1174    FFLAGS="$FFLAGS -lquadmath"
1175    FCFLAGS="$FCFLAGS -lquadmath"
1176    AC_MSG_WARN([GCC libquadmath is used if long double is enabled])
1177  fi
1178fi
1179
1180
1181# Configurations for Environment-Dependent Data Sizes
1182
1183########## Check Size of int ##########
1184if test "$TARGET" = ""; then
1185  AC_CHECK_SIZEOF(int)
1186else
1187  AC_DEFINE([SIZEOF_INT], [$ac_cv_sizeof_int], [Test the size of a `int', as computed by sizeof.])
1188fi
1189
1190########## Check Size of long int ##########
1191if test "$TARGET" = ""; then
1192  AC_CHECK_SIZEOF(long)
1193else
1194  AC_DEFINE([SIZEOF_LONG], [$ac_cv_sizeof_long], [Test the size of a `long', as computed by sizeof.])
1195fi
1196
1197########## Check Size of long long int ##########
1198if test "$TARGET" = ""; then
1199  AC_CHECK_SIZEOF(long long)
1200else
1201  AC_DEFINE([SIZEOF_LONG_LONG], [$ac_cv_sizeof_long_long], [Test the size of a `long long', as computed by sizeof.])
1202fi
1203
1204########## Check Size of float ##########
1205if test "$TARGET" = ""; then
1206  AC_CHECK_SIZEOF(float)
1207else
1208  AC_DEFINE([SIZEOF_FLOAT], [$ac_cv_sizeof_float], [Test the size of a `float', as computed by sizeof.])
1209fi
1210
1211########## Check Size of double ##########
1212if test "$TARGET" = ""; then
1213  AC_CHECK_SIZEOF(double)
1214else
1215  AC_DEFINE([SIZEOF_DOUBLE], [$ac_cv_sizeof_double], [Test the size of a `double', as computed by sizeof.])
1216fi
1217
1218########## Check Size of long double ##########
1219if test "$TARGET" = ""; then
1220  AC_CHECK_SIZEOF(long double)
1221else
1222  AC_DEFINE([SIZEOF_LONG_DOUBLE], [$ac_cv_sizeof_long_double], [Test the size of a `long double', as computed by sizeof.])
1223fi
1224
1225########## Check Size of __float128 ##########
1226if test -z "$HAVE_QUADMATH_H"; then
1227  if test "$TARGET" = ""; then
1228    AC_CHECK_SIZEOF(__float128)
1229  else
1230    AC_DEFINE([SIZEOF_LONG_DOUBLE], [$ac_cv_sizeof___float128], [Test the size of a `__float128', as computed by sizeof.])
1231  fi
1232fi
1233
1234########## Check Size of size_t ##########
1235if test "$TARGET" = ""; then
1236  AC_CHECK_SIZEOF(size_t)
1237else
1238  AC_DEFINE([SIZEOF_SIZE_T], [$ac_cv_sizeof_size_t], [Test the size of a `size_t', as computed by sizeof.])
1239fi
1240
1241########## Check Size of void_p ##########
1242if test "$TARGET" = ""; then
1243  AC_CHECK_SIZEOF(void *)
1244else
1245  AC_DEFINE([SIZEOF_VOID_P], [$ac_cv_sizeof_void_p], [Test the size of a `void *', as computed by sizeof.])
1246fi
1247
1248
1249# Configurations for Autotools
1250
1251AC_DISABLE_SHARED
1252AC_PROG_LIBTOOL
1253AC_PROG_INSTALL
1254
1255AM_CONDITIONAL(ENABLE_FORTRAN, test x$enable_fortran = xyes)
1256AM_CONDITIONAL(ENABLE_F90, test x$enable_f90 = xyes)
1257if test "$enable_f90" = "yes" ; then
1258  AM_CONDITIONAL(ENABLE_FORTRAN, test x$enable_f90 = xyes)
1259fi
1260AM_CONDITIONAL(ENABLE_SAAMG, test x$enable_saamg = xyes)
1261AM_CONDITIONAL(ENABLE_MPI, test x"$enable_mpi" = xyes)
1262AM_CONDITIONAL(ENABLE_OMP, test x"$enable_omp" = xyes)
1263AM_CONDITIONAL(ENABLE_QUAD, test x$enable_quad = xyes)
1264AM_CONDITIONAL(ENABLE_SSE2, test x$enable_sse2 = xyes)
1265AM_CONDITIONAL(DISABLE_TEST, test x$enable_test = xno)
1266AC_SUBST(enable_mpi)
1267AC_SUBST(enable_omp)
1268AC_SUBST(enable_saamg)
1269AC_SUBST(enable_quad)
1270AC_SUBST(enable_longdouble)
1271AC_SUBST(enable_complex)
1272AC_SUBST(enable_fortran)
1273AC_SUBST(enable_f90)
1274AC_SUBST(MPIRUN)
1275AC_SUBST(MPINP)
1276AC_SUBST(AMDEFS)
1277AC_SUBST(SIZEOF_VOID_P, $ac_cv_sizeof_void_p)
1278AC_SUBST(FCLDFLAGS)
1279
1280
1281# Configurations for Some Header Files
1282
1283AC_HEADER_STDC
1284AC_CHECK_HEADERS([malloc.h stdlib.h string.h sys/time.h])
1285
1286
1287# Configurations for Compiler Characteristics and Type Definitions
1288
1289AC_C_CONST
1290AC_TYPE_SIZE_T
1291
1292
1293# Configurations for Library Functions
1294
1295LIBS="-lm $LIBS"
1296
1297
1298# Output
1299
1300AC_CONFIG_FILES([Makefile
1301                 src/Makefile
1302                 src/vector/Makefile
1303                 src/matrix/Makefile
1304                 src/matvec/Makefile
1305                 src/array/Makefile
1306                 src/solver/Makefile
1307		 src/esolver/Makefile
1308                 src/precon/Makefile
1309                 src/system/Makefile
1310                 src/precision/Makefile
1311                 src/fortran/Makefile
1312                 src/fortran/amg/Makefile
1313                 include/Makefile
1314                 test/Makefile
1315                 include/lisf.h
1316                 ])
1317
1318DEFS="$DEFSADD $DEFS"
1319AC_OUTPUT()
1320
1321echo
1322echo "  Build with OpenMP library                  = $enable_omp"
1323echo "  Build with MPI library                     = $enable_mpi"
1324echo "  Enable FORTRAN 77 compatible interface     = $enable_fortran"
1325echo "  Enable Fortran 90 compatible interface     = $enable_f90"
1326echo "  Enable SA-AMG preconditioner               = $enable_saamg"
1327echo "  Enable double-double precision support     = $enable_quad"
1328if test "$enable_quad" = "yes"; then
1329echo "  Enable SSE2                                = $enable_sse2"
1330echo "  Enable FMA                                 = $enable_fma"
1331fi
1332echo "  Enable long double precision support       = $enable_longdouble"
1333echo "  Enable 64bit integer support               = $enable_longlong"
1334echo "  Enable complex scalar support              = $enable_complex"
1335if test "$enable_debug" = "yes"; then
1336echo "  Enable debugging                           = $enable_debug"
1337fi
1338echo "  Enable dynamic linking                     = $enable_shared"
1339echo "  Enable profiling                           = $enable_gprof"
1340echo
1341echo "  C compiler        = $CC"
1342echo "  C flags           = $CFLAGS $DEFS $MPFLAG $AMDEFS"
1343echo "  C libraries       = $LIBS $CLIBS"
1344
1345if test "$enable_fortran" = "yes"; then
1346    echo "  F77 compiler      = $F77"
1347    echo "  F77 flags         = $FFLAGS"
1348    echo "  F77 libraries     = $FLIBS"
1349fi
1350if test "$enable_f90" = "yes" || test "$enable_saamg" = "yes"; then
1351    echo "  F90 compiler      = $FC"
1352    echo "  F90 flags         = $FCFLAGS"
1353    echo "  F90 libraries     = $FCLIBS"
1354fi
1355if test "$enable_mpi" = "yes"; then
1356    echo "  MPI libraries     = $MPILIBS"
1357    echo "  MPIRUN script     = $MPIRUN"
1358fi
1359echo
1360