ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/ac-tools/aclocal.m4
Revision: 826
Committed: Mon Oct 27 23:00:59 2003 UTC (20 years, 8 months ago) by gezelter
File size: 28195 byte(s)
Log Message:
Stuff for MOD support in other compilers

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