ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/ac-tools/aclocal.m4
Revision: 838
Committed: Wed Oct 29 03:06:51 2003 UTC (20 years, 8 months ago) by gezelter
File size: 28880 byte(s)
Log Message:
compatibility fixes

File Contents

# Content
1 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_ERROR([Couldn't locate MPI F90 Modules])
175 fi
176
177 ])
178
179
180 dnl
181 dnl AM_PATH_SPRNG
182 dnl
183 AC_DEFUN([AM_PATH_SPRNG],[
184
185 AC_ARG_WITH(sprng_prefix, [ --with-sprng_prefix=PREFIX
186 Prefix where SPRNG is installed ],
187 sprng_prefix="$withval",
188 sprng_prefix="/usr/local")
189 AC_ARG_WITH(sprng-libdir, [ --with-sprng-libdir=PREFIX SPRNG library directory],
190 sprng_libdir="$withval",
191 sprng_libdir="/usr/local/lib")
192 AC_ARG_WITH(sprng-include, [ --with-sprng-include=PREFIX
193 SPRNG include directory],
194 sprng_include="$withval",
195 sprng_include="/usr/local/include/sprng")
196
197 if test x$sprng_libdir = x ; then
198 sprng_libdir=${sprng_prefix}/lib
199 fi
200
201 if test x$sprng_include = x ; then
202 sprng_include=${sprng_prefix}/include
203 fi
204
205 AC_MSG_CHECKING(for SPRNG include files in $sprng_include)
206 if test -f ${sprng_include}/sprng.h; then
207 have_sprngincl=yes
208 AC_MSG_RESULT(yes)
209 else
210 have_sprngincl=no
211 AC_MSG_RESULT(no)
212 AC_MSG_ERROR(Could not locate the SPRNG include files)
213 fi
214
215 AC_MSG_CHECKING(for SPRNG libraries in $sprng_libdir)
216 if test -f ${sprng_libdir}/libsprng.a; then
217 have_sprnglib=yes
218 AC_MSG_RESULT(yes)
219 else
220 have_sprnglib=no
221 AC_MSG_RESULT(no)
222 AC_MSG_ERROR(Could not locate the SPRNG libraries)
223 fi
224
225 AC_LANG_SAVE()
226 AC_LANG([C])
227 ac_save_CPPFLAGS=$CPPFLAGS
228 CPPFLAGS="${CPPFLAGS} -I${sprng_include}"
229 ac_save_LDFLAGS=$LDFLAGS
230 LDFLAGS="${LDFLAGS} -L${sprng_libdir} -lsprng"
231 AC_CHECK_HEADER(sprng.h, [
232 AC_CHECK_LIB(sprng,
233 init_rng,
234 [SPRNG_LIBDIR="${sprng_libdir}"
235 SPRNG_LIB="-lsprng" SPRNG_INC="-I${sprng_include}"
236 HAVE_SPRNG="yes"])])
237 CPPFLAGS=$ac_save_CPPFLAGS
238 LDFLAGS=$ac_save_LDFLAGS
239 AC_LANG_RESTORE()
240
241 if test x_$HAVE_SPRNG != x_yes; then
242 AC_MSG_ERROR(Can't build with SPRNG)
243 fi
244 AC_SUBST(SPRNG_LIBDIR)
245 AC_SUBST(SPRNG_LIB)
246 AC_SUBST(SPRNG_INC)
247 AC_SUBST(HAVE_SPRNG)
248 ])
249
250 dnl
251 dnl CHECK_MKL
252 dnl
253 AC_DEFUN([CHECK_MKL],
254 [AC_MSG_CHECKING(if MKL is wanted)
255 AC_ARG_WITH(mkl,
256 [ --with-mkl Do we want MKL [will check /usr/local/intel/mkl60 /opt/intel/mkl60]],
257 [ AC_MSG_RESULT(yes)
258 for dir in $withval /usr/local/intel/mkl60 /opt/intel/mkl60; do
259 mkldir="$dir"
260 if test -f "$dir/include/mkl.h"; then
261 found_mkl="yes";
262 break;
263 fi
264 done
265 if test x_$found_mkl != x_yes; then
266 AC_MSG_ERROR(Cannot find MKL includes)
267 else
268 printf "MKL includes found in $mkldir/include\n";
269 fi
270
271 AC_LANG_SAVE()
272 AC_LANG([C])
273 ac_save_CPPFLAGS=$CPPFLAGS
274 CPPFLAGS="${CPPFLAGS} -I${mkldir}/include"
275 ac_save_LDFLAGS=$LDFLAGS
276 LDFLAGS="${LDFLAGS} -L${mkldir}/lib/32 -lmkl -lvml -lguide"
277 AC_CHECK_HEADER(mkl.h, [
278 AC_CHECK_LIB(mkl,
279 vslNewStream,
280 [MKL_LIBDIR="${mkldir}/lib/32",
281 MKL_LIB="-lmkl -lvml -lguide",
282 HAVE_MKL="yes"])
283 ], [MKL_INC="-I${mkldir}/include"])
284 CPPFLAGS=$ac_save_CPPFLAGS
285 LDFLAGS=$ac_save_LDFLAGS
286 AC_LANG_RESTORE()
287
288 if test x_$HAVE_MKL != x_yes; then
289 AC_MSG_ERROR(Can't build with MKL)
290 fi
291 AC_SUBST(MKL_LIBDIR)
292 AC_SUBST(MKL_LIB)
293 AC_SUBST(MKL_INC)
294 AC_SUBST(HAVE_MKL)
295 ],
296 [
297 AC_MSG_RESULT(no)
298 ])
299 ])
300 dnl
301
302 AC_DEFUN(ACX_CHECK_CC_FLAGS,
303 [
304 AC_REQUIRE([AC_PROG_CC])
305 AC_CACHE_CHECK(whether ${CC-cc} accepts $1, ac_$2,
306 [echo 'void f(){}' > conftest.c
307 if test -z "`${CC-cc} $1 -c conftest.c 2>&1`"; then
308 ac_$2=yes
309 else
310 ac_$2=no
311 fi
312 rm -f conftest*
313 ])
314 if test "$ac_$2" = yes; then
315 :
316 $3
317 else
318 :
319 $4
320 fi
321 ])
322
323 AC_DEFUN(ACX_CHECK_CXX_FLAGS,
324 [
325 AC_REQUIRE([AC_PROG_CXX])
326 AC_CACHE_CHECK(whether ${CXX-c++} accepts $1, ac_$2,
327 [echo 'void f(){}' > conftest.cpp
328 if test -z "`${CXX-c++} $1 -c conftest.cpp 2>&1`"; then
329 ac_$2=yes
330 else
331 ac_$2=no
332 fi
333 rm -f conftest*
334 ])
335 if test "$ac_$2" = yes; then
336 :
337 $3
338 else
339 :
340 $4
341 fi
342 ])
343
344 dnl -------------------------------------------------------------------------
345 dnl ACX_CHECK_F90_FLAGS()
346 dnl
347 dnl Check for optimizer flags the Fortran compiler can use.
348 dnl
349 AC_DEFUN(ACX_CHECK_F90_FLAGS,
350 [
351 AC_CACHE_CHECK(whether ${F90-f90} accepts $1, ac_$2,
352 [
353 AC_LANG_SAVE
354 AC_LANG([Fortran 90])
355 echo 'program main' > conftest.$ac_ext
356 echo 'end program main' >> conftest.$ac_ext
357 ac_compile='${F90-f90} -c $1 $F90FLAGS conftest.$ac_ext 1>&AC_FD_CC'
358 if AC_TRY_EVAL(ac_compile); then
359 ac_$2=yes
360 else
361 ac_$2=no
362 fi
363 rm -f conftest*
364 AC_LANG_RESTORE()
365 ])
366 if test "$ac_$2" = yes; then
367 :
368 $3
369 else
370 :
371 $4
372 fi
373 ])
374
375 AC_DEFUN(ACX_PROG_GCC_VERSION,
376 [
377 AC_REQUIRE([AC_PROG_CC])
378 AC_CACHE_CHECK(whether we are using gcc $1.$2 or later, ac_cv_prog_gcc_$1_$2,
379 [
380 dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
381 cat > conftest.c <<EOF
382 #ifdef __GNUC__
383 # if (__GNUC__ > $1) || (__GNUC__ == $1 && __GNUC_MINOR__ >= $2)
384 yes;
385 # endif
386 #endif
387 EOF
388 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
389 ac_cv_prog_gcc_$1_$2=yes
390 else
391 ac_cv_prog_gcc_$1_$2=no
392 fi
393 ])
394 if test "$ac_cv_prog_gcc_$1_$2" = yes; then
395 :
396 $3
397 else
398 :
399 $4
400 fi
401 ])
402
403
404 AC_DEFUN(ACX_PROG_CC_MAXOPT,
405 [
406 AC_REQUIRE([AC_PROG_CC])
407 AC_REQUIRE([AC_CANONICAL_HOST])
408
409 # Try to determine "good" native compiler flags if none specified on command
410 # line
411 if test "$ac_test_CFLAGS" != "set"; then
412 CFLAGS=""
413 case "${host_cpu}-${host_os}" in
414
415 *linux*) if test "$CC" = icc; then
416 CFLAGS="-O"
417 fi;;
418 sparc-solaris2*) if test "$CC" = cc; then
419 CFLAGS="-native -fast -xO5 -dalign"
420 fi;;
421
422 alpha*-osf*) if test "$CC" = cc; then
423 CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host -arch host -std1"
424 fi;;
425
426 hppa*-hpux*) if test "$CC" = cc; then
427 CFLAGS="-Ae +O3 +Oall"
428 fi;;
429
430 rs6000*-aix*) if test "$CC" = cc -o "$CC" = xlc; then
431 CFLAGS="-O3 -qtune=auto -qansialias -w"
432 fi;;
433 powerpc*-aix*)
434 if test "$CC" = cc -o "$CC" = xlc; then
435 CFLAGS="-O3 -qtune=auto -qansialias -w"
436 echo "*******************************************************"
437 echo "* You have AIX on an unknown powerpc system. It is *"
438 echo "* recommended that you use *"
439 echo "* *"
440 echo "* CFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
441 echo "* ^^^ *"
442 echo "* where xxx is 601, 603, 604, or whatever kind of *"
443 echo "* PowerPC CPU you have. For more info, man cc. *"
444 echo "*******************************************************"
445 fi;;
446 *darwin*)
447 if test "$CC" = xlc -o "$CC" = cc; then
448 CFLAGS="-O3 -qtune=auto -w"
449 echo "*******************************************************"
450 echo "* You have Darwin on an unknown powerpc system. *"
451 echo "* It is recommended that you use *"
452 echo "* *"
453 echo "* CFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
454 echo "* ^^^ *"
455 echo "* where xxx is 601, 603, 604, or whatever kind of *"
456 echo "* PowerPC CPU you have. For more info, man cc. *"
457 echo "*******************************************************"
458 fi;;
459 esac
460
461 # use default flags for gcc on all systems
462 if test $ac_cv_prog_gcc = yes; then
463 CFLAGS="-O6 -fomit-frame-pointer -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic"
464 fi
465
466 # test for gcc-specific flags:
467 if test $ac_cv_prog_gcc = yes; then
468 # -malign-double for x86 systems
469 ACX_CHECK_CC_FLAGS(-malign-double,align_double, CFLAGS="$CFLAGS -malign-double")
470 # -fstrict-aliasing for gcc-2.95+
471 ACX_CHECK_CC_FLAGS(-fstrict-aliasing,fstrict_aliasing, CFLAGS="$CFLAGS -fstrict-aliasing")
472 fi
473
474 CPU_FLAGS=""
475 if test "$GCC" = "yes"; then
476 dnl try to guess correct CPU flags, at least for linux
477 case "${host_cpu}" in
478 i586*) ACX_CHECK_CC_FLAGS(-mcpu=pentium,cpu_pentium,
479 [CPU_FLAGS=-mcpu=pentium],
480 [ACX_CHECK_CC_FLAGS(-mpentium,pentium,
481 [CPU_FLAGS=-mpentium])])
482 ;;
483 i686*) ACX_CHECK_CC_FLAGS(-mcpu=pentiumpro,cpu_pentiumpro,
484 [CPU_FLAGS=-mcpu=pentiumpro],
485 [ACX_CHECK_CC_FLAGS(-mpentiumpro,pentiumpro,
486 [CPU_FLAGS=-mpentiumpro])])
487 ;;
488 powerpc*)
489 cputype=`(grep cpu /proc/cpuinfo | head -1 | cut -d: -f2 | sed 's/ //g') 2> /dev/null`
490 is60x=`echo $cputype | egrep "^60[0-9]e?$"`
491 if test -n "$is60x"; then
492 ACX_CHECK_CC_FLAGS(-mcpu=$cputype,m_cpu_60x,
493 CPU_FLAGS=-mcpu=$cputype)
494 elif test "$cputype" = 750; then
495 ACX_PROG_GCC_VERSION(2,95,
496 ACX_CHECK_CC_FLAGS(-mcpu=750,m_cpu_750,
497 CPU_FLAGS=-mcpu=750))
498 fi
499 if test -z "$CPU_FLAGS"; then
500 ACX_CHECK_CC_FLAGS(-mcpu=powerpc,m_cpu_powerpc,
501 CPU_FLAGS=-mcpu=powerpc)
502 fi
503 if test -z "$CPU_FLAGS"; then
504 ACX_CHECK_CC_FLAGS(-mpowerpc,m_powerpc,
505 CPU_FLAGS=-mpowerpc)
506 fi
507 esac
508 fi
509
510 if test -n "$CPU_FLAGS"; then
511 CFLAGS="$CFLAGS $CPU_FLAGS"
512 fi
513
514 if test -z "$CFLAGS"; then
515 echo ""
516 echo "********************************************************"
517 echo "* WARNING: Don't know the best CFLAGS for this system *"
518 echo "* Use make CFLAGS=..., or edit the top level Makefile *"
519 echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
520 echo "********************************************************"
521 echo ""
522 CFLAGS="-O3"
523 fi
524
525 ACX_CHECK_CC_FLAGS(${CFLAGS}, guessed_cflags, , [
526 echo ""
527 echo "********************************************************"
528 echo "* WARNING: The guessed CFLAGS don't seem to work with *"
529 echo "* your compiler. *"
530 echo "* Use make CFLAGS=..., or edit the top level Makefile *"
531 echo "********************************************************"
532 echo ""
533 CFLAGS=""
534 ])
535
536 fi
537 ])
538
539 AC_DEFUN(ACX_PROG_CXX_MAXOPT,
540 [
541 AC_REQUIRE([AC_PROG_CXX])
542 AC_REQUIRE([AC_CANONICAL_HOST])
543
544 # Try to determine "good" native compiler flags if none specified on command
545 # line
546 if test "$ac_test_CXXFLAGS" != "set"; then
547 CXXFLAGS=""
548 case "${host_cpu}-${host_os}" in
549
550 *linux*) if test "$CXX" = icc -o "$CXX" = icpc; then
551 CXXFLAGS="-O"
552 fi;;
553 sparc-solaris2*) if test "$CXX" = CC; then
554 CXXFLAGS="-native -fast -xO5 -dalign"
555 fi;;
556 rs6000*-aix*) if test "$CXX" = xlC; then
557 CXXFLAGS="-O3 -qarch=pwrx -qtune=pwrx -qansialias -w"
558 fi;;
559 powerpc*-aix*)
560 if test "$CXX" = xlC; then
561 CXXFLAGS="-O3 -qarch=ppc -qansialias -w"
562 echo "*******************************************************"
563 echo "* You have AIX on an unknown powerpc system. It is *"
564 echo "* recommended that you use *"
565 echo "* *"
566 echo "* CXXFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
567 echo "* ^^^ *"
568 echo "* where xxx is 601, 603, 604, or whatever kind of *"
569 echo "* PowerPC CPU you have. For more info, man cc. *"
570 echo "*******************************************************"
571 fi;;
572 *darwin*)
573 if test "$CXX" = xlC; then
574 CXXFLAGS="-O3 -qtune=auto -qansialias -w"
575 echo "*******************************************************"
576 echo "* You have AIX on an unknown powerpc system. It is *"
577 echo "* recommended that you use *"
578 echo "* *"
579 echo "* CXXFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
580 echo "* ^^^ *"
581 echo "* where xxx is 601, 603, 604, or whatever kind of *"
582 echo "* PowerPC CPU you have. For more info, man cc. *"
583 echo "*******************************************************"
584 fi;;
585 esac
586
587 # use default flags for gcc on all systems
588 if test $ac_cv_prog_gcc = yes; then
589 CXXFLAGS="-O6 -fomit-frame-pointer -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic"
590 fi
591
592 # test for gcc-specific flags:
593 if test $ac_cv_prog_gcc = yes; then
594 # -malign-double for x86 systems
595 ACX_CHECK_CXX_FLAGS(-malign-double,align_double, CXXFLAGS="$CXXFLAGS -malign-double")
596 # -fstrict-aliasing for gcc-2.95+
597 ACX_CHECK_CXX_FLAGS(-fstrict-aliasing,fstrict_aliasing, CXXFLAGS="$CXXFLAGS -fstrict-aliasing")
598 fi
599
600 CPU_FLAGS=""
601 if test "$GCC" = "yes"; then
602 dnl try to guess correct CPU flags, at least for linux
603 case "${host_cpu}" in
604 i586*) ACX_CHECK_CC_FLAGS(-mcpu=pentium,cpu_pentium,
605 [CPU_FLAGS=-mcpu=pentium],
606 [ACX_CHECK_CXX_FLAGS(-mpentium,pentium,
607 [CPU_FLAGS=-mpentium])])
608 ;;
609 i686*) ACX_CHECK_CXX_FLAGS(-mcpu=pentiumpro,cpu_pentiumpro,
610 [CPU_FLAGS=-mcpu=pentiumpro],
611 [ACX_CHECK_CXX_FLAGS(-mpentiumpro,pentiumpro,
612 [CPU_FLAGS=-mpentiumpro])])
613 ;;
614 powerpc*)
615 cputype=`(grep cpu /proc/cpuinfo | head -1 | cut -d: -f2 | sed 's/ //g') 2> /dev/null`
616 is60x=`echo $cputype | egrep "^60[0-9]e?$"`
617 if test -n "$is60x"; then
618 ACX_CHECK_CXX_FLAGS(-mcpu=$cputype,m_cpu_60x,
619 CPU_FLAGS=-mcpu=$cputype)
620 elif test "$cputype" = 750; then
621 ACX_PROG_GCC_VERSION(2,95,
622 ACX_CHECK_CXX_FLAGS(-mcpu=750,m_cpu_750,
623 CPU_FLAGS=-mcpu=750))
624 fi
625 if test -z "$CPU_FLAGS"; then
626 ACX_CHECK_CXX_FLAGS(-mcpu=powerpc,m_cpu_powerpc,
627 CPU_FLAGS=-mcpu=powerpc)
628 fi
629 if test -z "$CPU_FLAGS"; then
630 ACX_CHECK_CXX_FLAGS(-mpowerpc,m_powerpc,
631 CPU_FLAGS=-mpowerpc)
632 fi
633 esac
634 fi
635
636 if test -n "$CPU_FLAGS"; then
637 CXXFLAGS="$CXXFLAGS $CPU_FLAGS"
638 fi
639
640 if test -z "$CXXFLAGS"; then
641 echo ""
642 echo "**********************************************************"
643 echo "* WARNING: Don't know the best CXXFLAGS for this system *"
644 echo "* Use make CXXFLAGS=..., or edit the top level Makefile *"
645 echo "* (otherwise, a default of CXXFLAGS=-O3 will be used) *"
646 echo "**********************************************************"
647 echo ""
648 CXXFLAGS="-O3"
649 fi
650
651 ACX_CHECK_CXX_FLAGS(${CXXFLAGS}, guessed_cxxflags, , [
652 echo ""
653 echo "**********************************************************"
654 echo "* WARNING: The guessed CXXFLAGS don't seem to work with *"
655 echo "* your compiler. *"
656 echo "* Use make CXXFLAGS=..., or edit the top level Makefile *"
657 echo "**********************************************************"
658 echo ""
659 CXXFLAGS=""
660 ])
661
662 fi
663 ])
664
665 AC_DEFUN(ACX_PROG_F90_MAXOPT,
666 [
667 AC_REQUIRE([AC_PROG_F90])
668 AC_REQUIRE([AC_CANONICAL_HOST])
669
670 # Try to determine "good" native compiler flags if none specified on command
671 # line
672
673 if test x"$F90FLAGS" = x ; then
674 F90FLAGS=""
675 case "${host_cpu}-${host_os}" in
676
677 *linux*) if test "$F90" = ifc; then
678 F90FLAGS="-O"
679 fi;;
680 rs6000*-aix*) if test "$F90" = xlf90 -o "$F90" = f90; then
681 F90FLAGS="-O3 -qarch=pwrx -qtune=pwrx -qansialias -w"
682 fi;;
683 powerpc*-aix*)
684 if test "$F90" = f90 -o "$F90" = xlf90; then
685 F90FLAGS="-O3 -qarch=ppc -qansialias -w"
686 echo "*******************************************************"
687 echo "* You have AIX on an unknown powerpc system. It is *"
688 echo "* recommended that you use *"
689 echo "* *"
690 echo "* F90FLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
691 echo "* ^^^ *"
692 echo "* where xxx is 601, 603, 604, or whatever kind of *"
693 echo "* PowerPC CPU you have. For more info, man xlf. *"
694 echo "*******************************************************"
695 fi;;
696 *darwin*)
697 if test "$F90" = f90 -o "$F90" = xlf90; then
698 F90FLAGS="-O3 -qtune=auto -w"
699 echo "*********************************************************"
700 echo "* You have Darwin on an unknown powerpc system. It is *"
701 echo "* recommended that you use *"
702 echo "* *"
703 echo "* CXXFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
704 echo "* ^^^ *"
705 echo "* where xxx is 601, 603, 604, or whatever kind of *"
706 echo "* PowerPC CPU you have. For more info, man xlf. *"
707 echo "*********************************************************"
708 fi;;
709 esac
710
711 if test -n "$CPU_FLAGS"; then
712 F90FLAGS="$F90FLAGS $CPU_FLAGS"
713 fi
714
715 if test -z "$F90FLAGS"; then
716 echo ""
717 echo "**********************************************************"
718 echo "* WARNING: Don't know the best F90FLAGS for this system *"
719 echo "* Use make F90FLAGS=..., or edit the top level Makefile *"
720 echo "* (otherwise, a default of F90FLAGS=-O3 will be used) *"
721 echo "**********************************************************"
722 echo ""
723 F90FLAGS="-O3"
724 fi
725
726 ACX_CHECK_F90_FLAGS(${F90FLAGS}, guessed_f90flags, , [
727 echo ""
728 echo "**********************************************************"
729 echo "* WARNING: The guessed F90FLAGS don't seem to work with *"
730 echo "* your compiler. *"
731 echo "* Use make F90FLAGS=..., or edit the top level Makefile *"
732 echo "**********************************************************"
733 echo ""
734 F90FLAGS=""
735 ])
736
737 fi
738 ])
739
740 AC_DEFUN(ACX_PROG_F90_PREPFLAG,
741 [
742 AC_REQUIRE([AC_PROG_F90])
743 AC_REQUIRE([AC_CANONICAL_HOST])
744
745 # Try to determine native compiler flags that allow us to use F90 suffix
746 # for preprocessed f90 source.
747
748 if test "$ac_test_PREPFLAG" != "set"; then
749 PREPFLAG=""
750 case "${host_cpu}-${host_os}" in
751
752 *linux*) if test "$F90" = ifc; then
753 PREPFLAG="-fpp1 "
754 fi;;
755 *aix*) if test "$F90" = xlf90 -o "$F90" = f90; then
756 PREPFLAG="-qsuffix=cpp=F90 "
757 fi;;
758 *darwin*)
759 if test "$F90" = f90 -o "$F90" = xlf90; then
760 PREPFLAG="-qsuffix=cpp=F90 "
761 fi;;
762 esac
763
764 if test -z "$PREPFLAG"; then
765 echo ""
766 echo "**********************************************************"
767 echo "* WARNING: Don't know the best PREPFLAG for this system *"
768 echo "* Use make PREPFLAG=..., or edit the top level Makefile *"
769 echo "* (otherwise, an empty PREPFLAG will be used) *"
770 echo "**********************************************************"
771 echo ""
772 PREPFLAG=""
773 fi
774
775 AC_MSG_CHECKING(to make sure F90 preprocessor flag works)
776 AC_LANG_SAVE()
777 AC_LANG([Fortran 90])
778 ac_save_ext=$ac_ext
779 ac_ext=F90
780 ac_save_F90FLAGS=$F90FLAGS
781
782 AS_IF([test "$PREPFLAG"], [F90FLAGS="${F90FLAGS} ${PREPFLAG}-DTEST"])
783 _AC_COMPILE_IFELSE([
784 AC_LANG_PROGRAM([
785 integer :: i
786 i = 1
787 ])], [prepflagworks=1], [prepflagworks=0])
788
789 F90FLAGS=$ac_save_F90FLAGS
790 ac_ext=$ac_save_ext
791 AC_LANG_RESTORE()
792
793
794 if test "$prepflagworks" = 1; then
795 AC_MSG_RESULT(yes)
796 AC_SUBST(PREPFLAG)
797 else
798 AC_MSG_RESULT(no)
799 AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor flag])
800 fi
801 fi
802 ])
803
804
805 AC_DEFUN(ACX_PROG_F90_PREPDEFFLAG,
806 [
807 AC_REQUIRE([AC_PROG_F90])
808 AC_REQUIRE([AC_CANONICAL_HOST])
809
810 # Try to determine native compiler flags that allow us to use F90 suffix
811 # for preprocessed f90 source with -D type defines
812
813 if test "$ac_test_PREPDEFFLAG" != "set"; then
814 PREPDEFFLAG=""
815 case "${host_cpu}-${host_os}" in
816
817 *linux*) if test "$F90" = ifc; then
818 PREPDEFFLAG=" "
819 fi;;
820 *aix*) if test "$F90" = xlf90 -o "$F90" = f90; then
821 PREPDEFFLAG="-WF,"
822 fi;;
823 *darwin*)
824 if test "$F90" = f90 -o "$F90" = xlf90; then
825 PREPDEFFLAG="-WF,"
826 fi;;
827 esac
828
829 if test -z "$PREPDEFFLAG"; then
830 echo ""
831 echo "*************************************************************"
832 echo "* WARNING: Don't know the best PREPDEFFLAG for this system *"
833 echo "* Use make PREPDEFFLAG=..., or edit the top level Makefile *"
834 echo "* (otherwise, an empty PREPDEFFLAG will be used) *"
835 echo "*************************************************************"
836 echo ""
837 PREPDEFFLAG=" "
838 fi
839
840 AC_MSG_CHECKING(to make sure F90 preprocessor define flag works)
841 AC_LANG_SAVE()
842 AC_LANG([Fortran 90])
843 ac_save_ext=$ac_ext
844 ac_ext=F90
845 ac_save_F90FLAGS=$F90FLAGS
846
847 AS_IF([test "$PREPDEFFLAG"], [F90FLAGS="${F90FLAGS} ${PREPFLAG} ${PREPDEFFLAG}-DTEST"])
848 _AC_COMPILE_IFELSE([
849 AC_LANG_PROGRAM([
850 integer :: i
851 #ifdef TEST
852 i = 1
853 #else
854 choke me
855 #endif
856 ])], [prepdefflagworks=1], [prepdefflagworks=0])
857
858 F90FLAGS=$ac_save_F90FLAGS
859 ac_ext=$ac_save_ext
860 AC_LANG_RESTORE()
861
862
863 if test "$prepdefflagworks" = 1; then
864 AC_MSG_RESULT(yes)
865 AC_SUBST(PREPDEFFLAG)
866 else
867 AC_MSG_RESULT(no)
868 AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor define flag])
869 fi
870 fi
871 ])
872
873 AC_DEFUN([ACX_MPI], [
874 AC_PREREQ(2.50) dnl for AC_LANG_CASE
875
876 AC_LANG_CASE([C], [
877 AC_REQUIRE([AC_PROG_CC])
878 AC_ARG_VAR(MPICC,[MPI C compiler command])
879 AC_CHECK_PROGS(MPICC, mpicc hcc mpcc mpcc_r mpxlc, $CC)
880 acx_mpi_save_CC="$CC"
881 CC="$MPICC"
882 AC_SUBST(MPICC)
883 ],
884 [C++], [
885 AC_REQUIRE([AC_PROG_CXX])
886 AC_ARG_VAR(MPICXX,[MPI C++ compiler command])
887 AC_CHECK_PROGS(MPICXX, mpiCC mpCC, $CXX)
888 acx_mpi_save_CXX="$CXX"
889 CXX="$MPICXX"
890 AC_SUBST(MPICXX)
891 ],
892 [Fortran 90], [
893 AC_REQUIRE([AC_PROG_F90])
894 AC_ARG_VAR(MPIF77,[MPI Fortran compiler command])
895 AC_CHECK_PROGS(MPIF90, mpif90 hf90 mpxlf90 mpf90 mpxlf95 mpxlf_r, $F90)
896 acx_mpi_save_F90="$F90"
897 F90="$MPIF90"
898 AC_SUBST(MPIF90)
899 ])
900
901 if test x = x"$MPILIBS"; then
902 AC_LANG_CASE([C], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
903 [C++], [AC_CHECK_FUNC(MPI_Init, [MPILIBS=" "])],
904 [Fortran 90], [AC_MSG_CHECKING([for MPI_Init])
905 AC_TRY_LINK([],[ call MPI_Init], [MPILIBS=" "
906 AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])])
907 fi
908 if test x = x"$MPILIBS"; then
909 AC_CHECK_LIB(mpi, MPI_Init, [MPILIBS="-lmpi"])
910 fi
911 if test x = x"$MPILIBS"; then
912 AC_CHECK_LIB(mpich, MPI_Init, [MPILIBS="-lmpich"])
913 fi
914
915 dnl We have to use AC_TRY_COMPILE and not AC_CHECK_HEADER because the
916 dnl latter uses $CPP, not $CC (which may be mpicc).
917 AC_LANG_CASE([C], [if test x != x"$MPILIBS"; then
918 AC_MSG_CHECKING([for mpi.h])
919 AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
920 AC_MSG_RESULT(no)])
921 fi],
922 [C++], [if test x != x"$MPILIBS"; then
923 AC_MSG_CHECKING([for mpi.h])
924 AC_TRY_COMPILE([#include <mpi.h>],[],[AC_MSG_RESULT(yes)], [MPILIBS=""
925 AC_MSG_RESULT(no)])
926 fi])
927
928 AC_LANG_CASE([C], [CC="$acx_mpi_save_CC"],
929 [C++], [CXX="$acx_mpi_save_CXX"],
930 [Fortran 90], [F90="$acx_mpi_save_F90"])
931
932 AC_SUBST(MPILIBS)
933
934 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
935 if test x = x"$MPILIBS"; then
936 $2
937 :
938 else
939 ifelse([$1],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$1])
940 :
941 fi
942 ])dnl ACX_MPI
943