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 3 of the License, or
9 # (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
19 # As a special exception, the Free Software Foundation gives unlimited
20 # permission to copy, distribute and modify the configure scripts that
21 # are the output of Autoconf. You need not follow the terms of the GNU
22 # General Public License when using or distributing such scripts, even
23 # though portions of the text of Autoconf appear in them. The GNU
24 # General Public License (GPL) does govern all other use of the material
25 # that constitutes the Autoconf program.
27 # Certain portions of the Autoconf source text are designed to be copied
28 # (in certain cases, depending on the input) into the output of
29 # Autoconf. We call these the "data" portions. The rest of the Autoconf
30 # source text consists of comments plus executable code that decides which
31 # of the data portions to output in any given case. We call these
32 # comments and executable code the "non-data" portions. Autoconf never
33 # copies any of the non-data portions into its output.
35 # This special exception to the GPL applies to versions of Autoconf
36 # released by the Free Software Foundation. When you make and
37 # distribute a modified version of Autoconf, you may extend this special
38 # exception to the GPL to apply to your modified version as well, *unless*
39 # your modified version has the potential to copy into its output some
40 # of the text that was the non-data portion of the version that you started
41 # with. (In other words, unless your change moves or copies text from
42 # the non-data portions to the data portions.) If your modification has
43 # such potential, you must delete any notice of this special exception
44 # to the GPL from your modified version.
46 # Written by David MacKenzie, with help from
47 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
48 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
57 # 1. Language selection
58 # and routines to produce programs in a given language.
60 # 2. Producing programs in a given language.
62 # 3. Looking for a compiler
63 # And possibly the associated preprocessor.
65 # 4. Compilers' characteristics.
73 # Fortran vs. Fortran 77:
74 # This file contains macros for both "Fortran 77" and "Fortran", where
75 # the former is the "classic" autoconf Fortran interface and is intended
76 # for legacy F77 codes, while the latter is intended to support newer Fortran
77 # dialects. Fortran 77 uses environment variables F77, FFLAGS, and FLIBS,
78 # while Fortran uses FC, FCFLAGS, and FCLIBS. For each user-callable AC_*
79 # macro, there is generally both an F77 and an FC version, where both versions
80 # share the same _AC_*_FC_* backend. This backend macro requires that
81 # the appropriate language be AC_LANG_PUSH'ed, and uses _AC_LANG_ABBREV and
82 # _AC_LANG_PREFIX in order to name cache and environment variables, etc.
86 ## ------------------- ##
87 ## 0. Utility macros. ##
88 ## ------------------- ##
91 # _AC_LIST_MEMBER_IF(ELEMENT, LIST, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
92 # ---------------------------------------------------------------------------
94 # Processing the elements of a list is tedious in shell programming,
95 # as lists tend to be implemented as space delimited strings.
97 # This macro searches LIST for ELEMENT, and executes ACTION-IF-FOUND
98 # if ELEMENT is a member of LIST, otherwise it executes
99 # ACTION-IF-NOT-FOUND.
100 AC_DEFUN([_AC_LIST_MEMBER_IF],
101 [dnl Do some sanity checking of the arguments.
102 m4_if([$1], , [AC_FATAL([$0: missing argument 1])])dnl
103 m4_if([$2], , [AC_FATAL([$0: missing argument 2])])dnl
106 if test x"$1" = x"$ac_i"; then
112 AS_IF([test x"$ac_exists" = xtrue], [$3], [$4])[]dnl
113 ])# _AC_LIST_MEMBER_IF
116 # _AC_LINKER_OPTION(LINKER-OPTIONS, SHELL-VARIABLE)
117 # -------------------------------------------------
119 # Specifying options to the compiler (whether it be the C, C++ or
120 # Fortran 77 compiler) that are meant for the linker is compiler
121 # dependent. This macro lets you give options to the compiler that
122 # are meant for the linker in a portable, compiler-independent way.
124 # This macro take two arguments, a list of linker options that the
125 # compiler should pass to the linker (LINKER-OPTIONS) and the name of
126 # a shell variable (SHELL-VARIABLE). The list of linker options are
127 # appended to the shell variable in a compiler-dependent way.
129 # For example, if the selected language is C, then this:
131 # _AC_LINKER_OPTION([-R /usr/local/lib/foo], foo_LDFLAGS)
133 # will expand into this if the selected C compiler is gcc:
135 # foo_LDFLAGS="-Xlinker -R -Xlinker /usr/local/lib/foo"
137 # otherwise, it will expand into this:
139 # foo_LDFLAGS"-R /usr/local/lib/foo"
141 # You are encouraged to add support for compilers that this macro
142 # doesn't currently support.
143 # FIXME: Get rid of this macro.
144 AC_DEFUN([_AC_LINKER_OPTION],
145 [if test "$ac_compiler_gnu" = yes; then
146 for ac_link_opt in $1; do
147 $2="[$]$2 -Xlinker $ac_link_opt"
152 ])# _AC_LINKER_OPTION
156 ## ----------------------- ##
157 ## 1. Language selection. ##
158 ## ----------------------- ##
161 # AC_LANG(Fortran 77)
162 # -------------------
163 m4_define([AC_LANG(Fortran 77)],
165 ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
166 ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
167 ac_compiler_gnu=$ac_cv_f77_compiler_gnu
173 m4_define([AC_LANG(Fortran)],
174 [ac_ext=${ac_fc_srcext-f}
175 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
176 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
177 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
182 AU_DEFUN([AC_LANG_FORTRAN77], [AC_LANG(Fortran 77)])
187 # Current language must be Fortran or Fortran 77.
188 m4_defun([_AC_FORTRAN_ASSERT],
189 [m4_if(_AC_LANG, [Fortran], [],
190 [m4_if(_AC_LANG, [Fortran 77], [],
191 [m4_fatal([$0: current language is not Fortran: ] _AC_LANG)])])])
194 # _AC_LANG_ABBREV(Fortran 77)
195 # ---------------------------
196 m4_define([_AC_LANG_ABBREV(Fortran 77)], [f77])
198 # _AC_LANG_ABBREV(Fortran)
199 # ------------------------
200 m4_define([_AC_LANG_ABBREV(Fortran)], [fc])
203 # _AC_LANG_PREFIX(Fortran 77)
204 # ---------------------------
205 m4_define([_AC_LANG_PREFIX(Fortran 77)], [F])
207 # _AC_LANG_PREFIX(Fortran)
208 # ------------------------
209 m4_define([_AC_LANG_PREFIX(Fortran)], [FC])
214 # Return F77 or FC, depending upon the language.
216 [_AC_FORTRAN_ASSERT()dnl
217 AC_LANG_CASE([Fortran 77], [F77],
222 ## ----------------------- ##
223 ## 2. Producing programs. ##
224 ## ----------------------- ##
227 # AC_LANG_SOURCE(Fortran 77)(BODY)
228 # AC_LANG_SOURCE(Fortran)(BODY)
229 # --------------------------------
230 # FIXME: Apparently, according to former AC_TRY_COMPILER, the CPP
231 # directives must not be included. But AC_TRY_RUN_NATIVE was not
233 m4_define([AC_LANG_SOURCE(Fortran 77)],
235 m4_define([AC_LANG_SOURCE(Fortran)],
239 # AC_LANG_PROGRAM(Fortran 77)([PROLOGUE], [BODY])
240 # -----------------------------------------------
241 # Yes, we discard the PROLOGUE.
242 m4_define([AC_LANG_PROGRAM(Fortran 77)],
244 [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl
250 # AC_LANG_PROGRAM(Fortran)([PROLOGUE], [BODY])
251 # -----------------------------------------------
252 # FIXME: can the PROLOGUE be used?
253 m4_define([AC_LANG_PROGRAM(Fortran)],
255 [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl
261 # AC_LANG_CALL(Fortran 77)(PROLOGUE, FUNCTION)
262 # --------------------------------------------
263 # FIXME: This is a guess, help!
264 m4_define([AC_LANG_CALL(Fortran 77)],
265 [AC_LANG_PROGRAM([$1],
269 # AC_LANG_CALL(Fortran)(PROLOGUE, FUNCTION)
270 # --------------------------------------------
271 # FIXME: This is a guess, help!
272 m4_define([AC_LANG_CALL(Fortran)],
273 [AC_LANG_PROGRAM([$1],
278 ## -------------------------------------------- ##
279 ## 3. Looking for Compilers and Preprocessors. ##
280 ## -------------------------------------------- ##
283 # AC_LANG_PREPROC(Fortran 77)
284 # ---------------------------
285 # Find the Fortran 77 preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
286 AC_DEFUN([AC_LANG_PREPROC(Fortran 77)],
288 [$0: No preprocessor defined for ]_AC_LANG)])
290 # AC_LANG_PREPROC(Fortran)
291 # ---------------------------
292 # Find the Fortran preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
293 AC_DEFUN([AC_LANG_PREPROC(Fortran)],
295 [$0: No preprocessor defined for ]_AC_LANG)])
298 # AC_LANG_COMPILER(Fortran 77)
299 # ----------------------------
300 # Find the Fortran 77 compiler. Must be AC_DEFUN'd to be
302 AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],
303 [AC_REQUIRE([AC_PROG_F77])])
305 # AC_LANG_COMPILER(Fortran)
306 # ----------------------------
307 # Find the Fortran compiler. Must be AC_DEFUN'd to be
309 AC_DEFUN([AC_LANG_COMPILER(Fortran)],
310 [AC_REQUIRE([AC_PROG_FC])])
315 # We used to name the cache variable this way.
316 AU_DEFUN([ac_cv_prog_g77],
317 [ac_cv_f77_compiler_gnu])
320 # _AC_FC_DIALECT_YEAR([DIALECT])
321 # ------------------------------
322 # Given a Fortran DIALECT, which is Fortran [YY]YY or simply [YY]YY,
323 # convert to a 4-digit year. The dialect must be one of Fortran 77,
324 # 90, 95, or 2000, currently. If DIALECT is simply Fortran or the
325 # empty string, returns the empty string.
326 AC_DEFUN([_AC_FC_DIALECT_YEAR],
327 [m4_case(m4_bpatsubsts(m4_tolower([$1]), [fortran],[], [ *],[]),
328 [77],[1977], [1977],[1977],
329 [90],[1990], [1990],[1990],
330 [95],[1995], [1995],[1995],
333 [m4_fatal([unknown Fortran dialect])])])
336 # _AC_PROG_FC([DIALECT], [COMPILERS...])
337 # --------------------------------------
338 # DIALECT is a Fortran dialect, given by Fortran [YY]YY or simply [YY]YY,
339 # and must be one of those supported by _AC_FC_DIALECT_YEAR
341 # If DIALECT is supplied, then we search for compilers of that dialect
342 # first, and then later dialects. Otherwise, we search for compilers
343 # of the newest dialect first, and then earlier dialects in increasing age.
344 # This search order is necessarily imperfect because the dialect cannot
345 # always be inferred from the compiler name.
348 # f77/f90/f95: generic compiler names
349 # g77: GNU Fortran 77 compiler
350 # gfortran: GNU Fortran 95+ compiler (released in gcc 4.0)
351 # g95: original gcc-based f95 compiler (gfortran is a fork)
352 # ftn: native Fortran 95 compiler on Cray X1
353 # cf77: native F77 compiler under older Crays (prefer over fort77)
354 # fort77: native F77 compiler under HP-UX (and some older Crays)
355 # frt: Fujitsu F77 compiler
356 # pgf77/pgf90/pghpf/pgf95: Portland Group F77/F90/F95 compilers
357 # xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers
358 # Prefer xlf9x to the generic names because they do not reject file
359 # with extension `.f'.
360 # lf95: Lahey-Fujitsu F95 compiler
361 # fl32: Microsoft Fortran 77 "PowerStation" compiler
362 # af77: Apogee F77 compiler for Intergraph hardware running CLIX
363 # epcf90: "Edinburgh Portable Compiler" F90
364 # fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha
365 # ifort, previously ifc: Intel Fortran 95 compiler for Linux/x86
366 # efc: Intel Fortran 95 compiler for IA64
367 m4_define([_AC_F95_FC], [gfortran g95 xlf95 f95 fort ifort ifc efc pgf95 lf95 ftn])
368 m4_define([_AC_F90_FC], [xlf90 f90 pgf90 pghpf epcf90])
369 m4_define([_AC_F77_FC], [g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77])
370 AC_DEFUN([_AC_PROG_FC],
371 [_AC_FORTRAN_ASSERT()dnl
372 AC_CHECK_TOOLS([]_AC_FC[],
374 m4_case(_AC_FC_DIALECT_YEAR([$1]),
375 [1995], [_AC_F95_FC],
376 [1990], [_AC_F90_FC _AC_F95_FC],
377 [1977], [_AC_F77_FC _AC_F90_FC _AC_F95_FC],
378 [_AC_F95_FC _AC_F90_FC _AC_F77_FC])))
380 # Provide some information about the compiler.
381 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
384 _AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
385 _AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
386 _AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
389 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
390 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
391 # If we don't use `.F' as extension, the preprocessor is not run on the
392 # input file. (Note that this only needs to work for GNU compilers.)
395 _AC_LANG_COMPILER_GNU
401 # AC_PROG_F77([COMPILERS...])
402 # ---------------------------
403 # COMPILERS is a space separated list of Fortran 77 compilers to search
404 # for. See also _AC_PROG_FC.
405 AC_DEFUN([AC_PROG_F77],
406 [AC_LANG_PUSH(Fortran 77)dnl
407 AC_ARG_VAR([F77], [Fortran 77 compiler command])dnl
408 AC_ARG_VAR([FFLAGS], [Fortran 77 compiler flags])dnl
409 _AC_ARG_VAR_LDFLAGS()dnl
410 _AC_ARG_VAR_LIBS()dnl
411 _AC_PROG_FC([Fortran 77], [$1])
412 if test $ac_compiler_gnu = yes; then
417 AC_LANG_POP(Fortran 77)dnl
421 # AC_PROG_FC([COMPILERS...], [DIALECT])
422 # -------------------------------------
423 # COMPILERS is a space separated list of Fortran 77 compilers to search
424 # for, and [DIALECT] is an optional dialect. See also _AC_PROG_FC.
425 AC_DEFUN([AC_PROG_FC],
426 [AC_LANG_PUSH(Fortran)dnl
427 AC_ARG_VAR([FC], [Fortran compiler command])dnl
428 AC_ARG_VAR([FCFLAGS], [Fortran compiler flags])dnl
429 _AC_ARG_VAR_LDFLAGS()dnl
430 _AC_ARG_VAR_LIBS()dnl
431 _AC_PROG_FC([$2], [$1])
432 AC_LANG_POP(Fortran)dnl
438 # Check whether -g works, even if F[C]FLAGS is set, in case the package
439 # plays around with F[C]FLAGS (such as to build both debugging and normal
440 # versions of a library), tasteless as that idea is.
441 m4_define([_AC_PROG_FC_G],
442 [_AC_FORTRAN_ASSERT()dnl
443 ac_test_FFLAGS=${[]_AC_LANG_PREFIX[]FLAGS+set}
444 ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS
445 _AC_LANG_PREFIX[]FLAGS=
446 AC_CACHE_CHECK(whether $[]_AC_FC[] accepts -g, ac_cv_prog_[]_AC_LANG_ABBREV[]_g,
447 [_AC_LANG_PREFIX[]FLAGS=-g
448 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
449 [ac_cv_prog_[]_AC_LANG_ABBREV[]_g=yes],
450 [ac_cv_prog_[]_AC_LANG_ABBREV[]_g=no])
452 if test "$ac_test_FFLAGS" = set; then
453 _AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS
454 elif test $ac_cv_prog_[]_AC_LANG_ABBREV[]_g = yes; then
455 if test "x$ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu" = xyes; then
456 _AC_LANG_PREFIX[]FLAGS="-g -O2"
458 _AC_LANG_PREFIX[]FLAGS="-g"
461 if test "x$ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu" = xyes; then
462 _AC_LANG_PREFIX[]FLAGS="-O2"
464 _AC_LANG_PREFIX[]FLAGS=
472 # Test if the Fortran compiler accepts the options `-c' and `-o'
473 # simultaneously, and define `[F77/FC]_NO_MINUS_C_MINUS_O' if it does not.
475 # The usefulness of this macro is questionable, as I can't really see
476 # why anyone would use it. The only reason I include it is for
477 # completeness, since a similar test exists for the C compiler.
479 # FIXME: it seems like we could merge the C/C++/Fortran versions of this.
480 AC_DEFUN([_AC_PROG_FC_C_O],
481 [_AC_FORTRAN_ASSERT()dnl
482 AC_CACHE_CHECK([whether $[]_AC_FC[] understands -c and -o together],
483 [ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o],
484 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
485 # We test twice because some compilers refuse to overwrite an existing
486 # `.o' file with `-o', although they will create one.
487 ac_try='$[]_AC_FC[] $[]_AC_LANG_PREFIX[]FLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
489 if _AC_DO_VAR(ac_try) &&
490 test -f conftest2.$ac_objext &&
491 _AC_DO_VAR(ac_try); then
492 ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=yes
494 ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=no
497 if test $ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o = no; then
498 AC_DEFINE([]_AC_FC[]_NO_MINUS_C_MINUS_O, 1,
499 [Define to 1 if your Fortran compiler doesn't accept
500 -c and -o together.])
507 AC_DEFUN([AC_PROG_F77_C_O],
508 [AC_REQUIRE([AC_PROG_F77])dnl
509 AC_LANG_PUSH(Fortran 77)dnl
511 AC_LANG_POP(Fortran 77)dnl
517 AC_DEFUN([AC_PROG_FC_C_O],
518 [AC_REQUIRE([AC_PROG_FC])dnl
519 AC_LANG_PUSH(Fortran)dnl
521 AC_LANG_POP(Fortran)dnl
526 ## ------------------------------- ##
527 ## 4. Compilers' characteristics. ##
528 ## ------------------------------- ##
531 # _AC_PROG_FC_V_OUTPUT([FLAG = $ac_cv_prog_{f77/fc}_v])
532 # -------------------------------------------------
533 # Link a trivial Fortran program, compiling with a verbose output FLAG
534 # (whose default value, $ac_cv_prog_{f77/fc}_v, is computed by
535 # _AC_PROG_FC_V), and return the output in $ac_{f77/fc}_v_output. This
536 # output is processed in the way expected by _AC_FC_LIBRARY_LDFLAGS,
537 # so that any link flags that are echoed by the compiler appear as
538 # space-separated items.
539 AC_DEFUN([_AC_PROG_FC_V_OUTPUT],
540 [_AC_FORTRAN_ASSERT()dnl
541 AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
543 # Compile and link our simple test program by passing a flag (argument
544 # 1 to this macro) to the Fortran compiler in order to get
545 # "verbose" output that we can then parse for the Fortran linker
547 ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS
548 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS m4_default([$1], [$ac_cv_prog_[]_AC_LANG_ABBREV[]_v])"
549 eval "set x $ac_link"
552 ac_[]_AC_LANG_ABBREV[]_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`
553 AS_ECHO(["$ac_[]_AC_LANG_ABBREV[]_v_output"]) >&AS_MESSAGE_LOG_FD
554 _AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS
558 # On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
559 # /foo, /bar, and /baz are search directories for the Fortran linker.
560 # Here, we change these into -L/foo -L/bar -L/baz (and put it first):
561 ac_[]_AC_LANG_ABBREV[]_v_output="`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
563 sed 's,.*LPATH is\(: *[[^ ]]*\).*,\1,;s,: */, -L/,g'` $ac_[]_AC_LANG_ABBREV[]_v_output"
565 # FIXME: we keep getting bitten by quoted arguments; a more general fix
566 # that detects unbalanced quotes in FLIBS should be implemented
567 # and (ugh) tested at some point.
568 case $ac_[]_AC_LANG_ABBREV[]_v_output in
569 # If we are using xlf then replace all the commas with spaces.
571 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/,/ /g'` ;;
573 # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
574 # $LIBS confuse us, and the libraries appear later in the output anyway).
575 *mGLOB_options_string*)
576 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/"-mGLOB[[^"]]*"/ /g'` ;;
578 # Portland Group compiler has singly- or doubly-quoted -cmdline argument
579 # Singly-quoted arguments were reported for versions 5.2-4 and 6.0-4.
580 # Doubly-quoted arguments were reported for "PGF90/x86 Linux/x86 5.0-2".
581 *-cmdline\ * | *-ignore\ * | *-def\ *)
582 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed "\
583 s/-cmdline *'[[^']]*'/ /g; s/-cmdline *\"[[^\"]]*\"/ /g
584 s/-ignore *'[[^']]*'/ /g; s/-ignore *\"[[^\"]]*\"/ /g
585 s/-def *'[[^']]*'/ /g; s/-def *\"[[^\"]]*\"/ /g"` ;;
587 # If we are using Cray Fortran then delete quotes.
589 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/"//g'` ;;
592 ])# _AC_PROG_FC_V_OUTPUT
598 # Determine the flag that causes the Fortran compiler to print
599 # information of library and object files (normally -v)
600 # Needed for _AC_FC_LIBRARY_FLAGS
601 # Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###)
602 AC_DEFUN([_AC_PROG_FC_V],
603 [_AC_FORTRAN_ASSERT()dnl
604 AC_CACHE_CHECK([how to get verbose linking output from $[]_AC_FC[]],
605 [ac_cv_prog_[]_AC_LANG_ABBREV[]_v],
606 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
607 [ac_cv_prog_[]_AC_LANG_ABBREV[]_v=
608 # Try some options frequently used verbose output
609 for ac_verb in -v -verbose --verbose -V -\#\#\#; do
610 _AC_PROG_FC_V_OUTPUT($ac_verb)
611 # look for -l* and *.a constructs in the output
612 for ac_arg in $ac_[]_AC_LANG_ABBREV[]_v_output; do
614 [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*)
615 ac_cv_prog_[]_AC_LANG_ABBREV[]_v=$ac_verb
620 if test -z "$ac_cv_prog_[]_AC_LANG_ABBREV[]_v"; then
621 AC_MSG_WARN([cannot determine how to obtain linking information from $[]_AC_FC[]])
623 [AC_MSG_WARN([compilation failed])])
627 # _AC_FC_LIBRARY_LDFLAGS
628 # ----------------------
630 # Determine the linker flags (e.g. "-L" and "-l") for the Fortran
631 # intrinsic and runtime libraries that are required to successfully
632 # link a Fortran program or shared library. The output variable
633 # FLIBS/FCLIBS is set to these flags.
635 # This macro is intended to be used in those situations when it is
636 # necessary to mix, e.g. C++ and Fortran, source code into a single
637 # program or shared library.
639 # For example, if object files from a C++ and Fortran compiler must
640 # be linked together, then the C++ compiler/linker must be used for
641 # linking (since special C++-ish things need to happen at link time
642 # like calling global constructors, instantiating templates, enabling
643 # exception support, etc.).
645 # However, the Fortran intrinsic and runtime libraries must be
646 # linked in as well, but the C++ compiler/linker doesn't know how to
647 # add these Fortran libraries. Hence, the macro
648 # "AC_F77_LIBRARY_LDFLAGS" was created to determine these Fortran
651 # This macro was packaged in its current form by Matthew D. Langston.
652 # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro
653 # in "octave-2.0.13/aclocal.m4", and full credit should go to John
654 # W. Eaton for writing this extremely useful macro. Thank you John.
655 AC_DEFUN([_AC_FC_LIBRARY_LDFLAGS],
656 [_AC_FORTRAN_ASSERT()dnl
658 AC_CACHE_CHECK([for _AC_LANG libraries of $[]_AC_FC[]], ac_cv_[]_AC_LANG_ABBREV[]_libs,
659 [if test "x$[]_AC_LANG_PREFIX[]LIBS" != "x"; then
660 ac_cv_[]_AC_LANG_ABBREV[]_libs="$[]_AC_LANG_PREFIX[]LIBS" # Let the user override the test.
665 ac_cv_[]_AC_LANG_ABBREV[]_libs=
667 # Save positional arguments (if any)
668 ac_save_positional="$[@]"
670 set X $ac_[]_AC_LANG_ABBREV[]_v_output
671 while test $[@%:@] != 1; do
675 [[\\/]]*.a | ?:[[\\/]]*.a)
676 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
677 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
680 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
681 [_AC_LINKER_OPTION([$ac_arg], ac_cv_[]_AC_LANG_ABBREV[]_libs)])
683 # Ignore these flags.
684 -lang* | -lcrt*.o | -lc | -lgcc* | -lSystem | -libmil | -LANG:=* | -LIST:* | -LNO:*)
687 test x"$CYGWIN" != xyes && ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg"
690 # These flags, when seen by themselves, take an argument.
691 # We remove the space between option and argument and re-iterate
692 # unless we find an empty arg or a new option (starting with -)
703 for ac_j in `AS_ECHO(["$ac_arg"]) | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
704 _AC_LIST_MEMBER_IF($ac_j, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
705 [ac_arg="$ac_arg $ac_j"
706 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_j"])
710 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
711 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
713 -zallextract*| -zdefaultextract)
714 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg"
716 # Ignore everything else.
719 # restore positional arguments
720 set X $ac_save_positional; shift
722 # We only consider "LD_RUN_PATH" on Solaris systems. If this is seen,
723 # then we insist that the "run path" must be an absolute path (i.e. it
724 # must begin with a "/").
725 case `(uname -sr) 2>/dev/null` in
727 ac_ld_run_path=`AS_ECHO(["$ac_[]_AC_LANG_ABBREV[]_v_output"]) |
728 sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`
729 test "x$ac_ld_run_path" != x &&
730 _AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_[]_AC_LANG_ABBREV[]_libs)
733 fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
735 []_AC_LANG_PREFIX[]LIBS="$ac_cv_[]_AC_LANG_ABBREV[]_libs"
736 AC_SUBST([]_AC_LANG_PREFIX[]LIBS)
737 ])# _AC_FC_LIBRARY_LDFLAGS
740 # AC_F77_LIBRARY_LDFLAGS
741 # ----------------------
742 AC_DEFUN([AC_F77_LIBRARY_LDFLAGS],
743 [AC_REQUIRE([AC_PROG_F77])dnl
744 AC_LANG_PUSH(Fortran 77)dnl
745 _AC_FC_LIBRARY_LDFLAGS
746 AC_LANG_POP(Fortran 77)dnl
747 ])# AC_F77_LIBRARY_LDFLAGS
750 # AC_FC_LIBRARY_LDFLAGS
751 # ----------------------
752 AC_DEFUN([AC_FC_LIBRARY_LDFLAGS],
753 [AC_REQUIRE([AC_PROG_FC])dnl
754 AC_LANG_PUSH(Fortran)dnl
755 _AC_FC_LIBRARY_LDFLAGS
756 AC_LANG_POP(Fortran)dnl
757 ])# AC_FC_LIBRARY_LDFLAGS
760 # _AC_FC_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
761 # -----------------------------------------------------------
763 # Detect name of dummy main routine required by the Fortran libraries,
764 # (if any) and define {F77,FC}_DUMMY_MAIN to this name (which should be
765 # used for a dummy declaration, if it is defined). On some systems,
766 # linking a C program to the Fortran library does not work unless you
767 # supply a dummy function called something like MAIN__.
769 # Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C
770 # program with the {F77,FC} libs is found; default to exiting with an error
771 # message. Execute ACTION-IF-FOUND if a dummy routine name is needed
772 # and found or if it is not needed (default to defining {F77,FC}_DUMMY_MAIN
775 # What is technically happening is that the Fortran libraries provide
776 # their own main() function, which usually initializes Fortran I/O and
777 # similar stuff, and then calls MAIN__, which is the entry point of
778 # your program. Usually, a C program will override this with its own
779 # main() routine, but the linker sometimes complain if you don't
780 # provide a dummy (never-called) MAIN__ routine anyway.
782 # Of course, programs that want to allow Fortran subroutines to do
783 # I/O, etcetera, should call their main routine MAIN__() (or whatever)
784 # instead of main(). A separate autoconf test (_AC_FC_MAIN) checks
785 # for the routine to use in this case (since the semantics of the test
786 # are slightly different). To link to e.g. purely numerical
787 # libraries, this is normally not necessary, however, and most C/C++
788 # programs are reluctant to turn over so much control to Fortran. =)
790 # The name variants we check for are (in order):
791 # MAIN__ (g77, MAIN__ required on some systems; IRIX, MAIN__ optional)
792 # MAIN_, __main (SunOS)
793 # MAIN _MAIN __MAIN main_ main__ _main (we follow DDD and try these too)
794 AC_DEFUN([_AC_FC_DUMMY_MAIN],
795 [_AC_FORTRAN_ASSERT()dnl
796 m4_define(_AC_LANG_PROGRAM_C_[]_AC_FC[]_HOOKS,
797 [#ifdef ]_AC_FC[_DUMMY_MAIN
798 ]AC_LANG_CASE([Fortran], [#ifndef FC_DUMMY_MAIN_EQ_F77])
802 int ]_AC_FC[_DUMMY_MAIN() { return 1; }
803 ]AC_LANG_CASE([Fortran], [#endif])
806 AC_CACHE_CHECK([for dummy main to link with _AC_LANG libraries],
807 ac_cv_[]_AC_LANG_ABBREV[]_dummy_main,
808 [ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS=$LIBS
809 LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS"
810 ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN
813 # First, try linking without a dummy main:
814 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
815 [ac_cv_fortran_dummy_main=none],
816 [ac_cv_fortran_dummy_main=unknown])
818 if test $ac_cv_fortran_dummy_main = unknown; then
819 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
820 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@define $ac_fortran_dm_var $ac_func]])],
821 [ac_cv_fortran_dummy_main=$ac_func; break])
825 ac_cv_[]_AC_LANG_ABBREV[]_dummy_main=$ac_cv_fortran_dummy_main
827 LIBS=$ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS
829 []_AC_FC[]_DUMMY_MAIN=$ac_cv_[]_AC_LANG_ABBREV[]_dummy_main
830 AS_IF([test "$[]_AC_FC[]_DUMMY_MAIN" != unknown],
832 [if test $[]_AC_FC[]_DUMMY_MAIN != none; then
833 AC_DEFINE_UNQUOTED([]_AC_FC[]_DUMMY_MAIN, $[]_AC_FC[]_DUMMY_MAIN,
834 [Define to dummy `main' function (if any) required to
835 link to the Fortran libraries.])
836 if test "x$ac_cv_fc_dummy_main" = "x$ac_cv_f77_dummy_main"; then
837 AC_DEFINE([FC_DUMMY_MAIN_EQ_F77], 1,
838 [Define if F77 and FC dummy `main' functions are identical.])
842 [AC_MSG_FAILURE([linking to Fortran libraries from C fails])])])
843 ])# _AC_FC_DUMMY_MAIN
847 # ----------------------
848 AC_DEFUN([AC_F77_DUMMY_MAIN],
849 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
850 AC_LANG_PUSH(Fortran 77)dnl
851 _AC_FC_DUMMY_MAIN($@)
852 AC_LANG_POP(Fortran 77)dnl
853 ])# AC_F77_DUMMY_MAIN
857 # ----------------------
858 AC_DEFUN([AC_FC_DUMMY_MAIN],
859 [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
860 AC_LANG_PUSH(Fortran)dnl
861 _AC_FC_DUMMY_MAIN($@)
862 AC_LANG_POP(Fortran)dnl
868 # Define {F77,FC}_MAIN to name of alternate main() function for use with
869 # the Fortran libraries. (Typically, the libraries may define their
870 # own main() to initialize I/O, etcetera, that then call your own
871 # routine called MAIN__ or whatever.) See _AC_FC_DUMMY_MAIN, above.
872 # If no such alternate name is found, just define {F77,FC}_MAIN to main.
874 AC_DEFUN([_AC_FC_MAIN],
875 [_AC_FORTRAN_ASSERT()dnl
876 AC_CACHE_CHECK([for alternate main to link with _AC_LANG libraries],
877 ac_cv_[]_AC_LANG_ABBREV[]_main,
878 [ac_[]_AC_LANG_ABBREV[]_m_save_LIBS=$LIBS
879 LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS"
880 ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN
882 ac_cv_fortran_main="main" # default entry point name
883 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
884 AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@ifdef FC_DUMMY_MAIN_EQ_F77
885 @%:@ undef F77_DUMMY_MAIN
886 @%:@ undef FC_DUMMY_MAIN
888 @%:@ undef $ac_fortran_dm_var
890 @%:@define main $ac_func])],
891 [ac_cv_fortran_main=$ac_func; break])
894 ac_cv_[]_AC_LANG_ABBREV[]_main=$ac_cv_fortran_main
896 LIBS=$ac_[]_AC_LANG_ABBREV[]_m_save_LIBS
898 AC_DEFINE_UNQUOTED([]_AC_FC[]_MAIN, $ac_cv_[]_AC_LANG_ABBREV[]_main,
899 [Define to alternate name for `main' routine that is
900 called from a `main' in the Fortran libraries.])
906 AC_DEFUN([AC_F77_MAIN],
907 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
908 AC_LANG_PUSH(Fortran 77)dnl
910 AC_LANG_POP(Fortran 77)dnl
916 AC_DEFUN([AC_FC_MAIN],
917 [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
918 AC_LANG_PUSH(Fortran)dnl
920 AC_LANG_POP(Fortran)dnl
924 # __AC_FC_NAME_MANGLING
925 # ---------------------
926 # Test for the name mangling scheme used by the Fortran compiler.
928 # Sets ac_cv_{f77,fc}_mangling. The value contains three fields, separated
931 # lower case / upper case:
932 # case translation of the Fortran symbols
933 # underscore / no underscore:
934 # whether the compiler appends "_" to symbol names
935 # extra underscore / no extra underscore:
936 # whether the compiler appends an extra "_" to symbol names already
937 # containing at least one underscore
939 AC_DEFUN([__AC_FC_NAME_MANGLING],
940 [_AC_FORTRAN_ASSERT()dnl
941 AC_CACHE_CHECK([for _AC_LANG name-mangling scheme],
942 ac_cv_[]_AC_LANG_ABBREV[]_mangling,
944 [ subroutine foobar()
950 [mv conftest.$ac_objext cfortran_test.$ac_objext
953 LIBS="cfortran_test.$ac_objext $LIBS $[]_AC_LANG_PREFIX[]LIBS"
957 for ac_foobar in foobar FOOBAR; do
958 for ac_underscore in "" "_"; do
959 ac_func="$ac_foobar$ac_underscore"
960 AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
961 [ac_success=yes; break 2])
966 if test "$ac_success" = "yes"; then
980 for ac_extra in "" "_"; do
981 ac_func="$ac_foo_bar$ac_underscore$ac_extra"
982 AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
983 [ac_success_extra=yes; break])
987 if test "$ac_success_extra" = "yes"; then
988 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_case case"
989 if test -z "$ac_underscore"; then
990 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no underscore"
992 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, underscore"
994 if test -z "$ac_extra"; then
995 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no extra underscore"
997 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, extra underscore"
1000 ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
1003 ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
1007 rm -f cfortran_test* conftest*],
1008 [AC_MSG_FAILURE([cannot compile a simple Fortran program])])
1010 ])# __AC_FC_NAME_MANGLING
1012 # The replacement is empty.
1013 AU_DEFUN([AC_F77_NAME_MANGLING], [])
1016 # _AC_F77_NAME_MANGLING
1017 # ----------------------
1018 AC_DEFUN([_AC_F77_NAME_MANGLING],
1019 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
1020 AC_REQUIRE([AC_F77_DUMMY_MAIN])dnl
1021 AC_LANG_PUSH(Fortran 77)dnl
1022 __AC_FC_NAME_MANGLING
1023 AC_LANG_POP(Fortran 77)dnl
1024 ])# _AC_F77_NAME_MANGLING
1027 # _AC_FC_NAME_MANGLING
1028 # ----------------------
1029 AC_DEFUN([_AC_FC_NAME_MANGLING],
1030 [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
1031 AC_REQUIRE([AC_FC_DUMMY_MAIN])dnl
1032 AC_LANG_PUSH(Fortran)dnl
1033 __AC_FC_NAME_MANGLING
1034 AC_LANG_POP(Fortran)dnl
1035 ])# _AC_FC_NAME_MANGLING
1040 # Defines C macros {F77,FC}_FUNC(name,NAME) and {F77,FC}_FUNC_(name,NAME) to
1041 # properly mangle the names of C identifiers, and C identifiers with
1042 # underscores, respectively, so that they match the name mangling
1043 # scheme used by the Fortran compiler.
1044 AC_DEFUN([_AC_FC_WRAPPERS],
1045 [_AC_FORTRAN_ASSERT()dnl
1046 AH_TEMPLATE(_AC_FC[_FUNC],
1047 [Define to a macro mangling the given C identifier (in lower and upper
1048 case), which must not contain underscores, for linking with Fortran.])dnl
1049 AH_TEMPLATE(_AC_FC[_FUNC_],
1050 [As ]_AC_FC[_FUNC, but for C identifiers containing underscores.])dnl
1051 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
1052 "lower case, no underscore, no extra underscore")
1053 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name])
1054 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name]) ;;
1055 "lower case, no underscore, extra underscore")
1056 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name])
1057 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
1058 "lower case, underscore, no extra underscore")
1059 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _])
1060 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
1061 "lower case, underscore, extra underscore")
1062 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _])
1063 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## __]) ;;
1064 "upper case, no underscore, no extra underscore")
1065 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME])
1066 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME]) ;;
1067 "upper case, no underscore, extra underscore")
1068 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME])
1069 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
1070 "upper case, underscore, no extra underscore")
1071 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _])
1072 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
1073 "upper case, underscore, extra underscore")
1074 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _])
1075 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## __]) ;;
1077 AC_MSG_WARN([unknown Fortran name-mangling scheme])
1085 AC_DEFUN([AC_F77_WRAPPERS],
1086 [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
1087 AC_LANG_PUSH(Fortran 77)dnl
1089 AC_LANG_POP(Fortran 77)dnl
1095 AC_DEFUN([AC_FC_WRAPPERS],
1096 [AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl
1097 AC_LANG_PUSH(Fortran)dnl
1099 AC_LANG_POP(Fortran)dnl
1103 # _AC_FC_FUNC(NAME, [SHELLVAR = NAME])
1104 # ------------------------------------
1105 # For a Fortran subroutine of given NAME, define a shell variable
1106 # $SHELLVAR to the Fortran-mangled name. If the SHELLVAR
1107 # argument is not supplied, it defaults to NAME.
1108 AC_DEFUN([_AC_FC_FUNC],
1109 [_AC_FORTRAN_ASSERT()dnl
1110 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
1111 upper*) ac_val="m4_toupper([$1])" ;;
1112 lower*) ac_val="m4_tolower([$1])" ;;
1113 *) ac_val="unknown" ;;
1115 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac
1116 m4_if(m4_index([$1],[_]),-1,[],
1117 [case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac
1119 m4_default([$2],[$1])="$ac_val"
1123 # AC_F77_FUNC(NAME, [SHELLVAR = NAME])
1124 # ------------------------------------
1125 AC_DEFUN([AC_F77_FUNC],
1126 [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
1127 AC_LANG_PUSH(Fortran 77)dnl
1128 _AC_FC_FUNC([$1],[$2])
1129 AC_LANG_POP(Fortran 77)dnl
1133 # AC_FC_FUNC(NAME, [SHELLVAR = NAME])
1134 # -----------------------------------
1135 AC_DEFUN([AC_FC_FUNC],
1136 [AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl
1137 AC_LANG_PUSH(Fortran)dnl
1138 _AC_FC_FUNC([$1],[$2])
1139 AC_LANG_POP(Fortran)dnl
1143 # AC_FC_SRCEXT(EXT, [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
1144 # -----------------------------------------------------------
1145 # Set the source-code extension used in Fortran (FC) tests to EXT (which
1146 # defaults to f). Also, look for any necessary additional FCFLAGS needed
1147 # to allow this extension, and store them in the output variable
1148 # FCFLAGS_<EXT> (e.g. FCFLAGS_f90 for EXT=f90). If successful,
1149 # call ACTION-IF-SUCCESS. If unable to compile source code with EXT,
1150 # call ACTION-IF-FAILURE, which defaults to failing with an error
1153 # (The flags for the current source-code extension, if any, are stored in
1154 # $ac_fcflags_srcext and used automatically in subsequent autoconf tests.)
1156 # For ordinary extensions like f90, etcetera, the modified FCFLAGS
1157 # are currently needed for IBM's xlf* and Intel's ifc (grrr). Unfortunately,
1158 # xlf* will only take flags to recognize one extension at a time, so if the
1159 # user wants to compile multiple extensions (.f90 and .f95, say), she
1160 # will need to use the FCFLAGS_F90 and FCFLAGS_F95 individually rather
1161 # than just adding them all to FCFLAGS, for example.
1163 # Also, for Intel's ifc compiler (which does not accept .f95 by default in
1164 # some versions), the $FCFLAGS_<EXT> variable *must* go immediately before
1165 # the source file on the command line, unlike other $FCFLAGS. Ugh.
1166 AC_DEFUN([AC_FC_SRCEXT],
1167 [AC_LANG_PUSH(Fortran)dnl
1168 AC_CACHE_CHECK([for Fortran flag to compile .$1 files],
1171 ac_fcflags_srcext_save=$ac_fcflags_srcext
1173 ac_cv_fc_srcext_$1=unknown
1174 for ac_flag in none -qsuffix=f=$1 -Tf; do
1175 test "x$ac_flag" != xnone && ac_fcflags_srcext="$ac_flag"
1176 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_fc_srcext_$1=$ac_flag; break])
1178 rm -f conftest.$ac_objext conftest.$1
1179 ac_fcflags_srcext=$ac_fcflags_srcext_save
1181 if test "x$ac_cv_fc_srcext_$1" = xunknown; then
1182 m4_default([$3],[AC_MSG_ERROR([Fortran could not compile .$1 files])])
1185 if test "x$ac_cv_fc_srcext_$1" = xnone; then
1186 ac_fcflags_srcext=""
1189 ac_fcflags_srcext=$ac_cv_fc_srcext_$1
1190 FCFLAGS_[]$1[]=$ac_cv_fc_srcext_$1
1192 AC_SUBST(FCFLAGS_[]$1)
1195 AC_LANG_POP(Fortran)dnl
1199 # AC_FC_FREEFORM([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
1200 # ------------------------------------------------------------------
1201 # Look for a compiler flag to make the Fortran (FC) compiler accept
1202 # free-format source code, and adds it to FCFLAGS. Call
1203 # ACTION-IF-SUCCESS (defaults to nothing) if successful (i.e. can
1204 # compile code using new extension) and ACTION-IF-FAILURE (defaults to
1205 # failing with an error message) if not. (Defined via DEFUN_ONCE to
1206 # prevent flag from being added to FCFLAGS multiple times.)
1208 # The known flags are:
1209 # -ffree-form: GNU g77
1210 # -FR: Intel compiler (icc, ecc)
1211 # -free: Compaq compiler (fort)
1212 # -qfree: IBM compiler (xlf)
1213 # -Mfree, -Mfreeform: Portland Group compiler
1214 # -freeform: SGI compiler
1215 # -f free: Absoft Fortran
1216 # We try to test the "more popular" flags first, by some prejudiced
1217 # notion of popularity.
1218 AC_DEFUN_ONCE([AC_FC_FREEFORM],
1219 [AC_LANG_PUSH(Fortran)dnl
1220 AC_CACHE_CHECK([for Fortran flag needed to allow free-form source],
1222 [ac_cv_fc_freeform=unknown
1223 ac_fc_freeform_FCFLAGS_save=$FCFLAGS
1224 for ac_flag in none -ffree-form -FR -free -qfree -Mfree -Mfreeform \
1227 test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_freeform_FCFLAGS_save $ac_flag"
1230 ! FIXME: how to best confuse non-freeform compilers?
1231 print *, 'Hello ', &
1234 [ac_cv_fc_freeform=$ac_flag; break])
1236 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
1237 FCFLAGS=$ac_fc_freeform_FCFLAGS_save
1239 if test "x$ac_cv_fc_freeform" = xunknown; then
1241 [AC_MSG_ERROR([Fortran does not accept free-form source], 77)])
1243 if test "x$ac_cv_fc_freeform" != xnone; then
1244 FCFLAGS="$FCFLAGS $ac_cv_fc_freeform"
1248 AC_LANG_POP(Fortran)dnl