ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/ac-tools/aclocal.m4
Revision: 942
Committed: Wed Jan 14 15:49:26 2004 UTC (20 years, 5 months ago) by gezelter
File size: 30131 byte(s)
Log Message:
autoconf compatibility changes for icc8

File Contents

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