ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/ac-tools/aclocal.m4
Revision: 747
Committed: Fri Sep 5 21:28:52 2003 UTC (20 years, 10 months ago) by gezelter
File size: 24827 byte(s)
Log Message:
Changes to autoconf / configure method of configuring OOPSE

File Contents

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