1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Fortran languages support.
3 # Copyright (C) 2001, 2003, 2004
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., 59 Temple Place - Suite 330, 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=${FC_SRCEXT-f}
153 ac_compile='$FC -c $FCFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
154 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $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: putative GNU Fortran 95+ compiler (in progress)
337 # fort77: native F77 compiler under HP-UX (and some older Crays)
338 # frt: Fujitsu F77 compiler
339 # pgf77/pgf90/pgf95: Portland Group F77/F90/F95 compilers
340 # xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers
341 # lf95: Lahey-Fujitsu F95 compiler
342 # fl32: Microsoft Fortran 77 "PowerStation" compiler
343 # af77: Apogee F77 compiler for Intergraph hardware running CLIX
344 # epcf90: "Edinburgh Portable Compiler" F90
345 # fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha
346 # ifc: Intel Fortran 95 compiler for Linux/x86
347 # efc: Intel Fortran 95 compiler for IA64
348 m4_define([_AC_F95_FC], [f95 fort xlf95 ifc efc pgf95 lf95 gfortran])
349 m4_define([_AC_F90_FC], [f90 xlf90 pgf90 epcf90])
350 m4_define([_AC_F77_FC], [g77 f77 xlf frt pgf77 fort77 fl32 af77])
351 AC_DEFUN([_AC_PROG_FC],
352 [_AC_FORTRAN_ASSERT()dnl
353 AC_CHECK_TOOLS([]_AC_FC[],
355 m4_case(_AC_FC_DIALECT_YEAR([$1]),
356 [1995], [_AC_F95_FC],
357 [1990], [_AC_F90_FC _AC_F95_FC],
358 [1977], [_AC_F77_FC _AC_F90_FC _AC_F95_FC],
359 [_AC_F95_FC _AC_F90_FC _AC_F77_FC])))
361 # Provide some information about the compiler.
362 echo "$as_me:__oline__:" \
363 "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
364 ac_compiler=`set X $ac_compile; echo $[2]`
365 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
366 _AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
367 _AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
370 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
371 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
372 # If we don't use `.F' as extension, the preprocessor is not run on the
373 # input file. (Note that this only needs to work for GNU compilers.)
376 _AC_LANG_COMPILER_GNU
382 # AC_PROG_F77([COMPILERS...])
383 # ---------------------------
384 # COMPILERS is a space separated list of Fortran 77 compilers to search
385 # for. See also _AC_PROG_FC.
386 AC_DEFUN([AC_PROG_F77],
387 [AC_LANG_PUSH(Fortran 77)dnl
388 AC_ARG_VAR([F77], [Fortran 77 compiler command])dnl
389 AC_ARG_VAR([FFLAGS], [Fortran 77 compiler flags])dnl
390 _AC_ARG_VAR_LDFLAGS()dnl
391 _AC_PROG_FC([Fortran 77], [$1])
392 G77=`test $ac_compiler_gnu = yes && echo yes`
393 AC_LANG_POP(Fortran 77)dnl
397 # AC_PROG_FC([COMPILERS...], [DIALECT])
398 # -------------------------------------
399 # COMPILERS is a space separated list of Fortran 77 compilers to search
400 # for, and [DIALECT] is an optional dialect. See also _AC_PROG_FC.
401 AC_DEFUN([AC_PROG_FC],
402 [AC_LANG_PUSH(Fortran)dnl
403 AC_ARG_VAR([FC], [Fortran compiler command])dnl
404 AC_ARG_VAR([FCFLAGS], [Fortran compiler flags])dnl
405 _AC_ARG_VAR_LDFLAGS()dnl
406 _AC_PROG_FC([$2], [$1])
407 AC_LANG_POP(Fortran)dnl
413 # Check whether -g works, even if F[C]FLAGS is set, in case the package
414 # plays around with F[C]FLAGS (such as to build both debugging and normal
415 # versions of a library), tasteless as that idea is.
416 m4_define([_AC_PROG_FC_G],
417 [_AC_FORTRAN_ASSERT()dnl
418 ac_test_FFLAGS=${[]_AC_LANG_PREFIX[]FLAGS+set}
419 ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS
420 _AC_LANG_PREFIX[]FLAGS=
421 AC_CACHE_CHECK(whether $[]_AC_FC[] accepts -g, ac_cv_prog_[]_AC_LANG_ABBREV[]_g,
422 [_AC_LANG_PREFIX[]FLAGS=-g
423 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
424 [ac_cv_prog_[]_AC_LANG_ABBREV[]_g=yes],
425 [ac_cv_prog_[]_AC_LANG_ABBREV[]_g=no])
427 if test "$ac_test_FFLAGS" = set; then
428 _AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS
429 elif test $ac_cv_prog_[]_AC_LANG_ABBREV[]_g = yes; then
430 if test "x$ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu" = xyes; then
431 _AC_LANG_PREFIX[]FLAGS="-g -O2"
433 _AC_LANG_PREFIX[]FLAGS="-g"
436 if test "x$ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu" = xyes; then
437 _AC_LANG_PREFIX[]FLAGS="-O2"
439 _AC_LANG_PREFIX[]FLAGS=
447 # Test if the Fortran compiler accepts the options `-c' and `-o'
448 # simultaneously, and define `[F77/FC]_NO_MINUS_C_MINUS_O' if it does not.
450 # The usefulness of this macro is questionable, as I can't really see
451 # why anyone would use it. The only reason I include it is for
452 # completeness, since a similar test exists for the C compiler.
454 # FIXME: it seems like we could merge the C/Fortran versions of this.
455 AC_DEFUN([_AC_PROG_FC_C_O],
456 [_AC_FORTRAN_ASSERT()dnl
457 AC_CACHE_CHECK([whether $[]_AC_FC[] understands -c and -o together],
458 [ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o],
459 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
460 # We test twice because some compilers refuse to overwrite an existing
461 # `.o' file with `-o', although they will create one.
462 ac_try='$[]_AC_FC[] $[]_AC_LANG_PREFIX[]FLAGS -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
463 if AC_TRY_EVAL(ac_try) &&
464 test -f conftest.$ac_objext &&
465 AC_TRY_EVAL(ac_try); then
466 ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=yes
468 ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=no
471 if test $ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o = no; then
472 AC_DEFINE([]_AC_FC[]_NO_MINUS_C_MINUS_O, 1,
473 [Define to 1 if your Fortran compiler doesn't accept
474 -c and -o together.])
481 AC_DEFUN([AC_PROG_F77_C_O],
482 [AC_REQUIRE([AC_PROG_F77])dnl
483 AC_LANG_PUSH(Fortran 77)dnl
485 AC_LANG_POP(Fortran 77)dnl
491 AC_DEFUN([AC_PROG_FC_C_O],
492 [AC_REQUIRE([AC_PROG_FC])dnl
493 AC_LANG_PUSH(Fortran)dnl
495 AC_LANG_POP(Fortran)dnl
499 ## ------------------------------- ##
500 ## 4. Compilers' characteristics. ##
501 ## ------------------------------- ##
504 # ---------------------------------------- #
505 # 4d. Fortran 77 compiler characteristics. #
506 # ---------------------------------------- #
509 # _AC_PROG_FC_V_OUTPUT([FLAG = $ac_cv_prog_{f77/fc}_v])
510 # -------------------------------------------------
511 # Link a trivial Fortran program, compiling with a verbose output FLAG
512 # (whose default value, $ac_cv_prog_{f77/fc}_v, is computed by
513 # _AC_PROG_FC_V), and return the output in $ac_{f77/fc}_v_output. This
514 # output is processed in the way expected by _AC_FC_LIBRARY_LDFLAGS,
515 # so that any link flags that are echoed by the compiler appear as
516 # space-separated items.
517 AC_DEFUN([_AC_PROG_FC_V_OUTPUT],
518 [_AC_FORTRAN_ASSERT()dnl
519 AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
521 # Compile and link our simple test program by passing a flag (argument
522 # 1 to this macro) to the Fortran compiler in order to get
523 # "verbose" output that we can then parse for the Fortran linker
525 ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS
526 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS m4_default([$1], [$ac_cv_prog_[]_AC_LANG_ABBREV[]_v])"
527 (eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD
528 ac_[]_AC_LANG_ABBREV[]_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`
529 echo "$ac_[]_AC_LANG_ABBREV[]_v_output" >&AS_MESSAGE_LOG_FD
530 _AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS
534 # On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
535 # /foo, /bar, and /baz are search directories for the Fortran linker.
536 # Here, we change these into -L/foo -L/bar -L/baz (and put it first):
537 ac_[]_AC_LANG_ABBREV[]_v_output="`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
539 sed 's,.*LPATH is\(: *[[^ ]]*\).*,\1,;s,: */, -L/,g'` $ac_[]_AC_LANG_ABBREV[]_v_output"
541 case $ac_[]_AC_LANG_ABBREV[]_v_output in
542 # If we are using xlf then replace all the commas with spaces.
544 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/,/ /g'` ;;
546 # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
547 # $LIBS confuse us, and the libraries appear later in the output anyway).
548 *mGLOB_options_string*)
549 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/\"-mGLOB[[^\"]]*\"/ /g'` ;;
551 # If we are using Cray Fortran then delete quotes.
552 # Use "\"" instead of '"' for font-lock-mode.
553 # FIXME: a more general fix for quoted arguments with spaces?
555 ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed "s/\"//g"` ;;
558 ])# _AC_PROG_FC_V_OUTPUT
564 # Determine the flag that causes the Fortran compiler to print
565 # information of library and object files (normally -v)
566 # Needed for _AC_FC_LIBRARY_FLAGS
567 # Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###)
568 AC_DEFUN([_AC_PROG_FC_V],
569 [_AC_FORTRAN_ASSERT()dnl
570 AC_CACHE_CHECK([how to get verbose linking output from $[]_AC_FC[]],
571 [ac_cv_prog_[]_AC_LANG_ABBREV[]_v],
572 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
573 [ac_cv_prog_[]_AC_LANG_ABBREV[]_v=
574 # Try some options frequently used verbose output
575 for ac_verb in -v -verbose --verbose -V -\#\#\#; do
576 _AC_PROG_FC_V_OUTPUT($ac_verb)
577 # look for -l* and *.a constructs in the output
578 for ac_arg in $ac_[]_AC_LANG_ABBREV[]_v_output; do
580 [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*)
581 ac_cv_prog_[]_AC_LANG_ABBREV[]_v=$ac_verb
586 if test -z "$ac_cv_prog_[]_AC_LANG_ABBREV[]_v"; then
587 AC_MSG_WARN([cannot determine how to obtain linking information from $[]_AC_FC[]])
589 [AC_MSG_WARN([compilation failed])])
593 # _AC_FC_LIBRARY_LDFLAGS
594 # ----------------------
596 # Determine the linker flags (e.g. "-L" and "-l") for the Fortran
597 # intrinsic and run-time libraries that are required to successfully
598 # link a Fortran program or shared library. The output variable
599 # FLIBS/FCLIBS is set to these flags.
601 # This macro is intended to be used in those situations when it is
602 # necessary to mix, e.g. C++ and Fortran, source code into a single
603 # program or shared library.
605 # For example, if object files from a C++ and Fortran compiler must
606 # be linked together, then the C++ compiler/linker must be used for
607 # linking (since special C++-ish things need to happen at link time
608 # like calling global constructors, instantiating templates, enabling
609 # exception support, etc.).
611 # However, the Fortran intrinsic and run-time libraries must be
612 # linked in as well, but the C++ compiler/linker doesn't know how to
613 # add these Fortran libraries. Hence, the macro
614 # "AC_F77_LIBRARY_LDFLAGS" was created to determine these Fortran
617 # This macro was packaged in its current form by Matthew D. Langston.
618 # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro
619 # in "octave-2.0.13/aclocal.m4", and full credit should go to John
620 # W. Eaton for writing this extremely useful macro. Thank you John.
621 AC_DEFUN([_AC_FC_LIBRARY_LDFLAGS],
622 [_AC_FORTRAN_ASSERT()dnl
624 AC_CACHE_CHECK([for Fortran libraries of $[]_AC_FC[]], ac_cv_[]_AC_LANG_ABBREV[]_libs,
625 [if test "x$[]_AC_LANG_PREFIX[]LIBS" != "x"; then
626 ac_cv_[]_AC_LANG_ABBREV[]_libs="$[]_AC_LANG_PREFIX[]LIBS" # Let the user override the test.
631 ac_cv_[]_AC_LANG_ABBREV[]_libs=
633 # Save positional arguments (if any)
634 ac_save_positional="$[@]"
636 set X $ac_[]_AC_LANG_ABBREV[]_v_output
637 while test $[@%:@] != 1; do
641 [[\\/]]*.a | ?:[[\\/]]*.a)
642 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
643 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
646 _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
647 [_AC_LINKER_OPTION([$ac_arg], ac_cv_[]_AC_LANG_ABBREV[]_libs)])
649 # Ignore these flags.
650 -lang* | -lcrt*.o | -lc | -lgcc | -libmil | -LANG:=*)
653 test x"$CYGWIN" != xyes && ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg"
656 # These flags, when seen by themselves, take an argument.
657 # We remove the space between option and argument and re-iterate
658 # unless we find an empty arg or a new option (starting with -)
669 for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
670 _AC_LIST_MEMBER_IF($ac_j, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
671 [ac_arg="$ac_arg $ac_j"
672 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_j"])
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")
679 # Ignore everything else.
682 # restore positional arguments
683 set X $ac_save_positional; shift
685 # We only consider "LD_RUN_PATH" on Solaris systems. If this is seen,
686 # then we insist that the "run path" must be an absolute path (i.e. it
687 # must begin with a "/").
688 case `(uname -sr) 2>/dev/null` in
690 ac_ld_run_path=`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
691 sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`
692 test "x$ac_ld_run_path" != x &&
693 _AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_[]_AC_LANG_ABBREV[]_libs)
696 fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
698 []_AC_LANG_PREFIX[]LIBS="$ac_cv_[]_AC_LANG_ABBREV[]_libs"
699 AC_SUBST([]_AC_LANG_PREFIX[]LIBS)
700 ])# _AC_FC_LIBRARY_LDFLAGS
703 # AC_F77_LIBRARY_LDFLAGS
704 # ----------------------
705 AC_DEFUN([AC_F77_LIBRARY_LDFLAGS],
706 [AC_REQUIRE([AC_PROG_F77])dnl
707 AC_LANG_PUSH(Fortran 77)dnl
708 _AC_FC_LIBRARY_LDFLAGS
709 AC_LANG_POP(Fortran 77)dnl
710 ])# AC_F77_LIBRARY_LDFLAGS
713 # AC_FC_LIBRARY_LDFLAGS
714 # ----------------------
715 AC_DEFUN([AC_FC_LIBRARY_LDFLAGS],
716 [AC_REQUIRE([AC_PROG_FC])dnl
717 AC_LANG_PUSH(Fortran)dnl
718 _AC_FC_LIBRARY_LDFLAGS
719 AC_LANG_POP(Fortran)dnl
720 ])# AC_FC_LIBRARY_LDFLAGS
723 # _AC_FC_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
724 # -----------------------------------------------------------
726 # Detect name of dummy main routine required by the Fortran libraries,
727 # (if any) and define {F77,FC}_DUMMY_MAIN to this name (which should be
728 # used for a dummy declaration, if it is defined). On some systems,
729 # linking a C program to the Fortran library does not work unless you
730 # supply a dummy function called something like MAIN__.
732 # Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C
733 # program with the {F77,FC} libs is found; default to exiting with an error
734 # message. Execute ACTION-IF-FOUND if a dummy routine name is needed
735 # and found or if it is not needed (default to defining {F77,FC}_DUMMY_MAIN
738 # What is technically happening is that the Fortran libraries provide
739 # their own main() function, which usually initializes Fortran I/O and
740 # similar stuff, and then calls MAIN__, which is the entry point of
741 # your program. Usually, a C program will override this with its own
742 # main() routine, but the linker sometimes complain if you don't
743 # provide a dummy (never-called) MAIN__ routine anyway.
745 # Of course, programs that want to allow Fortran subroutines to do
746 # I/O, etcetera, should call their main routine MAIN__() (or whatever)
747 # instead of main(). A separate autoconf test (_AC_FC_MAIN) checks
748 # for the routine to use in this case (since the semantics of the test
749 # are slightly different). To link to e.g. purely numerical
750 # libraries, this is normally not necessary, however, and most C/C++
751 # programs are reluctant to turn over so much control to Fortran. =)
753 # The name variants we check for are (in order):
754 # MAIN__ (g77, MAIN__ required on some systems; IRIX, MAIN__ optional)
755 # MAIN_, __main (SunOS)
756 # MAIN _MAIN __MAIN main_ main__ _main (we follow DDD and try these too)
757 AC_DEFUN([_AC_FC_DUMMY_MAIN],
758 [_AC_FORTRAN_ASSERT()dnl
759 m4_define(_AC_LANG_PROGRAM_C_[]_AC_FC[]_HOOKS,
760 [#ifdef ]_AC_FC[_DUMMY_MAIN
761 ]AC_LANG_CASE([Fortran], [#ifndef FC_DUMMY_MAIN_EQ_F77])
765 int ]_AC_FC[_DUMMY_MAIN() { return 1; }
766 ]AC_LANG_CASE([Fortran], [#endif])
769 AC_CACHE_CHECK([for dummy main to link with Fortran libraries],
770 ac_cv_[]_AC_LANG_ABBREV[]_dummy_main,
771 [ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS=$LIBS
772 LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS"
773 ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN
776 # First, try linking without a dummy main:
777 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
778 [ac_cv_fortran_dummy_main=none],
779 [ac_cv_fortran_dummy_main=unknown])
781 if test $ac_cv_fortran_dummy_main = unknown; then
782 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
783 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@define $ac_fortran_dm_var $ac_func]])],
784 [ac_cv_fortran_dummy_main=$ac_func; break])
788 ac_cv_[]_AC_LANG_ABBREV[]_dummy_main=$ac_cv_fortran_dummy_main
790 LIBS=$ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS
792 []_AC_FC[]_DUMMY_MAIN=$ac_cv_[]_AC_LANG_ABBREV[]_dummy_main
793 AS_IF([test "$[]_AC_FC[]_DUMMY_MAIN" != unknown],
795 [if test $[]_AC_FC[]_DUMMY_MAIN != none; then
796 AC_DEFINE_UNQUOTED([]_AC_FC[]_DUMMY_MAIN, $[]_AC_FC[]_DUMMY_MAIN,
797 [Define to dummy `main' function (if any) required to
798 link to the Fortran libraries.])
799 if test "x$ac_cv_fc_dummy_main" = "x$ac_cv_f77_dummy_main"; then
800 AC_DEFINE([FC_DUMMY_MAIN_EQ_F77], 1,
801 [Define if F77 and FC dummy `main' functions are identical.])
805 [AC_MSG_FAILURE([linking to Fortran libraries from C fails])])])
806 ])# _AC_FC_DUMMY_MAIN
810 # ----------------------
811 AC_DEFUN([AC_F77_DUMMY_MAIN],
812 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
813 AC_LANG_PUSH(Fortran 77)dnl
815 AC_LANG_POP(Fortran 77)dnl
816 ])# AC_F77_DUMMY_MAIN
820 # ----------------------
821 AC_DEFUN([AC_FC_DUMMY_MAIN],
822 [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
823 AC_LANG_PUSH(Fortran)dnl
825 AC_LANG_POP(Fortran)dnl
831 # Define {F77,FC}_MAIN to name of alternate main() function for use with
832 # the Fortran libraries. (Typically, the libraries may define their
833 # own main() to initialize I/O, etcetera, that then call your own
834 # routine called MAIN__ or whatever.) See _AC_FC_DUMMY_MAIN, above.
835 # If no such alternate name is found, just define {F77,FC}_MAIN to main.
837 AC_DEFUN([_AC_FC_MAIN],
838 [_AC_FORTRAN_ASSERT()dnl
839 AC_CACHE_CHECK([for alternate main to link with Fortran libraries],
840 ac_cv_[]_AC_LANG_ABBREV[]_main,
841 [ac_[]_AC_LANG_ABBREV[]_m_save_LIBS=$LIBS
842 LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS"
843 ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN
845 ac_cv_fortran_main="main" # default entry point name
846 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
847 AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@ifdef FC_DUMMY_MAIN_EQ_F77
848 @%:@ undef F77_DUMMY_MAIN
849 @%:@ undef FC_DUMMY_MAIN
851 @%:@ undef $ac_fortran_dm_var
853 @%:@define main $ac_func])],
854 [ac_cv_fortran_main=$ac_func; break])
857 ac_cv_[]_AC_LANG_ABBREV[]_main=$ac_cv_fortran_main
859 LIBS=$ac_[]_AC_LANG_ABBREV[]_m_save_LIBS
861 AC_DEFINE_UNQUOTED([]_AC_FC[]_MAIN, $ac_cv_[]_AC_LANG_ABBREV[]_main,
862 [Define to alternate name for `main' routine that is
863 called from a `main' in the Fortran libraries.])
869 AC_DEFUN([AC_F77_MAIN],
870 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
871 AC_LANG_PUSH(Fortran 77)dnl
873 AC_LANG_POP(Fortran 77)dnl
879 AC_DEFUN([AC_FC_MAIN],
880 [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
881 AC_LANG_PUSH(Fortran)dnl
883 AC_LANG_POP(Fortran)dnl
887 # __AC_FC_NAME_MANGLING
888 # ---------------------
889 # Test for the name mangling scheme used by the Fortran compiler.
891 # Sets ac_cv_{f77,fc}_mangling. The value contains three fields, separated
894 # lower case / upper case:
895 # case translation of the Fortran symbols
896 # underscore / no underscore:
897 # whether the compiler appends "_" to symbol names
898 # extra underscore / no extra underscore:
899 # whether the compiler appends an extra "_" to symbol names already
900 # containing at least one underscore
902 AC_DEFUN([__AC_FC_NAME_MANGLING],
903 [_AC_FORTRAN_ASSERT()dnl
904 AC_CACHE_CHECK([for Fortran name-mangling scheme],
905 ac_cv_[]_AC_LANG_ABBREV[]_mangling,
907 [ subroutine foobar()
913 [mv conftest.$ac_objext cfortran_test.$ac_objext
916 LIBS="cfortran_test.$ac_objext $LIBS $[]_AC_LANG_PREFIX[]LIBS"
920 for ac_foobar in foobar FOOBAR; do
921 for ac_underscore in "" "_"; do
922 ac_func="$ac_foobar$ac_underscore"
923 AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
924 [ac_success=yes; break 2])
929 if test "$ac_success" = "yes"; then
943 for ac_extra in "" "_"; do
944 ac_func="$ac_foo_bar$ac_underscore$ac_extra"
945 AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
946 [ac_success_extra=yes; break])
950 if test "$ac_success_extra" = "yes"; then
951 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_case case"
952 if test -z "$ac_underscore"; then
953 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no underscore"
955 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, underscore"
957 if test -z "$ac_extra"; then
958 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no extra underscore"
960 ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, extra underscore"
963 ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
966 ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
970 rm -f cfortran_test* conftest*],
971 [AC_MSG_FAILURE([cannot compile a simple Fortran program])])
973 ])# __AC_FC_NAME_MANGLING
975 # The replacement is empty.
976 AU_DEFUN([AC_F77_NAME_MANGLING], [])
979 # _AC_F77_NAME_MANGLING
980 # ----------------------
981 AC_DEFUN([_AC_F77_NAME_MANGLING],
982 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
983 AC_REQUIRE([AC_F77_DUMMY_MAIN])dnl
984 AC_LANG_PUSH(Fortran 77)dnl
985 __AC_FC_NAME_MANGLING
986 AC_LANG_POP(Fortran 77)dnl
987 ])# _AC_F77_NAME_MANGLING
990 # _AC_FC_NAME_MANGLING
991 # ----------------------
992 AC_DEFUN([_AC_FC_NAME_MANGLING],
993 [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
994 AC_REQUIRE([AC_FC_DUMMY_MAIN])dnl
995 AC_LANG_PUSH(Fortran)dnl
996 __AC_FC_NAME_MANGLING
997 AC_LANG_POP(Fortran)dnl
998 ])# _AC_FC_NAME_MANGLING
1003 # Defines C macros {F77,FC}_FUNC(name,NAME) and {F77,FC}_FUNC_(name,NAME) to
1004 # properly mangle the names of C identifiers, and C identifiers with
1005 # underscores, respectively, so that they match the name mangling
1006 # scheme used by the Fortran compiler.
1007 AC_DEFUN([_AC_FC_WRAPPERS],
1008 [_AC_FORTRAN_ASSERT()dnl
1009 AH_TEMPLATE(_AC_FC[_FUNC],
1010 [Define to a macro mangling the given C identifier (in lower and upper
1011 case), which must not contain underscores, for linking with Fortran.])dnl
1012 AH_TEMPLATE(_AC_FC[_FUNC_],
1013 [As ]_AC_FC[_FUNC, but for C identifiers containing underscores.])dnl
1014 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
1015 "lower case, no underscore, no extra underscore")
1016 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name])
1017 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name]) ;;
1018 "lower case, no underscore, extra underscore")
1019 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name])
1020 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
1021 "lower case, underscore, no extra underscore")
1022 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _])
1023 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
1024 "lower case, underscore, extra underscore")
1025 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [name ## _])
1026 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## __]) ;;
1027 "upper case, no underscore, no extra underscore")
1028 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME])
1029 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME]) ;;
1030 "upper case, no underscore, extra underscore")
1031 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME])
1032 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
1033 "upper case, underscore, no extra underscore")
1034 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _])
1035 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
1036 "upper case, underscore, extra underscore")
1037 AC_DEFINE(_AC_FC[_FUNC(name,NAME)], [NAME ## _])
1038 AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## __]) ;;
1040 AC_MSG_WARN([unknown Fortran name-mangling scheme])
1048 AC_DEFUN([AC_F77_WRAPPERS],
1049 [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
1050 AC_LANG_PUSH(Fortran 77)dnl
1052 AC_LANG_POP(Fortran 77)dnl
1058 AC_DEFUN([AC_FC_WRAPPERS],
1059 [AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl
1060 AC_LANG_PUSH(Fortran)dnl
1062 AC_LANG_POP(Fortran)dnl
1066 # _AC_FC_FUNC(NAME, [SHELLVAR = NAME])
1067 # ------------------------------------
1068 # For a Fortran subroutine of given NAME, define a shell variable
1069 # $SHELLVAR to the Fortran-mangled name. If the SHELLVAR
1070 # argument is not supplied, it defaults to NAME.
1071 AC_DEFUN([_AC_FC_FUNC],
1072 [_AC_FORTRAN_ASSERT()dnl
1073 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
1074 upper*) ac_val="m4_toupper([$1])" ;;
1075 lower*) ac_val="m4_tolower([$1])" ;;
1076 *) ac_val="unknown" ;;
1078 case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac
1079 m4_if(m4_index([$1],[_]),-1,[],
1080 [case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac
1082 m4_default([$2],[$1])="$ac_val"
1086 # AC_F77_FUNC(NAME, [SHELLVAR = NAME])
1087 # ------------------------------------
1088 AC_DEFUN([AC_F77_FUNC],
1089 [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
1090 AC_LANG_PUSH(Fortran 77)dnl
1091 _AC_FC_FUNC([$1],[$2])
1092 AC_LANG_POP(Fortran 77)dnl
1096 # AC_FC_FUNC(NAME, [SHELLVAR = NAME])
1097 # -----------------------------------
1098 AC_DEFUN([AC_FC_FUNC],
1099 [AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl
1100 AC_LANG_PUSH(Fortran)dnl
1101 _AC_FC_FUNC([$1],[$2])
1102 AC_LANG_POP(Fortran)dnl
1106 # AC_FC_SRCEXT(EXT, [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
1107 # -----------------------------------------------------------
1108 # Set the source-code extension used in Fortran (FC) tests to EXT (which
1109 # defaults to f). Also, look for any necessary additional FCFLAGS needed
1110 # to allow this extension, and store them in the output variable
1111 # FCFLAGS_<EXT> (e.g. FCFLAGS_f90 for EXT=f90). If successful,
1112 # call ACTION-IF-SUCCESS. If unable to compile source code with EXT,
1113 # call ACTION-IF-FAILURE, which defaults to failing with an error
1116 # (The flags for the current source-code extension, if any, are stored
1117 # in the FCFLAGS_SRCEXT variable and are automatically used in subsequent
1120 # For ordinary extensions like f90, etcetera, the modified FCFLAGS
1121 # are currently needed for IBM's xlf* and Intel's ifc (grrr). Unfortunately,
1122 # xlf* will only take flags to recognize one extension at a time, so if the
1123 # user wants to compile multiple extensions (.f90 and .f95, say), she
1124 # will need to use the FCFLAGS_F90 and FCFLAGS_F95 individually rather
1125 # than just adding them all to FCFLAGS, for example.
1127 # Also, for Intel's ifc compiler (which does not accept .f95 by default in
1128 # some versions), the $FCFLAGS_<EXT> variable *must* go immediately before
1129 # the source file on the command line, unlike other $FCFLAGS. Ugh.
1130 AC_DEFUN([AC_FC_SRCEXT],
1131 [AC_LANG_ASSERT(Fortran)dnl
1132 AC_CACHE_CHECK([for Fortran flag to compile .$1 files],
1135 ac_fc_srcext_FCFLAGS_SRCEXT_save=$FCFLAGS_SRCEXT
1137 ac_cv_fc_srcext_$1=unknown
1138 for ac_flag in none -qsuffix=f=$1 -Tf; do
1139 test "x$ac_flag" != xnone && FCFLAGS_SRCEXT="$ac_flag"
1140 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_fc_srcext_$1=$ac_flag; break])
1142 rm -f conftest.$ac_objext conftest.$1
1143 FCFLAGS_SRCEXT=$ac_fc_srcext_FCFLAGS_SRCEXT_save
1145 if test "x$ac_cv_fc_srcext_$1" = xunknown; then
1146 m4_default([$3],[AC_MSG_ERROR([Fortran could not compile .$1 files])])
1149 if test "x$ac_cv_fc_srcext_$1" = xnone; then
1153 FCFLAGS_SRCEXT=$ac_cv_fc_srcext_$1
1154 FCFLAGS_[]$1[]=$ac_cv_fc_srcext_$1
1156 AC_SUBST(FCFLAGS_[]$1)
1162 # AC_FC_FREEFORM([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
1163 # ------------------------------------------------------------------
1164 # Look for a compiler flag to make the Fortran (FC) compiler accept
1165 # free-format source code, and adds it to FCFLAGS. Call
1166 # ACTION-IF-SUCCESS (defaults to nothing) if successful (i.e. can
1167 # compile code using new extension) and ACTION-IF-FAILURE (defaults to
1168 # failing with an error message) if not. (Defined via DEFUN_ONCE to
1169 # prevent flag from being added to FCFLAGS multiple times.)
1171 # The known flags are:
1172 # -ffree-form: GNU g77
1173 # -FR: Intel compiler (icc, ecc)
1174 # -free: Compaq compiler (fort)
1175 # -qfree: IBM compiler (xlf)
1176 # -Mfree, -Mfreeform: Portland Group compiler
1177 # -freeform: SGI compiler
1178 # -f free: Absoft Fortran
1179 # We try to test the "more popular" flags first, by some prejudiced
1180 # notion of popularity.
1181 AC_DEFUN_ONCE([AC_FC_FREEFORM],
1182 [AC_LANG_ASSERT([Fortran])dnl
1183 AC_CACHE_CHECK([for Fortran flag needed to allow free-form source],
1185 [ac_cv_fc_freeform=unknown
1186 ac_fc_freeform_FCFLAGS_save=$FCFLAGS
1187 for ac_flag in none -ffree-form -FR -free -qfree -Mfree -Mfreeform \
1190 test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_freeform_FCFLAGS_save $ac_flag"
1193 ! FIXME: how to best confuse non-freeform compilers?
1194 print *, 'Hello ', &
1197 [ac_cv_fc_freeform=$ac_flag; break])
1199 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
1200 FCFLAGS=$ac_fc_freeform_FCFLAGS_save
1202 if test "x$ac_cv_fc_freeform" = xunknown; then
1204 [AC_MSG_ERROR([Fortran does not accept free-form source], 77)])
1206 if test "x$ac_cv_fc_freeform" != xnone; then
1207 FCFLAGS="$FCFLAGS $ac_cv_fc_freeform"