root/mpich2/branches/dev/kumudb/confdb/aclangf90.m4 @ 4870

Revision 4870, 40.8 KB (checked in by kumudb, 5 months ago)

Merge from trunk to kumudb r4748:r4869

Line 
1# This file is part of Autoconf.                       -*- Autoconf -*-
2# Programming languages support.
3# Copyright 2000, 2001
4# Free Software Foundation, Inc.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19# 02111-1307, USA.
20#
21# As a special exception, the Free Software Foundation gives unlimited
22# permission to copy, distribute and modify the configure scripts that
23# are the output of Autoconf.  You need not follow the terms of the GNU
24# General Public License when using or distributing such scripts, even
25# though portions of the text of Autoconf appear in them.  The GNU
26# General Public License (GPL) does govern all other use of the material
27# that constitutes the Autoconf program.
28#
29# Certain portions of the Autoconf source text are designed to be copied
30# (in certain cases, depending on the input) into the output of
31# Autoconf.  We call these the "data" portions.  The rest of the Autoconf
32# source text consists of comments plus executable code that decides which
33# of the data portions to output in any given case.  We call these
34# comments and executable code the "non-data" portions.  Autoconf never
35# copies any of the non-data portions into its output.
36#
37# This special exception to the GPL applies to versions of Autoconf
38# released by the Free Software Foundation.  When you make and
39# distribute a modified version of Autoconf, you may extend this special
40# exception to the GPL to apply to your modified version as well, *unless*
41# your modified version has the potential to copy into its output some
42# of the text that was the non-data portion of the version that you started
43# with.  (In other words, unless your change moves or copies text from
44# the non-data portions to the data portions.)  If your modification has
45# such potential, you must delete any notice of this special exception
46# to the GPL from your modified version.
47#
48# Written by David MacKenzie, with help from
49# Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
50# Roland McGrath, Noah Friedman, david d zuhn, and many others.
51#
52#
53# This file was created from aclang.m4, from the autoconf 2.52 distribution
54# It contains modifications that are specific to Fortran 90 support,
55# needed to support systems that wish to use separate Fortran compilers
56# for Fortran 77 and Fortran 90 programs.
57# Fortran 90 part written by William Gropp. 
58#
59
60
61## ----------------------- ##
62## 1. Language selection.  ##
63## ----------------------- ##
64
65
66
67
68# ----------------------------- #
69# 1e. The Fortran 90 language.  #
70# ----------------------------- #
71
72
73# AC_LANG(Fortran 90)
74# -------------------
75# There is a problem here.  There is no standard extension for Fortran 90,
76# and some compiler will fail to accept f90; others fail to accept f (the
77# various IBM xlf/f90 compilers are very picky, and there is no extension
78# that both IBM compilers will accept without additional options).
79m4_define([AC_LANG(Fortran 90)],
80[ac_ext=${ac_f90ext-f}
81ac_compile='$F90 -c $F90FLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
82ac_link='$F90 -o conftest$ac_exeext $F90FLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
83ac_compiler_gnu=$ac_cv_f90_compiler_gnu
84])
85
86
87# AC_LANG_FORTRAN90
88# -----------------
89AU_DEFUN([AC_LANG_FORTRAN90], [AC_LANG(Fortran 90)])
90
91
92# _AC_LANG_ABBREV(Fortran 90)
93# ---------------------------
94m4_define([_AC_LANG_ABBREV(Fortran 90)], [f90])
95
96
97
98## ---------------------- ##
99## 2.Producing programs.  ##
100## ---------------------- ##
101
102
103
104# ------------------------ #
105# 2e. Fortran 90 sources.  #
106# ------------------------ #
107
108# AC_LANG_SOURCE(Fortran 90)(BODY)
109# --------------------------------
110# FIXME: Apparently, according to former AC_TRY_COMPILER, the CPP
111# directives must not be included.  But AC_TRY_RUN_NATIVE was not
112# avoiding them, so?
113m4_define([AC_LANG_SOURCE(Fortran 90)],
114[$1])
115
116
117# AC_LANG_PROGRAM(Fortran 90)([PROLOGUE], [BODY])
118# -----------------------------------------------
119# Yes, we discard the PROLOGUE.
120m4_define([AC_LANG_PROGRAM(Fortran 90)],
121[m4_ifval([$1],
122       [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl
123      program main
124$2
125      end])
126
127
128# AC_LANG_CALL(Fortran 90)(PROLOGUE, FUNCTION)
129# --------------------------------------------
130# FIXME: This is a guess, help!
131m4_define([AC_LANG_CALL(Fortran 90)],
132[AC_LANG_PROGRAM([$1],
133[      call $2])])
134
135
136## -------------------------------------------- ##
137## 3. Looking for Compilers and Preprocessors.  ##
138## -------------------------------------------- ##
139
140
141# ----------------------------- #
142# 3e. The Fortran 90 compiler.  #
143# ----------------------------- #
144
145
146# AC_LANG_PREPROC(Fortran 90)
147# ---------------------------
148# Find the Fortran 90 preprocessor.  Must be AC_DEFUN'd to be AC_REQUIRE'able.
149AC_DEFUN([AC_LANG_PREPROC(Fortran 90)],
150[m4_warn([syntax],
151         [$0: No preprocessor defined for ]_AC_LANG)])
152
153
154# AC_LANG_COMPILER(Fortran 90)
155# ----------------------------
156# Find the Fortran 90 compiler.  Must be AC_DEFUN'd to be
157# AC_REQUIRE'able.
158AC_DEFUN([AC_LANG_COMPILER(Fortran 90)],
159[AC_REQUIRE([AC_PROG_F90])])
160
161
162# ac_cv_prog_g90
163# --------------
164# We used to name the cache variable this way.
165AU_DEFUN([ac_cv_prog_g90],
166[ac_cv_f90_compiler_gnu])
167
168
169# AC_PROG_F90([COMPILERS...])
170# ---------------------------
171# COMPILERS is a space separated list of Fortran 90 compilers to search
172# for.
173#
174# Compilers are ordered by
175#  1. F95, F90
176#  2. Good/tested native compilers, bad/untested native compilers
177#
178# frt is the Fujitsu Fortran compiler.
179# pgf90 is the Portland Group F90 compilers.
180# xlf90/xlf95 are IBM (AIX) F90/F95 compilers.
181# lf95 is the Lahey-Fujitsu compiler.
182# fl32 is the Microsoft Fortran "PowerStation" compiler.
183# epcf90 is the "Edinburgh Portable Compiler" F90.
184# pathf90 is the Pathscale Fortran 90 compiler
185# fort is the Compaq Fortran 90 (now 95) compiler for Tru64 and Linux/Alpha.
186# ifort is another name for the Inten f90 compiler
187# efc - An older Intel compiler (?)
188# ifc - An older Intel compiler
189AC_DEFUN([AC_PROG_F90],
190[# This is the aclangf90 version of f90 language support
191AC_LANG_PUSH(Fortran 90)dnl
192AC_ARG_VAR([F90],    [Fortran 90 compiler command])dnl
193AC_ARG_VAR([F90FLAGS], [Fortran 90 compiler flags])dnl
194_AC_ARG_VAR_LDFLAGS()dnl
195AC_CHECK_TOOLS(F90,
196      [m4_default([$1],
197                  [f95 f90 pgf90 ifort epcf90 fort xlf95 xlf90 xlf lf95 pathf95 pathf90 g95 gfortran ifc efc])])
198
199# Once we find the compiler, confirm the extension
200AC_MSG_CHECKING([that $ac_ext works as the extension for Fortran 90 program])
201cat > conftest.$ac_ext <<EOF
202      program conftest
203      end
204EOF
205if AC_TRY_EVAL(ac_compile) ; then
206    AC_MSG_RESULT(yes)
207else
208    AC_MSG_RESULT(no)
209    AC_MSG_CHECKING([for extension for Fortran 90 programs])
210    ac_ext="f90"
211    cat > conftest.$ac_ext <<EOF
212      program conftest
213      end
214EOF
215    if AC_TRY_EVAL(ac_compile) ; then
216        AC_MSG_RESULT([f90])
217    else
218        rm -f conftest*
219        ac_ext="f"
220        cat > conftest.$ac_ext <<EOF
221      program conftest
222      end
223EOF
224        if AC_TRY_EVAL(ac_compile) ; then
225            AC_MSG_RESULT([f])
226        else
227            AC_MSG_RESULT([unknown!])
228        fi
229    fi
230    ac_f90ext=$ac_ext
231    if test "$ac_ext" = "f90" ; then
232        pac_cv_f90_ext_f90=yes
233    else
234        pac_cv_f90_ext_f90=no
235    fi
236    pac_cv_f90_ext=$ac_ext
237    rm -f conftest*
238fi
239
240# Provide some information about the compiler.
241echo "$as_me:__oline__:" \
242     "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
243ac_compiler=`set X $ac_compile; echo $[2]`
244_AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
245_AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
246_AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
247
248m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
249m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
250# If we don't use `.F' as extension, the preprocessor is not run on the
251# input file.
252ac_save_ext=$ac_ext
253ac_ext=F
254_AC_LANG_COMPILER_GNU
255ac_ext=$ac_save_ext
256G90=`test $ac_compiler_gnu = yes && echo yes`
257_AC_PROG_F90_G
258AC_LANG_POP(Fortran 90)dnl
259])# AC_PROG_F90
260
261
262# _AC_PROG_F90_G
263# --------------
264# Check whether -g works, even if F90FLAGS is set, in case the package
265# plays around with F90FLAGS (such as to build both debugging and normal
266# versions of a library), tasteless as that idea is.
267m4_define([_AC_PROG_F90_G],
268[ac_test_F90FLAGS=${F90FLAGS+set}
269ac_save_F90FLAGS=$F90FLAGS
270F90FLAGS=
271AC_CACHE_CHECK(whether $F90 accepts -g, ac_cv_prog_f90_g,
272[F90FLAGS=-g
273_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
274[ac_cv_prog_f90_g=yes],
275[ac_cv_prog_f90_g=no])
276])
277if test "$ac_test_F90FLAGS" = set; then
278  F90FLAGS=$ac_save_F90FLAGS
279elif test $ac_cv_prog_f90_g = yes; then
280  if test "$G95" = yes; then
281    F90FLAGS="-g -O2"
282  else
283    F90FLAGS="-g"
284  fi
285else
286  if test "$G95" = yes; then
287    F90FLAGS="-O2"
288  else
289    F90FLAGS=
290  fi
291fi[]dnl
292])# _AC_PROG_F90_G
293
294
295# AC_PROG_F90_C_O
296# ---------------
297# Test if the Fortran 90 compiler accepts the options `-c' and `-o'
298# simultaneously, and define `F90_NO_MINUS_C_MINUS_O' if it does not.
299#
300# The usefulness of this macro is questionable, as I can't really see
301# why anyone would use it.  The only reason I include it is for
302# completeness, since a similar test exists for the C compiler.
303AC_DEFUN([AC_PROG_F90_C_O],
304[AC_REQUIRE([AC_PROG_F90])dnl
305AC_CACHE_CHECK([whether $F90 understand -c and -o together],
306               [ac_cv_prog_f90_c_o],
307[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
308# We test twice because some compilers refuse to overwrite an existing
309# `.o' file with `-o', although they will create one.
310ac_try='$F90 $F90FLAGS -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
311if AC_TRY_EVAL(ac_try) &&
312     test -f conftest.$ac_objext &&
313     AC_TRY_EVAL(ac_try); then
314  ac_cv_prog_f90_c_o=yes
315else
316  ac_cv_prog_f90_c_o=no
317fi
318rm -f conftest*])
319if test $ac_cv_prog_f90_c_o = no; then
320  AC_DEFINE(F90_NO_MINUS_C_MINUS_O, 1,
321            [Define if your Fortran 90 compiler doesn't accept -c and -o together.])
322fi
323])# AC_PROG_F90_C_O
324
325## ------------------------------- ##
326## 4. Compilers' characteristics.  ##
327## ------------------------------- ##
328
329# ---------------------------------------- #
330# 4d. Fortan 90 compiler characteristics.  #
331# ---------------------------------------- #
332
333
334# _AC_PROG_F90_V_OUTPUT([FLAG = $ac_cv_prog_f90_v])
335# -------------------------------------------------
336# Link a trivial Fortran program, compiling with a verbose output FLAG
337# (which default value, $ac_cv_prog_f90_v, is computed by
338# _AC_PROG_F90_V), and return the output in $ac_f90_v_output.  This
339# output is processed in the way expected by AC_F90_LIBRARY_LDFLAGS,
340# so that any link flags that are echoed by the compiler appear as
341# space-separated items.
342AC_DEFUN([_AC_PROG_F90_V_OUTPUT],
343[AC_REQUIRE([AC_PROG_F90])dnl
344AC_LANG_PUSH(Fortran 90)dnl
345
346AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
347
348# Compile and link our simple test program by passing a flag (argument
349# 1 to this macro) to the Fortran 90 compiler in order to get
350# "verbose" output that we can then parse for the Fortran 90 linker
351# flags.
352ac_save_F90FLAGS=$F90FLAGS
353F90FLAGS="$F90FLAGS m4_default([$1], [$ac_cv_prog_f90_v])"
354(eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD
355ac_f90_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`
356echo "$ac_f90_v_output" >&AS_MESSAGE_LOG_FD
357F90FLAGS=$ac_save_F90FLAGS
358
359rm -f conftest*
360AC_LANG_POP(Fortran 90)dnl
361
362# If we are using xlf then replace all the commas with spaces.
363if echo $ac_f90_v_output | grep xlfentry >/dev/null 2>&1; then
364  ac_f90_v_output=`echo $ac_f90_v_output | sed 's/,/ /g'`
365fi
366
367# If we are using Cray Fortran then delete quotes.
368# Use "\"" instead of '"' for font-lock-mode.
369# FIXME: a more general fix for quoted arguments with spaces?
370if echo $ac_f90_v_output | grep cft90 >/dev/null 2>&1; then
371  ac_f90_v_output=`echo $ac_f90_v_output | sed "s/\"//g"`
372fi[]dnl
373])# _AC_PROG_F90_V_OUTPUT
374
375
376# _AC_PROG_F90_V
377# --------------
378#
379# Determine the flag that causes the Fortran 90 compiler to print
380# information of library and object files (normally -v)
381# Needed for AC_F90_LIBRARY_FLAGS
382# Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###)
383AC_DEFUN([_AC_PROG_F90_V],
384[AC_CACHE_CHECK([how to get verbose linking output from $F90],
385                [ac_cv_prog_f90_v],
386[AC_LANG_ASSERT(Fortran 90)
387AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
388[ac_cv_prog_f90_v=
389# Try some options frequently used verbose output
390for ac_verb in -v -verbose --verbose -V -\#\#\#; do
391  _AC_PROG_F90_V_OUTPUT($ac_verb)
392  # look for -l* and *.a constructs in the output
393  for ac_arg in $ac_f90_v_output; do
394     case $ac_arg in
395        [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*)
396          ac_cv_prog_f90_v=$ac_verb
397          break 2 ;;
398     esac
399  done
400done
401if test -z "$ac_cv_prog_f90_v"; then
402   AC_MSG_WARN([cannot determine how to obtain linking information from $F90])
403fi],
404                  [AC_MSG_WARN([compilation failed])])
405])])# _AC_PROG_F90_V
406
407
408# AC_F90_LIBRARY_LDFLAGS
409# ----------------------
410#
411# Determine the linker flags (e.g. "-L" and "-l") for the Fortran 90
412# intrinsic and run-time libraries that are required to successfully
413# link a Fortran 90 program or shared library.  The output variable
414# F90LIBS is set to these flags.
415#
416# This macro is intended to be used in those situations when it is
417# necessary to mix, e.g. C++ and Fortran 90, source code into a single
418# program or shared library.
419#
420# For example, if object files from a C++ and Fortran 90 compiler must
421# be linked together, then the C++ compiler/linker must be used for
422# linking (since special C++-ish things need to happen at link time
423# like calling global constructors, instantiating templates, enabling
424# exception support, etc.).
425#
426# However, the Fortran 90 intrinsic and run-time libraries must be
427# linked in as well, but the C++ compiler/linker doesn't know how to
428# add these Fortran 90 libraries.  Hence, the macro
429# "AC_F90_LIBRARY_LDFLAGS" was created to determine these Fortran 90
430# libraries.
431#
432# This macro was packaged in its current form by Matthew D. Langston.
433# However, nearly all of this macro came from the "OCTAVE_FLIBS" macro
434# in "octave-2.0.13/aclocal.m4", and full credit should go to John
435# W. Eaton for writing this extremely useful macro.  Thank you John.
436AC_DEFUN([AC_F90_LIBRARY_LDFLAGS],
437[AC_LANG_PUSH(Fortran 90)dnl
438_AC_PROG_F90_V
439AC_CACHE_CHECK([for Fortran 90 libraries], ac_cv_f90libs,
440[if test "x$F90LIBS" != "x"; then
441  ac_cv_f90libs="$F90LIBS" # Let the user override the test.
442else
443
444_AC_PROG_F90_V_OUTPUT
445
446ac_cv_f90libs=
447
448# Save positional arguments (if any)
449ac_save_positional="$[@]"
450
451set X $ac_f90_v_output
452while test $[@%:@] != 1; do
453  shift
454  ac_arg=$[1]
455  case $ac_arg in
456        [[\\/]]*.a | ?:[[\\/]]*.a)
457          AC_LIST_MEMBER_OF($ac_arg, $ac_cv_f90libs, ,
458              ac_cv_f90libs="$ac_cv_f90libs $ac_arg")
459          ;;
460        -bI:*)
461          AC_LIST_MEMBER_OF($ac_arg, $ac_cv_f90libs, ,
462             [AC_LINKER_OPTION([$ac_arg], ac_cv_f90libs)])
463          ;;
464          # Ignore these flags.
465        -lang* | -lcrt0.o | -lc | -lgcc | -LANG:=*)
466          ;;
467        -lkernel32)
468          test x"$CYGWIN" != xyes && ac_cv_f90libs="$ac_cv_f90libs $ac_arg"
469          ;;
470        -[[LRuY]])
471          # These flags, when seen by themselves, take an argument.
472          # We remove the space between option and argument and re-iterate
473          # unless we find an empty arg or a new option (starting with -)
474          case $[2] in
475             "" | -*);;
476             *)
477                ac_arg="$ac_arg$[2]"
478                shift; shift
479                set X $ac_arg "$[@]"
480                ;;
481          esac
482          ;;
483        -YP,*)
484          for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
485            AC_LIST_MEMBER_OF($ac_j, $ac_cv_f90libs, ,
486                            [ac_arg="$ac_arg $ac_j"
487                             ac_cv_f90libs="$ac_cv_f90libs $ac_j"])
488          done
489          ;;
490        -[[lLR]]*)
491          AC_LIST_MEMBER_OF($ac_arg, $ac_cv_f90libs, ,
492                          ac_cv_f90libs="$ac_cv_f90libs $ac_arg")
493          ;;
494          # Ignore everything else.
495  esac
496done
497# restore positional arguments
498set X $ac_save_positional; shift
499
500# We only consider "LD_RUN_PATH" on Solaris systems.  If this is seen,
501# then we insist that the "run path" must be an absolute path (i.e. it
502# must begin with a "/").
503case `(uname -sr) 2>/dev/null` in
504   "SunOS 5"*)
505      ac_ld_run_path=`echo $ac_f90_v_output |
506                        sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`
507      test "x$ac_ld_run_path" != x &&
508        AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_f90libs)
509      ;;
510esac
511fi # test "x$F90LIBS" = "x"
512])
513F90LIBS="$ac_cv_f90libs"
514AC_SUBST(F90LIBS)
515AC_LANG_POP(Fortran 90)dnl
516])# AC_F90_LIBRARY_LDFLAGS
517
518
519# AC_F90_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
520# -----------------------------------------------------------
521#
522# Detect name of dummy main routine required by the Fortran libraries,
523# (if any) and define F90_DUMMY_MAIN to this name (which should be
524# used for a dummy declaration, if it is defined).  On some systems,
525# linking a C program to the Fortran library does not work unless you
526# supply a dummy function called something like MAIN__.
527#
528# Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C
529# program with the F90 libs is found; default to exiting with an error
530# message.  Execute ACTION-IF-FOUND if a dummy routine name is needed
531# and found or if it is not needed (default to defining F90_DUMMY_MAIN
532# when needed).
533#
534# What is technically happening is that the Fortran libraries provide
535# their own main() function, which usually initializes Fortran I/O and
536# similar stuff, and then calls MAIN__, which is the entry point of
537# your program.  Usually, a C program will override this with its own
538# main() routine, but the linker sometimes complain if you don't
539# provide a dummy (never-called) MAIN__ routine anyway.
540#
541# Of course, programs that want to allow Fortran subroutines to do
542# I/O, etcetera, should call their main routine MAIN__() (or whatever)
543# instead of main().  A separate autoconf test (AC_F90_MAIN) checks
544# for the routine to use in this case (since the semantics of the test
545# are slightly different).  To link to e.g. purely numerical
546# libraries, this is normally not necessary, however, and most C/C++
547# programs are reluctant to turn over so much control to Fortran.  =)
548#
549# The name variants we check for are (in order):
550#   MAIN__ (g90, MAIN__ required on some systems; IRIX, MAIN__ optional)
551#   MAIN_, __main (SunOS)
552#   MAIN _MAIN __MAIN main_ main__ _main (we follow DDD and try these too)
553AC_DEFUN([AC_F90_DUMMY_MAIN],
554[AC_REQUIRE([AC_F90_LIBRARY_LDFLAGS])dnl
555m4_define([_AC_LANG_PROGRAM_C_F90_HOOKS],
556[#ifdef F90_DUMMY_MAIN
557#  ifdef __cplusplus
558     extern "C"
559#  endif
560   int F90_DUMMY_MAIN() { return 1; }
561#endif
562])
563AC_CACHE_CHECK([for dummy main to link with Fortran 90 libraries],
564               ac_cv_f90_dummy_main,
565[AC_LANG_PUSH(C)dnl
566 ac_f90_dm_save_LIBS=$LIBS
567 LIBS="$LIBS $F90LIBS"
568
569 # First, try linking without a dummy main:
570 AC_TRY_LINK([], [],
571             ac_cv_f90_dummy_main=none,
572             ac_cv_f90_dummy_main=unknown)
573
574 if test $ac_cv_f90_dummy_main = unknown; then
575   for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
576     AC_TRY_LINK([@%:@define F90_DUMMY_MAIN $ac_func],
577                 [], [ac_cv_f90_dummy_main=$ac_func; break])
578   done
579 fi
580 rm -f conftest*
581 LIBS=$ac_f90_dm_save_LIBS
582 AC_LANG_POP(C)dnl
583])
584F90_DUMMY_MAIN=$ac_cv_f90_dummy_main
585AS_IF([test "$F90_DUMMY_MAIN" != unknown],
586      [m4_default([$1],
587[if test $F90_DUMMY_MAIN != none; then
588  AC_DEFINE_UNQUOTED([F90_DUMMY_MAIN], $F90_DUMMY_MAIN,
589                     [Define to dummy `main' function (if any) required to
590                      link to the Fortran 90 libraries.])
591fi])],
592      [m4_default([$2],
593                [AC_MSG_ERROR([Linking to Fortran libraries from C fails.])])])
594])# AC_F90_DUMMY_MAIN
595
596
597# AC_F90_MAIN
598# -----------
599# Define F90_MAIN to name of alternate main() function for use with
600# the Fortran libraries.  (Typically, the libraries may define their
601# own main() to initialize I/O, etcetera, that then call your own
602# routine called MAIN__ or whatever.)  See AC_F90_DUMMY_MAIN, above.
603# If no such alternate name is found, just define F90_MAIN to main.
604#
605AC_DEFUN([AC_F90_MAIN],
606[AC_REQUIRE([AC_F90_LIBRARY_LDFLAGS])dnl
607AC_CACHE_CHECK([for alternate main to link with Fortran 90 libraries],
608               ac_cv_f90_main,
609[AC_LANG_PUSH(C)dnl
610 ac_f90_m_save_LIBS=$LIBS
611 LIBS="$LIBS $F90LIBS"
612 ac_cv_f90_main="main" # default entry point name
613
614 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
615   AC_TRY_LINK([#undef F90_DUMMY_MAIN
616@%:@define main $ac_func], [], [ac_cv_f90_main=$ac_func; break])
617 done
618 rm -f conftest*
619 LIBS=$ac_f90_m_save_LIBS
620 AC_LANG_POP(C)dnl
621])
622AC_DEFINE_UNQUOTED([F90_MAIN], $ac_cv_f90_main,
623                   [Define to alternate name for `main' routine that is
624                    called from a `main' in the Fortran libraries.])
625])# AC_F90_MAIN
626
627
628# _AC_F90_NAME_MANGLING
629# ---------------------
630# Test for the name mangling scheme used by the Fortran 90 compiler.
631#
632# Sets ac_cv_f90_mangling. The value contains three fields, separated
633# by commas:
634#
635# lower case / upper case:
636#    case translation of the Fortan 90 symbols
637# underscore / no underscore:
638#    whether the compiler appends "_" to symbol names
639# extra underscore / no extra underscore:
640#    whether the compiler appends an extra "_" to symbol names already
641#    containing at least one underscore
642#
643AC_DEFUN([_AC_F90_NAME_MANGLING],
644[AC_REQUIRE([AC_F90_LIBRARY_LDFLAGS])dnl
645AC_REQUIRE([AC_F90_DUMMY_MAIN])dnl
646AC_CACHE_CHECK([for Fortran 90 name-mangling scheme],
647               ac_cv_f90_mangling,
648[AC_LANG_PUSH(Fortran 90)dnl
649AC_COMPILE_IFELSE(
650[      subroutine foobar()
651      return
652      end
653      subroutine foo_bar()
654      return
655      end],
656[mv conftest.$ac_objext cf90_test.$ac_objext
657
658  AC_LANG_PUSH(C)dnl
659
660  ac_save_LIBS=$LIBS
661  LIBS="cf90_test.$ac_objext $LIBS $F90LIBS"
662
663  ac_success=no
664  for ac_foobar in foobar FOOBAR; do
665    for ac_underscore in "" "_"; do
666      ac_func="$ac_foobar$ac_underscore"
667      AC_TRY_LINK_FUNC($ac_func,
668         [ac_success=yes; break 2])
669    done
670  done
671
672  if test "$ac_success" = "yes"; then
673     case $ac_foobar in
674        foobar)
675           ac_case=lower
676           ac_foo_bar=foo_bar
677           ;;
678        FOOBAR)
679           ac_case=upper
680           ac_foo_bar=FOO_BAR
681           ;;
682     esac
683
684     ac_success_extra=no
685     for ac_extra in "" "_"; do
686        ac_func="$ac_foo_bar$ac_underscore$ac_extra"
687        AC_TRY_LINK_FUNC($ac_func,
688        [ac_success_extra=yes; break])
689     done
690
691     if test "$ac_success_extra" = "yes"; then
692        ac_cv_f90_mangling="$ac_case case"
693        if test -z "$ac_underscore"; then
694           ac_cv_f90_mangling="$ac_cv_f90_mangling, no underscore"
695        else
696           ac_cv_f90_mangling="$ac_cv_f90_mangling, underscore"
697        fi
698        if test -z "$ac_extra"; then
699           ac_cv_f90_mangling="$ac_cv_f90_mangling, no extra underscore"
700        else
701           ac_cv_f90_mangling="$ac_cv_f90_mangling, extra underscore"
702        fi
703      else
704        ac_cv_f90_mangling="unknown"
705      fi
706  else
707     ac_cv_f90_mangling="unknown"
708  fi
709
710  LIBS=$ac_save_LIBS
711  AC_LANG_POP(C)dnl
712  rm -f cf90_test* conftest*])
713AC_LANG_POP(Fortran 90)dnl
714])
715])# _AC_F90_NAME_MANGLING
716
717# The replacement is empty.
718AU_DEFUN([AC_F90_NAME_MANGLING], [])
719
720
721# AC_F90_WRAPPERS
722# ---------------
723# Defines C macros F90_FUNC(name,NAME) and F90_FUNC_(name,NAME) to
724# properly mangle the names of C identifiers, and C identifiers with
725# underscores, respectively, so that they match the name mangling
726# scheme used by the Fortran 90 compiler.
727AC_DEFUN([AC_F90_WRAPPERS],
728[AC_REQUIRE([_AC_F90_NAME_MANGLING])dnl
729AH_TEMPLATE([F90_FUNC],
730    [Define to a macro mangling the given C identifier (in lower and upper
731     case), which must not contain underscores, for linking with Fortran.])dnl
732AH_TEMPLATE([F90_FUNC_],
733    [As F90_FUNC, but for C identifiers containing underscores.])dnl
734case $ac_cv_f90_mangling in
735  "lower case, no underscore, no extra underscore")
736          AC_DEFINE([F90_FUNC(name,NAME)],  [name])
737          AC_DEFINE([F90_FUNC_(name,NAME)], [name]) ;;
738  "lower case, no underscore, extra underscore")
739          AC_DEFINE([F90_FUNC(name,NAME)],  [name])
740          AC_DEFINE([F90_FUNC_(name,NAME)], [name ## _]) ;;
741  "lower case, underscore, no extra underscore")
742          AC_DEFINE([F90_FUNC(name,NAME)],  [name ## _])
743          AC_DEFINE([F90_FUNC_(name,NAME)], [name ## _]) ;;
744  "lower case, underscore, extra underscore")
745          AC_DEFINE([F90_FUNC(name,NAME)],  [name ## _])
746          AC_DEFINE([F90_FUNC_(name,NAME)], [name ## __]) ;;
747  "upper case, no underscore, no extra underscore")
748          AC_DEFINE([F90_FUNC(name,NAME)],  [NAME])
749          AC_DEFINE([F90_FUNC_(name,NAME)], [NAME]) ;;
750  "upper case, no underscore, extra underscore")
751          AC_DEFINE([F90_FUNC(name,NAME)],  [NAME])
752          AC_DEFINE([F90_FUNC_(name,NAME)], [NAME ## _]) ;;
753  "upper case, underscore, no extra underscore")
754          AC_DEFINE([F90_FUNC(name,NAME)],  [NAME ## _])
755          AC_DEFINE([F90_FUNC_(name,NAME)], [NAME ## _]) ;;
756  "upper case, underscore, extra underscore")
757          AC_DEFINE([F90_FUNC(name,NAME)],  [NAME ## _])
758          AC_DEFINE([F90_FUNC_(name,NAME)], [NAME ## __]) ;;
759  *)
760          AC_MSG_WARN([unknown Fortran 90 name-mangling scheme])
761          ;;
762esac
763])# AC_F90_WRAPPERS
764
765
766# AC_F90_FUNC(NAME, [SHELLVAR = NAME])
767# ------------------------------------
768# For a Fortran subroutine of given NAME, define a shell variable
769# $SHELLVAR to the Fortran-90 mangled name.  If the SHELLVAR
770# argument is not supplied, it defaults to NAME.
771AC_DEFUN([AC_F90_FUNC],
772[AC_REQUIRE([_AC_F90_NAME_MANGLING])dnl
773case $ac_cv_f90_mangling in
774  upper*) ac_val="m4_toupper([$1])" ;;
775  lower*) ac_val="m4_tolower([$1])" ;;
776  *)      ac_val="unknown" ;;
777esac
778case $ac_cv_f90_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac
779m4_if(m4_index([$1],[_]),-1,[],
780[case $ac_cv_f90_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac
781])
782m4_default([$2],[$1])="$ac_val"
783])# AC_F90_FUNC
784
785#
786# ------------------------------------------------------------------------
787# Special characteristics that have no autoconf counterpart but that
788# we need as part of the Fortran 90 support.  To distinquish these, they
789# have a [PAC] prefix.
790#
791dnl
792dnl PAC_F90_MODULE_EXT(action if found,action if not found)
793dnl
794AC_DEFUN([PAC_F90_MODULE_EXT],
795[AC_CACHE_CHECK([for Fortran 90 module extension],
796pac_cv_f90_module_ext,[
797# aclang90.m4 version
798pac_cv_f90_module_case="unknown"
799AC_LANG_PUSH(Fortran 90)
800cat >conftest.$ac_ext <<EOF
801        module conftest
802        integer n
803        parameter (n=1)
804        end module conftest
805EOF
806if AC_TRY_EVAL(ac_compile) ; then
807   dnl Look for module name
808   dnl First, try to find known names.  This avoids confusion caused by
809   dnl additional files (like <name>.stb created by some versions of pgf90)
810   for name in conftest CONFTEST ; do
811       for ext in mod MOD ; do
812           if test -s $name.$ext ; then
813               if test $name = conftest ; then
814                   pac_cv_f90_module_case=lower
815               else
816                   pac_cv_f90_module_case=upper
817               fi
818               pac_cv_f90_module_ext=$ext
819               pac_MOD=$ext
820               break
821           fi
822       done
823       if test -n "$pac_cv_f90_module_ext" ; then break ; fi
824   done
825   if test -z "$pac_MOD" ; then
826      pac_MOD=`ls conftest* AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v conftest.$ac_ext | grep -v conftest.o`
827      pac_MOD=`echo $pac_MOD | sed -e 's/conftest\.//g'`
828      pac_cv_f90_module_case="lower"
829      if test "X$pac_MOD" = "X" ; then
830           for file in CONFTEST* ; do
831               if test "x$file" = "xCONFTEST.$ac_ext" ; then continue ; fi
832               if test "x$file" = "xCONFTEST.o" ; then continue ; fi
833               if test -s "$file" ; then
834                   pac_MOD=$file
835                   break
836               fi
837           done
838           pac_MOD=`echo $pac_MOD | sed -e 's/CONFTEST\.//g'`
839           if test -n "$pac_MOD" ; then
840               testname="CONFTEST"
841               pac_cv_f90_module_case="upper"
842           fi
843       fi
844       if test -z "$pac_MOD" ; then
845           pac_cv_f90_module_ext="unknown"
846       else
847           pac_cv_f90_module_ext=$pac_MOD
848       fi
849    fi
850else
851    echo "configure: failed program was:" >&AC_FD_CC
852    cat conftest.$ac_ext >&AC_FD_CC
853    pac_cv_f90_module_ext="unknown"
854fi
855AC_LANG_POP
856rm -f conftest*
857])
858AC_SUBST(F90MODEXT)
859if test "$pac_cv_f90_module_ext" = "unknown" ; then
860    ifelse($2,,:,[$2])
861else
862    ifelse($1,,F90MODEXT=$pac_MOD,[$1])
863fi
864])
865dnl
866dnl PAC_F90_MODULE_INCFLAG
867AC_DEFUN([PAC_F90_MODULE_INCFLAG],[
868AC_CACHE_CHECK([for Fortran 90 module include flag],
869pac_cv_f90_module_incflag,[
870AC_REQUIRE([PAC_F90_MODULE_EXT])
871AC_LANG_PUSH(Fortran 90)
872#
873# Note that the name of the file and the name of the module must be
874# the same (some compilers use the module, some the file name)
875rm -f work.pc work.pcl conftest.$ac_ext
876cat >conftest.$ac_ext <<EOF
877        module conf
878        integer n
879        parameter (n=1)
880        end module conf
881EOF
882pac_madedir="no"
883if test ! -d conftestdir ; then mkdir conftestdir ; pac_madedir="yes"; fi
884if test "$pac_cv_f90_module_case" = "upper" ; then
885    pac_module="CONF.$pac_cv_f90_module_ext"
886else
887    pac_module="conf.$pac_cv_f90_module_ext"
888fi
889if AC_TRY_EVAL(ac_compile) ; then
890    if test -s "$pac_module" ; then
891        mv $pac_module conftestdir
892        # Remove any temporary files, and hide the work.pc file (if
893        # the compiler generates them)
894        if test -f work.pc ; then
895            mv -f work.pc conftest.pc
896        fi
897        rm -f work.pcl
898    else
899        AC_MSG_WARN([Unable to build a simple F90 module])
900        echo "configure: failed program was:" >&AC_FD_CC
901        cat conftest.$ac_f90ext >&AC_FD_CC
902    fi
903else
904    echo "configure: failed program was:" >&AC_FD_CC
905    cat conftest.$ac_ext >&AC_FD_CC
906fi
907rm -f conftest.$ac_ext
908cat >conftest.$ac_ext <<EOF
909        program main
910        use conf
911        end
912EOF
913if ${F90-f90} -c $F90FLAGS -Iconftestdir conftest.$ac_ext 1>&AC_FD_CC 2>&1 && \
914        test -s conftest.o ; then
915    pac_cv_f90_module_incflag="-I"
916elif ${F90-f90} -c $F90FLAGS -Mconftestdir conftest.$ac_ext 1>&AC_FD_CC 2>&1 && \
917        test-s conftest.o ; then
918    pac_cv_f90_module_incflag="-M"
919elif ${F90-f90} -c $F90FLAGS -pconftestdir conftest.$ac_ext 1>&AC_FD_CC 2>&1 && \
920        test -s conftest.o ; then
921    pac_cv_f90_module_incflag="-p"
922elif test -s work.pc ; then
923     mv conftest.pc conftestdir/mpimod.pc
924     echo "mpimod.pc" > conftestdir/mpimod.pcl
925     echo "`pwd`/conftestdir/mpimod.pc" >> conftestdir/mpimod.pcl
926     if ${F90-f90} -c $F90FLAGS -cl,conftestdir/mpimod.pcl conftest.$ac_ext 1>&AC_FD_CC 2>&1 && test -s conftest.o ; then
927         pac_cv_f90_module_incflag='-cl,'
928        # Not quite right; see the comments that follow
929         AC_MSG_RESULT([-cl,filename where filename contains a list of files and directories])
930         F90_WORK_FILES_ARG="-cl,mpimod.pcl"
931         F90MODINCSPEC="-cl,<dir>/<file>mod.pcl"
932         AC_SUBST(F90_WORK_FILES_ARG)
933     else
934         # The version of the Intel compiler that I have refuses to let
935         # you put the "work catalog" list anywhere but the current directory.
936         pac_cv_f90_module_incflag="Unavailable!"
937     fi
938else
939    # Early versions of the Intel ifc compiler required a *file*
940    # containing the names of files that contained the names of the
941    #
942    # -cl,filename.pcl
943    #   filename.pcl contains
944    #     fullpathname.pc
945    # The "fullpathname.pc" is generated, I believe, when a module is
946    # compiled. 
947    # Intel compilers use a wierd system: -cl,filename.pcl .  If no file is
948    # specified, work.pcl and work.pc are created.  However, if you specify
949    # a file, it must contain a the name of a file ending in .pc .  Ugh!
950    pac_cv_f90_module_incflag="unknown"
951fi
952if test "$pac_madedir" = "yes" ; then rm -rf conftestdir ; fi
953rm -f conftest*
954AC_LANG_POP
955])
956AC_SUBST(F90MODINCFLAG)
957F90MODINCFLAG=$pac_cv_f90_module_incflag
958])
959AC_DEFUN([PAC_F90_MODULE],[
960PAC_F90_MODULE_EXT
961PAC_F90_MODULE_INCFLAG
962])
963AC_DEFUN([PAC_F90_EXT],[
964AC_CACHE_CHECK([whether Fortran 90 accepts f90 suffix],
965pac_cv_f90_ext_f90,[
966save_ac_f90ext=$ac_f90ext
967ac_f90ext="f90"
968AC_LANG_PUSH(Fortran 90)
969AC_TRY_COMPILE(,,pac_cv_f90_ext_f90="yes",pac_cv_f90_ext_f90="no")
970AC_LANG_POP
971])
972if test "$pac_cv_f90_ext_f90" = "yes" ; then
973    ac_f90ext=f90
974else
975    ac_f90ext=f
976fi
977])
978dnl
979dnl/*D
980dnl PAC_PROG_F90_INT_KIND - Determine kind parameter for an integer with
981dnl the specified number of bytes.
982dnl
983dnl Synopsis:
984dnl  PAC_PROG_F90_INT_KIND(variable-to-set,number-of-bytes,[cross-size])
985dnl
986dnl D*/
987AC_DEFUN([PAC_PROG_F90_INT_KIND],[
988# Set the default
989$1=-1
990if test "$pac_cv_prog_f90_cross" = "yes" ; then
991    $1="$3"
992else
993AC_LANG_PUSH(Fortran 90)
994if test -n "$ac_compile" ; then
995    AC_MSG_CHECKING([for Fortran 90 integer kind for $2-byte integers])
996    # Convert bytes to digits
997    case $2 in
998        1) sellen=2 ;;
999        2) sellen=4 ;;
1000        4) sellen=8 ;;
1001        8) sellen=16 ;;
1002       16) sellen=30 ;;
1003        *) sellen=8 ;;
1004    esac
1005    # Check for cached value
1006    eval testval=\$"pac_cv_prog_f90_int_kind_$sellen"
1007    if test -n "$testval" ; then
1008        AC_MSG_RESULT([$testval (cached)])
1009        $1=$testval
1010    else
1011        # must compute
1012        rm -f conftest*
1013        cat <<EOF > conftest.$ac_ext
1014      program main
1015      integer i
1016      i = selected_int_kind($sellen)
1017      open(8, file="conftest1.out", form="formatted")
1018      write (8,*) i
1019      close(8)
1020      stop
1021      end
1022EOF
1023        KINDVAL="unavailable"
1024        eval "pac_cv_prog_f90_int_kind_$sellen"=-1
1025        if AC_TRY_EVAL(ac_link) && test -s conftest ; then
1026            ./conftest >>config.log 2>&1
1027            if test -s conftest1.out ; then
1028                # Because of write, there may be a leading blank.
1029                KINDVAL=`cat conftest1.out | sed 's/ //g'`
1030                eval "pac_cv_prog_f90_int_kind_$sellen"=$KINDVAL
1031                $1=$KINDVAL
1032            fi
1033        fi
1034        rm -f conftest*
1035        AC_MSG_RESULT($KINDVAL)
1036    fi # not cached
1037fi # Has Fortran 90
1038AC_LANG_POP
1039fi # is not cross compiling
1040])dnl
1041dnl
1042dnl PAC_F90_AND_F77_COMPATIBLE([action-if-true],[action-if-false])
1043dnl
1044dnl Determine whether object files compiled with Fortran 77 can be
1045dnl linked to Fortran 90 main programs.
1046dnl
1047dnl The test uses a name that includes an underscore unless the 3rd
1048dnl argument provides another routine name.
1049dnl
1050AC_DEFUN([PAC_F90_AND_F77_COMPATIBLE],[
1051AC_REQUIRE([PAC_PROG_F90_WORKS])
1052AC_CACHE_CHECK([whether Fortran 90 works with Fortran 77],
1053pac_cv_f90_and_f77,[
1054pac_cv_f90_and_f77="unknown"
1055rm -f conftest*
1056if test -z "$ac_ext_f90" -a -n "$pac_cv_f90_ext" ; then ac_ext_f90=$pac_cv_f90_ext ; fi
1057# Define the two language-specific steps
1058link_f90='${F90-f90} -o conftest${ac_exeext} $F90FLAGS $LDFLAGS conftest1.$ac_ext_f90 conftest2.o $LIBS 1>&AC_FD_CC'
1059compile_f77='${F77-f77} -c $FFLAGS conftest2.f 1>&AC_FD_CC'
1060# Create test programs
1061pacTestRoutine=t1_2
1062# eval the assignment in case the argument is a variable.
1063ifelse([$3],,,[eval pacTestRoutine=$3])
1064cat > conftest1.$ac_ext_f90 <<EOF
1065       program main
1066       integer a
1067       a = 1
1068       call ${pacTestRoutine}(a)
1069       end
1070EOF
1071cat > conftest2.f <<EOF
1072       subroutine ${pacTestRoutine}(b)
1073       integer b
1074       b = b + 1
1075       end
1076EOF
1077# compile the f77 program and link with the f90 program
1078# The reverse may not work because the Fortran 90 environment may
1079# expect to be in control (and to provide library files unknown to any other
1080# environment, even Fortran 77!)
1081if AC_TRY_EVAL(compile_f77) ; then
1082    if AC_TRY_EVAL(link_f90) && test -x conftest ; then
1083        pac_cv_f90_and_f77="yes"
1084    else
1085        pac_cv_f90_and_f77="no"
1086    fi
1087    # Some versions of the Intel compiler produce these two files
1088    rm -f work.pc work.pcl
1089else
1090    pac_cv_f90_and_f77="yes"
1091fi])
1092# Perform the requested action based on whether the test succeeded
1093if test "$pac_cv_f90_and_f77" = yes ; then
1094    ifelse($1,,:,[$1])
1095else
1096    ifelse($2,,:,[$2])
1097fi
1098])
1099dnl
1100dnl Backwards compatibility features
1101dnl
1102AC_DEFUN([PAC_PROG_F90],[AC_PROG_F90])
1103AC_DEFUN([PAC_LANG_FORTRAN90],[AC_LANG_PUSH(Fortran 90)])
1104dnl Internal routine for testing F90
1105dnl PAC_PROG_F90_WORKS()
1106AC_DEFUN([PAC_PROG_F90_WORKS],
1107[AC_MSG_CHECKING([for extension for Fortran 90 programs])
1108pac_cv_f90_ext="f90"
1109cat > conftest.$pac_cv_f90_ext <<EOF
1110      program conftest
1111      end
1112EOF
1113ac_compile='${F90-f90} -c $F90FLAGS conftest.$pac_cv_f90_ext 1>&AC_FD_CC'
1114if AC_TRY_EVAL(ac_compile) ; then
1115    AC_MSG_RESULT([f90])
1116else
1117    rm -f conftest*
1118    pac_cv_f90_ext="f"
1119    cat > conftest.$pac_cv_f90_ext <<EOF
1120      program conftest
1121      end
1122EOF
1123    if AC_TRY_EVAL(ac_compile) ; then
1124        AC_MSG_RESULT([f])
1125    else
1126        AC_MSG_RESULT([unknown!])
1127    fi
1128fi
1129AC_MSG_CHECKING([whether the Fortran 90 compiler ($F90 $F90FLAGS $LDFLAGS) works])
1130AC_LANG_SAVE
1131# We cannot use _LANG_FORTRAN90 here because we will usually be executing this
1132# test in the context of _PROG_F90, which is a require on _LANG_FORTRAN90.
1133# Instead, we insert the necessary code from _LANG_FORTRAN90 here
1134dnl PAC_LANG_FORTRAN90
1135dnl define(ifdef([_AC_LANG],[_AC_LANG],[AC_LANG]), [FORTRAN90])dnl
1136ifdef([_AC_LANG],[define([_AC_LANG],FORTRAN90)],[define([AC_LANG],FORTRAN90)])
1137dnl define([AC_LANG], [FORTRAN90])dnl
1138ac_ext=$pac_cv_f90_ext
1139ac_compile='${F90-f90} -c $F90FLAGS conftest.$ac_ext 1>&AC_FD_CC'
1140ac_link='${F90-f90} -o conftest${ac_exeext} $F90FLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AC_FD_CC'
1141dnl cross_compiling no longer maintained by autoconf as part of the
1142dnl AC_LANG changes.  If we set it here, a later AC_LANG may not
1143dnl restore it (in the case where one compiler claims to be a cross compiler
1144dnl and another does not)
1145dnl cross_compiling=$pac_cv_prog_f90_cross
1146# Include a Fortran 90 construction to distinguish between Fortran 77
1147# and Fortran 90 compilers.
1148cat >conftest.$ac_ext <<EOF
1149      program conftest
1150      integer, dimension(10) :: n
1151      end
1152EOF
1153if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeect} ; then
1154    pac_cv_prog_f90_works="yes"
1155    if (./conftest; exit) 2>/dev/null ; then
1156        pac_cv_prog_f90_cross="no"
1157    else
1158        pac_cv_prog_f90_cross="yes"
1159    fi
1160else
1161  echo "configure: failed program was:" >&AC_FD_CC
1162  cat conftest.$ac_ext >&AC_FD_CC
1163  pac_cv_prog_f90_works="no"
1164fi
1165rm -f conftest*
1166# The intel compiler sometimes generates these work.pc and .pcl files
1167rm -f work.pc work.pcl
1168AC_LANG_RESTORE
1169AC_MSG_RESULT($pac_cv_prog_f90_works)
1170if test "$pac_cv_prog_f90_works" = no; then
1171  AC_MSG_WARN([installation or configuration problem: Fortran 90 compiler cannot create executables.])
1172fi
1173AC_MSG_CHECKING([whether the Fortran 90 compiler ($F90 $F90FLAGS $LDFLAGS) is a cross-compiler])
1174AC_MSG_RESULT($pac_cv_prog_f90_cross)
1175dnl cross_compiling no longer maintained by autoconf as part of the
1176dnl AC_LANG changes.  If we set it here, a later AC_LANG may not
1177dnl restore it (in the case where one compiler claims to be a cross compiler
1178dnl and another does not)
1179dnl cross_compiling=$pac_cv_prog_f90_cross
1180])
1181dnl
1182dnl PAC_F90_AND_F77_COMPATIBLE([action-if-true],[action-if-false])
1183dnl
1184AC_DEFUN([PAC_F90_AND_F77_COMPATIBLE],[
1185AC_REQUIRE([PAC_PROG_F90_WORKS])
1186AC_CACHE_CHECK([whether Fortran 90 works with Fortran 77],
1187pac_cv_f90_and_f77,[
1188pac_cv_f90_and_f77="unknown"
1189rm -f conftest*
1190if test -z "$ac_ext_f90" ; then ac_ext_f90=$pac_cv_f90_ext ; fi
1191# Define the two language-specific steps
1192link_f90='${F90-f90} -o conftest${ac_exeext} $F90FLAGS $LDFLAGS conftest1.$ac_ext_f90 conftest2.o $LIBS 1>&AC_FD_CC'
1193compile_f77='${F77-f77} -c $FFLAGS conftest2.f 1>&AC_FD_CC'
1194# Create test programs
1195cat > conftest1.$ac_ext_f90 <<EOF
1196       program main
1197       integer a
1198       a = 1
1199       call t1(a)
1200       end
1201EOF
1202cat > conftest2.f <<EOF
1203       subroutine t1(b)
1204       integer b
1205       b = b + 1
1206       end
1207EOF
1208# compile the f77 program and link with the f90 program
1209# The reverse may not work because the Fortran 90 environment may
1210# expect to be in control (and to provide library files unknown to any other
1211# environment, even Fortran 77!)
1212if AC_TRY_EVAL(compile_f77) ; then
1213    if AC_TRY_EVAL(link_f90) && test -x conftest ; then
1214        pac_cv_f90_and_f77="yes"
1215    else
1216        pac_cv_f90_and_f77="no"
1217    fi
1218    # Some versions of the Intel compiler produce these two files
1219    rm -f work.pc work.pcl
1220else
1221    pac_cv_f90_and_f77="yes"
1222fi])
1223# Perform the requested action based on whether the test succeeded
1224if test "$pac_cv_f90_and_f77" = yes ; then
1225    ifelse($1,,:,[$1])
1226else
1227    ifelse($2,,:,[$2])
1228fi
1229])
1230dnl /*D
1231dnl PAC_PROG_F90_HAS_POINTER - Determine if Fortran allows pointer type
1232dnl
1233dnl Synopsis:
1234dnl   PAC_PROG_F90_HAS_POINTER(action-if-true,action-if-false)
1235dnl D*/
1236AC_DEFUN([PAC_PROG_F90_HAS_POINTER],[
1237AC_CACHE_CHECK([whether Fortran 90 has Cray-style pointer declaration],
1238pac_cv_prog_f90_has_pointer,[
1239AC_LANG_PUSH(Fortran 90)
1240AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
1241        integer M
1242        pointer (MPTR,M)
1243        data MPTR/0/
1244])],
1245    pac_cv_prog_f90_has_pointer="yes",
1246    pac_cv_prog_f90_has_pointer="no")
1247AC_LANG_POP
1248])
1249if test "$pac_cv_prog_f90_has_pointer" = "yes" ; then
1250    ifelse([$1],,:,[$1])
1251else
1252    ifelse([$2],,:,[$2])
1253fi
1254])
Note: See TracBrowser for help on using the browser.