ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/oopse-1.0/ac-tools/aclocal.m4
Revision: 1447
Committed: Fri Jul 30 21:01:35 2004 UTC (19 years, 11 months ago) by gezelter
File size: 29981 byte(s)
Log Message:
Initial import of OOPSE sources into cvs tree

File Contents

# User Rev Content
1 gezelter 1447 dnl
2     dnl AC_CHECK_MODSUFFIX
3     dnl
4     AC_DEFUN([AC_CHECK_MODSUFFIX],[
5    
6     AC_MSG_CHECKING(for module suffix)
7     rm -f conftest*
8     # Intel ifc compiler generates files by the name of work.pc and work.pcl (!)
9     rm -f work*
10     cat >conftest.f90 <<EOF
11     module conftest
12     integer n
13     parameter (n=1)
14     end module conftest
15     EOF
16     # SGI and absoft compilers generates module name in upper case!
17     testname="conftest"
18     modcase="lower"
19     if $F90 -c conftest.f90 > conftest.out 2>&1 ; then
20     MOD=`ls conftest* | grep -v conftest.f | grep -v conftest.o`
21     MOD=`echo "$MOD" | sed -e 's/conftest\.//g'`
22     if test -z "$MOD" ; then
23     MOD=`ls CONFTEST* 2>/dev/null \
24     | grep -v CONFTEST.f | grep -v CONFTEST.o`
25     MOD=`echo "$MOD" | sed -e 's/CONFTEST\.//g'`
26     if test -n "$MOD" ; then
27     testname="CONFTEST"
28     modcase="upper"
29     fi
30     fi
31     if test -z "$MOD" ; then
32     AC_MSG_RESULT(unknown)
33     # Use mod if we can't figure it out
34     MOD="mod"
35     else
36     AC_MSG_RESULT($MOD)
37     fi
38     if test -s work.pcl ; then
39     AC_MSG_WARN([Compiler generates auxillery files!])
40     fi
41     else
42     AC_MSG_RESULT(unknown)
43     fi
44     AC_SUBST(MOD)
45    
46     ])
47    
48    
49     dnl
50     dnl AC_CHECK_MODDIRFLAG
51     dnl
52     AC_DEFUN([AC_CHECK_MODDIRFLAG],[
53    
54     # Check for module include path (some use -I, some (Solaris) use -M, some
55     # (absoft) use -p).
56     # Intel compilers use a wierd system: -cl,filename.pcl . If no file is
57     # specified, work.pcl and work.pc are created. However, if you specify
58     # a file, it must contain a the name of a file ending in .pc . Ugh!
59     # Use the module made above
60     AC_MSG_CHECKING(for module directory path flag)
61     rm -f conftest*
62     # Intel ifc compiler generates files by the name of work.pc and work.pcl (!)
63     rm -f work*
64     cat >conftest.f90 <<EOF
65     module conftest
66     integer n
67     parameter (n=1)
68     end module conftest
69     EOF
70     # SGI and absoft compilers generates module name in upper case!
71     testname="conftest"
72     if $F90 -c conftest.f90 > conftest.out 2>&1 ; then
73     mod=`ls CONFTEST* 2>/dev/null | grep -v CONFTEST.f | grep -v CONFTEST.o`
74     mod=`echo "$mod" | sed -e 's/CONFTEST\.//g'`
75     if test -n "$mod" ; then
76     testname="CONFTEST"
77     fi
78     madedir=0
79     if test ! -d conf ; then mkdir conf ; madedir=1; fi
80     cp $testname.$MOD conf
81     rm -f conftest* CONFTEST*
82     cat >conftest1.f90 <<EOF
83     program main
84     use conftest
85     print *, n
86     end
87     EOF
88     F90_WORK_FILES_ARG=""
89     F90MODINCSPEC=""
90     if $F90 -c -Iconf conftest1.f90 > conftest.out 2>&1 ; then
91     MODDIRFLAG="-I"
92     F90MODINCSPEC="-I<dir>"
93     AC_MSG_RESULT(-I)
94     elif $F90 -c -Mconf conftest1.f90 >> conftest.out 2>&1 ; then
95     MODDIRFLAG="-M"
96     F90MODINCSPEC="-M<dir>"
97     AC_MSG_RESULT(-M)
98     elif $F90 -c -pconf conftest1.f90 >> conftest.out 2>&1 ; then
99     MODDIRFLAG="-p"
100     F90MODINCSPEC="-p<dir>"
101     AC_MSG_RESULT(-p)
102     elif test -s work.pc ; then
103     cp work.pc conf/mpimod.pc
104     echo "mpimod.pc" > conf/mpimod.pcl
105     echo "`pwd`/conf/mpimod.pc" >> conf/mpimod.pcl
106     if $F90 -c -cl,conf/mpimod.pcl conftest1.f >>conftest.out 2>&1 ; then
107     MODDIRFLAG='-cl,mpimod.pcl'
108     AC_MSG_RESULT([-cl,filename where filename contains a list of files and directories])
109     F90_WORK_FILES_ARG="-cl,mpimod.pcl"
110     F90MODINCSPEC="-cl,<dir>/<file>mod.pcl"
111     AC_SUBST(F90_WORK_FILES_ARG)
112     else
113     # The version of the Intel compiler that I have refuses to let
114     # you put the "work catalog" list anywhere but the current
115     # directory. For example, you cannot in
116     :
117     fi
118     fi
119     if test -z "MODDIRFLAG" ; then
120     AC_MSG_RESULT(unknown)
121     fi
122     AC_SUBST(MODDIRFLAG)
123     AC_SUBST(F90MODINCSPEC)
124     rm -f conftest* conf/conftest* conf/CONFTEST* CONFTEST* conf/mpimod*
125     if test $madedir = 1 ; then rmdir conf ; fi
126     fi
127    
128     ])
129    
130    
131     dnl
132     dnl AC_CHECK_MPI_F90MOD
133     dnl
134     AC_DEFUN([AC_CHECK_MPI_F90MOD],[
135    
136     AC_ARG_WITH(mpi_f90_mods, [ --with-mpi_f90_mods=<dir>
137     Location where MPI f90 modules are installed ],
138     mpi_f90_mods="$withval",
139     mpi_f90_mods="/usr/local/include/f90choice")
140    
141     AC_MSG_CHECKING(for MPI F90 modules)
142     AC_LANG_SAVE()
143     AC_LANG([Fortran 90])
144     ac_save_F90FLAGS=$F90FLAGS
145    
146     AS_IF([test "$mpi_f90_mods"], [F90FLAGS="${F90FLAGS} ${MODDIRFLAG}${mpi_f90_mods}"])
147     _AC_COMPILE_IFELSE([
148     AC_LANG_PROGRAM([
149     use mpi
150     integer :: ierr
151     call MPI_Init(ierr)
152     ])], [HAVE_MPI_MOD=1], [HAVE_MPI_MOD=0])
153    
154     F90FLAGS=$ac_save_F90FLAGS
155     AC_LANG_RESTORE()
156    
157     if test "$HAVE_MPI_MOD" = 1; then
158     AC_MSG_RESULT(yes)
159     AC_DEFINE(MPI_MOD, 1, [have mpi module])
160     MPI_F90_MODS="${mpi_f90_mods}"
161     AC_SUBST(MPI_F90_MODS)
162     # The library name:
163     if test -z "$MPI_LIB" ; then
164     MPI_LIBNAME=-lmpich
165     else
166     MPI_LIBNAME="$MPI_LIB"
167     fi
168     if test -z "$MPIMODLIBNAME" ; then
169     MPIMODLIBNAME="${MPI_LIBNAME}f90"
170     fi
171     AC_SUBST(MPIMODLIBNAME)
172     else
173     AC_MSG_RESULT(no)
174     AC_MSG_WARN([Couldn't locate MPI F90 Modules])
175     fi
176    
177     ])
178    
179    
180    
181    
182     dnl
183     dnl AM_PATH_SPRNG
184     dnl
185     AC_DEFUN([AM_PATH_SPRNG],[
186    
187     AC_ARG_WITH(sprng_prefix, [ --with-sprng_prefix=PREFIX
188     Prefix where SPRNG is installed ],
189     sprng_prefix="$withval",
190     sprng_prefix="/usr/local")
191     AC_ARG_WITH(sprng-libdir, [ --with-sprng-libdir=PREFIX SPRNG library directory],
192     sprng_libdir="$withval",
193     sprng_libdir="/usr/local/lib")
194     AC_ARG_WITH(sprng-include, [ --with-sprng-include=PREFIX
195     SPRNG include directory],
196     sprng_include="$withval",
197     sprng_include="/usr/local/include/sprng")
198    
199     if test x$sprng_libdir = x ; then
200     sprng_libdir=${sprng_prefix}/lib
201     fi
202    
203     if test x$sprng_include = x ; then
204     sprng_include=${sprng_prefix}/include
205     fi
206    
207     AC_MSG_CHECKING(for SPRNG include files in $sprng_include)
208     if test -f ${sprng_include}/sprng.h; then
209     have_sprngincl=yes
210     AC_MSG_RESULT(yes)
211     else
212     have_sprngincl=no
213     AC_MSG_RESULT(no)
214     AC_MSG_ERROR(Could not locate the SPRNG include files)
215     fi
216    
217     AC_MSG_CHECKING(for SPRNG libraries in $sprng_libdir)
218     if test -f ${sprng_libdir}/libsprng.a; then
219     have_sprnglib=yes
220     AC_MSG_RESULT(yes)
221     else
222     have_sprnglib=no
223     AC_MSG_RESULT(no)
224     AC_MSG_ERROR(Could not locate the SPRNG libraries)
225     fi
226    
227     AC_LANG_SAVE()
228     AC_LANG([C])
229     ac_save_CPPFLAGS=$CPPFLAGS
230     CPPFLAGS="${CPPFLAGS} -I${sprng_include}"
231     ac_save_LDFLAGS=$LDFLAGS
232     LDFLAGS="${LDFLAGS} -L${sprng_libdir} -lsprng"
233     AC_CHECK_HEADER(sprng.h, [
234     AC_CHECK_LIB(sprng,
235     init_rng,
236     [SPRNG_LIBDIR="${sprng_libdir}"
237     SPRNG_LIB="-lsprng" SPRNG_INC="-I${sprng_include}"
238     HAVE_SPRNG="yes"])])
239     CPPFLAGS=$ac_save_CPPFLAGS
240     LDFLAGS=$ac_save_LDFLAGS
241     AC_LANG_RESTORE()
242    
243     if test x_$HAVE_SPRNG != x_yes; then
244     AC_MSG_ERROR(Can't build with SPRNG)
245     fi
246     AC_SUBST(SPRNG_LIBDIR)
247     AC_SUBST(SPRNG_LIB)
248     AC_SUBST(SPRNG_INC)
249     AC_SUBST(HAVE_SPRNG)
250     ])
251    
252     dnl
253     dnl CHECK_MKL
254     dnl
255     AC_DEFUN([CHECK_MKL],
256     [AC_MSG_CHECKING(if MKL is wanted)
257     AC_ARG_WITH(mkl,
258     [ --with-mkl Do we want MKL [will check /usr/local/intel/mkl61 /opt/intel/mkl61]],
259     [ AC_MSG_RESULT(yes)
260     for dir in $withval /usr/local/intel/mkl61 /opt/intel/mkl61; do
261     mkldir="$dir"
262     if test -f "$dir/include/mkl.h"; then
263     found_mkl="yes";
264     break;
265     fi
266     done
267     if test x_$found_mkl != x_yes; then
268     AC_MSG_ERROR(Cannot find MKL includes)
269     else
270     printf "MKL includes found in $mkldir/include\n";
271     fi
272    
273     AC_LANG_SAVE()
274     AC_LANG([C])
275     ac_save_CPPFLAGS=$CPPFLAGS
276     CPPFLAGS="${CPPFLAGS} -I${mkldir}/include"
277     ac_save_LDFLAGS=$LDFLAGS
278     LDFLAGS="${LDFLAGS} -L${mkldir}/lib/32 -lmkl -lvml -lguide"
279     AC_CHECK_HEADER(mkl.h, [
280     AC_CHECK_LIB(mkl,
281     vslNewStream,
282     [MKL_LIBDIR="${mkldir}/lib/32",
283     MKL_LIB="-lmkl -lvml -lguide",
284     HAVE_MKL="yes"])
285     ], [MKL_INC="-I${mkldir}/include"])
286     CPPFLAGS=$ac_save_CPPFLAGS
287     LDFLAGS=$ac_save_LDFLAGS
288     AC_LANG_RESTORE()
289    
290     if test x_$HAVE_MKL != x_yes; then
291     AC_MSG_ERROR(Can't build with MKL)
292     fi
293     AC_SUBST(MKL_LIBDIR)
294     AC_SUBST(MKL_LIB)
295     AC_SUBST(MKL_INC)
296     AC_SUBST(HAVE_MKL)
297     ],
298     [
299     AC_MSG_RESULT(no)
300     ])
301     ])
302     dnl
303    
304    
305     AC_DEFUN(ACX_CHECK_CC_FLAGS,
306     [
307     AC_REQUIRE([AC_PROG_CC])
308     AC_CACHE_CHECK(whether ${CC-cc} accepts $1, ac_$2,
309     [echo 'void f(){}' > conftest.c
310     if test -z "`${CC-cc} $1 -c conftest.c 2>&1`"; then
311     ac_$2=yes
312     else
313     ac_$2=no
314     fi
315     rm -f conftest*
316     ])
317     if test "$ac_$2" = yes; then
318     :
319     $3
320     else
321     :
322     $4
323     fi
324     ])
325    
326     AC_DEFUN(ACX_CHECK_CXX_FLAGS,
327     [
328     AC_REQUIRE([AC_PROG_CXX])
329     AC_CACHE_CHECK(whether ${CXX-c++} accepts $1, ac_$2,
330     [echo 'void f(){}' > conftest.cpp
331     if test -z "`${CXX-c++} $1 -c conftest.cpp 2>&1`"; then
332     ac_$2=yes
333     else
334     ac_$2=no
335     fi
336     rm -f conftest*
337     ])
338     if test "$ac_$2" = yes; then
339     :
340     $3
341     else
342     :
343     $4
344     fi
345     ])
346    
347     dnl -------------------------------------------------------------------------
348     dnl ACX_CHECK_F90_FLAGS()
349     dnl
350     dnl Check for optimizer flags the Fortran compiler can use.
351     dnl
352     AC_DEFUN(ACX_CHECK_F90_FLAGS,
353     [
354     AC_CACHE_CHECK(whether ${F90-f90} accepts $1, ac_$2,
355     [
356     AC_LANG_SAVE
357     AC_LANG([Fortran 90])
358     echo 'program main' > conftest.$ac_ext
359     echo 'end program main' >> conftest.$ac_ext
360     ac_compile='${F90-f90} -c $1 $F90FLAGS conftest.$ac_ext 1>&AC_FD_CC'
361     if AC_TRY_EVAL(ac_compile); then
362     ac_$2=yes
363     else
364     ac_$2=no
365     fi
366     rm -f conftest*
367     AC_LANG_RESTORE()
368     ])
369     if test "$ac_$2" = yes; then
370     :
371     $3
372     else
373     :
374     $4
375     fi
376     ])
377    
378     AC_DEFUN(ACX_PROG_GCC_VERSION,
379     [
380     AC_REQUIRE([AC_PROG_CC])
381     AC_CACHE_CHECK(whether we are using gcc $1.$2 or later, ac_cv_prog_gcc_$1_$2,
382     [
383     dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
384     cat > conftest.c <<EOF
385     #ifdef __GNUC__ && !defined (__INTEL_COMPILER)
386     # if (__GNUC__ > $1) || (__GNUC__ == $1 && __GNUC_MINOR__ >= $2)
387     yes;
388     # endif
389     #endif
390     EOF
391     if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
392     ac_cv_prog_gcc_$1_$2=yes
393     else
394     ac_cv_prog_gcc_$1_$2=no
395     fi
396     ])
397     if test "$ac_cv_prog_gcc_$1_$2" = yes; then
398     :
399     $3
400     else
401     :
402     $4
403     fi
404     ])
405    
406     AC_DEFUN(ACX_PROG_GXX_VERSION,
407     [
408     AC_REQUIRE([AC_PROG_CXX])
409     AC_CACHE_CHECK(whether we are using g++ $1.$2 or later, ac_cv_prog_gxx_$1_$2,
410     [
411     dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
412     cat > conftest.cpp <<EOF
413     #ifdef __GNUC__ && !defined (__INTEL_COMPILER)
414     # if (__GNUC__ > $1) || (__GNUC__ == $1 && __GNUC_MINOR__ >= $2)
415     yes;
416     # endif
417     #endif
418     EOF
419     if AC_TRY_COMMAND(${CXX-c++} -E conftest.cpp) | egrep yes >/dev/null 2>&1; then
420     ac_cv_prog_gxx_$1_$2=yes
421     else
422     ac_cv_prog_gxx_$1_$2=no
423     fi
424     ])
425     if test "$ac_cv_prog_gxx_$1_$2" = yes; then
426     :
427     $3
428     else
429     :
430     $4
431     fi
432     ])
433    
434     AC_DEFUN(ACX_PROG_REALLY_GCC,
435     [
436     AC_REQUIRE([AC_PROG_CC])
437     AC_CACHE_CHECK(whether we are *really* using GNU cc, ac_cv_prog_really_gcc,
438     [
439     dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
440     cat > conftest.c <<EOF
441     #ifdef __GNUC__
442     #ifndef __INTEL_COMPILER
443     yes;
444     #endif
445     #endif
446     EOF
447     if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
448     ac_cv_prog_really_gcc=yes
449     else
450     ac_cv_prog_really_gcc=no
451     fi
452     ])
453     if test "$ac_cv_prog_really_gcc" = yes; then
454     :
455     $1
456     else
457     :
458     $2
459     fi
460     ])
461    
462     AC_DEFUN(ACX_PROG_REALLY_GXX,
463     [
464     AC_REQUIRE([AC_PROG_CXX])
465     AC_CACHE_CHECK(whether we are *really* using GNU c++, ac_cv_prog_really_gxx,
466     [
467     dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
468     cat > conftest.cpp <<EOF
469     #ifdef __GNUC__
470     #ifndef __INTEL_COMPILER
471     yes;
472     #endif
473     #endif
474     EOF
475     if AC_TRY_COMMAND(${CXX-c++} -E conftest.cpp) | egrep yes >/dev/null 2>&1; then
476     ac_cv_prog_really_gxx=yes
477     else
478     ac_cv_prog_really_gxx=no
479     fi
480     ])
481     if test "$ac_cv_prog_really_gxx" = yes; then
482     :
483     $1
484     else
485     :
486     $2
487     fi
488     ])
489    
490    
491     AC_DEFUN(ACX_PROG_CC_MAXOPT,
492     [
493     AC_REQUIRE([AC_PROG_CC])
494     AC_REQUIRE([AC_CANONICAL_HOST])
495    
496     ACX_PROG_REALLY_GCC
497    
498     # Try to determine "good" native compiler flags if none specified on command
499     # line
500     if test "$ac_test_CFLAGS" != "set"; then
501     CFLAGS=""
502     case "${host_cpu}-${host_os}" in
503    
504     *linux*) if test "$CC" = icc; then
505     CFLAGS="-O"
506     fi;;
507     sparc-solaris2*) if test "$CC" = cc; then
508     CFLAGS="-native -fast -xO5 -dalign"
509     fi;;
510    
511     alpha*-osf*) if test "$CC" = cc; then
512     CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host -arch host -std1"
513     fi;;
514    
515     hppa*-hpux*) if test "$CC" = cc; then
516     CFLAGS="-Ae +O3 +Oall"
517     fi;;
518    
519     rs6000*-aix*) if test "$CC" = cc -o "$CC" = xlc; then
520     CFLAGS="-O3 -qtune=auto -qansialias -w"
521     fi;;
522     powerpc*-aix*)
523     if test "$CC" = cc -o "$CC" = xlc; then
524     CFLAGS="-O3 -qtune=auto -qansialias -w"
525     echo "*******************************************************"
526     echo "* You have AIX on an unknown powerpc system. It is *"
527     echo "* recommended that you use *"
528     echo "* *"
529     echo "* CFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
530     echo "* ^^^ *"
531     echo "* where xxx is 601, 603, 604, or whatever kind of *"
532     echo "* PowerPC CPU you have. For more info, man cc. *"
533     echo "*******************************************************"
534     fi;;
535     *darwin*)
536     if test "$CC" = xlc -o "$CC" = cc; then
537     CFLAGS="-qthreaded -O5 -qtune=auto -qarch=auto -qunroll=auto -qaltivec"
538     fi;;
539     esac
540    
541     # use default flags for gcc on all systems
542     if test $ac_cv_prog_really_gcc = yes; then
543     CFLAGS="-O6 -fomit-frame-pointer -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic"
544     fi
545    
546     # test for gcc-specific flags:
547     if test $ac_cv_prog_really_gcc = yes; then
548     # -malign-double for x86 systems
549     ACX_CHECK_CC_FLAGS(-malign-double,align_double, CFLAGS="$CFLAGS -malign-double")
550     # -fstrict-aliasing for gcc-2.95+
551     ACX_CHECK_CC_FLAGS(-fstrict-aliasing,fstrict_aliasing, CFLAGS="$CFLAGS -fstrict-aliasing")
552     fi
553    
554     CPU_FLAGS=""
555     if test $ac_cv_prog_really_gcc = yes; then
556     dnl try to guess correct CPU flags, at least for linux
557     case "${host_cpu}" in
558     i586*) ACX_CHECK_CC_FLAGS(-mcpu=pentium,cpu_pentium,
559     [CPU_FLAGS=-mcpu=pentium],
560     [ACX_CHECK_CC_FLAGS(-mpentium,pentium,
561     [CPU_FLAGS=-mpentium])])
562     ;;
563     i686*) ACX_CHECK_CC_FLAGS(-mcpu=pentiumpro,cpu_pentiumpro,
564     [CPU_FLAGS=-mcpu=pentiumpro],
565     [ACX_CHECK_CC_FLAGS(-mpentiumpro,pentiumpro,
566     [CPU_FLAGS=-mpentiumpro])])
567     ;;
568     powerpc*)
569     cputype=`(grep cpu /proc/cpuinfo | head -1 | cut -d: -f2 | sed 's/ //g') 2> /dev/null`
570     is60x=`echo $cputype | egrep "^60[0-9]e?$"`
571     if test -n "$is60x"; then
572     ACX_CHECK_CC_FLAGS(-mcpu=$cputype,m_cpu_60x,
573     CPU_FLAGS=-mcpu=$cputype)
574     elif test "$cputype" = 750; then
575     ACX_PROG_GCC_VERSION(2,95,
576     ACX_CHECK_CC_FLAGS(-mcpu=750,m_cpu_750,
577     CPU_FLAGS=-mcpu=750))
578     fi
579     if test -z "$CPU_FLAGS"; then
580     ACX_CHECK_CC_FLAGS(-mcpu=powerpc,m_cpu_powerpc,
581     CPU_FLAGS=-mcpu=powerpc)
582     fi
583     if test -z "$CPU_FLAGS"; then
584     ACX_CHECK_CC_FLAGS(-mpowerpc,m_powerpc,
585     CPU_FLAGS=-mpowerpc)
586     fi
587     esac
588     fi
589    
590     if test -n "$CPU_FLAGS"; then
591     CFLAGS="$CFLAGS $CPU_FLAGS"
592     fi
593    
594     if test -z "$CFLAGS"; then
595     echo ""
596     echo "********************************************************"
597     echo "* WARNING: Don't know the best CFLAGS for this system *"
598     echo "* Use make CFLAGS=..., or edit the top level Makefile *"
599     echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
600     echo "********************************************************"
601     echo ""
602     CFLAGS="-O3"
603     fi
604    
605     ACX_CHECK_CC_FLAGS(${CFLAGS}, guessed_cflags, , [
606     echo ""
607     echo "********************************************************"
608     echo "* WARNING: The guessed CFLAGS don't seem to work with *"
609     echo "* your compiler. *"
610     echo "* Use make CFLAGS=..., or edit the top level Makefile *"
611     echo "********************************************************"
612     echo ""
613     CFLAGS=""
614     ])
615    
616     fi
617     ])
618    
619     AC_DEFUN(ACX_PROG_CXX_MAXOPT,
620     [
621     AC_REQUIRE([AC_PROG_CXX])
622     AC_REQUIRE([AC_CANONICAL_HOST])
623    
624     ACX_PROG_REALLY_GXX
625    
626     # Try to determine "good" native compiler flags if none specified on command
627     # line
628     if test "$ac_test_CXXFLAGS" != "set"; then
629     CXXFLAGS=""
630     case "${host_cpu}-${host_os}" in
631    
632     *linux*) if test "$CXX" = icc -o "$CXX" = icpc; then
633     CXXFLAGS="-O"
634     fi;;
635     sparc-solaris2*) if test "$CXX" = CC; then
636     CXXFLAGS="-native -fast -xO5 -dalign"
637     fi;;
638     rs6000*-aix*) if test "$CXX" = xlC; then
639     CXXFLAGS="-O3 -qarch=pwrx -qtune=pwrx -qansialias -w"
640     fi;;
641     powerpc*-aix*)
642     if test "$CXX" = xlC; then
643     CXXFLAGS="-O3 -qarch=ppc -qansialias -w"
644     echo "*******************************************************"
645     echo "* You have AIX on an unknown powerpc system. It is *"
646     echo "* recommended that you use *"
647     echo "* *"
648     echo "* CXXFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
649     echo "* ^^^ *"
650     echo "* where xxx is 601, 603, 604, or whatever kind of *"
651     echo "* PowerPC CPU you have. For more info, man cc. *"
652     echo "*******************************************************"
653     fi;;
654     *darwin*)
655     if test "$CXX" = xlc++; then
656     CXXFLAGS="-qthreaded -O5 -qtune=auto -qarch=auto -qunroll=auto -qaltivec"
657     fi;;
658     esac
659    
660     # use default flags for gcc on all systems
661     if test $ac_cv_prog_really_gxx = yes; then
662     CXXFLAGS="-O6 -fomit-frame-pointer -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic"
663     fi
664    
665     # test for gcc-specific flags:
666     if test $ac_cv_prog_really_gxx = yes; then
667     # -malign-double for x86 systems
668     ACX_CHECK_CXX_FLAGS(-malign-double,align_double, CXXFLAGS="$CXXFLAGS -malign-double")
669     # -fstrict-aliasing for gcc-2.95+
670     ACX_CHECK_CXX_FLAGS(-fstrict-aliasing,fstrict_aliasing, CXXFLAGS="$CXXFLAGS -fstrict-aliasing")
671     fi
672    
673     CPU_FLAGS=""
674     if test $ac_cv_prog_really_gxx = yes; then
675     dnl try to guess correct CPU flags, at least for linux
676     case "${host_cpu}" in
677     i586*) ACX_CHECK_CXX_FLAGS(-mcpu=pentium,cpu_pentium,
678     [CPU_FLAGS=-mcpu=pentium],
679     [ACX_CHECK_CXX_FLAGS(-mpentium,pentium,
680     [CPU_FLAGS=-mpentium])])
681     ;;
682     i686*) ACX_CHECK_CXX_FLAGS(-mcpu=pentiumpro,cpu_pentiumpro,
683     [CPU_FLAGS=-mcpu=pentiumpro],
684     [ACX_CHECK_CXX_FLAGS(-mpentiumpro,pentiumpro,
685     [CPU_FLAGS=-mpentiumpro])])
686     ;;
687     powerpc*)
688     cputype=`(grep cpu /proc/cpuinfo | head -1 | cut -d: -f2 | sed 's/ //g') 2> /dev/null`
689     is60x=`echo $cputype | egrep "^60[0-9]e?$"`
690     if test -n "$is60x"; then
691     ACX_CHECK_CXX_FLAGS(-mcpu=$cputype,m_cpu_60x,
692     CPU_FLAGS=-mcpu=$cputype)
693     elif test "$cputype" = 750; then
694     ACX_PROG_GXX_VERSION(2,95,
695     ACX_CHECK_CXX_FLAGS(-mcpu=750,m_cpu_750,
696     CPU_FLAGS=-mcpu=750))
697     fi
698     if test -z "$CPU_FLAGS"; then
699     ACX_CHECK_CXX_FLAGS(-mcpu=powerpc,m_cpu_powerpc,
700     CPU_FLAGS=-mcpu=powerpc)
701     fi
702     if test -z "$CPU_FLAGS"; then
703     ACX_CHECK_CXX_FLAGS(-mpowerpc,m_powerpc,
704     CPU_FLAGS=-mpowerpc)
705     fi
706     esac
707     fi
708    
709     if test -n "$CPU_FLAGS"; then
710     CXXFLAGS="$CXXFLAGS $CPU_FLAGS"
711     fi
712    
713     if test -z "$CXXFLAGS"; then
714     echo ""
715     echo "**********************************************************"
716     echo "* WARNING: Don't know the best CXXFLAGS for this system *"
717     echo "* Use make CXXFLAGS=..., or edit the top level Makefile *"
718     echo "* (otherwise, a default of CXXFLAGS=-O3 will be used) *"
719     echo "**********************************************************"
720     echo ""
721     CXXFLAGS="-O3"
722     fi
723    
724     ACX_CHECK_CXX_FLAGS(${CXXFLAGS}, guessed_cxxflags, , [
725     echo ""
726     echo "**********************************************************"
727     echo "* WARNING: The guessed CXXFLAGS don't seem to work with *"
728     echo "* your compiler. *"
729     echo "* Use make CXXFLAGS=..., or edit the top level Makefile *"
730     echo "**********************************************************"
731     echo ""
732     CXXFLAGS=""
733     ])
734    
735     fi
736     ])
737    
738     AC_DEFUN(ACX_PROG_F90_MAXOPT,
739     [
740     AC_REQUIRE([AC_PROG_F90])
741     AC_REQUIRE([AC_CANONICAL_HOST])
742    
743     # Try to determine "good" native compiler flags if none specified on command
744     # line
745    
746     if test x"$F90FLAGS" = x ; then
747     F90FLAGS=""
748     case "${host_cpu}-${host_os}" in
749    
750     *linux*) if test "$F90" = ifc -o "$F90" = ifort; then
751     F90FLAGS="-O"
752     fi;;
753     rs6000*-aix*) if test "$F90" = xlf90 -o "$F90" = f90; then
754     F90FLAGS="-O3 -qarch=pwrx -qtune=pwrx -qansialias -w"
755     fi;;
756     powerpc*-aix*)
757     if test "$F90" = f90 -o "$F90" = xlf90; then
758     F90FLAGS="-O3 -qarch=ppc -qansialias -w"
759     echo "*******************************************************"
760     echo "* You have AIX on an unknown powerpc system. It is *"
761     echo "* recommended that you use *"
762     echo "* *"
763     echo "* F90FLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
764     echo "* ^^^ *"
765     echo "* where xxx is 601, 603, 604, or whatever kind of *"
766     echo "* PowerPC CPU you have. For more info, man xlf. *"
767     echo "*******************************************************"
768     fi;;
769     *darwin*)
770     if test "$F90" = f90 -o "$F90" = xlf90 -o "$F90" = xlf95; then
771     F90FLAGS="-qthreaded -O5 -qtune=auto -qarch=auto -qunroll=auto"
772     fi;;
773     esac
774    
775     if test -n "$CPU_FLAGS"; then
776     F90FLAGS="$F90FLAGS $CPU_FLAGS"
777     fi
778    
779     if test -z "$F90FLAGS"; then
780     echo ""
781     echo "**********************************************************"
782     echo "* WARNING: Don't know the best F90FLAGS for this system *"
783     echo "* Use make F90FLAGS=..., or edit the top level Makefile *"
784     echo "* (otherwise, a default of F90FLAGS=-O3 will be used) *"
785     echo "**********************************************************"
786     echo ""
787     F90FLAGS="-O3"
788     fi
789    
790     ACX_CHECK_F90_FLAGS(${F90FLAGS}, guessed_f90flags, , [
791     echo ""
792     echo "**********************************************************"
793     echo "* WARNING: The guessed F90FLAGS don't seem to work with *"
794     echo "* your compiler. *"
795     echo "* Use make F90FLAGS=..., or edit the top level Makefile *"
796     echo "**********************************************************"
797     echo ""
798     F90FLAGS=""
799     ])
800    
801     fi
802     ])
803    
804     AC_DEFUN(ACX_PROG_F90_PREPFLAG,
805     [
806     AC_REQUIRE([AC_PROG_F90])
807     AC_REQUIRE([AC_CANONICAL_HOST])
808    
809     # Try to determine native compiler flags that allow us to use F90 suffix
810     # for preprocessed f90 source.
811    
812     if test "$ac_test_PREPFLAG" != "set"; then
813     PREPFLAG=""
814     case "${host_cpu}-${host_os}" in
815    
816     *linux*) if test "$F90" = ifc -o "$F90" = ifort; then
817     PREPFLAG="-fpp1 "
818     fi;;
819     *aix*) if test "$F90" = xlf90 -o "$F90" = f90; then
820     PREPFLAG="-qsuffix=cpp=F90 "
821     fi;;
822     *darwin*)
823     if test "$F90" = f90 -o "$F90" = xlf90; then
824     PREPFLAG="-qsuffix=cpp=F90 "
825     fi;;
826     esac
827    
828     if test -z "$PREPFLAG"; then
829     AC_MSG_WARN("Using empty PREPFLAG")
830     PREPFLAG=""
831     fi
832    
833     AC_MSG_CHECKING(to make sure F90 preprocessor flag works)
834     AC_LANG_SAVE()
835     AC_LANG([Fortran 90])
836     ac_save_ext=$ac_ext
837     ac_ext=F90
838     ac_save_F90FLAGS=$F90FLAGS
839    
840     AS_IF([test "$PREPFLAG"], [F90FLAGS="${F90FLAGS} ${PREPFLAG}-DTEST"])
841     _AC_COMPILE_IFELSE([
842     AC_LANG_PROGRAM([
843     integer :: i
844     i = 1
845     ])], [prepflagworks=1], [prepflagworks=0])
846    
847     F90FLAGS=$ac_save_F90FLAGS
848     ac_ext=$ac_save_ext
849     AC_LANG_RESTORE()
850    
851     if test "$prepflagworks" = 1; then
852     AC_MSG_RESULT(yes)
853     AC_SUBST(PREPFLAG)
854     else
855     AC_MSG_RESULT(no)
856     AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor flag])
857     fi
858     fi
859     ])
860    
861    
862     AC_DEFUN(ACX_PROG_F90_PREPDEFFLAG,
863     [
864     AC_REQUIRE([AC_PROG_F90])
865     AC_REQUIRE([AC_CANONICAL_HOST])
866    
867     # Try to determine native compiler flags that allow us to use F90 suffix
868     # for preprocessed f90 source with -D type defines
869    
870     if test "$ac_test_PREPDEFFLAG" != "set"; then
871     PREPDEFFLAG=""
872     case "${host_cpu}-${host_os}" in
873    
874     *linux*) if test "$F90" = ifc -o "$F90" = ifort; then
875     PREPDEFFLAG=" "
876     fi;;
877     *aix*) if test "$F90" = xlf90 -o "$F90" = f90; then
878     PREPDEFFLAG="-WF,"
879     fi;;
880     *darwin*)
881     if test "$F90" = f90 -o "$F90" = xlf90; then
882     PREPDEFFLAG="-WF,"
883     fi;;
884     esac
885    
886     if test -z "$PREPDEFFLAG"; then
887     AC_MSG_WARN("Using empty PREPDEFFLAG")
888     PREPDEFFLAG=" "
889     fi
890    
891     AC_MSG_CHECKING(to make sure F90 preprocessor define flag works)
892     AC_LANG_SAVE()
893     AC_LANG([Fortran 90])
894     ac_save_ext=$ac_ext
895     ac_ext=F90
896     ac_save_F90FLAGS=$F90FLAGS
897    
898     AS_IF([test "$PREPDEFFLAG"], [F90FLAGS="${F90FLAGS} ${PREPFLAG} ${PREPDEFFLAG}-DTEST"])
899     _AC_COMPILE_IFELSE([
900     AC_LANG_PROGRAM([
901     integer :: i
902     #ifdef TEST
903     i = 1
904     #else
905     choke me
906     #endif
907     ])], [prepdefflagworks=1], [prepdefflagworks=0])
908    
909     F90FLAGS=$ac_save_F90FLAGS
910     ac_ext=$ac_save_ext
911     AC_LANG_RESTORE()
912    
913    
914     if test "$prepdefflagworks" = 1; then
915     AC_MSG_RESULT(yes)
916     AC_SUBST(PREPDEFFLAG)
917     else
918     AC_MSG_RESULT(no)
919     AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor define flag])
920     fi
921     fi
922     ])
923    
924     dnl check for the required MPI library
925     AC_DEFUN([ACX_MPI], [
926    
927     # Set variables...
928     MPI_LIB_DIR="$MPI/lib"
929     MPI_INC_DIR="$MPI/include"
930     AC_SUBST([MPI_LIB_DIR])
931     AC_SUBST([MPI_INC_DIR])
932    
933     AC_MSG_CHECKING([for mpi.h])
934     have_mpi_h=0
935     echo '#include <mpi.h>' > conftest.cc
936     if test -z "`${CXX} -I${MPI_INC_DIR} -c conftest.cc 2>&1`"; then
937     AC_MSG_RESULT(yes)
938     have_mpi_h=1
939     else
940     AC_MSG_RESULT(no! Check MPI include paths)
941     USE_MPI="no"
942     fi
943     rm -f conftest*
944     if test "$have_mpi_h" = 1; then
945     AC_DEFINE(HAVE_MPI_H, 1, [have mpi.h])
946     fi
947    
948     AC_MSG_CHECKING([whether mpif.h is usable])
949     have_mpif_h=0
950     rm -f conftest*
951     cat >conftest.f90 <<EOF
952     program main
953     include 'mpif.h'
954     end
955     EOF
956     if $F90 -I$MPI_INC_DIR -c conftest.f90 > conftest.out 2>&1 ; then
957     AC_MSG_RESULT(yes)
958     MPI_F90_INC="$MPI_INC_DIR"
959     have_mpif_h=1
960     else
961     if test -s conftest.out ; then
962     cat conftest.out >> config.log
963     fi
964     AC_MSG_RESULT([no! Check MPI include paths])
965     USE_MPI="no"
966     fi
967     rm -f conftest*
968     AC_SUBST(MPI_F90_INC)
969     if test "$have_mpif_h" = 1; then
970     AC_DEFINE(HAVE_MPIF_H, 1, [have mpif.h])
971     fi
972    
973     AC_LANG_PUSH(C)
974     ac_save_LDFLAGS=$LDFLAGS
975     LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR} "
976    
977     if test x = x"$MPI_LIB"; then
978     AC_CHECK_LIB(mpich, MPI_Init, [MPI_LIB="-lmpich"])
979     fi
980     if test x = x"$MPI_LIB"; then
981     AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi"])
982     fi
983     $as_unset ac_cv_lib_mpi_MPI_Init
984     if test x = x"$MPI_LIB"; then
985     AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi -llam"], [],
986     "-llam")
987     fi
988    
989     $as_unset ac_cv_lib_mpi_MPI_Init
990     if test x = x"$MPI_LIB"; then
991     AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi -llam -lpthread"],[
992     AC_MSG_ERROR([Didn't find liblam, libmpi, or libmpich; check path for MPI package first...])
993     USE_MPI="no"
994     ],
995     [-llam -lpthread])
996     fi
997    
998     AC_SUBST(MPI_LIB)
999    
1000     AC_MSG_CHECKING([for MPI Fortran library])
1001     MPI_F90_LIB=""
1002     if test -f "$MPI_LIB_DIR/libfmpich.a" ; then
1003     MPI_F90_LIB="-lfmpich"
1004     elif test -f "$MPI_LIB_DIR/liblamf77mpi.a" ; then
1005     MPI_F90_LIB="-llamf77mpi"
1006     else
1007     dnl nothing special found, we'll assume that the C
1008     dnl library is all we need
1009     MPI_F90_LIB=" "
1010     fi
1011     AC_MSG_RESULT([found $MPI_F90_LIB])
1012     AC_SUBST(MPI_F90_LIB)
1013     ])dnl ACX_MPI
1014    
1015    
1016     dnl check for the required SPRNG library
1017     AC_DEFUN([ACX_SPRNG], [
1018    
1019     # Set variables...
1020     SPRNG_LIB_DIR="$SPRNG/lib"
1021     SPRNG_INC_DIR="$SPRNG/include"
1022     AC_SUBST([SPRNG_LIB_DIR])
1023     AC_SUBST([SPRNG_INC_DIR])
1024    
1025     AC_MSG_CHECKING([for sprng.h])
1026     have_sprng_h=0
1027     echo '#include <sprng.h>' > conftest.cc
1028     if test -z "`${CXX} -I${SPRNG_INC_DIR} -c conftest.cc 2>&1`"; then
1029     AC_MSG_RESULT(yes)
1030     have_sprng_h=1
1031     else
1032     AC_MSG_RESULT([no! Check SPRNG include path!])
1033     USE_SPRNG="no"
1034     fi
1035     rm -f conftest*
1036     if test "$have_sprng_h" = 1; then
1037     AC_DEFINE(HAVE_SPRNG_H, 1, [have sprng.h])
1038     fi
1039    
1040     AC_LANG_PUSH(C)
1041     ac_save_LDFLAGS=$LDFLAGS
1042     LDFLAGS="${LDFLAGS} -L${SPRNG_LIB_DIR} "
1043    
1044     AC_CHECK_LIB(sprng, init_rng, [SPRNG_LIB="-lsprng"], [
1045     AC_MSG_ERROR([Didn't find libsprng; check path for SPRNG package first...])
1046     USE_SPRNG="no"
1047     ])
1048    
1049     if test "$USE_SPRNG" = "no"; then
1050     AC_MSG_ERROR(No working SPRNG library found)
1051     fi
1052     AC_SUBST(SPRNG_LIB)
1053     ])dnl ACX_SPRNG
1054    
1055     AC_DEFUN([adl_FUNC_GETOPT_LONG],
1056     [AC_PREREQ(2.49)dnl
1057     # clean out junk possibly left behind by a previous configuration
1058     rm -f utils/getopt.h
1059     # Check for getopt_long support
1060     AC_CHECK_HEADERS([getopt.h])
1061     AC_CHECK_FUNCS([getopt_long],,
1062     [# FreeBSD has a gnugetopt library for this
1063     AC_CHECK_LIB([gnugetopt],[getopt_long],[AC_DEFINE([HAVE_GETOPT_LONG])],
1064     [# use the GNU replacement
1065     AC_LIBOBJ(getopt)
1066     AC_LIBOBJ(getopt1)
1067     AC_CONFIG_LINKS([utils/getopt.h:utils/gnugetopt.h])])])])