1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Fortran languages support.
3 # Copyright (C) 2001, 2003, 2004, 2005, 2006
4 # Free Software Foundation, Inc.
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)
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA
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.
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.
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.
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.
52 # Fortran vs. Fortran 77:
53 # This file contains macros for both "Fortran 77" and "Fortran", where
54 # the former is the "classic" autoconf Fortran interface and is intended
55 # for legacy F77 codes, while the latter is intended to support newer Fortran
56 # dialects. Fortran 77 uses environment variables F77, FFLAGS, and FLIBS,
57 # while Fortran uses FC, FCFLAGS, and FCLIBS. For each user-callable AC_*
58 # macro, there is generally both an F77 and an FC version, where both versions
59 # share the same _AC_*_FC_* backend. This backend macro requires that
60 # the appropriate language be AC_LANG_PUSH'ed, and uses _AC_LANG_ABBREV and
61 # _AC_LANG_PREFIX in order to name cache and environment variables, etc.
64 # _AC_LIST_MEMBER_IF(ELEMENT, LIST, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
65 # ---------------------------------------------------------------------------
67 # Processing the elements of a list is tedious in shell programming,
68 # as lists tend to be implemented as space delimited strings.
70 # This macro searches LIST for ELEMENT, and executes ACTION-IF-FOUND
71 # if ELEMENT is a member of LIST, otherwise it executes
72 # ACTION-IF-NOT-FOUND.
73 AC_DEFUN([_AC_LIST_MEMBER_IF],
74 [dnl Do some sanity checking of the arguments.
75 m4_if([$1], , [AC_FATAL([$0: missing argument 1])])dnl
76 m4_if([$2], , [AC_FATAL([$0: missing argument 2])])dnl
79 if test x"$1" = x"$ac_i"; then
85 AS_IF([test x"$ac_exists" = xtrue], [$3], [$4])[]dnl
86 ])# _AC_LIST_MEMBER_IF
89 # _AC_LINKER_OPTION(LINKER-OPTIONS, SHELL-VARIABLE)
90 # -------------------------------------------------
92 # Specifying options to the compiler (whether it be the C, C++ or
93 # Fortran 77 compiler) that are meant for the linker is compiler
94 # dependent. This macro lets you give options to the compiler that
95 # are meant for the linker in a portable, compiler-independent way.
97 # This macro take two arguments, a list of linker options that the
98 # compiler should pass to the linker (LINKER-OPTIONS) and the name of
99 # a shell variable (SHELL-VARIABLE). The list of linker options are
100 # appended to the shell variable in a compiler-dependent way.
102 # For example, if the selected language is C, then this:
104 # _AC_LINKER_OPTION([-R /usr/local/lib/foo], foo_LDFLAGS)
106 # will expand into this if the selected C compiler is gcc:
108 # foo_LDFLAGS="-Xlinker -R -Xlinker /usr/local/lib/foo"
110 # otherwise, it will expand into this:
112 # foo_LDFLAGS"-R /usr/local/lib/foo"
114 # You are encouraged to add support for compilers that this macro
115 # doesn't currently support.
116 # FIXME: Get rid of this macro.
117 AC_DEFUN([_AC_LINKER_OPTION],
118 [if test "$ac_compiler_gnu" = yes; then
119 for ac_link_opt in $1; do
120 $2="[$]$2 -Xlinker $ac_link_opt"
125 ])# _AC_LINKER_OPTION
129 ## ----------------------- ##
130 ## 1. Language selection. ##
131 ## ----------------------- ##
134 # -------------------------- #
135 # 1d. The Fortran language. #
136 # -------------------------- #
139 # AC_LANG(Fortran 77)
140 # -------------------
141 m4_define([AC_LANG(Fortran 77)],
143 ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
144 ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
145 ac_compiler_gnu=$ac_cv_f77_compiler_gnu
151 m4_define([AC_LANG(Fortran)],
152 [ac_ext=${ac_fc_srcext-f}
153 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
154 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
155 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
160 AU_DEFUN([AC_LANG_FORTRAN77], [AC_LANG(Fortran 77)])
165 # Current language must be Fortran or Fortran 77.
166 m4_defun([_AC_FORTRAN_ASSERT],
167 [m4_if(_AC_LANG, [Fortran], [],
168 [m4_if(_AC_LANG, [Fortran 77], [],
169 [m4_fatal([$0: current language is not Fortran: ] _AC_LANG)])])])
172 # _AC_LANG_ABBREV(Fortran 77)
173 # ---------------------------
174 m4_define([_AC_LANG_ABBREV(Fortran 77)], [f77])
176 # _AC_LANG_ABBREV(Fortran)
177 # ------------------------
178 m4_define([_AC_LANG_ABBREV(Fortran)], [fc])
181 # _AC_LANG_PREFIX(Fortran 77)
182 # ---------------------------
183 m4_define([_AC_LANG_PREFIX(Fortran 77)], [F])
185 # _AC_LANG_PREFIX(Fortran)
186 # ------------------------
187 m4_define([_AC_LANG_PREFIX(Fortran)], [FC])
192 # Return F77 or FC, depending upon the language.
194 [_AC_FORTRAN_ASSERT()dnl
195 AC_LANG_CASE([Fortran 77], [F77],
199 ## ---------------------- ##
200 ## 2.Producing programs. ##
201 ## ---------------------- ##
204 # --------------------- #
205 # 2d. Fortran sources. #
206 # --------------------- #
208 # AC_LANG_SOURCE(Fortran 77)(BODY)
209 # AC_LANG_SOURCE(Fortran)(BODY)
210 # --------------------------------
211 # FIXME: Apparently, according to former AC_TRY_COMPILER, the CPP
212 # directives must not be included. But AC_TRY_RUN_NATIVE was not
214 m4_define([AC_LANG_SOURCE(Fortran 77)],
216 m4_define([AC_LANG_SOURCE(Fortran)],
220 # AC_LANG_PROGRAM(Fortran 77)([PROLOGUE], [BODY])
221 # -----------------------------------------------
222 # Yes, we discard the PROLOGUE.
223 m4_define([AC_LANG_PROGRAM(Fortran 77)],
225 [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl
231 # AC_LANG_PROGRAM(Fortran)([PROLOGUE], [BODY])
232 # -----------------------------------------------
233 # FIXME: can the PROLOGUE be used?
234 m4_define([AC_LANG_PROGRAM(Fortran)],
236 [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl
242 # AC_LANG_CALL(Fortran 77)(PROLOGUE, FUNCTION)
243 # --------------------------------------------
244 # FIXME: This is a guess, help!
245 m4_define([AC_LANG_CALL(Fortran 77)],
246 [AC_LANG_PROGRAM([$1],
250 # AC_LANG_CALL(Fortran)(PROLOGUE, FUNCTION)
251 # --------------------------------------------
252 # FIXME: This is a guess, help!
253 m4_define([AC_LANG_CALL(Fortran)],
254 [AC_LANG_PROGRAM([$1],
259 ## -------------------------------------------- ##
260 ## 3. Looking for Compilers and Preprocessors. ##
261 ## -------------------------------------------- ##
264 # -------------------------- #
265 # 3d. The Fortran compiler. #
266 # -------------------------- #
269 # AC_LANG_PREPROC(Fortran 77)
270 # ---------------------------
271 # Find the Fortran 77 preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
272 AC_DEFUN([AC_LANG_PREPROC(Fortran 77)],
274 [$0: No preprocessor defined for ]_AC_LANG)])
276 # AC_LANG_PREPROC(Fortran)
277 # ---------------------------
278 # Find the Fortran preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
279 AC_DEFUN([AC_LANG_PREPROC(Fortran)],
281 [$0: No preprocessor defined for ]_AC_LANG)])
284 # AC_LANG_COMPILER(Fortran 77)
285 # ----------------------------
286 # Find the Fortran 77 compiler. Must be AC_DEFUN'd to be
288 AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],
289 [AC_REQUIRE([AC_PROG_F77])])
291 # AC_LANG_COMPILER(Fortran)
292 # ----------------------------
293 # Find the Fortran compiler. Must be AC_DEFUN'd to be
295 AC_DEFUN([AC_LANG_COMPILER(Fortran)],
296 [AC_REQUIRE([AC_PROG_FC])])
301 # We used to name the cache variable this way.
302 AU_DEFUN([ac_cv_prog_g77],
303 [ac_cv_f77_compiler_gnu])
306 # _AC_FC_DIALECT_YEAR([DIALECT])
307 # ------------------------------
308 # Given a Fortran DIALECT, which is Fortran [YY]YY or simply [YY]YY,
309 # convert to a 4-digit year. The dialect must be one of Fortran 77,
310 # 90, 95, or 2000, currently. If DIALECT is simply Fortran or the
311 # empty string, returns the empty string.
312 AC_DEFUN([_AC_FC_DIALECT_YEAR],
313 [m4_case(m4_bpatsubsts(m4_tolower([$1]), [fortran],[], [ *],[]),
314 [77],[1977], [1977],[1977],
315 [90],[1990], [1990],[1990],
316 [95],[1995], [1995],[1995],
319 [m4_fatal([unknown Fortran dialect])])])
322 # _AC_PROG_FC([DIALECT], [COMPILERS...])
323 # --------------------------------------
324 # DIALECT is a Fortran dialect, given by Fortran [YY]YY or simply [YY]YY,
325 # and must be one of those supported by _AC_FC_DIALECT_YEAR
327 # If DIALECT is supplied, then we search for compilers of that dialect
328 # first, and then later dialects. Otherwise, we search for compilers
329 # of the newest dialect first, and then earlier dialects in increasing age.
330 # This search order is necessarily imperfect because the dialect cannot
331 # always be inferred from the compiler name.
334 # f77/f90/f95: generic compiler names
335 # g77: GNU Fortran 77 compiler
336 # gfortran: GNU Fortran 95+ compiler (released in gcc 4.0)
337 # g95: original gcc-based f95 compiler (gfortran is a fork)
338 # ftn: native Fortran 95 compiler on Cray X1
339 # cf77: native F77 compiler under older Crays (prefer over fort77)
340 # fort77: native F77 compiler under HP-UX (and some older Crays)
341 # frt: Fujitsu F77 compiler
342 # pgf77/pgf90/pghpf/pgf95: Portland Group F77/F90/F95 compilers
343 # xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers
344 # Prefer xlf9x to the generic names because they do not reject file
345 # with extension `.f'.
346 # lf95: Lahey-Fujitsu F95 compiler
347 # fl32: Microsoft Fortran 77 "PowerStation" compiler
348 # af77: Apogee F77 compiler for Intergraph hardware running CLIX
349 # epcf90: "Edinburgh Portable Compiler" F90
350 # fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha
351 # ifort, previously ifc: Intel Fortran 95 compiler for Linux/x86
352 # efc: Intel Fortran 95 compiler for IA64
353 m4_define([_AC_F95_FC], [gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn])
354 m4_define([_AC_F90_FC], [xlf90 f90 pgf90 pghpf epcf90])
355 m4_define([_AC_F77_FC], [g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77])
356 AC_DEFUN([_AC_PROG_FC],
357 [_AC_FORTRAN_ASSERT()dnl
358 AC_CHECK_TOOLS([]_AC_FC[],
360 m4_case(_AC_FC_DIALECT_YEAR([$1]),
361 [1995], [_AC_F95_FC],
362 [1990], [_AC_F90_FC _AC_F95_FC],
363 [1977], [_AC_F77_FC _AC_F90_FC _AC_F95_FC],
364 [_AC_F95_FC _AC_F90_FC _AC_F77_FC])))
366 # Provide some information about the compiler.
367 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
370 _AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
371 _AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
372 _AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
375 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
376 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
377 # If we don't use `.F' as extension, the preprocessor is not run on the
378 # input file. (Note that this only needs to work for GNU compilers.)
381 _AC_LANG_COMPILER_GNU
387 # AC_PROG_F77([COMPILERS...])
388 # ---------------------------
389 # COMPILERS is a space separated list of Fortran 77 compilers to search
390 # for. See also _AC_PROG_FC.
391 AC_DEFUN([AC_PROG_F77],
392 [AC_LANG_PUSH(Fortran 77)dnl
393 AC_ARG_VAR([F77], [Fortran 77 compiler command])dnl
394 AC_ARG_VAR([FFLAGS], [Fortran 77 compiler flags])dnl
395 _AC_ARG_VAR_LDFLAGS()dnl
396 _AC_ARG_VAR_LIBS()dnl
397 _AC_PROG_FC([Fortran 77], [$1])
398 if test $ac_compiler_gnu = yes; then
403 AC_LANG_POP(Fortran 77)dnl
407 # AC_PROG_FC([COMPILERS...], [DIALECT])
408 # -------------------------------------
409 # COMPILERS is a space separated list of Fortran 77 compilers to search
410 # for, and [DIALECT] is an optional dialect. See also _AC_PROG_FC.
411 AC_DEFUN([AC_PROG_FC],
412 [AC_LANG_PUSH(Fortran)dnl
413 AC_ARG_VAR([FC], [Fortran compiler command])dnl
414 AC_ARG_VAR([FCFLAGS], [Fortran compiler flags])dnl
415 _AC_ARG_VAR_LDFLAGS()dnl
416 _AC_ARG_VAR_LIBS()dnl
417 _AC_PROG_FC([$2], [$1])
418 AC_LANG_POP(Fortran)dnl
424 # Check whether -g works, even if F[C]FLAGS is set, in case the package
425 # plays around with F[C]FLAGS (such as to build both debugging and normal
426 # versions of a library), tasteless as that idea is.
427 m4_define([_AC_PROG_FC_G],
428 [_AC_FORTRAN_ASSERT()dnl
429 ac_test_FFLAGS=${[]_AC_LANG_PREFIX[]FLAGS+set}
430 ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS
431 _AC_LANG_PREFIX[]FLAGS=
432 AC_CACHE_CHECK(whether $[]_AC_FC[] accepts -g, ac_cv_prog_[]_AC_LANG_ABBREV[]_g,
433 [_AC_LANG_PREFIX[]FLAGS=-g
434 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
435 [ac_cv_prog_[]_AC_LANG_ABBREV[]_g=yes],
436 [ac_cv_prog_[]_AC_LANG_ABBREV[]_g=no])
438 if test "$ac_test_FFLAGS" = set; then
439 _AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS
440 elif test $ac_cv_prog_[]_AC_LANG_ABBREV[]_g = yes; then
441 if test "x$ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu" = xyes; then
442 _AC_LANG_PREFIX[]FLAGS="-g -O2"
444 _AC_LANG_PREFIX[]FLAGS="-g"
447 if test "x$ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu" = xyes; then
448 _AC_LANG_PREFIX[]FLAGS="-O2"
450 _AC_LANG_PREFIX[]FLAGS=
458 # Test if the Fortran compiler accepts the options `-c' and `-o'
459 # simultaneously, and define `[F77/FC]_NO_MINUS_C_MINUS_O' if it does not.
461 # The usefulness of this macro is questionable, as I can't really see
462 # why anyone would use it. The only reason I include it is for
463 # completeness, since a similar test exists for the C compiler.
465 # FIXME: it seems like we could merge the C/C++/Fortran versions of this.
466 AC_DEFUN([_AC_PROG_FC_C_O],
467 [_AC_FORTRAN_ASSERT()dnl
468 AC_CACHE_CHECK([whether $[]_AC_FC[] understands -c and -o together],
469 [ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o],
470 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
471 # We test twice because some compilers refuse to overwrite an existing
472 # `.o' file with `-o', although they will create one.
473 ac_try='$[]_AC_FC[] $[]_AC_LANG_PREFIX[]FLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
475 if _AC_DO_VAR(ac_try) &&
476 test -f conftest2.$ac_objext &&
477 _AC_DO_VAR(ac_try); then
478 ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=yes
480 ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=no
483 if test $ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o = no; then
484 AC_DEFINE([]_AC_FC[]_NO_MINUS_C_MINUS_O, 1,
485 [Define to 1 if your Fortran compiler doesn't accept
486 -c and -o together.])
493 AC_DEFUN([AC_PROG_F77_C_O],
494 [AC_REQUIRE([AC_PROG_F77])dnl
495 AC_LANG_PUSH(Fortran 77)dnl
497 AC_LANG_POP(Fortran 77)dnl
503 AC_DEFUN([AC_PROG_FC_C_O],
504 [AC_REQUIRE([AC_PROG_FC])dnl
505 AC_LANG_PUSH(Fortran)dnl
507 AC_LANG_POP(Fortran)dnl
511 ## ------------------------------- ##
512 ## 4. Compilers' characteristics. ##
513 ## ------------------------------- ##
516 # ---------------------------------------- #
517 # 4d. Fortran 77 compiler characteristics. #
518 # ---------------------------------------- #
521 # _AC_PROG_FC_V_OUTPUT([FLAG = $ac_cv_prog_{f77/fc}_v])
522 # -------------------------------------------------
523 # Link a trivial Fortran program, compiling with a verbose output FLAG
524 # (whose default value, $ac_cv_prog_{f77/fc}_v, is computed by
525 # _AC_PROG_FC_V), and return the output in $ac_{f77/fc}_v_output. This
526 # output is processed in the way expected by _AC_FC_LIBRARY_LDFLAGS,
527 # so that any link flags that are echoed by the compiler appear as
528 # space-separated items.
529 AC_DEFUN([_AC_PROG_FC_V_OUTPUT],
530 [_AC_FORTRAN_ASSERT()dnl
531 AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
533 # Compile and link our simple test program by passing a flag (argument
534 # 1 to this macro) to the Fortran compiler in order to get
535 # "verbose" output that we can then parse for the Fortran linker
537 ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS
538 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS m4_default([$1], [$ac_cv_prog_[]_AC_LANG_ABBREV[]_v])"
539 eval "set x $ac_link"
542 ac_[]_AC_LANG_ABBREV[]_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`
543 AS_ECHO(["$ac_[]_AC_LANG_ABBREV[]_v_output"]) >&AS_MESSAGE_LOG_FD
544 _AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS
548 # On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
549 # /foo, /bar, and /baz are search directories for the Fortran linker.
550 # Here, we change these into -L/foo -L/bar -L/baz (and put it first):
551 ac_[]_AC_LANG_ABBREV[]_v_output="`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
553 sed 's,.*LPATH is\(: *[[^ ]]*\).*,\1,;s,: */, -L/,g'` $ac_[]_AC_LANG_ABBREV[]_v_output"
555 # FIXME: we keep getting bitten by quoted arguments; a more general fix
556 # that detects unbalanced quotes in FLIBS should be implemented
557 # and (ugh) tested at some point.
558 case $ac_[]_AC_LANG_ABBREV[]_v_output in
559 # If we are using xlf then replace all the commas with spaces.
561 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/,/ /g'` ;;
563 # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
564 # $LIBS confuse us, and the libraries appear later in the output anyway).
565 *mGLOB_options_string*)
566 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/"-mGLOB[[^"]]*"/ /g'` ;;
568 # Portland Group compiler has singly- or doubly-quoted -cmdline argument
569 # Singly-quoted arguments were reported for versions 5.2-4 and 6.0-4.
570 # Doubly-quoted arguments were reported for "PGF90/x86 Linux/x86 5.0-2".
571 *-cmdline\ * | *-ignore\ * | *-def\ *)
572 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed "\
573 s/-cmdline *'[[^']]*'/ /g; s/-cmdline *\"[[^\"]]*\"/ /g
574 s/-ignore *'[[^']]*'/ /g; s/-ignore *\"[[^\"]]*\"/ /g
575 s/-def *'[[^']]*'/ /g; s/-def *\"[[^\"]]*\"/ /g"` ;;
577 # If we are using Cray Fortran then delete quotes.
579 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/"//g'` ;;
582 ])# _AC_PROG_FC_V_OUTPUT
588 # Determine the flag that causes the Fortran compiler to print
589 # information of library and object files (normally -v)
590 # Needed for _AC_FC_LIBRARY_FLAGS
591 # Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###)
592 AC_DEFUN([_AC_PROG_FC_V],
593 [_AC_FORTRAN_ASSERT()dnl
594 AC_CACHE_CHECK([how to get verbose linking output from $[]_AC_FC[]],
595 [ac_cv_prog_[]_AC_LANG_ABBREV[]_v],
596 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
597 [ac_cv_prog_[]_AC_LANG_ABBREV[]_v=
598 # Try some options frequently used verbose output
599 for ac_verb in -v -verbose --verbose -V -\#\#\#; do
600 _AC_PROG_FC_V_OUTPUT($ac_verb)
601 # look for -l* and *.a constructs in the output
602 for ac_arg in $ac_[]_AC_LANG_ABBREV[]_v_output; do
604 [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*)
605 ac_cv_prog_[]_AC_LANG_ABBREV[]_v=$ac_verb
610 if test -z "$ac_cv_prog_[]_AC_LANG_ABBREV[]_v"; then
611 AC_MSG_WARN([cannot determine how to obtain linking information from $[]_AC_FC[]])
613 [AC_MSG_WARN([compilation failed])])
617 # _AC_FC_LIBRARY_LDFLAGS
618 # ----------------------
620 # Determine the linker flags (e.g. "-L" and "-l") for the Fortran
621 # intrinsic and runtime libraries that are required to successfully
622 # link a Fortran program or shared library. The output variable
623 # FLIBS/FCLIBS is set to these flags.
625 # This macro is intended to be used in those situations when it is
626 # necessary to mix, e.g. C++ and Fortran, source code into a single
627 # program or shared library.
629 # For example, if object files from a C++ and Fortran compiler must
630 # be linked together, then the C++ compiler/linker must be used for
631 # linking (since special C++-ish things need to happen at link time
632 # like calling global constructors, instantiating templates, enabling
633 # exception support, etc.).
635 # However, the Fortran intrinsic and runtime libraries must be
636 # linked in as well, but the C++ compiler/linker doesn't know how to
637 # add these Fortran libraries. Hence, the macro
638 # "AC_F77_LIBRARY_LDFLAGS" was created to determine these Fortran
641 # This macro was packaged in its current form by Matthew D. Langston.
642 # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro
643 # in "octave-2.0.13/aclocal.m4", and full credit should go to John
644 # W. Eaton for writing this extremely useful macro. Thank you John.
645 AC_DEFUN([_AC_FC_LIBRARY_LDFLAGS],
646 [_AC_FORTRAN_ASSERT()dnl
648 AC_CACHE_CHECK([for _AC_LANG libraries of $[]_AC_FC[]], ac_cv_[]_AC_LANG_ABBREV[]_libs,
649 [if test "x$[]_AC_LANG_PREFIX[]LIBS" != "x"; then
650 ac_cv_[]_AC_LANG_ABBREV[]_libs="$[]_AC_LANG_PREFIX[]LIBS" # Let the user override the test.
655 ac_cv_[]_AC_LANG_ABBREV[]_libs=
657 # Save positional arguments (if any)
658 ac_save_positional="$[@]"
660 set X $ac_[]_AC_LANG_ABBREV[]_v_output
661 while test $[@%:@] != 1; do
665 [[\\/]]*.a | ?:[[\\/]]*.a)
666 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
667 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
670 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
671 [_AC_LINKER_OPTION([$ac_arg], ac_cv_[]_AC_LANG_ABBREV[]_libs)])
673 # Ignore these flags.
674 -lang* | -lcrt*.o | -lc | -lgcc* | -lSystem | -libmil | -LANG:=* | -LIST:* | -LNO:*)
677 test x"$CYGWIN" != xyes && ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg"
680 # These flags, when seen by themselves, take an argument.
681 # We remove the space between option and argument and re-iterate
682 # unless we find an empty arg or a new option (starting with -)
693 for ac_j in `AS_ECHO(["$ac_arg"]) | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
694 _AC_LIST_MEMBER_IF($ac_j, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
695 [ac_arg="$ac_arg $ac_j"
696 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_j"])
700 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
701 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
703 -zallextract*| -zdefaultextract)
704 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg"
706 # Ignore everything else.
709 # restore positional arguments
710 set X $ac_save_positional; shift
712 # We only consider "LD_RUN_PATH" on Solaris systems. If this is seen,
713 # then we insist that the "run path" must be an absolute path (i.e. it
714 # must begin with a "/").
715 case `(uname -sr) 2>/dev/null` in
717 ac_ld_run_path=`AS_ECHO(["$ac_[]_AC_LANG_ABBREV[]_v_output"]) |
718 sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`
719 test "x$ac_ld_run_path" != x &&
720 _AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_[]_AC_LANG_ABBREV[]_libs)
723 fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
725 []_AC_LANG_PREFIX[]LIBS="$ac_cv_[]_AC_LANG_ABBREV[]_libs"
726 AC_SUBST([]_AC_LANG_PREFIX[]LIBS)
727 ])# _AC_FC_LIBRARY_LDFLAGS
730 # AC_F77_LIBRARY_LDFLAGS
731 # ----------------------
732 AC_DEFUN([AC_F77_LIBRARY_LDFLAGS],
733 [AC_REQUIRE([AC_PROG_F77])dnl
734 AC_LANG_PUSH(Fortran 77)dnl
735 _AC_FC_LIBRARY_LDFLAGS
736 AC_LANG_POP(Fortran 77)dnl
737 ])# AC_F77_LIBRARY_LDFLAGS
740 # AC_FC_LIBRARY_LDFLAGS
741 # ----------------------
742 AC_DEFUN([AC_FC_LIBRARY_LDFLAGS],
743 [AC_REQUIRE([AC_PROG_FC])dnl
744 AC_LANG_PUSH(Fortran)dnl
745 _AC_FC_LIBRARY_LDFLAGS
746 AC_LANG_POP(Fortran)dnl
747 ])# AC_FC_LIBRARY_LDFLAGS
750 # _AC_FC_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
751 # -----------------------------------------------------------
753 # Detect name of dummy main routine required by the Fortran libraries,
754 # (if any) and define {F77,FC}_DUMMY_MAIN to this name (which should be
755 # used for a dummy declaration, if it is defined). On some systems,
756 # linking a C program to the Fortran library does not work unless you
757 # supply a dummy function called something like MAIN__.
759 # Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C
760 # program with the {F77,FC} libs is found; default to exiting with an error
761 # message. Execute ACTION-IF-FOUND if a dummy routine name is needed
762 # and found or if it is not needed (default to defining {F77,FC}_DUMMY_MAIN
765 # What is technically happening is that the Fortran libraries provide
766 # their own main() function, which usually initializes Fortran I/O and
767 # similar stuff, and then calls MAIN__, which is the entry point of
768 # your program. Usually, a C program will override this with its own
769 # main() routine, but the linker sometimes complain if you don't
770 # provide a dummy (never-called) MAIN__ routine anyway.
772 # Of course, programs that want to allow Fortran subroutines to do
773 # I/O, etcetera, should call their main routine MAIN__() (or whatever)
774 # instead of main(). A separate autoconf test (_AC_FC_MAIN) checks
775 # for the routine to use in this case (since the semantics of the test
776 # are slightly different). To link to e.g. purely numerical
777 # libraries, this is normally not necessary, however, and most C/C++
778 # programs are reluctant to turn over so much control to Fortran. =)
780 # The name variants we check for are (in order):
781 # MAIN__ (g77, MAIN__ required on some systems; IRIX, MAIN__ optional)
782 # MAIN_, __main (SunOS)
783 # MAIN _MAIN __MAIN main_ main__ _main (we follow DDD and try these too)
784 AC_DEFUN([_AC_FC_DUMMY_MAIN],
785 [_AC_FORTRAN_ASSERT()dnl
786 m4_define(_AC_LANG_PROGRAM_C_[]_AC_FC[]_HOOKS,
787 [#ifdef ]_AC_FC[_DUMMY_MAIN
788 ]AC_LANG_CASE([Fortran], [#ifndef FC_DUMMY_MAIN_EQ_F77])
792 int ]_AC_FC[_DUMMY_MAIN() { return 1; }
793 ]AC_LANG_CASE([Fortran], [#endif])
796 AC_CACHE_CHECK([for dummy main to link with _AC_LANG libraries],
797 ac_cv_[]_AC_LANG_ABBREV[]_dummy_main,
798 [ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS=$LIBS
799 LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS"
800 ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN
803 # First, try linking without a dummy main:
804 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
805 [ac_cv_fortran_dummy_main=none],
806 [ac_cv_fortran_dummy_main=unknown])
808 if test $ac_cv_fortran_dummy_main = unknown; then
809 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
810 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@define $ac_fortran_dm_var $ac_func]])],
811 [ac_cv_fortran_dummy_main=$ac_func; break])
815 ac_cv_[]_AC_LANG_ABBREV[]_dummy_main=$ac_cv_fortran_dummy_main
817 LIBS=$ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS
819 []_AC_FC[]_DUMMY_MAIN=$ac_cv_[]_AC_LANG_ABBREV[]_dummy_main
820 AS_IF([test "$[]_AC_FC[]_DUMMY_MAIN" != unknown],
822 [if test $[]_AC_FC[]_DUMMY_MAIN != none; then
823 AC_DEFINE_UNQUOTED([]_AC_FC[]_DUMMY_MAIN, $[]_AC_FC[]_DUMMY_MAIN,
824 [Define to dummy `main' function (if any) required to
825 link to the Fortran libraries.])
826 if test "x$ac_cv_fc_dummy_main" = "x$ac_cv_f77_dummy_main"; then
827 AC_DEFINE([FC_DUMMY_MAIN_EQ_F77], 1,
828 [Define if F77 and FC dummy `main' functions are identical.])
832 [AC_MSG_FAILURE([linking to Fortran libraries from C fails])])])
833 ])# _AC_FC_DUMMY_MAIN
837 # ----------------------
838 AC_DEFUN([AC_F77_DUMMY_MAIN],
839 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
840 AC_LANG_PUSH(Fortran 77)dnl
841 _AC_FC_DUMMY_MAIN($@)
842 AC_LANG_POP(Fortran 77)dnl
843 ])# AC_F77_DUMMY_MAIN
847 # ----------------------
848 AC_DEFUN([AC_FC_DUMMY_MAIN],
849 [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
850 AC_LANG_PUSH(Fortran)dnl
851 _AC_FC_DUMMY_MAIN($@)
852 AC_LANG_POP(Fortran)dnl
858 # Define {F77,FC}_MAIN to name of alternate main() function for use with
859 # the Fortran libraries. (Typically, the libraries may define their
860 # own main() to initialize I/O, etcetera, that then call your own
861 # routine called MAIN__ or whatever.) See _AC_FC_DUMMY_MAIN, above.
862 # If no such alternate name is found, just define {F77,FC}_MAIN to main.
864 AC_DEFUN([_AC_FC_MAIN],
865 [_AC_FORTRAN_ASSERT()dnl
866 AC_CACHE_CHECK([for alternate main to link with _AC_LANG libraries],
867 ac_cv_[]_AC_LANG_ABBREV[]_main,
868 [ac_[]_AC_LANG_ABBREV[]_m_save_LIBS=$LIBS
869 LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS"
870 ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN
872 ac_cv_fortran_main="main" # default entry point name
873 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
874 AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@ifdef FC_DUMMY_MAIN_EQ_F77
875 @%:@ undef F77_DUMMY_MAIN
876 @%:@ undef FC_DUMMY_MAIN
878 @%:@ undef $ac_fortran_dm_var
880 @%:@define main $ac_func])],
881 [ac_cv_fortran_main=$ac_func; break])
884 ac_cv_[]_AC_LANG_ABBREV[]_main=$ac_cv_fortran_main
886 LIBS=$ac_[]_AC_LANG_ABBREV[]_m_save_LIBS
888 AC_DEFINE_UNQUOTED([]_AC_FC[]_MAIN, $ac_cv_[]_AC_LANG_ABBREV[]_main,
889 [Define to alternate name for `main' routine that is
890 called from a `main' in the Fortran libraries.])
896 AC_DEFUN([AC_F77_MAIN],
897 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
898 AC_LANG_PUSH(Fortran 77)dnl
900 AC_LANG_POP(Fortran 77)dnl
906 AC_DEFUN([AC_FC_MAIN],
907 [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
908 AC_LANG_PUSH(Fortran)dnl
910 AC_LANG_POP(Fortran)dnl
914 # __AC_FC_NAME_MANGLING
915 # ---------------------
916 # Test for the name mangling scheme used by the Fortran compiler.
918 # Sets ac_cv_{f77,fc}_mangling. The value contains three fields, separated
921 # lower case / upper case:
922 # case translation of the Fortran symbols
923 # underscore / no underscore:
924 # whether the compiler appends "_" to symbol names
925 # extra underscore / no extra underscore:
926 # whether the compiler appends an extra "_" to symbol names already
927 # containing at least one underscore
929 AC_DEFUN([__AC_FC_NAME_MANGLING],
930 [_AC_FORTRAN_ASSERT()dnl
931 AC_CACHE_CHECK([for _AC_LANG name-mangling scheme],
932 ac_cv_[]_AC_LANG_ABBREV[]_mangling,
934 [ subroutine foobar()
940 [mv conftest.$ac_objext cfortran_test.$ac_objext
943 LIBS="cfortran_test.$ac_objext $LIBS $[]_AC_LANG_PREFIX[]LIBS"
947 for ac_foobar in foobar FOOBAR; do
948 for ac_underscore in "" "_"; do
949 ac_func="$ac_foobar$ac_underscore"
950 AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
951 [ac_success=yes; break 2])
956 if test "$ac_success" = "yes"; then
970 for ac_extra in "" "_"; do
971 ac_func="$ac_foo_bar$ac_underscore$ac_extra"
972 AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
973 [ac_success_extra=yes; break])
977 if test "$ac_success_extra" = "yes"; then
978 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_case case"
979 if test -z "$ac_underscore"; then
980 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no underscore"
982 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, underscore"
984 if test -z "$ac_extra"; then
985 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no extra underscore"
987 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, extra underscore"
990 ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
993 ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
997 rm -f cfortran_test* conftest*],
998 [AC_MSG_FAILURE([cannot compile a simple Fortran program])])
1000 ])# __AC_FC_NAME_MANGLING
1002 # The replacement is empty.
1003 AU_DEFUN([AC_F77_NAME_MANGLING], [])
1006 # _AC_F77_NAME_MANGLING
1007 # ----------------------
1008 AC_DEFUN([_AC_F77_NAME_MANGLING],
1009 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
1010 AC_REQUIRE([AC_F77_DUMMY_MAIN])dnl
1011 AC_LANG_PUSH(Fortran 77)dnl
1012 __AC_FC_NAME_MANGLING
1013 AC_LANG_POP(Fortran 77)dnl
1014 ])# _AC_F77_NAME_MANGLING
1017 # _AC_FC_NAME_MANGLING
1018 # ----------------------
1019 AC_DEFUN([_AC_FC_NAME_MANGLING],
1020 [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
1021 AC_REQUIRE([AC_FC_DUMMY_MAIN])dnl
1022 AC_LANG_PUSH(Fortran)dnl
1023 __AC_FC_NAME_MANGLING
1024 AC_LANG_POP(Fortran)dnl
1025 ])# _AC_FC_NAME_MANGLING
1030 # Defines C macros {F77,FC}_FUNC(name,NAME) and {F77,FC}_FUNC_(name,NAME) to
1031 # properly mangle the names of C identifiers, and C identifiers with
1032 # underscores, respectively, so that they match the name mangling
1033 # scheme used by the Fortran compiler.
1034 AC_DEFUN([_AC_FC_WRAPPERS],
1035 [_AC_FORTRAN_ASSERT()dnl
1036 AH_TEMPLATE(_AC_FC[_FUNC],
1037 [Define to a macro mangling the given C identifier (in lower and upper
1038 case), which must not contain underscores, for linking with Fortran.])dnl
1039 AH_TEMPLATE(_AC_FC[_FUNC_],
1040 [As ]_AC_FC[_FUNC, but for C identifiers containing underscores.])dnl
1041 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
1042 "lower case, no underscore, no extra underscore")
1043 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name])
1044 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name]) ;;
1045 "lower case, no underscore, extra underscore")
1046 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name])
1047 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
1048 "lower case, underscore, no extra underscore")
1049 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _])
1050 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
1051 "lower case, underscore, extra underscore")
1052 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _])
1053 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## __]) ;;
1054 "upper case, no underscore, no extra underscore")
1055 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME])
1056 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME]) ;;
1057 "upper case, no underscore, extra underscore")
1058 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME])
1059 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
1060 "upper case, underscore, no extra underscore")
1061 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _])
1062 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
1063 "upper case, underscore, extra underscore")
1064 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _])
1065 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## __]) ;;
1067 AC_MSG_WARN([unknown Fortran name-mangling scheme])
1075 AC_DEFUN([AC_F77_WRAPPERS],
1076 [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
1077 AC_LANG_PUSH(Fortran 77)dnl
1079 AC_LANG_POP(Fortran 77)dnl
1085 AC_DEFUN([AC_FC_WRAPPERS],
1086 [AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl
1087 AC_LANG_PUSH(Fortran)dnl
1089 AC_LANG_POP(Fortran)dnl
1093 # _AC_FC_FUNC(NAME, [SHELLVAR = NAME])
1094 # ------------------------------------
1095 # For a Fortran subroutine of given NAME, define a shell variable
1096 # $SHELLVAR to the Fortran-mangled name. If the SHELLVAR
1097 # argument is not supplied, it defaults to NAME.
1098 AC_DEFUN([_AC_FC_FUNC],
1099 [_AC_FORTRAN_ASSERT()dnl
1100 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
1101 upper*) ac_val="m4_toupper([$1])" ;;
1102 lower*) ac_val="m4_tolower([$1])" ;;
1103 *) ac_val="unknown" ;;
1105 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac
1106 m4_if(m4_index([$1],[_]),-1,[],
1107 [case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac
1109 m4_default([$2],[$1])="$ac_val"
1113 # AC_F77_FUNC(NAME, [SHELLVAR = NAME])
1114 # ------------------------------------
1115 AC_DEFUN([AC_F77_FUNC],
1116 [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
1117 AC_LANG_PUSH(Fortran 77)dnl
1118 _AC_FC_FUNC([$1],[$2])
1119 AC_LANG_POP(Fortran 77)dnl
1123 # AC_FC_FUNC(NAME, [SHELLVAR = NAME])
1124 # -----------------------------------
1125 AC_DEFUN([AC_FC_FUNC],
1126 [AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl
1127 AC_LANG_PUSH(Fortran)dnl
1128 _AC_FC_FUNC([$1],[$2])
1129 AC_LANG_POP(Fortran)dnl
1133 # AC_FC_SRCEXT(EXT, [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
1134 # -----------------------------------------------------------
1135 # Set the source-code extension used in Fortran (FC) tests to EXT (which
1136 # defaults to f). Also, look for any necessary additional FCFLAGS needed
1137 # to allow this extension, and store them in the output variable
1138 # FCFLAGS_<EXT> (e.g. FCFLAGS_f90 for EXT=f90). If successful,
1139 # call ACTION-IF-SUCCESS. If unable to compile source code with EXT,
1140 # call ACTION-IF-FAILURE, which defaults to failing with an error
1143 # (The flags for the current source-code extension, if any, are stored in
1144 # $ac_fcflags_srcext and used automatically in subsequent autoconf tests.)
1146 # For ordinary extensions like f90, etcetera, the modified FCFLAGS
1147 # are currently needed for IBM's xlf* and Intel's ifc (grrr). Unfortunately,
1148 # xlf* will only take flags to recognize one extension at a time, so if the
1149 # user wants to compile multiple extensions (.f90 and .f95, say), she
1150 # will need to use the FCFLAGS_F90 and FCFLAGS_F95 individually rather
1151 # than just adding them all to FCFLAGS, for example.
1153 # Also, for Intel's ifc compiler (which does not accept .f95 by default in
1154 # some versions), the $FCFLAGS_<EXT> variable *must* go immediately before
1155 # the source file on the command line, unlike other $FCFLAGS. Ugh.
1156 AC_DEFUN([AC_FC_SRCEXT],
1157 [AC_LANG_PUSH(Fortran)dnl
1158 AC_CACHE_CHECK([for Fortran flag to compile .$1 files],
1161 ac_fcflags_srcext_save=$ac_fcflags_srcext
1163 ac_cv_fc_srcext_$1=unknown
1164 for ac_flag in none -qsuffix=f=$1 -Tf; do
1165 test "x$ac_flag" != xnone && ac_fcflags_srcext="$ac_flag"
1166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_fc_srcext_$1=$ac_flag; break])
1168 rm -f conftest.$ac_objext conftest.$1
1169 ac_fcflags_srcext=$ac_fcflags_srcext_save
1171 if test "x$ac_cv_fc_srcext_$1" = xunknown; then
1172 m4_default([$3],[AC_MSG_ERROR([Fortran could not compile .$1 files])])
1175 if test "x$ac_cv_fc_srcext_$1" = xnone; then
1176 ac_fcflags_srcext=""
1179 ac_fcflags_srcext=$ac_cv_fc_srcext_$1
1180 FCFLAGS_[]$1[]=$ac_cv_fc_srcext_$1
1182 AC_SUBST(FCFLAGS_[]$1)
1185 AC_LANG_POP(Fortran)dnl
1189 # AC_FC_FREEFORM([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
1190 # ------------------------------------------------------------------
1191 # Look for a compiler flag to make the Fortran (FC) compiler accept
1192 # free-format source code, and adds it to FCFLAGS. Call
1193 # ACTION-IF-SUCCESS (defaults to nothing) if successful (i.e. can
1194 # compile code using new extension) and ACTION-IF-FAILURE (defaults to
1195 # failing with an error message) if not. (Defined via DEFUN_ONCE to
1196 # prevent flag from being added to FCFLAGS multiple times.)
1198 # The known flags are:
1199 # -ffree-form: GNU g77
1200 # -FR: Intel compiler (icc, ecc)
1201 # -free: Compaq compiler (fort)
1202 # -qfree: IBM compiler (xlf)
1203 # -Mfree, -Mfreeform: Portland Group compiler
1204 # -freeform: SGI compiler
1205 # -f free: Absoft Fortran
1206 # We try to test the "more popular" flags first, by some prejudiced
1207 # notion of popularity.
1208 AC_DEFUN_ONCE([AC_FC_FREEFORM],
1209 [AC_LANG_PUSH(Fortran)dnl
1210 AC_CACHE_CHECK([for Fortran flag needed to allow free-form source],
1212 [ac_cv_fc_freeform=unknown
1213 ac_fc_freeform_FCFLAGS_save=$FCFLAGS
1214 for ac_flag in none -ffree-form -FR -free -qfree -Mfree -Mfreeform \
1217 test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_freeform_FCFLAGS_save $ac_flag"
1220 ! FIXME: how to best confuse non-freeform compilers?
1221 print *, 'Hello ', &
1224 [ac_cv_fc_freeform=$ac_flag; break])
1226 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
1227 FCFLAGS=$ac_fc_freeform_FCFLAGS_save
1229 if test "x$ac_cv_fc_freeform" = xunknown; then
1231 [AC_MSG_ERROR([Fortran does not accept free-form source], 77)])
1233 if test "x$ac_cv_fc_freeform" != xnone; then
1234 FCFLAGS="$FCFLAGS $ac_cv_fc_freeform"
1238 AC_LANG_POP(Fortran)dnl