ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/ac-tools/aclocal.m4
Revision: 878
Committed: Fri Dec 12 15:42:13 2003 UTC (20 years, 7 months ago) by gezelter
File size: 29404 byte(s)
Log Message:
Changes for gradients (to do minimizations)

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