ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/ac-tools/aclocal.m4
Revision: 2717
Committed: Mon Apr 17 21:49:12 2006 UTC (19 years, 3 months ago) by gezelter
File size: 35739 byte(s)
Log Message:
Many performance improvements

File Contents

# Content
1 dnl We need a function similar to AC_CHECK_LIB to check for C++ libraries.
2 dnl AC_CHECK_CXX_LIB provides a similar interface like AC_CHECK_LIB
3 dnl and uses AC_TRY_LINK.
4 dnl
5 dnl $1 library name (without "-l")
6 dnl $2 object name to check for
7 dnl $3 neccessary include directive(s)
8 dnl $4 command to create object $2
9 dnl $5 yes-action
10 dnl $6 no-action
11 dnl $7 include dir for $3 (with -I)
12 dnl $8 additional libraries to link with
13
14 AC_DEFUN(AC_CHECK_CXX_LIB, AC_MSG_CHECKING([for $2 in -l$1])
15 save_CXXFLAGS_CHECK_CXX_LIB="$CXXFLAGS"
16 CXXFLAGS="$CXXFLAGS $7"
17 save_LIBS_CHECK_CXX_LIB="$LIBS"
18 LIBS="-l$1 $8 $LIBS"
19 [AC_TRY_LINK([$3], [$4], [AC_MSG_RESULT([yes])
20 $5], [AC_MSG_RESULT([no])
21 $6])]
22 CXXFLAGS="$save_CXXFLAGS_CHECK_CXX_LIB"
23 LIBS="$save_LIBS_CHECK_CXX_LIB")dnl
24
25 dnl
26 dnl AC_CHECK_MODSUFFIX
27 dnl
28 AC_DEFUN([AC_CHECK_MODSUFFIX],[
29
30 AC_MSG_CHECKING(for module suffix)
31 rm -f conftest*
32 # Intel ifc compiler generates files by the name of work.pc and work.pcl (!)
33 rm -f work*
34 cat >conftest.$ac_ext <<EOF
35 module conftest
36 integer n
37 parameter (n=1)
38 end module conftest
39 EOF
40 # SGI and absoft compilers generates module name in upper case!
41 testname="conftest"
42 modcase="lower"
43 if (eval $ac_compile) 2>/dev/null ; then
44 MOD=`ls conftest* | grep -v conftest.$ac_ext | grep -v conftest.o`
45 MOD=`echo "$MOD" | sed -e 's/conftest\.//g'`
46 if test -z "$MOD" ; then
47 MOD=`ls CONFTEST* 2>/dev/null \
48 | grep -v CONFTEST.$ac_ext | grep -v CONFTEST.o`
49 MOD=`echo "$MOD" | sed -e 's/CONFTEST\.//g'`
50 if test -n "$MOD" ; then
51 testname="CONFTEST"
52 modcase="upper"
53 fi
54 fi
55 if test -z "$MOD" ; then
56 AC_MSG_RESULT(unknown)
57 # Use mod if we can't figure it out
58 MOD="mod"
59 else
60 AC_MSG_RESULT($MOD)
61 fi
62 if test -s work.pcl ; then
63 AC_MSG_WARN([Compiler generates auxillery files!])
64 fi
65 else
66 AC_MSG_RESULT(unknown)
67 fi
68 AC_SUBST(MOD)
69
70 ])
71
72
73 dnl
74 dnl AC_CHECK_MODDIRFLAG
75 dnl
76 AC_DEFUN([AC_CHECK_MODDIRFLAG],[
77
78 # Check for module include path (some use -I, some (Solaris) use -M, some
79 # (absoft) use -p).
80 # Intel compilers use a wierd system: -cl,filename.pcl . If no file is
81 # specified, work.pcl and work.pc are created. However, if you specify
82 # a file, it must contain a the name of a file ending in .pc . Ugh!
83 # Use the module made above
84 AC_MSG_CHECKING(for module directory path flag)
85 rm -f conftest*
86 # Intel ifc compiler generates files by the name of work.pc and work.pcl (!)
87 rm -f work*
88 cat >conftest.$ac_ext <<EOF
89 module conftest
90 integer n
91 parameter (n=1)
92 end module conftest
93 EOF
94 # SGI and absoft compilers generates module name in upper case!
95 testname="conftest"
96 if (eval $ac_compile) 2>/dev/null ; then
97 mod=`ls CONFTEST* 2>/dev/null | grep -v CONFTEST.$ac_ext | grep -v CONFTEST.o`
98 mod=`echo "$mod" | sed -e 's/CONFTEST\.//g'`
99 if test -n "$mod" ; then
100 testname="CONFTEST"
101 fi
102 madedir=0
103 if test ! -d conf ; then mkdir conf ; madedir=1; fi
104 cp $testname.$MOD conf
105 rm -f conftest* CONFTEST*
106 cat >conftest1.$ac_ext <<EOF
107 program main
108 use conftest
109 print *, n
110 end
111 EOF
112 F90_WORK_FILES_ARG=""
113 F90MODINCSPEC=""
114 if $FC -c -Iconf $FCFLAGS $FCFLAGS_SRCEXT conftest1.$ac_ext > conftest.out 2>&1 ; then
115 MODDIRFLAG="-I"
116 F90MODINCSPEC="-I<dir>"
117 AC_MSG_RESULT(-I)
118 elif $FC -c -Mconf $FCFLAGS $FCFLAGS_SRCEXT conftest1.$ac_ext >> conftest.out 2>&1 ; then
119 MODDIRFLAG="-M"
120 F90MODINCSPEC="-M<dir>"
121 AC_MSG_RESULT(-M)
122 elif $FC -c -pconf $FCFLAGS $FCFLAGS_SRCEXT conftest1.$ac_ext >> conftest.out 2>&1 ; then
123 MODDIRFLAG="-p"
124 F90MODINCSPEC="-p<dir>"
125 AC_MSG_RESULT(-p)
126 elif test -s work.pc ; then
127 cp work.pc conf/mpimod.pc
128 echo "mpimod.pc" > conf/mpimod.pcl
129 echo "`pwd`/conf/mpimod.pc" >> conf/mpimod.pcl
130 if $FC -c -cl,conf/mpimod.pcl $FCFLAGS $FCFLAGS_SRCEXT conftest1.$ac_ext >>conftest.out 2>&1 ; then
131 MODDIRFLAG='-cl,mpimod.pcl'
132 AC_MSG_RESULT([-cl,filename where filename contains a list of files and directories])
133 F90_WORK_FILES_ARG="-cl,mpimod.pcl"
134 F90MODINCSPEC="-cl,<dir>/<file>mod.pcl"
135 AC_SUBST(F90_WORK_FILES_ARG)
136 else
137 # The version of the Intel compiler that I have refuses to let
138 # you put the "work catalog" list anywhere but the current
139 # directory. For example, you cannot in
140 :
141 fi
142 fi
143 if test -z "MODDIRFLAG" ; then
144 AC_MSG_RESULT(unknown)
145 fi
146 AC_SUBST(MODDIRFLAG)
147 AC_SUBST(F90MODINCSPEC)
148 rm -f conftest* conf/conftest* conf/CONFTEST* CONFTEST* conf/mpimod*
149 if test $madedir = 1 ; then rmdir conf ; fi
150 fi
151
152 ])
153
154 AC_DEFUN(ACX_CHECK_CC_FLAGS,
155 [
156 AC_REQUIRE([AC_PROG_CC])
157 AC_CACHE_CHECK(whether ${CC} accepts $1, ac_$2,
158 [echo 'void f(){}' > conftest.c
159 if test -z "`${CC} $1 -c conftest.c 2>&1`"; then
160 ac_$2=yes
161 else
162 ac_$2=no
163 fi
164 rm -f conftest*
165 ])
166 if test "$ac_$2" = yes; then
167 :
168 $3
169 else
170 :
171 $4
172 fi
173 ])
174
175 AC_DEFUN(ACX_CHECK_CXX_FLAGS,
176 [
177 AC_REQUIRE([AC_PROG_CXX])
178 AC_CACHE_CHECK(whether ${CXX} accepts $1, ac_$2,
179 [echo 'void f(){}' > conftest.cpp
180 if test -z "`${CXX} $1 -c conftest.cpp 2>&1`"; then
181 ac_$2=yes
182 else
183 ac_$2=no
184 fi
185 rm -f conftest*
186 ])
187 if test "$ac_$2" = yes; then
188 :
189 $3
190 else
191 :
192 $4
193 fi
194 ])
195
196 dnl -------------------------------------------------------------------------
197 dnl ACX_CHECK_FC_FLAGS()
198 dnl
199 dnl Check for optimizer flags the Fortran compiler can use.
200 dnl
201 AC_DEFUN(ACX_CHECK_FC_FLAGS,
202 [
203 AC_CACHE_CHECK(whether ${FC} accepts $1, ac_$2,
204 [
205 AC_LANG_SAVE
206 AC_LANG(Fortran)
207 echo 'program main' > conftest.$ac_ext
208 echo 'end program main' >> conftest.$ac_ext
209 ac_compile='${FC} -c $1 $FCFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext 1>&AC_FD_CC'
210 if AC_TRY_EVAL(ac_compile); then
211 ac_$2=yes
212 else
213 ac_$2=no
214 fi
215 rm -f conftest*
216 AC_LANG_RESTORE()
217 ])
218 if test "$ac_$2" = yes; then
219 :
220 $3
221 else
222 :
223 $4
224 fi
225 ])
226
227 AC_DEFUN(ACX_PROG_GCC_VERSION,
228 [
229 AC_REQUIRE([AC_PROG_CC])
230 AC_CACHE_CHECK(whether we are using gcc $1.$2 or later, ac_cv_prog_gcc_$1_$2,
231 [
232 dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
233 cat > conftest.c <<EOF
234 #ifdef __GNUC__ && !defined (__INTEL_COMPILER)
235 # if (__GNUC__ > $1) || (__GNUC__ == $1 && __GNUC_MINOR__ >= $2)
236 yes;
237 # endif
238 #endif
239 EOF
240 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
241 ac_cv_prog_gcc_$1_$2=yes
242 else
243 ac_cv_prog_gcc_$1_$2=no
244 fi
245 ])
246 if test "$ac_cv_prog_gcc_$1_$2" = yes; then
247 :
248 $3
249 else
250 :
251 $4
252 fi
253 ])
254
255 AC_DEFUN(ACX_PROG_GXX_VERSION,
256 [
257 AC_REQUIRE([AC_PROG_CXX])
258 AC_CACHE_CHECK(whether we are using g++ $1.$2 or later, ac_cv_prog_gxx_$1_$2,
259 [
260 dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
261 cat > conftest.cpp <<EOF
262 #ifdef __GNUC__ && !defined (__INTEL_COMPILER)
263 # if (__GNUC__ > $1) || (__GNUC__ == $1 && __GNUC_MINOR__ >= $2)
264 yes;
265 # endif
266 #endif
267 EOF
268 if AC_TRY_COMMAND(${CXX-c++} -E conftest.cpp) | egrep yes >/dev/null 2>&1; then
269 ac_cv_prog_gxx_$1_$2=yes
270 else
271 ac_cv_prog_gxx_$1_$2=no
272 fi
273 ])
274 if test "$ac_cv_prog_gxx_$1_$2" = yes; then
275 :
276 $3
277 else
278 :
279 $4
280 fi
281 ])
282
283 AC_DEFUN(ACX_PROG_REALLY_GCC,
284 [
285 AC_REQUIRE([AC_PROG_CC])
286 AC_CACHE_CHECK(whether we are *really* using GNU cc, ac_cv_prog_really_gcc,
287 [
288 dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
289 cat > conftest.c <<EOF
290 #ifdef __GNUC__
291 #if defined(__INTEL_COMPILER) || defined(__PATHCC__)
292 no;
293 #else
294 yes;
295 #endif
296 #endif
297 EOF
298 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
299 ac_cv_prog_really_gcc=yes
300 else
301 ac_cv_prog_really_gcc=no
302 fi
303 ])
304 if test "$ac_cv_prog_really_gcc" = yes; then
305 :
306 $1
307 else
308 :
309 $2
310 fi
311 ])
312
313 AC_DEFUN(ACX_PROG_REALLY_GXX,
314 [
315 AC_REQUIRE([AC_PROG_CXX])
316 AC_CACHE_CHECK(whether we are *really* using GNU c++, ac_cv_prog_really_gxx,
317 [
318 dnl The semicolon after "yes" below is to pacify NeXT's syntax-checking cpp.
319 cat > conftest.cpp <<EOF
320 #ifdef __GNUC__
321 #if defined(__INTEL_COMPILER) || defined(__PATHCC__)
322 no;
323 #else
324 yes;
325 #endif
326 #endif
327 EOF
328 if AC_TRY_COMMAND(${CXX-c++} -E conftest.cpp) | egrep yes >/dev/null 2>&1; then
329 ac_cv_prog_really_gxx=yes
330 else
331 ac_cv_prog_really_gxx=no
332 fi
333 ])
334 if test "$ac_cv_prog_really_gxx" = yes; then
335 :
336 $1
337 else
338 :
339 $2
340 fi
341 ])
342
343
344 AC_DEFUN(ACX_PROG_CC_MAXOPT,
345 [
346 AC_REQUIRE([AC_PROG_CC])
347 AC_REQUIRE([AC_CANONICAL_HOST])
348
349 ACX_PROG_REALLY_GCC
350
351 # Try to determine "good" native compiler flags if none specified on command
352 # line
353 if test "$ac_test_CFLAGS" != "set"; then
354 CFLAGS=""
355 case "${host_cpu}-${host_os}" in
356
357 *linux*) if test "$CC" = icc; then
358 CFLAGS="-O"
359 fi;;
360 sparc-solaris2*) if test "$CC" = cc; then
361 CFLAGS="-O -dalign"
362 fi;;
363
364 alpha*-osf*) if test "$CC" = cc; then
365 CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host -arch host -std1"
366 fi;;
367
368 hppa*-hpux*) if test "$CC" = cc; then
369 CFLAGS="-Ae +O3 +Oall"
370 fi;;
371
372 rs6000*-aix*) if test "$CC" = cc -o "$CC" = xlc; then
373 CFLAGS="-O3 -qtune=auto -qansialias -w"
374 fi;;
375 powerpc*-aix*)
376 if test "$CC" = cc -o "$CC" = xlc; then
377 CFLAGS="-O3 -qtune=auto -qansialias -w"
378 echo "*******************************************************"
379 echo "* You have AIX on an unknown powerpc system. It is *"
380 echo "* recommended that you use *"
381 echo "* *"
382 echo "* CFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
383 echo "* ^^^ *"
384 echo "* where xxx is 601, 603, 604, or whatever kind of *"
385 echo "* PowerPC CPU you have. For more info, man cc. *"
386 echo "*******************************************************"
387 fi;;
388 *darwin*)
389 if test "$CC" = xlc -o "$CC" = cc; then
390 CFLAGS="-qthreaded -O -qtune=auto -qarch=auto -qunroll=auto -qaltivec"
391 fi;;
392 esac
393
394 # use default flags for gcc on all systems
395 if test $ac_cv_prog_really_gcc = yes; then
396 CFLAGS="-O6 -fomit-frame-pointer -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic"
397 fi
398
399 # test for gcc-specific flags:
400 if test $ac_cv_prog_really_gcc = yes; then
401 # -malign-double for x86 systems
402 ACX_CHECK_CC_FLAGS(-malign-double,align_double, CFLAGS="$CFLAGS -malign-double")
403 # -fstrict-aliasing for gcc-2.95+
404 ACX_CHECK_CC_FLAGS(-fstrict-aliasing,fstrict_aliasing, CFLAGS="$CFLAGS -fstrict-aliasing")
405 fi
406
407 CPU_FLAGS=""
408 if test $ac_cv_prog_really_gcc = yes; then
409 dnl try to guess correct CPU flags, at least for linux
410 case "${host_cpu}" in
411 i586*) ACX_CHECK_CC_FLAGS(-mcpu=pentium,cpu_pentium,
412 [CPU_FLAGS=-mcpu=pentium],
413 [ACX_CHECK_CC_FLAGS(-mpentium,pentium,
414 [CPU_FLAGS=-mpentium])])
415 ;;
416 i686*) ACX_CHECK_CC_FLAGS(-mcpu=pentiumpro,cpu_pentiumpro,
417 [CPU_FLAGS=-mcpu=pentiumpro],
418 [ACX_CHECK_CC_FLAGS(-mpentiumpro,pentiumpro,
419 [CPU_FLAGS=-mpentiumpro])])
420 ;;
421 powerpc*)
422 cputype=`(grep cpu /proc/cpuinfo | head -1 | cut -d: -f2 | sed 's/ //g') 2> /dev/null`
423 is60x=`echo $cputype | egrep "^60[0-9]e?$"`
424 if test -n "$is60x"; then
425 ACX_CHECK_CC_FLAGS(-mcpu=$cputype,m_cpu_60x,
426 CPU_FLAGS=-mcpu=$cputype)
427 elif test "$cputype" = 750; then
428 ACX_PROG_GCC_VERSION(2,95,
429 ACX_CHECK_CC_FLAGS(-mcpu=750,m_cpu_750,
430 CPU_FLAGS=-mcpu=750))
431 fi
432 if test -z "$CPU_FLAGS"; then
433 ACX_CHECK_CC_FLAGS(-mcpu=powerpc,m_cpu_powerpc,
434 CPU_FLAGS=-mcpu=powerpc)
435 fi
436 if test -z "$CPU_FLAGS"; then
437 ACX_CHECK_CC_FLAGS(-mpowerpc,m_powerpc,
438 CPU_FLAGS=-mpowerpc)
439 fi
440 esac
441 fi
442
443 if test -n "$CPU_FLAGS"; then
444 CFLAGS="$CFLAGS $CPU_FLAGS"
445 fi
446
447 if test -z "$CFLAGS"; then
448 echo ""
449 echo "********************************************************"
450 echo "* WARNING: Don't know the best CFLAGS for this system *"
451 echo "* Use make CFLAGS=..., or edit the top level Makefile *"
452 echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
453 echo "********************************************************"
454 echo ""
455 CFLAGS="-O3"
456 fi
457
458 ACX_CHECK_CC_FLAGS(${CFLAGS}, guessed_cflags, , [
459 echo ""
460 echo "********************************************************"
461 echo "* WARNING: The guessed CFLAGS don't seem to work with *"
462 echo "* your compiler. *"
463 echo "* Use make CFLAGS=..., or edit the top level Makefile *"
464 echo "********************************************************"
465 echo ""
466 CFLAGS=""
467 ])
468
469 fi
470 ])
471
472 AC_DEFUN(ACX_PROG_CXX_MAXOPT,
473 [
474 AC_REQUIRE([AC_PROG_CXX])
475 AC_REQUIRE([AC_CANONICAL_HOST])
476
477 ACX_PROG_REALLY_GXX
478
479 # Try to determine "good" native compiler flags if none specified on command
480 # line
481 if test "$ac_test_CXXFLAGS" != "set"; then
482 CXXFLAGS=""
483 case "${host_cpu}-${host_os}" in
484
485 *linux*) if test "$CXX" = icc -o "$CXX" = icpc; then
486 CXXFLAGS="-O"
487 fi;;
488 sparc-solaris2*) if test "$CXX" = CC; then
489 CXXFLAGS="-features=extensions -O -dalign"
490 fi;;
491 rs6000*-aix*) if test "$CXX" = xlC; then
492 CXXFLAGS="-O3 -qarch=pwrx -qtune=pwrx -qansialias -w"
493 fi;;
494 powerpc*-aix*)
495 if test "$CXX" = xlC; then
496 CXXFLAGS="-O3 -qarch=ppc -qansialias -w"
497 echo "*******************************************************"
498 echo "* You have AIX on an unknown powerpc system. It is *"
499 echo "* recommended that you use *"
500 echo "* *"
501 echo "* CXXFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
502 echo "* ^^^ *"
503 echo "* where xxx is 601, 603, 604, or whatever kind of *"
504 echo "* PowerPC CPU you have. For more info, man cc. *"
505 echo "*******************************************************"
506 fi;;
507 *darwin*)
508 if test "$CXX" = xlc++ -o "$CXX" = xlC ; then
509 CXXFLAGS="-qthreaded -O -qtune=auto -qarch=auto -qunroll=auto -qaltivec"
510 fi;;
511 esac
512
513 # use default flags for gcc on all systems
514 if test $ac_cv_prog_really_gxx = yes; then
515 CXXFLAGS="-O6 -fomit-frame-pointer -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -pedantic"
516 fi
517
518 # test for gcc-specific flags:
519 if test $ac_cv_prog_really_gxx = yes; then
520 # -malign-double for x86 systems
521 ACX_CHECK_CXX_FLAGS(-malign-double,align_double, CXXFLAGS="$CXXFLAGS -malign-double")
522 # -fstrict-aliasing for gcc-2.95+
523 ACX_CHECK_CXX_FLAGS(-fstrict-aliasing,fstrict_aliasing, CXXFLAGS="$CXXFLAGS -fstrict-aliasing")
524 fi
525
526 CPU_FLAGS=""
527 if test $ac_cv_prog_really_gxx = yes; then
528 dnl try to guess correct CPU flags, at least for linux
529 case "${host_cpu}" in
530 i586*) ACX_CHECK_CXX_FLAGS(-mcpu=pentium,cpu_pentium,
531 [CPU_FLAGS=-mcpu=pentium],
532 [ACX_CHECK_CXX_FLAGS(-mpentium,pentium,
533 [CPU_FLAGS=-mpentium])])
534 ;;
535 i686*) ACX_CHECK_CXX_FLAGS(-mcpu=pentiumpro,cpu_pentiumpro,
536 [CPU_FLAGS=-mcpu=pentiumpro],
537 [ACX_CHECK_CXX_FLAGS(-mpentiumpro,pentiumpro,
538 [CPU_FLAGS=-mpentiumpro])])
539 ;;
540 powerpc*)
541 cputype=`(grep cpu /proc/cpuinfo | head -1 | cut -d: -f2 | sed 's/ //g') 2> /dev/null`
542 is60x=`echo $cputype | egrep "^60[0-9]e?$"`
543 if test -n "$is60x"; then
544 ACX_CHECK_CXX_FLAGS(-mcpu=$cputype,m_cpu_60x,
545 CPU_FLAGS=-mcpu=$cputype)
546 elif test "$cputype" = 750; then
547 ACX_PROG_GXX_VERSION(2,95,
548 ACX_CHECK_CXX_FLAGS(-mcpu=750,m_cpu_750,
549 CPU_FLAGS=-mcpu=750))
550 fi
551 if test -z "$CPU_FLAGS"; then
552 ACX_CHECK_CXX_FLAGS(-mcpu=powerpc,m_cpu_powerpc,
553 CPU_FLAGS=-mcpu=powerpc)
554 fi
555 if test -z "$CPU_FLAGS"; then
556 ACX_CHECK_CXX_FLAGS(-mpowerpc,m_powerpc,
557 CPU_FLAGS=-mpowerpc)
558 fi
559 esac
560 fi
561
562 if test -n "$CPU_FLAGS"; then
563 CXXFLAGS="$CXXFLAGS $CPU_FLAGS"
564 fi
565
566 if test -z "$CXXFLAGS"; then
567 echo ""
568 echo "**********************************************************"
569 echo "* WARNING: Don't know the best CXXFLAGS for this system *"
570 echo "* Use make CXXFLAGS=..., or edit the top level Makefile *"
571 echo "* (otherwise, a default of CXXFLAGS=-O3 will be used) *"
572 echo "**********************************************************"
573 echo ""
574 CXXFLAGS="-O3"
575 fi
576
577 ACX_CHECK_CXX_FLAGS(${CXXFLAGS}, guessed_cxxflags, , [
578 echo ""
579 echo "**********************************************************"
580 echo "* WARNING: The guessed CXXFLAGS don't seem to work with *"
581 echo "* your compiler. *"
582 echo "* Use make CXXFLAGS=..., or edit the top level Makefile *"
583 echo "**********************************************************"
584 echo ""
585 CXXFLAGS=""
586 ])
587
588 fi
589 ])
590
591 AC_DEFUN(ACX_PROG_FC_MAXOPT,
592 [
593 AC_REQUIRE([AC_PROG_FC])
594 AC_REQUIRE([AC_CANONICAL_HOST])
595
596 # Try to determine "good" native compiler flags if none specified on command
597 # line
598
599 if test "$ac_test_FFLAGS" != "set"; then
600 FCFLAGS=""
601 case "${host_cpu}-${host_os}" in
602
603 *linux*) if test "$FC" = ifc -o "$FC" = ifort; then
604 FCFLAGS="-O"
605 fi;;
606 rs6000*-aix*) if test "$FC" = xlf90 -o "$FC" = f90 -o "$FC" = xlf95; then
607 FCFLAGS="-O3 -qarch=pwrx -qtune=pwrx -qansialias -w"
608 fi;;
609 powerpc*-aix*)
610 if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
611 FCFLAGS="-O3 -qarch=ppc -qansialias -w"
612 echo "*******************************************************"
613 echo "* You have AIX on an unknown powerpc system. It is *"
614 echo "* recommended that you use *"
615 echo "* *"
616 echo "* FCFLAGS=-O3 -qarch=ppc -qtune=xxx -qansialias -w *"
617 echo "* ^^^ *"
618 echo "* where xxx is 601, 603, 604, or whatever kind of *"
619 echo "* PowerPC CPU you have. For more info, man xlf. *"
620 echo "*******************************************************"
621 fi;;
622 *darwin*)
623 if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
624 FCFLAGS="-qthreaded -O -qtune=auto -qarch=auto -qunroll=auto"
625 fi;;
626 esac
627
628 if test -n "$CPU_FLAGS"; then
629 FCFLAGS="$FCFLAGS $CPU_FLAGS"
630 fi
631
632 if test -z "$FCFLAGS"; then
633 echo ""
634 echo "*********************************************************"
635 echo "* WARNING: Don't know the best FCFLAGS for this system *"
636 echo "* Use make FCFLAGS=..., or edit the top level Makefile *"
637 echo "* (otherwise, a default of FCFLAGS=-O3 will be used) *"
638 echo "*********************************************************"
639 echo ""
640 FCFLAGS="-O3"
641 fi
642
643 ACX_CHECK_FC_FLAGS(${FCFLAGS}, guessed_f90flags, , [
644 echo ""
645 echo "**********************************************************"
646 echo "* WARNING: The guessed FCFLAGS don't seem to work with *"
647 echo "* your compiler. *"
648 echo "* Use make FCFLAGS=..., or edit the top level Makefile *"
649 echo "*********************************************************"
650 echo ""
651 FCFLAGS=""
652 ])
653
654 fi
655 ])
656
657 AC_DEFUN(ACX_PROG_F90_PREPFLAG,
658 [
659 AC_REQUIRE([AC_PROG_FC])
660 AC_REQUIRE([AC_CANONICAL_HOST])
661
662 # Try to determine native compiler flags that allow us to use F90 suffix
663 # for preprocessed f90 source.
664
665 if test "$ac_test_PREPFLAG" != "set"; then
666 PREPFLAG=""
667 case "${host_cpu}-${host_os}" in
668
669 *linux*) if test "$FC" = ifc -o "$FC" = ifort; then
670 PREPFLAG="-fpp1 "
671 fi;;
672 *aix*) if test "$FC" = xlf90 -o "$FC" = f90 -o "$FC" = xlf95; then
673 PREPFLAG="-qsuffix=cpp=F90 "
674 fi;;
675 *darwin*)
676 if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
677 PREPFLAG="-qsuffix=cpp=F90 "
678 fi;;
679 esac
680
681 if test -z "$PREPFLAG"; then
682 AC_MSG_WARN("Using empty PREPFLAG")
683 PREPFLAG=""
684 fi
685
686 AC_MSG_CHECKING(to make sure F90 preprocessor flag works)
687 AC_LANG_SAVE()
688 AC_LANG(Fortran)
689 ac_save_ext=$ac_ext
690 ac_ext=F90
691 ac_save_FCFLAGS_SRCEXT=$FCFLAGS_SRCEXT
692
693 AS_IF([test "$PREPFLAG"], [FCFLAGS_SRCEXT="${PREPFLAG}"])
694 _AC_COMPILE_IFELSE([
695 AC_LANG_SOURCE([
696 program conftest
697 integer :: i
698 i = 1
699 end program conftest
700 ])], [prepflagworks=1], [prepflagworks=0])
701
702 FCFLAGS_SRCEXT=$ac_save_FCFLAGS_SRCEXT
703 ac_ext=$ac_save_ext
704 AC_LANG_RESTORE()
705
706 if test "$prepflagworks" = 1; then
707 AC_MSG_RESULT(yes)
708 FCFLAGS_SRCEXT="${PREPFLAG}"
709 AC_SUBST(FCFLAGS_SRCEXT)
710 else
711 AC_MSG_RESULT(no)
712 AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor flag])
713 fi
714 fi
715 ])
716
717
718 AC_DEFUN(ACX_PROG_F90_PREPDEFFLAG,
719 [
720 AC_REQUIRE([AC_PROG_FC])
721 AC_REQUIRE([AC_CANONICAL_HOST])
722
723 # Try to determine native compiler flags that allow us to use F90 suffix
724 # for preprocessed f90 source with -D type defines
725
726 if test "$ac_test_PREPDEFFLAG" != "set"; then
727 PREPDEFFLAG=""
728 case "${host_cpu}-${host_os}" in
729
730 *linux*) if test "$FC" = ifc -o "$FC" = ifort; then
731 PREPDEFFLAG=" "
732 fi;;
733 *aix*) if test "$FC" = xlf90 -o "$FC" = f90 -o "$FC" = xlf95; then
734 PREPDEFFLAG="-WF,"
735 fi;;
736 *darwin*)
737 if test "$FC" = f90 -o "$FC" = xlf90 -o "$FC" = xlf95; then
738 PREPDEFFLAG="-WF,"
739 fi;;
740 esac
741
742 if test -z "$PREPDEFFLAG"; then
743 AC_MSG_WARN("Using empty PREPDEFFLAG")
744 PREPDEFFLAG=" "
745 fi
746
747 AC_MSG_CHECKING(to make sure F90 preprocessor define flag works)
748 AC_LANG_SAVE()
749 AC_LANG(Fortran)
750 ac_save_ext=$ac_ext
751 ac_ext=F90
752 ac_save_FCFLAGS=$FCFLAGS
753
754 AS_IF([test "$PREPDEFFLAG"], [FCFLAGS="${FCFLAGS} ${PREPDEFFLAG}-DTEST"])
755 _AC_COMPILE_IFELSE([
756 AC_LANG_SOURCE([
757 program conftest
758 integer :: i
759 #ifdef TEST
760 i = 1
761 #else
762 choke me
763 #endif
764 end program conftest
765 ])], [prepdefflagworks=1], [prepdefflagworks=0])
766
767 FCFLAGS=$ac_save_FCFLAGS
768 ac_ext=$ac_save_ext
769 AC_LANG_RESTORE()
770
771 if test "$prepdefflagworks" = 1; then
772 AC_MSG_RESULT(yes)
773 AC_SUBST(PREPDEFFLAG)
774 else
775 AC_MSG_RESULT(no)
776 AC_MSG_ERROR([Can't figure out working Fortran90 preprocessor define flag])
777 fi
778 fi
779 ])
780
781 dnl check for the required MPI library
782 AC_DEFUN([ACX_MPI], [
783
784 # Set variables...
785 MPI_LIB_DIR="$MPI/lib"
786 MPI_INC_DIR="$MPI/include"
787 AC_SUBST([MPI_LIB_DIR])
788 AC_SUBST([MPI_INC_DIR])
789
790 AC_MSG_CHECKING([for mpi.h])
791 have_mpi_h=0
792 rm -f conftest*
793 echo '#include <mpi.h>' > conftest.cc
794 if ${CXX} -I${MPI_INC_DIR} -c conftest.cc 2>&1 ; then
795 AC_MSG_RESULT(yes)
796 have_mpi_h=1
797 else
798 if test -s conftest.out ; then
799 cat conftest.out >> config.log
800 fi
801 AC_MSG_RESULT(no! Check MPI include paths)
802 USE_MPI="no"
803 fi
804 rm -f conftest*
805 if test "$have_mpi_h" = 1; then
806 AC_DEFINE(HAVE_MPI_H, 1, [have mpi.h])
807 fi
808
809 AC_MSG_CHECKING([whether mpif.h is usable])
810 have_mpif_h=0
811 rm -f conftest*
812 cat >conftest.$ac_ext <<EOF
813 program main
814 include 'mpif.h'
815 end
816 EOF
817 if $FC -I$MPI_INC_DIR -c $FCFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext > conftest.out 2>&1 ; then
818 AC_MSG_RESULT(yes)
819 MPI_F90_INC="$MPI_INC_DIR"
820 have_mpif_h=1
821 else
822 if test -s conftest.out ; then
823 cat conftest.out >> config.log
824 fi
825 AC_MSG_RESULT([no! Check MPI include paths])
826 USE_MPI="no"
827 fi
828 rm -f conftest*
829 AC_SUBST(MPI_F90_INC)
830 if test "$have_mpif_h" = 1; then
831 AC_DEFINE(HAVE_MPIF_H, 1, [have mpif.h])
832 fi
833
834 AC_LANG_PUSH(C)
835 ac_save_LDFLAGS=$LDFLAGS
836 LDFLAGS="${LDFLAGS} -L${MPI_LIB_DIR} "
837
838 if test x = x"$MPI_LIB"; then
839 AC_CHECK_LIB(mpich, MPI_Init, [MPI_LIB="-lmpich"])
840 fi
841 if test x = x"$MPI_LIB"; then
842 AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi"])
843 fi
844 $as_unset ac_cv_lib_mpi_MPI_Init
845 if test x = x"$MPI_LIB"; then
846 AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi -llam"], [],
847 "-llam")
848 fi
849 $as_unset ac_cv_lib_mpich_MPI_Init
850 if test x = x"$MPI_LIB"; then
851 AC_CHECK_LIB(mpich, MPI_Init, [MPI_LIB="-lpmpich -lmpich"], [],
852 "-lpmpich")
853 fi
854
855 $as_unset ac_cv_lib_mpi_MPI_Init
856 if test x = x"$MPI_LIB"; then
857 AC_CHECK_LIB(mpi, MPI_Init, [MPI_LIB="-lmpi -llam -lpthread"],[
858 AC_MSG_ERROR([Didn't find liblam, libmpi, or libmpich; check path for MPI package first...])
859 USE_MPI="no"
860 ],
861 [-llam -lpthread])
862 fi
863
864 AC_SUBST(MPI_LIB)
865
866 AC_MSG_CHECKING([for MPI Fortran library])
867 MPI_F90_LIB=""
868 if test -f "$MPI_LIB_DIR/libfmpich.a" ; then
869 MPI_F90_LIB="-lfmpich"
870 elif test -f "$MPI_LIB_DIR/liblamf77mpi.a" ; then
871 MPI_F90_LIB="-llamf77mpi"
872 else
873 dnl nothing special found, we'll assume that the C
874 dnl library is all we need
875 MPI_F90_LIB=" "
876 fi
877 AC_MSG_RESULT([found $MPI_F90_LIB])
878 AC_SUBST(MPI_F90_LIB)
879 ])dnl ACX_MPI
880
881 AC_DEFUN([adl_FUNC_GETOPT_LONG],
882 [AC_PREREQ(2.49)dnl
883 # clean out junk possibly left behind by a previous configuration
884 rm -f src/getopt.h
885 # Check for getopt_long support
886 AC_CHECK_HEADERS([getopt.h])
887 AC_CHECK_FUNCS([getopt_long],,
888 [# FreeBSD has a gnugetopt library for this
889 AC_CHECK_LIB([gnugetopt],[getopt_long],[AC_DEFINE([HAVE_GETOPT_LONG])],
890 [# use the GNU replacement
891 AC_LIBOBJ(getopt)
892 AC_LIBOBJ(getopt1)
893 AC_CONFIG_LINKS([src/getopt.h:src/utils/gnugetopt.h])])])])
894
895
896 AC_DEFUN([ACX_CONFIG_HOME], [
897 myDir=${0%/*}
898 if [ "$myDir" = "$0" ]; then
899 # Ran from local directory
900 myDir=$PWD
901 fi
902 # Resolve symlinks.
903 myProgram="$0"
904 while [ -L "$myProgram" ]; do
905 ls=`/bin/ls -ld "$myProgram"`
906 link=`/usr/bin/expr "$ls" : '.*-> \(.*\)$'`
907 if /usr/bin/expr "$link" : '.*/.*' > /dev/null; then
908 myProgram="$link"
909 else
910 myProgram="`AS_DIRNAME([$myProgram])`/$link"
911 fi
912 done
913 myDir=`AS_DIRNAME([$myProgram])`
914 fi
915 CONFIG_HOME=$myDir
916 ])
917
918 AC_DEFUN(BB_ENABLE_DOXYGEN,
919 [
920 AC_ARG_ENABLE(doxygen, [ --enable-doxygen enable documentation generation with doxygen (auto)])
921 AC_ARG_ENABLE(dot, [ --enable-dot use 'dot' to generate graphs in doxygen (auto)])
922 AC_ARG_ENABLE(html-docs, [ --enable-html-docs enable HTML generation with doxygen (yes)], [], [ enable_html_docs=yes])
923 AC_ARG_ENABLE(latex-docs, [ --enable-latex-docs enable LaTeX documentation generation with doxygen (no)], [], [ enable_latex_docs=no])
924 if test "x$enable_doxygen" = xno; then
925 enable_doc=no
926 else
927 AC_PATH_PROG(DOXYGEN, doxygen, , $PATH)
928 if test "x$DOXYGEN" = x; then
929 if test "x$enable_doxygen" = xyes; then
930 AC_MSG_ERROR([could not find doxygen])
931 fi
932 enable_doc=no
933 else
934 enable_doc=yes
935 AC_PATH_PROG(DOT, dot, , $PATH)
936 fi
937 fi
938
939 if test "x$enable_doc" = xyes; then
940 DOC=1
941 else
942 DOC=0
943 fi
944 AC_SUBST(DOC)
945
946 if test x$DOT = x; then
947 if test "x$enable_dot" = xyes; then
948 AC_MSG_ERROR([could not find dot])
949 fi
950 enable_dot=no
951 else
952 enable_dot=yes
953 fi
954 AC_SUBST(enable_dot)
955 AC_SUBST(enable_html_docs)
956 AC_SUBST(enable_latex_docs)
957 ])
958 #
959 #
960 #
961 AC_DEFUN([AX_SYS_PERLSHARPBANG],[dnl
962
963 AC_PATH_PROG(PERLINTERP,perl,perl)
964 ac_cv_path_perlinterp="$PERLINTERP"
965 _sHpB='#!'
966
967 AC_ARG_WITH(perl-shebang,
968 AC_HELP_STRING([--with-perl-shebang],
969 [override what perl thinks is the way for the kernel to start it (seldom needed)]dnl
970 ),
971 [opt_perl_shebang="$withval"]dnl
972 ,dnl
973 [opt_perl_shebang="not_set"]dnl
974 )dnl
975
976 AC_CACHE_CHECK([whether explicit instead of detected sharpbang is to be used],
977 ax_cv_opt_perl_shebang,
978 [ case "$opt_perl_shebang" in
979 not_set ) ax_cv_opt_perl_shebang=''
980 ;;
981 * )
982 ax_cv_opt_perl_shebang=`echo "$opt_perl_shebang" | sed -e's|^#!\s*\(.*\)$|\1|'`
983 esac
984 ]dnl
985 )dnl
986
987 if test "A$ax_cv_opt_perl_shebang" != "A"
988 then
989 ac_cv_sys_kernshrpbang_perl="$ax_cv_opt_perl_shebang"
990 PERL_SHEBANG="$ac_cv_sys_kernshrpbang_perl"
991 AC_SUBST(PERL_SHEBANG)dnl
992 AC_MSG_NOTICE([OK - PERL_SHEBANG is $_sHpB$PERL_SHEBANG.])
993
994 # Automatic detection of sharpbang formula starts here
995 else dnl
996
997 _somian_shbangperl=`$PERLINTERP -V:startperl`
998 negclass="[[^']]"; dnl
999 # must leave this comment: m4 will remove the outer brackets for us, heheh
1000 AC_CACHE_CHECK([for kernel sharpbang invocation to start perl],
1001 ac_cv_sys_kernshrpbang_perl,
1002 [_somian_kspb_perl=`echo "$_somian_shbangperl" | sed -ne"s|.*='\($negclass*\)';$|\1|p"`
1003 if test "x$_somian_kspb_perl" == x
1004 then _somian_ksbp_warn_empty='durnit'
1005 else
1006 case "A$_somian_kspb_perl" in
1007 A#!*perl* )
1008 ac_cv_sys_kernshrpbang_perl=`echo "$_somian_kspb_perl" | sed -e's|#!\(.*\)$|\1|'`
1009 ;;
1010 A* ) _somian_ksbp_warn_defau='trouble'
1011 ac_cv_sys_kernshrpbang_perl="$PERLINTERP"
1012 esac
1013 fi
1014 ])dnl Done with testing sharpbang
1015
1016 # The above prints Checking ... result message to user.
1017 PERL_SHEBANG="$ac_cv_sys_kernshrpbang_perl"
1018 AC_SUBST(PERL_SHEBANG)
1019 if test A${_somian_ksbp_warn_empty+set} == Aset
1020 then AC_MSG_WARN([dnl
1021 In last check, doing $PERLINTERP -V:startperl yielded empty result! That should not happen.])
1022 fi
1023 # Inform user after printing result value
1024 if test A${_somian_ksbp_warn_defau+set} == Aset
1025 then AC_MSG_NOTICE([Maybe Not good -])
1026 AC_MSG_WARN([dnl
1027 In last check perl's Config query did not work so we bunted: $_sHpB$PERLINTERP])
1028 else AC_MSG_NOTICE([OK Good result - ])
1029 AC_MSG_NOTICE([dnl
1030 In last check we got a proper-looking answer from perl's Config: $_somian_shbangperl])
1031 dnl Done with user info messages
1032 fi
1033 dnl Outer loop checked for user override term here
1034 fi dnl
1035
1036 ])dnl EOMACRO DEF
1037
1038 AC_DEFUN([ACX_CHECK_ZLIB],
1039 #
1040 # Handle user hints
1041 #
1042 [AC_MSG_CHECKING(if zlib is wanted)
1043 AC_ARG_WITH(zlib,
1044 [ --with-zlib=DIR root directory path of zlib installation [defaults to
1045 /usr/local or /usr if not found in /usr/local]
1046 --without-zlib to disable zlib usage completely],
1047 [if test "$withval" != no ; then
1048 AC_MSG_RESULT(yes)
1049 if test -d "$withval"
1050 then
1051 ZLIB_HOME="$withval"
1052 else
1053 AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
1054 fi
1055 else
1056 AC_MSG_RESULT(no)
1057 fi])
1058
1059 ZLIB_HOME=/usr/local
1060 if test ! -f "${ZLIB_HOME}/include/zlib.h"
1061 then
1062 ZLIB_HOME=/usr
1063 fi
1064
1065 #
1066 # Locate zlib, if wanted
1067 #
1068 if test -n "${ZLIB_HOME}"
1069 then
1070 ZLIB_OLD_LDFLAGS=$LDFLAGS
1071 ZLIB_OLD_CPPFLAGS=$LDFLAGS
1072 LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
1073 CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
1074 AC_LANG_SAVE
1075 AC_LANG_C
1076 AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no])
1077 AC_CHECK_HEADER(zlib.h, [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
1078 AC_LANG_RESTORE
1079 if test "$zlib_cv_libz" = "yes" -a "$zlib_cv_zlib_h" = "yes"
1080 then
1081 #
1082 # If both library and header were found, use them
1083 #
1084 AC_CHECK_LIB(z, inflateEnd)
1085 AC_MSG_CHECKING(zlib in ${ZLIB_HOME})
1086 AC_MSG_RESULT(ok)
1087 else
1088 #
1089 # If either header or library was not found, revert and bomb
1090 #
1091 AC_MSG_CHECKING(zlib in ${ZLIB_HOME})
1092 LDFLAGS="$ZLIB_OLD_LDFLAGS"
1093 CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
1094 AC_MSG_RESULT(failed)
1095 AC_MSG_ERROR(either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib)
1096 fi
1097 fi
1098
1099 ])
1100 # AC_F90_MODULE_NAMES
1101 # -------------------
1102 #
1103 # Figure out how the Fortran 90 compiler constructs module file names
1104 #
1105 AC_DEFUN([AC_F90_MODULE_NAMES],
1106 [AC_REQUIRE([AC_PROG_FC])dnl
1107 AC_CACHE_CHECK([for Fortran 90 module file names],
1108 ac_cv_f90_module_names,
1109 [AC_LANG_PUSH(Fortran)
1110 # carry out the test in a new directory, so that we don't miss anything
1111 mkdir conftest
1112 cd conftest
1113 AC_COMPILE_IFELSE(
1114 [MODULE Bar
1115 END MODULE Bar],
1116 ac_cv_f90_module_names=
1117 [ac_file_list=*
1118 for ac_file in $ac_file_list; do
1119 case $ac_file in
1120 # don't care for original source and object files
1121 conftest.$ac_ext | conftest.$ac_objext | conftest.err )
1122 :
1123 ;;
1124 # look for new files derived from the file name
1125 *conftest*)
1126 ac_pat=`echo $ac_file | sed s/conftest/%FILE%/`
1127 _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1128 ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1129 ;;
1130 # look for new files derived from the module name,
1131 # with different case translation schemes
1132 *Bar*)
1133 ac_pat=`echo $ac_file | sed s/Bar/%Module%/`
1134 _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1135 ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1136 ;;
1137 *bar*)
1138 ac_pat=`echo $ac_file | sed s/bar/%module%/`
1139 _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1140 ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1141 ;;
1142 *BAR*)
1143 ac_pat=`echo $ac_file | sed s/BAR/%MODULE%/`
1144 _AC_LIST_MEMBER_IF($ac_pat, $ac_cv_f90_module_names,,
1145 ac_cv_f90_module_names="$ac_cv_f90_module_names $ac_pat")
1146 ;;
1147 # Other files - we have no idea how they are generated
1148 *)
1149 AC_MSG_WARN([Bogus file found: $ac_file])
1150 ;;
1151 esac
1152 done
1153 if test "x$ac_cv_f90_module_names" = "x"; then
1154 AC_MSG_WARN([Couldn't determine module file names])
1155 fi
1156 ],
1157 [ac_cv_f90_module_names=
1158 AC_MSG_WARN([Couldn't determine module file names])])
1159 cd ..
1160 # cleanup
1161 rm -rf conftest
1162 AC_LANG_POP()dnl
1163 ]) # AC_CACHE_CHECK
1164
1165 # We now generate a shell script that will help us to figure out the correct
1166 # module file names, using the value of ac_cv_f90_module_names
1167
1168 echo "Generating shell script modnam"
1169
1170 cat > scripts/modnam << EOF
1171 #! /bin/sh
1172 # This script is auto-generated by configure
1173 #
1174 usage="\\
1175 Usage: \$[0] [[FILES]]
1176
1177 [[FILES]] are Fortran 90 source files.
1178 The output is a list of module file names that the Fortran 90 compiler
1179 generates when compiling [[FILES]]."
1180
1181 list=
1182 empty=
1183
1184 if test \$[@%:@] -eq 0; then
1185 echo "\$usage"; exit 0
1186 fi
1187
1188 while test \$[@%:@] != 0; do
1189
1190 file=\$[1]
1191 shift
1192
1193 # strip suffix
1194 base=\`echo \$file | sed 's/[[.]][[^.]]*$//'\`
1195
1196 test ! -f \$file && continue
1197
1198 # Look for module definitions and transform them to upper / lower case
1199 mods=\`cat \$file | sed '/^ *[[mM][oO][dD][uU][lL][eE]]/!d;s/^ *[[mM][oO][dD][uU][lL][eE]] *\([[A-Za-z_][A-Za-z0-9_]]*\).*\$/\1/'\`
1200 upper=\`echo \$mods | tr a-z A-Z\`
1201 lower=\`echo \$mods | tr A-Z a-z\`
1202
1203 # Here, the patterns for generating module file names were inserted by configure
1204 for trans in $ac_cv_f90_module_names; do
1205
1206 pat=\`echo \$trans | sed 's/.*\(%.*%\).*/\1/'\`
1207 var=empty
1208 case \$pat in
1209 %MODULE%)
1210 var=upper ;;
1211 %Module%)
1212 var=mods ;;
1213 %module%)
1214 var=lower ;;
1215 %FILE%)
1216 test -n "\$mods" && var=base ;;
1217 esac
1218 new=\`eval '(for i in \$'\$var '; do echo \$trans | sed s/\$pat/\$i/; done)'\`
1219 list="\$list \$new"
1220 done
1221 done
1222
1223 echo \$list
1224 # end of configure-generated script
1225 EOF
1226 chmod 755 scripts/modnam
1227 ]) # AC_F90_MODULE_NAMES