ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/ac-tools/aclocal.m4
Revision: 944
Committed: Wed Jan 14 22:41:34 2004 UTC (20 years, 5 months ago) by gezelter
File size: 30140 byte(s)
Log Message:
autoconf fixes

File Contents

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