ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/ac-tools/aclocal.m4
Revision: 749
Committed: Fri Sep 5 22:36:12 2003 UTC (20 years, 10 months ago) by gezelter
File size: 24821 byte(s)
Log Message:
fixed sprng problem

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