/[autoconf]/autoconf/lib/autoconf/fortran.m4
ViewVC logotype

Diff of /autoconf/lib/autoconf/fortran.m4

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.166 by eggert, Fri Jul 25 21:23:10 2003 UTC revision 1.167 by eggert, Wed Sep 3 00:35:52 2003 UTC
# Line 49  Line 49 
49  # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,  # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
50  # Roland McGrath, Noah Friedman, david d zuhn, and many others.  # Roland McGrath, Noah Friedman, david d zuhn, and many others.
51    
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.
62    
63    
64  # _AC_LIST_MEMBER_IF(ELEMENT, LIST, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])  # _AC_LIST_MEMBER_IF(ELEMENT, LIST, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
65  # ---------------------------------------------------------------------------  # ---------------------------------------------------------------------------
# Line 121  fi[]dnl Line 132  fi[]dnl
132    
133    
134  # ----------------------------- #  # ----------------------------- #
135  # 1d. The Fortran 77 language.  #  # 1d. The Fortran language.  #
136  # ----------------------------- #  # ----------------------------- #
137    
138    
# Line 135  ac_compiler_gnu=$ac_cv_f77_compiler_gnu Line 146  ac_compiler_gnu=$ac_cv_f77_compiler_gnu
146  ])  ])
147    
148    
149    # AC_LANG(Fortran)
150    # -------------------
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
156    ])
157    
158  # AC_LANG_FORTRAN77  # AC_LANG_FORTRAN77
159  # -----------------  # -----------------
160  AU_DEFUN([AC_LANG_FORTRAN77], [AC_LANG(Fortran 77)])  AU_DEFUN([AC_LANG_FORTRAN77], [AC_LANG(Fortran 77)])
161    
162    
163    # _AC_FORTRAN_ASSERT
164    # --------------------
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)])])])
170    
171    
172  # _AC_LANG_ABBREV(Fortran 77)  # _AC_LANG_ABBREV(Fortran 77)
173  # ---------------------------  # ---------------------------
174  m4_define([_AC_LANG_ABBREV(Fortran 77)], [f77])  m4_define([_AC_LANG_ABBREV(Fortran 77)], [f77])
175    
176    # _AC_LANG_ABBREV(Fortran)
177    # ---------------------------
178    m4_define([_AC_LANG_ABBREV(Fortran)], [fc])
179    
180    
181    # _AC_LANG_PREFIX(Fortran 77)
182    # ---------------------------
183    m4_define([_AC_LANG_PREFIX(Fortran 77)], [F])
184    
185    # _AC_LANG_PREFIX(Fortran)
186    # ---------------------------
187    m4_define([_AC_LANG_PREFIX(Fortran)], [FC])
188    
189    
190    # _AC_FC
191    # -------------------
192    # Return F77 or FC, depending upon the language.
193    AC_DEFUN([_AC_FC],
194    [_AC_FORTRAN_ASSERT()dnl
195    AC_LANG_CASE([Fortran 77], [F77], [Fortran], [FC])])
196    
197    
198  ## ---------------------- ##  ## ---------------------- ##
# Line 152  m4_define([_AC_LANG_ABBREV(Fortran 77)], Line 201  m4_define([_AC_LANG_ABBREV(Fortran 77)],
201    
202    
203  # ------------------------ #  # ------------------------ #
204  # 2d. Fortran 77 sources.  #  # 2d. Fortran sources.  #
205  # ------------------------ #  # ------------------------ #
206    
207  # AC_LANG_SOURCE(Fortran 77)(BODY)  # AC_LANG_SOURCE(Fortran 77)(BODY)
208    # AC_LANG_SOURCE(Fortran)(BODY)
209  # --------------------------------  # --------------------------------
210  # FIXME: Apparently, according to former AC_TRY_COMPILER, the CPP  # FIXME: Apparently, according to former AC_TRY_COMPILER, the CPP
211  # directives must not be included.  But AC_TRY_RUN_NATIVE was not  # directives must not be included.  But AC_TRY_RUN_NATIVE was not
212  # avoiding them, so?  # avoiding them, so?
213  m4_define([AC_LANG_SOURCE(Fortran 77)],  m4_define([AC_LANG_SOURCE(Fortran 77)],
214  [$1])  [$1])
215    m4_define([AC_LANG_SOURCE(Fortran)],
216    [$1])
217    
218    
219  # AC_LANG_PROGRAM(Fortran 77)([PROLOGUE], [BODY])  # AC_LANG_PROGRAM(Fortran 77)([PROLOGUE], [BODY])
# Line 175  $2 Line 227  $2
227        end])        end])
228    
229    
230    # AC_LANG_PROGRAM(Fortran)([PROLOGUE], [BODY])
231    # -----------------------------------------------
232    # FIXME: can the PROLOGUE be used?
233    m4_define([AC_LANG_PROGRAM(Fortran)],
234    [m4_ifval([$1],
235           [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl
236          program main
237    $2
238          end])
239    
240    
241  # AC_LANG_CALL(Fortran 77)(PROLOGUE, FUNCTION)  # AC_LANG_CALL(Fortran 77)(PROLOGUE, FUNCTION)
242  # --------------------------------------------  # --------------------------------------------
243  # FIXME: This is a guess, help!  # FIXME: This is a guess, help!
# Line 183  m4_define([AC_LANG_CALL(Fortran 77)], Line 246  m4_define([AC_LANG_CALL(Fortran 77)],
246  [      call $2])])  [      call $2])])
247    
248    
249    # AC_LANG_CALL(Fortran)(PROLOGUE, FUNCTION)
250    # --------------------------------------------
251    # FIXME: This is a guess, help!
252    m4_define([AC_LANG_CALL(Fortran)],
253    [AC_LANG_PROGRAM([$1],
254    [      call $2])])
255    
256    
257    
258  ## -------------------------------------------- ##  ## -------------------------------------------- ##
# Line 191  m4_define([AC_LANG_CALL(Fortran 77)], Line 261  m4_define([AC_LANG_CALL(Fortran 77)],
261    
262    
263  # ----------------------------- #  # ----------------------------- #
264  # 3d. The Fortran 77 compiler.  #  # 3d. The Fortran compiler.  #
265  # ----------------------------- #  # ----------------------------- #
266    
267    
# Line 202  AC_DEFUN([AC_LANG_PREPROC(Fortran 77)], Line 272  AC_DEFUN([AC_LANG_PREPROC(Fortran 77)],
272  [m4_warn([syntax],  [m4_warn([syntax],
273           [$0: No preprocessor defined for ]_AC_LANG)])           [$0: No preprocessor defined for ]_AC_LANG)])
274    
275    # AC_LANG_PREPROC(Fortran)
276    # ---------------------------
277    # Find the Fortran preprocessor.  Must be AC_DEFUN'd to be AC_REQUIRE'able.
278    AC_DEFUN([AC_LANG_PREPROC(Fortran)],
279    [m4_warn([syntax],
280             [$0: No preprocessor defined for ]_AC_LANG)])
281    
282    
283  # AC_LANG_COMPILER(Fortran 77)  # AC_LANG_COMPILER(Fortran 77)
284  # ----------------------------  # ----------------------------
# Line 210  AC_DEFUN([AC_LANG_PREPROC(Fortran 77)], Line 287  AC_DEFUN([AC_LANG_PREPROC(Fortran 77)],
287  AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],  AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],
288  [AC_REQUIRE([AC_PROG_F77])])  [AC_REQUIRE([AC_PROG_F77])])
289    
290    # AC_LANG_COMPILER(Fortran)
291    # ----------------------------
292    # Find the Fortran compiler.  Must be AC_DEFUN'd to be
293    # AC_REQUIRE'able.
294    AC_DEFUN([AC_LANG_COMPILER(Fortran)],
295    [AC_REQUIRE([AC_PROG_FC])])
296    
297    
298  # ac_cv_prog_g77  # ac_cv_prog_g77
299  # --------------  # --------------
# Line 217  AC_DEFUN([AC_LANG_COMPILER(Fortran 77)], Line 301  AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],
301  AU_DEFUN([ac_cv_prog_g77],  AU_DEFUN([ac_cv_prog_g77],
302  [ac_cv_f77_compiler_gnu])  [ac_cv_f77_compiler_gnu])
303    
304    # _AC_FC_DIALECT_YEAR([DIALECT])
305    # Given a Fortran DIALECT, which is Fortran [YY]YY or simply [YY]YY,
306    # convert to a 4-digit year.  The dialect must be one of Fortran 77,
307    # 90, 95, or 2000, currently.  If DIALECT is simply Fortran or the
308    # empty string, returns the empty string.
309    AC_DEFUN([_AC_FC_DIALECT_YEAR],
310    [m4_case(m4_bpatsubsts(m4_tolower([$1]), [fortran],[], [ *],[]),
311             [77],[1977], [1977],[1977],
312             [90],[1990], [1990],[1990],
313             [95],[1995], [1995],[1995],
314             [2000],[2000],
315             [],[],
316             [m4_fatal([unknown Fortran dialect])])])
317    
318  # AC_PROG_F77([COMPILERS...])  # _AC_PROG_FC([DIALECT], [COMPILERS...])
319  # ---------------------------  # ---------------------------
320  # COMPILERS is a space separated list of Fortran 77 compilers to search  # DIALECT is a Fortran dialect, given by Fortran [YY]YY or simply [YY]YY,
321  # for.  Fortran 95 isn't strictly backwards-compatible with Fortran 77,  # and must be one of those supported by _AC_FC_DIALECT_YEAR
 # but `f95' is worth trying.  
322  #  #
323  # Compilers are ordered by  # If DIALECT is supplied, then we search for compilers of that dialect
324  #  1. F77, F90, F95  # first, and then later dialects.  Otherwise, we search for compilers
325  #  2. Good/tested native compilers, bad/untested native compilers  # of the newest dialect first, and then earlier dialects in increasing age.
326  #  3. Wrappers around f2c go last.  # This search order is necessarily imperfect because the dialect cannot
327  #  # always be inferred from the compiler name.
328  # `fort77' is a wrapper around `f2c'.  #
329  # It is believed that under HP-UX `fort77' is the name of the native  # Known compilers:
330  # compiler.  On some Cray systems, fort77 is a native compiler.  #  f77/f90/f95: generic compiler names
331  # frt is the Fujitsu F77 compiler.  #  g77: GNU Fortran 77 compiler
332  # pgf77 and pgf90 are the Portland Group F77 and F90 compilers.  #  g95: putative GNU Fortran 95 compiler (in progress)
333  # xlf/xlf90/xlf95 are IBM (AIX) F77/F90/F95 compilers.  #  fort77: native F77 compiler under HP-UX (and some older Crays)
334  # lf95 is the Lahey-Fujitsu compiler.  #  frt: Fujitsu F77 compiler
335  # fl32 is the Microsoft Fortran "PowerStation" compiler.  #  pgf77/pgf90/pgf95: Portland Group F77/F90/F95 compilers
336  # af77 is the Apogee F77 compiler for Intergraph hardware running CLIX.  #  xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers
337  # epcf90 is the "Edinburgh Portable Compiler" F90.  #  lf95: Lahey-Fujitsu F95 compiler
338  # fort is the Compaq Fortran 90 (now 95) compiler for Tru64 and Linux/Alpha.  #  fl32: Microsoft Fortran 77 "PowerStation" compiler
339  AC_DEFUN([AC_PROG_F77],  #  af77: Apogee F77 compiler for Intergraph hardware running CLIX
340  [AC_LANG_PUSH(Fortran 77)dnl  #  epcf90: "Edinburgh Portable Compiler" F90
341  AC_ARG_VAR([F77],    [Fortran 77 compiler command])dnl  #  fort: Compaq (now HP) Fortran 90/95 compiler for Tru64 and Linux/Alpha
342  AC_ARG_VAR([FFLAGS], [Fortran 77 compiler flags])dnl  #  ifc: Intel Fortran 95 compiler for Linux/x86
343  _AC_ARG_VAR_LDFLAGS()dnl  #  efc: Intel Fortran 95 compiler for IA64
344  AC_CHECK_TOOLS(F77,  m4_define([_AC_F95_FC], [f95 fort xlf95 ifc efc pgf95 lf95 g95])
345        [m4_default([$1],  m4_define([_AC_F90_FC], [f90 xlf90 pgf90 epcf90])
346                    [g77 f77 xlf frt pgf77 fl32 af77 fort77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 lf95 g95])])  m4_define([_AC_F77_FC], [g77 f77 xlf frt pgf77 fort77 fl32 af77])
347    AC_DEFUN([_AC_PROG_FC],
348    [_AC_FORTRAN_ASSERT()dnl
349    AC_CHECK_TOOLS([]_AC_FC[],
350          m4_default([$2],
351            m4_case(_AC_FC_DIALECT_YEAR([$1]),
352                    [1995], [_AC_F95_FC],
353                    [1990], [_AC_F90_FC _AC_F95_FC],
354                    [1977], [_AC_F77_FC _AC_F90_FC _AC_F95_FC],
355                    [_AC_F95_FC _AC_F90_FC _AC_F77_FC])))
356    
357  # Provide some information about the compiler.  # Provide some information about the compiler.
358  echo "$as_me:__oline__:" \  echo "$as_me:__oline__:" \
# Line 260  _AC_EVAL([$ac_compiler -V </dev/null >&A Line 365  _AC_EVAL([$ac_compiler -V </dev/null >&A
365  m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl  m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
366  m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl  m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
367  # If we don't use `.F' as extension, the preprocessor is not run on the  # If we don't use `.F' as extension, the preprocessor is not run on the
368  # input file.  # input file.  (Note that this only needs to work for GNU compilers.)
369  ac_save_ext=$ac_ext  ac_save_ext=$ac_ext
370  ac_ext=F  ac_ext=F
371  _AC_LANG_COMPILER_GNU  _AC_LANG_COMPILER_GNU
372  ac_ext=$ac_save_ext  ac_ext=$ac_save_ext
373    _AC_PROG_FC_G]
374    )
375    
376    # AC_PROG_F77([COMPILERS...])
377    # ---------------------------
378    # COMPILERS is a space separated list of Fortran 77 compilers to search
379    # for.  See also _AC_PROG_FC.
380    AC_DEFUN([AC_PROG_F77],
381    [AC_LANG_PUSH(Fortran 77)dnl
382    AC_ARG_VAR([F77],    [Fortran 77 compiler command])dnl
383    AC_ARG_VAR([FFLAGS], [Fortran 77 compiler flags])dnl
384    _AC_ARG_VAR_LDFLAGS()dnl
385    _AC_PROG_FC([Fortran 77], [$1])
386  G77=`test $ac_compiler_gnu = yes && echo yes`  G77=`test $ac_compiler_gnu = yes && echo yes`
 _AC_PROG_F77_G  
387  AC_LANG_POP(Fortran 77)dnl  AC_LANG_POP(Fortran 77)dnl
388  ])# AC_PROG_F77  ])# AC_PROG_F77
389    
390    # AC_PROG_FC([DIALECT], [COMPILERS...])
391    # ---------------------------
392    # COMPILERS is a space separated list of Fortran 77 compilers to search
393    # for, and [DIALECT] is an optional dialect.  See also _AC_PROG_FC.
394    AC_DEFUN([AC_PROG_FC],
395    [AC_LANG_PUSH(Fortran)dnl
396    AC_ARG_VAR([FC],    [Fortran compiler command])dnl
397    AC_ARG_VAR([FCFLAGS], [Fortran compiler flags])dnl
398    _AC_ARG_VAR_LDFLAGS()dnl
399    _AC_PROG_FC([$1], [$2])
400    AC_LANG_POP(Fortran)dnl
401    ])# AC_PROG_FC
402    
403    
404  # _AC_PROG_F77_G  # _AC_PROG_FC_G
405  # --------------  # --------------
406  # Check whether -g works, even if FFLAGS is set, in case the package  # Check whether -g works, even if F[C]FLAGS is set, in case the package
407  # plays around with FFLAGS (such as to build both debugging and normal  # plays around with F[C]FLAGS (such as to build both debugging and normal
408  # versions of a library), tasteless as that idea is.  # versions of a library), tasteless as that idea is.
409  m4_define([_AC_PROG_F77_G],  m4_define([_AC_PROG_FC_G],
410  [ac_test_FFLAGS=${FFLAGS+set}  [_AC_FORTRAN_ASSERT()dnl
411  ac_save_FFLAGS=$FFLAGS  ac_test_FFLAGS=${[]_AC_LANG_PREFIX[]FLAGS+set}
412  FFLAGS=  ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS
413  AC_CACHE_CHECK(whether $F77 accepts -g, ac_cv_prog_f77_g,  _AC_LANG_PREFIX[]FLAGS=
414  [FFLAGS=-g  AC_CACHE_CHECK(whether $[]_AC_FC[] accepts -g, ac_cv_prog_[]_AC_LANG_ABBREV[]_g,
415    [_AC_LANG_PREFIX[]FLAGS=-g
416  _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],  _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
417  [ac_cv_prog_f77_g=yes],  [ac_cv_prog_[]_AC_LANG_ABBREV[]_g=yes],
418  [ac_cv_prog_f77_g=no])  [ac_cv_prog_[]_AC_LANG_ABBREV[]_g=no])
419  ])  ])
420  if test "$ac_test_FFLAGS" = set; then  if test "$ac_test_FFLAGS" = set; then
421    FFLAGS=$ac_save_FFLAGS    _AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS
422  elif test $ac_cv_prog_f77_g = yes; then  elif test $ac_cv_prog_[]_AC_LANG_ABBREV[]_g = yes; then
423    if test "$G77" = yes; then    if test "$G77" = yes; then
424      FFLAGS="-g -O2"      _AC_LANG_PREFIX[]FLAGS="-g -O2"
425    else    else
426      FFLAGS="-g"      _AC_LANG_PREFIX[]FLAGS="-g"
427    fi    fi
428  else  else
429    if test "$G77" = yes; then    if test "$G77" = yes; then
430      FFLAGS="-O2"      _AC_LANG_PREFIX[]FLAGS="-O2"
431    else    else
432      FFLAGS=      _AC_LANG_PREFIX[]FLAGS=
433    fi    fi
434  fi[]dnl  fi[]dnl
435  ])# _AC_PROG_F77_G  ])# _AC_PROG_FC_G
436    
437    
438  # AC_PROG_F77_C_O  # _AC_PROG_FC_C_O
439  # ---------------  # ---------------
440  # Test if the Fortran 77 compiler accepts the options `-c' and `-o'  # Test if the Fortran compiler accepts the options `-c' and `-o'
441  # simultaneously, and define `F77_NO_MINUS_C_MINUS_O' if it does not.  # simultaneously, and define `[F77/FC]_NO_MINUS_C_MINUS_O' if it does not.
442  #  #
443  # The usefulness of this macro is questionable, as I can't really see  # The usefulness of this macro is questionable, as I can't really see
444  # why anyone would use it.  The only reason I include it is for  # why anyone would use it.  The only reason I include it is for
445  # completeness, since a similar test exists for the C compiler.  # completeness, since a similar test exists for the C compiler.
446  AC_DEFUN([AC_PROG_F77_C_O],  #
447  [AC_REQUIRE([AC_PROG_F77])dnl  # FIXME: it seems like we could merge the C/Fortran versions of this.
448  AC_CACHE_CHECK([whether $F77 understand -c and -o together],  AC_DEFUN([_AC_PROG_FC_C_O],
449                 [ac_cv_prog_f77_c_o],  [_AC_FORTRAN_ASSERT()dnl
450    AC_CACHE_CHECK([whether $[]_AC_FC[] understands -c and -o together],
451                   [ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o],
452  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
453  # We test twice because some compilers refuse to overwrite an existing  # We test twice because some compilers refuse to overwrite an existing
454  # `.o' file with `-o', although they will create one.  # `.o' file with `-o', although they will create one.
455  ac_try='$F77 $FFLAGS -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'  ac_try='$[]_AC_FC[] $[]_AC_LANG_PREFIX[]FLAGS -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
456  if AC_TRY_EVAL(ac_try) &&  if AC_TRY_EVAL(ac_try) &&
457       test -f conftest.$ac_objext &&       test -f conftest.$ac_objext &&
458       AC_TRY_EVAL(ac_try); then       AC_TRY_EVAL(ac_try); then
459    ac_cv_prog_f77_c_o=yes    ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=yes
460  else  else
461    ac_cv_prog_f77_c_o=no    ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o=no
462  fi  fi
463  rm -f conftest*])  rm -f conftest*])
464  if test $ac_cv_prog_f77_c_o = no; then  if test $ac_cv_prog_[]_AC_LANG_ABBREV[]_c_o = no; then
465    AC_DEFINE(F77_NO_MINUS_C_MINUS_O, 1,    AC_DEFINE([]_AC_FC[]_NO_MINUS_C_MINUS_O, 1,
466              [Define to 1 if your Fortran 77 compiler doesn't accept              [Define to 1 if your Fortran compiler doesn't accept
467               -c and -o together.])               -c and -o together.])
468  fi  fi
469  ])# AC_PROG_F77_C_O  ])# _AC_PROG_FC_C_O
   
470    
471    # AC_PROG_F77_C_O
472    # ---------------
473    AC_DEFUN([AC_PROG_F77_C_O],
474    [AC_REQUIRE([AC_PROG_F77])dnl
475    AC_LANG_PUSH(Fortran 77)dnl
476    _AC_PROG_FC_C_O
477    AC_LANG_POP(Fortran 77)dnl
478    ])# AC_PROG_F77_C_O
479    
480    # AC_PROG_FC_C_O
481    # ---------------
482    AC_DEFUN([AC_PROG_FC_C_O],
483    [AC_REQUIRE([AC_PROG_FC])dnl
484    AC_LANG_PUSH(Fortran)dnl
485    _AC_PROG_FC_C_O
486    AC_LANG_POP(Fortran)dnl
487    ])# AC_PROG_FC_C_O
488    
489    
490  ## ------------------------------- ##  ## ------------------------------- ##
# Line 349  fi Line 497  fi
497  # ---------------------------------------- #  # ---------------------------------------- #
498    
499    
500  # _AC_PROG_F77_V_OUTPUT([FLAG = $ac_cv_prog_f77_v])  # _AC_PROG_FC_V_OUTPUT([FLAG = $ac_cv_prog_{f77/fc}_v])
501  # -------------------------------------------------  # -------------------------------------------------
502  # Link a trivial Fortran program, compiling with a verbose output FLAG  # Link a trivial Fortran program, compiling with a verbose output FLAG
503  # (which default value, $ac_cv_prog_f77_v, is computed by  # (whose default value, $ac_cv_prog_{f77/fc}_v, is computed by
504  # _AC_PROG_F77_V), and return the output in $ac_f77_v_output.  This  # _AC_PROG_FC_V), and return the output in $ac_{f77/fc}_v_output.  This
505  # output is processed in the way expected by AC_F77_LIBRARY_LDFLAGS,  # output is processed in the way expected by _AC_FC_LIBRARY_LDFLAGS,
506  # so that any link flags that are echoed by the compiler appear as  # so that any link flags that are echoed by the compiler appear as
507  # space-separated items.  # space-separated items.
508  AC_DEFUN([_AC_PROG_F77_V_OUTPUT],  AC_DEFUN([_AC_PROG_FC_V_OUTPUT],
509  [AC_REQUIRE([AC_PROG_F77])dnl  [_AC_FORTRAN_ASSERT()dnl
 AC_LANG_PUSH(Fortran 77)dnl  
   
510  AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])  AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
511    
512  # Compile and link our simple test program by passing a flag (argument  # Compile and link our simple test program by passing a flag (argument
513  # 1 to this macro) to the Fortran 77 compiler in order to get  # 1 to this macro) to the Fortran compiler in order to get
514  # "verbose" output that we can then parse for the Fortran 77 linker  # "verbose" output that we can then parse for the Fortran linker
515  # flags.  # flags.
516  ac_save_FFLAGS=$FFLAGS  ac_save_FFLAGS=$[]_AC_LANG_PREFIX[]FLAGS
517  FFLAGS="$FFLAGS m4_default([$1], [$ac_cv_prog_f77_v])"  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS m4_default([$1], [$ac_cv_prog_[]_AC_LANG_ABBREV[]_v])"
518  (eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD  (eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD
519  ac_f77_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`  ac_[]_AC_LANG_ABBREV[]_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`
520  echo "$ac_f77_v_output" >&AS_MESSAGE_LOG_FD  echo "$ac_[]_AC_LANG_ABBREV[]_v_output" >&AS_MESSAGE_LOG_FD
521  FFLAGS=$ac_save_FFLAGS  _AC_LANG_PREFIX[]FLAGS=$ac_save_FFLAGS
522    
523  rm -f conftest*  rm -f conftest*
 AC_LANG_POP(Fortran 77)dnl  
524    
525  # If we are using xlf then replace all the commas with spaces.  # If we are using xlf then replace all the commas with spaces.
526  if echo $ac_f77_v_output | grep xlfentry >/dev/null 2>&1; then  if echo $ac_[]_AC_LANG_ABBREV[]_v_output | grep xlfentry >/dev/null 2>&1; then
527    ac_f77_v_output=`echo $ac_f77_v_output | sed 's/,/ /g'`    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/,/ /g'`
528  fi  fi
529    
530  # On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where  # On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
531  # /foo, /bar, and /baz are search directories for the Fortran linker.  # /foo, /bar, and /baz are search directories for the Fortran linker.
532  # Here, we change these into -L/foo -L/bar -L/baz (and put it first):  # Here, we change these into -L/foo -L/bar -L/baz (and put it first):
533  ac_f77_v_output="`echo $ac_f77_v_output |  ac_[]_AC_LANG_ABBREV[]_v_output="`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
534          grep 'LPATH is:' |          grep 'LPATH is:' |
535          sed 's,.*LPATH is\(: *[[^ ]]*\).*,\1,;s,: */, -L/,g'` $ac_f77_v_output"          sed 's,.*LPATH is\(: *[[^ ]]*\).*,\1,;s,: */, -L/,g'` $ac_[]_AC_LANG_ABBREV[]_v_output"
536    
537  # If we are using Cray Fortran then delete quotes.  # If we are using Cray Fortran then delete quotes.
538  # Use "\"" instead of '"' for font-lock-mode.  # Use "\"" instead of '"' for font-lock-mode.
539  # FIXME: a more general fix for quoted arguments with spaces?  # FIXME: a more general fix for quoted arguments with spaces?
540  if echo $ac_f77_v_output | grep cft90 >/dev/null 2>&1; then  if echo $ac_[]_AC_LANG_ABBREV[]_v_output | grep cft90 >/dev/null 2>&1; then
541    ac_f77_v_output=`echo $ac_f77_v_output | sed "s/\"//g"`    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed "s/\"//g"`
542  fi[]dnl  fi[]dnl
543  ])# _AC_PROG_F77_V_OUTPUT  ])# _AC_PROG_FC_V_OUTPUT
544    
545    
546  # _AC_PROG_F77_V  # _AC_PROG_FC_V
547  # --------------  # --------------
548  #  #
549  # Determine the flag that causes the Fortran 77 compiler to print  # Determine the flag that causes the Fortran compiler to print
550  # information of library and object files (normally -v)  # information of library and object files (normally -v)
551  # Needed for AC_F77_LIBRARY_FLAGS  # Needed for _AC_FC_LIBRARY_FLAGS
552  # Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###)  # Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###)
553  AC_DEFUN([_AC_PROG_F77_V],  AC_DEFUN([_AC_PROG_FC_V],
554  [AC_CACHE_CHECK([how to get verbose linking output from $F77],  [_AC_FORTRAN_ASSERT()dnl
555                  [ac_cv_prog_f77_v],  AC_CACHE_CHECK([how to get verbose linking output from $[]_AC_FC[]],
556  [AC_LANG_ASSERT(Fortran 77)                  [ac_cv_prog_[]_AC_LANG_ABBREV[]_v],
557  AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
558  [ac_cv_prog_f77_v=  [ac_cv_prog_[]_AC_LANG_ABBREV[]_v=
559  # Try some options frequently used verbose output  # Try some options frequently used verbose output
560  for ac_verb in -v -verbose --verbose -V -\#\#\#; do  for ac_verb in -v -verbose --verbose -V -\#\#\#; do
561    _AC_PROG_F77_V_OUTPUT($ac_verb)    _AC_PROG_FC_V_OUTPUT($ac_verb)
562    # look for -l* and *.a constructs in the output    # look for -l* and *.a constructs in the output
563    for ac_arg in $ac_f77_v_output; do    for ac_arg in $ac_[]_AC_LANG_ABBREV[]_v_output; do
564       case $ac_arg in       case $ac_arg in
565          [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*)          [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*)
566            ac_cv_prog_f77_v=$ac_verb            ac_cv_prog_[]_AC_LANG_ABBREV[]_v=$ac_verb
567            break 2 ;;            break 2 ;;
568       esac       esac
569    done    done
570  done  done
571  if test -z "$ac_cv_prog_f77_v"; then  if test -z "$ac_cv_prog_[]_AC_LANG_ABBREV[]_v"; then
572     AC_MSG_WARN([cannot determine how to obtain linking information from $F77])     AC_MSG_WARN([cannot determine how to obtain linking information from $[]_AC_FC[]])
573  fi],  fi],
574                    [AC_MSG_WARN([compilation failed])])                    [AC_MSG_WARN([compilation failed])])
575  ])])# _AC_PROG_F77_V  ])])# _AC_PROG_FC_V
576    
577    
578  # AC_F77_LIBRARY_LDFLAGS  # _AC_FC_LIBRARY_LDFLAGS
579  # ----------------------  # ----------------------
580  #  #
581  # Determine the linker flags (e.g. "-L" and "-l") for the Fortran 77  # Determine the linker flags (e.g. "-L" and "-l") for the Fortran
582  # intrinsic and run-time libraries that are required to successfully  # intrinsic and run-time libraries that are required to successfully
583  # link a Fortran 77 program or shared library.  The output variable  # link a Fortran program or shared library.  The output variable
584  # FLIBS is set to these flags.  # FLIBS/FCLIBS is set to these flags.
585  #  #
586  # This macro is intended to be used in those situations when it is  # This macro is intended to be used in those situations when it is
587  # necessary to mix, e.g. C++ and Fortran 77, source code into a single  # necessary to mix, e.g. C++ and Fortran, source code into a single
588  # program or shared library.  # program or shared library.
589  #  #
590  # For example, if object files from a C++ and Fortran 77 compiler must  # For example, if object files from a C++ and Fortran compiler must
591  # be linked together, then the C++ compiler/linker must be used for  # be linked together, then the C++ compiler/linker must be used for
592  # linking (since special C++-ish things need to happen at link time  # linking (since special C++-ish things need to happen at link time
593  # like calling global constructors, instantiating templates, enabling  # like calling global constructors, instantiating templates, enabling
594  # exception support, etc.).  # exception support, etc.).
595  #  #
596  # However, the Fortran 77 intrinsic and run-time libraries must be  # However, the Fortran intrinsic and run-time libraries must be
597  # linked in as well, but the C++ compiler/linker doesn't know how to  # linked in as well, but the C++ compiler/linker doesn't know how to
598  # add these Fortran 77 libraries.  Hence, the macro  # add these Fortran libraries.  Hence, the macro
599  # "AC_F77_LIBRARY_LDFLAGS" was created to determine these Fortran 77  # "AC_F77_LIBRARY_LDFLAGS" was created to determine these Fortran
600  # libraries.  # libraries.
601  #  #
602  # This macro was packaged in its current form by Matthew D. Langston.  # This macro was packaged in its current form by Matthew D. Langston.
603  # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro  # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro
604  # in "octave-2.0.13/aclocal.m4", and full credit should go to John  # in "octave-2.0.13/aclocal.m4", and full credit should go to John
605  # W. Eaton for writing this extremely useful macro.  Thank you John.  # W. Eaton for writing this extremely useful macro.  Thank you John.
606  AC_DEFUN([AC_F77_LIBRARY_LDFLAGS],  AC_DEFUN([_AC_FC_LIBRARY_LDFLAGS],
607  [AC_LANG_PUSH(Fortran 77)dnl  [_AC_FORTRAN_ASSERT()dnl
608  _AC_PROG_F77_V  _AC_PROG_FC_V
609  AC_CACHE_CHECK([for Fortran 77 libraries], ac_cv_flibs,  AC_CACHE_CHECK([for Fortran libraries of $[]_AC_FC[]], ac_cv_[]_AC_LANG_ABBREV[]_libs,
610  [if test "x$FLIBS" != "x"; then  [if test "x$[]_AC_LANG_PREFIX[]LIBS" != "x"; then
611    ac_cv_flibs="$FLIBS" # Let the user override the test.    ac_cv_[]_AC_LANG_ABBREV[]_libs="$[]_AC_LANG_PREFIX[]LIBS" # Let the user override the test.
612  else  else
613    
614  _AC_PROG_F77_V_OUTPUT  _AC_PROG_FC_V_OUTPUT
615    
616  ac_cv_flibs=  ac_cv_[]_AC_LANG_ABBREV[]_libs=
617    
618  # Save positional arguments (if any)  # Save positional arguments (if any)
619  ac_save_positional="$[@]"  ac_save_positional="$[@]"
620    
621  set X $ac_f77_v_output  set X $ac_[]_AC_LANG_ABBREV[]_v_output
622  while test $[@%:@] != 1; do  while test $[@%:@] != 1; do
623    shift    shift
624    ac_arg=$[1]    ac_arg=$[1]
625    case $ac_arg in    case $ac_arg in
626          [[\\/]]*.a | ?:[[\\/]]*.a)          [[\\/]]*.a | ?:[[\\/]]*.a)
627            _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_flibs, ,            _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
628                ac_cv_flibs="$ac_cv_flibs $ac_arg")                ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
629            ;;            ;;
630          -bI:*)          -bI:*)
631            _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_flibs, ,            _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
632               [_AC_LINKER_OPTION([$ac_arg], ac_cv_flibs)])               [_AC_LINKER_OPTION([$ac_arg], ac_cv_[]_AC_LANG_ABBREV[]_libs)])
633            ;;            ;;
634            # Ignore these flags.            # Ignore these flags.
635          -lang* | -lcrt[01].o | -lc | -lgcc | -libmil | -LANG:=*)          -lang* | -lcrt[01].o | -lc | -lgcc | -libmil | -LANG:=*)
636            ;;            ;;
637          -lkernel32)          -lkernel32)
638            test x"$CYGWIN" != xyes && ac_cv_flibs="$ac_cv_flibs $ac_arg"            test x"$CYGWIN" != xyes && ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg"
639            ;;            ;;
640          -[[LRuY]])          -[[LRuY]])
641            # These flags, when seen by themselves, take an argument.            # These flags, when seen by themselves, take an argument.
642            # We remove the space between option and argument and re-iterate            # We remove the space between option and argument and re-iterate
643            # unless we find an empty arg or a new option (starting with -)            # unless we find an empty arg or a new option (starting with -)
644            case $[2] in            case $[2] in
645               "" | -*);;               "" | -*);;
646               *)               *)
# Line 504  while test $[@%:@] != 1; do Line 649  while test $[@%:@] != 1; do
649                  set X $ac_arg "$[@]"                  set X $ac_arg "$[@]"
650                  ;;                  ;;
651            esac            esac
652            ;;            ;;
653          -YP,*)          -YP,*)
654            for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do            for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
655              _AC_LIST_MEMBER_IF($ac_j, $ac_cv_flibs, ,              _AC_LIST_MEMBER_IF($ac_j, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
656                                 [ac_arg="$ac_arg $ac_j"                                 [ac_arg="$ac_arg $ac_j"
657                                 ac_cv_flibs="$ac_cv_flibs $ac_j"])                                 ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_j"])
658            done            done
659            ;;            ;;
660          -[[lLR]]*)          -[[lLR]]*)
661            _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_flibs, ,            _AC_LIST_MEMBER_IF($ac_arg, $ac_cv_[]_AC_LANG_ABBREV[]_libs, ,
662                               ac_cv_flibs="$ac_cv_flibs $ac_arg")                               ac_cv_[]_AC_LANG_ABBREV[]_libs="$ac_cv_[]_AC_LANG_ABBREV[]_libs $ac_arg")
663            ;;            ;;
664            # Ignore everything else.            # Ignore everything else.
665    esac    esac
666  done  done
667  # restore positional arguments  # restore positional arguments
# Line 527  set X $ac_save_positional; shift Line 672  set X $ac_save_positional; shift
672  # must begin with a "/").  # must begin with a "/").
673  case `(uname -sr) 2>/dev/null` in  case `(uname -sr) 2>/dev/null` in
674     "SunOS 5"*)     "SunOS 5"*)
675        ac_ld_run_path=`echo $ac_f77_v_output |        ac_ld_run_path=`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
676                          sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`                          sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`
677        test "x$ac_ld_run_path" != x &&        test "x$ac_ld_run_path" != x &&
678          _AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_flibs)          _AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_[]_AC_LANG_ABBREV[]_libs)
679        ;;        ;;
680  esac  esac
681  fi # test "x$FLIBS" = "x"  fi # test "x$[]_AC_LANG_PREFIX[]LIBS" = "x"
682  ])  ])
683  FLIBS="$ac_cv_flibs"  []_AC_LANG_PREFIX[]LIBS="$ac_cv_[]_AC_LANG_ABBREV[]_libs"
684  AC_SUBST(FLIBS)  AC_SUBST([]_AC_LANG_PREFIX[]LIBS)
685    ])# _AC_FC_LIBRARY_LDFLAGS
686    
687    # AC_F77_LIBRARY_LDFLAGS
688    # ----------------------
689    AC_DEFUN([AC_F77_LIBRARY_LDFLAGS],
690    [AC_REQUIRE([AC_PROG_F77])dnl
691    AC_LANG_PUSH(Fortran 77)dnl
692    _AC_FC_LIBRARY_LDFLAGS
693  AC_LANG_POP(Fortran 77)dnl  AC_LANG_POP(Fortran 77)dnl
694  ])# AC_F77_LIBRARY_LDFLAGS  ])# AC_F77_LIBRARY_LDFLAGS
695    
696    # AC_FC_LIBRARY_LDFLAGS
697    # ----------------------
698    AC_DEFUN([AC_FC_LIBRARY_LDFLAGS],
699    [AC_REQUIRE([AC_PROG_FC])dnl
700    AC_LANG_PUSH(Fortran)dnl
701    _AC_FC_LIBRARY_LDFLAGS
702    AC_LANG_POP(Fortran)dnl
703    ])# AC_FC_LIBRARY_LDFLAGS
704    
705    
706  # AC_F77_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])  # _AC_FC_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
707  # -----------------------------------------------------------  # -----------------------------------------------------------
708  #  #
709  # Detect name of dummy main routine required by the Fortran libraries,  # Detect name of dummy main routine required by the Fortran libraries,
710  # (if any) and define F77_DUMMY_MAIN to this name (which should be  # (if any) and define {F77,FC}_DUMMY_MAIN to this name (which should be
711  # used for a dummy declaration, if it is defined).  On some systems,  # used for a dummy declaration, if it is defined).  On some systems,
712  # linking a C program to the Fortran library does not work unless you  # linking a C program to the Fortran library does not work unless you
713  # supply a dummy function called something like MAIN__.  # supply a dummy function called something like MAIN__.
714  #  #
715  # Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C  # Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C
716  # program with the F77 libs is found; default to exiting with an error  # program with the {F77,FC} libs is found; default to exiting with an error
717  # message.  Execute ACTION-IF-FOUND if a dummy routine name is needed  # message.  Execute ACTION-IF-FOUND if a dummy routine name is needed
718  # and found or if it is not needed (default to defining F77_DUMMY_MAIN  # and found or if it is not needed (default to defining {F77,FC}_DUMMY_MAIN
719  # when needed).  # when needed).
720  #  #
721  # What is technically happening is that the Fortran libraries provide  # What is technically happening is that the Fortran libraries provide
# Line 565  AC_LANG_POP(Fortran 77)dnl Line 727  AC_LANG_POP(Fortran 77)dnl
727  #  #
728  # Of course, programs that want to allow Fortran subroutines to do  # Of course, programs that want to allow Fortran subroutines to do
729  # I/O, etcetera, should call their main routine MAIN__() (or whatever)  # I/O, etcetera, should call their main routine MAIN__() (or whatever)
730  # instead of main().  A separate autoconf test (AC_F77_MAIN) checks  # instead of main().  A separate autoconf test (_AC_FC_MAIN) checks
731  # for the routine to use in this case (since the semantics of the test  # for the routine to use in this case (since the semantics of the test
732  # are slightly different).  To link to e.g. purely numerical  # are slightly different).  To link to e.g. purely numerical
733  # libraries, this is normally not necessary, however, and most C/C++  # libraries, this is normally not necessary, however, and most C/C++
# Line 575  AC_LANG_POP(Fortran 77)dnl Line 737  AC_LANG_POP(Fortran 77)dnl
737  #   MAIN__ (g77, MAIN__ required on some systems; IRIX, MAIN__ optional)  #   MAIN__ (g77, MAIN__ required on some systems; IRIX, MAIN__ optional)
738  #   MAIN_, __main (SunOS)  #   MAIN_, __main (SunOS)
739  #   MAIN _MAIN __MAIN main_ main__ _main (we follow DDD and try these too)  #   MAIN _MAIN __MAIN main_ main__ _main (we follow DDD and try these too)
740  AC_DEFUN([AC_F77_DUMMY_MAIN],  AC_DEFUN([_AC_FC_DUMMY_MAIN],
741  [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl  [_AC_FORTRAN_ASSERT()dnl
742  m4_define([_AC_LANG_PROGRAM_C_F77_HOOKS],  m4_define(_AC_LANG_PROGRAM_C_[]_AC_FC[]_HOOKS,
743  [#ifdef F77_DUMMY_MAIN  [#ifdef ]_AC_FC[_DUMMY_MAIN
744  #  ifdef __cplusplus  ]AC_LANG_CASE([Fortran], [#ifndef FC_DUMMY_MAIN_EQ_F77])
745    [#  ifdef __cplusplus
746       extern "C"       extern "C"
747  #  endif  #  endif
748     int F77_DUMMY_MAIN() { return 1; }     int ]_AC_FC[_DUMMY_MAIN() { return 1; }
749  #endif  ]AC_LANG_CASE([Fortran], [#endif])
750    [#endif
751  ])  ])
752  AC_CACHE_CHECK([for dummy main to link with Fortran 77 libraries],  AC_CACHE_CHECK([for dummy main to link with Fortran libraries],
753                 ac_cv_f77_dummy_main,                 ac_cv_[]_AC_LANG_ABBREV[]_dummy_main,
754  [AC_LANG_PUSH(C)dnl  [ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS=$LIBS
755   ac_f77_dm_save_LIBS=$LIBS   LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS"
756   LIBS="$LIBS $FLIBS"   ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN
757     AC_LANG_PUSH(C)dnl
758    
759   # First, try linking without a dummy main:   # First, try linking without a dummy main:
760   AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],   AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
761                  [ac_cv_f77_dummy_main=none],                  [ac_cv_fortran_dummy_main=none],
762                  [ac_cv_f77_dummy_main=unknown])                  [ac_cv_fortran_dummy_main=unknown])
763    
764   if test $ac_cv_f77_dummy_main = unknown; then   if test $ac_cv_fortran_dummy_main = unknown; then
765     for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do     for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
766       AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@define F77_DUMMY_MAIN $ac_func]])],       AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@define $ac_fortran_dm_var $ac_func]])],
767                      [ac_cv_f77_dummy_main=$ac_func; break])                      [ac_cv_fortran_dummy_main=$ac_func; break])
768     done     done
769   fi   fi
  rm -f conftest*  
  LIBS=$ac_f77_dm_save_LIBS  
770   AC_LANG_POP(C)dnl   AC_LANG_POP(C)dnl
771     ac_cv_[]_AC_LANG_ABBREV[]_dummy_main=$ac_cv_fortran_dummy_main
772     rm -f conftest*
773     LIBS=$ac_[]_AC_LANG_ABBREV[]_dm_save_LIBS
774  ])  ])
775  F77_DUMMY_MAIN=$ac_cv_f77_dummy_main  []_AC_FC[]_DUMMY_MAIN=$ac_cv_[]_AC_LANG_ABBREV[]_dummy_main
776  AS_IF([test "$F77_DUMMY_MAIN" != unknown],  AS_IF([test "$[]_AC_FC[]_DUMMY_MAIN" != unknown],
777        [m4_default([$1],        [m4_default([$1],
778  [if test $F77_DUMMY_MAIN != none; then  [if test $[]_AC_FC[]_DUMMY_MAIN != none; then
779    AC_DEFINE_UNQUOTED([F77_DUMMY_MAIN], $F77_DUMMY_MAIN,    AC_DEFINE_UNQUOTED([]_AC_FC[]_DUMMY_MAIN, $[]_AC_FC[]_DUMMY_MAIN,
780                       [Define to dummy `main' function (if any) required to                       [Define to dummy `main' function (if any) required to
781                        link to the Fortran 77 libraries.])                        link to the Fortran libraries.])
782      if test "x$ac_cv_fc_dummy_main" = "x$ac_cv_f77_dummy_main"; then
783            AC_DEFINE([FC_DUMMY_MAIN_EQ_F77], 1,
784                      [Define if F77 and FC dummy `main' functions are identical.])
785      fi
786  fi])],  fi])],
787        [m4_default([$2],        [m4_default([$2],
788              [AC_MSG_FAILURE([linking to Fortran libraries from C fails])])])              [AC_MSG_FAILURE([linking to Fortran libraries from C fails])])])
789    ])# _AC_FC_DUMMY_MAIN
790    
791    # AC_F77_DUMMY_MAIN
792    # ----------------------
793    AC_DEFUN([AC_F77_DUMMY_MAIN],
794    [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
795    AC_LANG_PUSH(Fortran 77)dnl
796    _AC_FC_DUMMY_MAIN
797    AC_LANG_POP(Fortran 77)dnl
798  ])# AC_F77_DUMMY_MAIN  ])# AC_F77_DUMMY_MAIN
799    
800    # AC_FC_DUMMY_MAIN
801    # ----------------------
802    AC_DEFUN([AC_FC_DUMMY_MAIN],
803    [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
804    AC_LANG_PUSH(Fortran)dnl
805    _AC_FC_DUMMY_MAIN
806    AC_LANG_POP(Fortran)dnl
807    ])# AC_FC_DUMMY_MAIN
808    
809  # AC_F77_MAIN  
810    # _AC_FC_MAIN
811  # -----------  # -----------
812  # Define F77_MAIN to name of alternate main() function for use with  # Define {F77,FC}_MAIN to name of alternate main() function for use with
813  # the Fortran libraries.  (Typically, the libraries may define their  # the Fortran libraries.  (Typically, the libraries may define their
814  # own main() to initialize I/O, etcetera, that then call your own  # own main() to initialize I/O, etcetera, that then call your own
815  # routine called MAIN__ or whatever.)  See AC_F77_DUMMY_MAIN, above.  # routine called MAIN__ or whatever.)  See _AC_FC_DUMMY_MAIN, above.
816  # If no such alternate name is found, just define F77_MAIN to main.  # If no such alternate name is found, just define {F77,FC}_MAIN to main.
817  #  #
818  AC_DEFUN([AC_F77_MAIN],  AC_DEFUN([_AC_FC_MAIN],
819  [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl  [_AC_FORTRAN_ASSERT()dnl
820  AC_CACHE_CHECK([for alternate main to link with Fortran 77 libraries],  AC_CACHE_CHECK([for alternate main to link with Fortran libraries],
821                 ac_cv_f77_main,                 ac_cv_[]_AC_LANG_ABBREV[]_main,
822  [AC_LANG_PUSH(C)dnl  [ac_[]_AC_LANG_ABBREV[]_m_save_LIBS=$LIBS
823   ac_f77_m_save_LIBS=$LIBS   LIBS="$LIBS $[]_AC_LANG_PREFIX[]LIBS"
824   LIBS="$LIBS $FLIBS"   ac_fortran_dm_var=[]_AC_FC[]_DUMMY_MAIN
825   ac_cv_f77_main="main" # default entry point name   AC_LANG_PUSH(C)dnl
826     ac_cv_fortran_main="main" # default entry point name
827   for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do   for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
828     AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@undef F77_DUMMY_MAIN     AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@ifdef FC_DUMMY_MAIN_EQ_F77
829    @%:@  undef F77_DUMMY_MAIN
830    @%:@  undef FC_DUMMY_MAIN
831    @%:@else
832    @%:@  undef $ac_fortran_dm_var
833    @%:@endif
834  @%:@define main $ac_func])],  @%:@define main $ac_func])],
835                    [ac_cv_f77_main=$ac_func; break])                    [ac_cv_fortran_main=$ac_func; break])
836   done   done
  rm -f conftest*  
  LIBS=$ac_f77_m_save_LIBS  
837   AC_LANG_POP(C)dnl   AC_LANG_POP(C)dnl
838     ac_cv_[]_AC_LANG_ABBREV[]_main=$ac_cv_fortran_main
839     rm -f conftest*
840     LIBS=$ac_[]_AC_LANG_ABBREV[]_m_save_LIBS
841  ])  ])
842  AC_DEFINE_UNQUOTED([F77_MAIN], $ac_cv_f77_main,  AC_DEFINE_UNQUOTED([]_AC_FC[]_MAIN, $ac_cv_[]_AC_LANG_ABBREV[]_main,
843                     [Define to alternate name for `main' routine that is                     [Define to alternate name for `main' routine that is
844                      called from a `main' in the Fortran libraries.])                      called from a `main' in the Fortran libraries.])
845    ])# _AC_FC_MAIN
846    
847    # AC_F77_MAIN
848    # ----------------------
849    AC_DEFUN([AC_F77_MAIN],
850    [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
851    AC_LANG_PUSH(Fortran 77)dnl
852    _AC_FC_MAIN
853    AC_LANG_POP(Fortran 77)dnl
854  ])# AC_F77_MAIN  ])# AC_F77_MAIN
855    
856    # AC_FC_MAIN
857    # ----------------------
858    AC_DEFUN([AC_FC_MAIN],
859    [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
860    AC_LANG_PUSH(Fortran)dnl
861    _AC_FC_MAIN
862    AC_LANG_POP(Fortran)dnl
863    ])# AC_FC_MAIN
864    
865    
866  # _AC_F77_NAME_MANGLING  # __AC_FC_NAME_MANGLING
867  # ---------------------  # ---------------------
868  # Test for the name mangling scheme used by the Fortran 77 compiler.  # Test for the name mangling scheme used by the Fortran compiler.
869  #  #
870  # Sets ac_cv_f77_mangling. The value contains three fields, separated  # Sets ac_cv_{f77,fc}_mangling. The value contains three fields, separated
871  # by commas:  # by commas:
872  #  #
873  # lower case / upper case:  # lower case / upper case:
874  #    case translation of the Fortran 77 symbols  #    case translation of the Fortran symbols
875  # underscore / no underscore:  # underscore / no underscore:
876  #    whether the compiler appends "_" to symbol names  #    whether the compiler appends "_" to symbol names
877  # extra underscore / no extra underscore:  # extra underscore / no extra underscore:
878  #    whether the compiler appends an extra "_" to symbol names already  #    whether the compiler appends an extra "_" to symbol names already
879  #    containing at least one underscore  #    containing at least one underscore
880  #  #
881  AC_DEFUN([_AC_F77_NAME_MANGLING],  AC_DEFUN([__AC_FC_NAME_MANGLING],
882  [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl  [_AC_FORTRAN_ASSERT()dnl
883  AC_REQUIRE([AC_F77_DUMMY_MAIN])dnl  AC_CACHE_CHECK([for Fortran name-mangling scheme],
884  AC_CACHE_CHECK([for Fortran 77 name-mangling scheme],                 ac_cv_[]_AC_LANG_ABBREV[]_mangling,
885                 ac_cv_f77_mangling,  [AC_COMPILE_IFELSE(
 [AC_LANG_PUSH(Fortran 77)dnl  
 AC_COMPILE_IFELSE(  
886  [      subroutine foobar()  [      subroutine foobar()
887        return        return
888        end        end
889        subroutine foo_bar()        subroutine foo_bar()
890        return        return
891        end],        end],
892  [mv conftest.$ac_objext cf77_test.$ac_objext  [mv conftest.$ac_objext cfortran_test.$ac_objext
   
   AC_LANG_PUSH(C)dnl  
893    
894    ac_save_LIBS=$LIBS    ac_save_LIBS=$LIBS
895    LIBS="cf77_test.$ac_objext $LIBS $FLIBS"    LIBS="cfortran_test.$ac_objext $LIBS $[]_AC_LANG_PREFIX[]LIBS"
896    
897      AC_LANG_PUSH(C)dnl
898    ac_success=no    ac_success=no
899    for ac_foobar in foobar FOOBAR; do    for ac_foobar in foobar FOOBAR; do
900      for ac_underscore in "" "_"; do      for ac_underscore in "" "_"; do
# Line 694  AC_COMPILE_IFELSE( Line 903  AC_COMPILE_IFELSE(
903                       [ac_success=yes; break 2])                       [ac_success=yes; break 2])
904      done      done
905    done    done
906      AC_LANG_POP(C)dnl
907    
908    if test "$ac_success" = "yes"; then    if test "$ac_success" = "yes"; then
909       case $ac_foobar in       case $ac_foobar in
# Line 707  AC_COMPILE_IFELSE( Line 917  AC_COMPILE_IFELSE(
917             ;;             ;;
918       esac       esac
919    
920         AC_LANG_PUSH(C)dnl
921       ac_success_extra=no       ac_success_extra=no
922       for ac_extra in "" "_"; do       for ac_extra in "" "_"; do
923          ac_func="$ac_foo_bar$ac_underscore$ac_extra"          ac_func="$ac_foo_bar$ac_underscore$ac_extra"
924          AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],          AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
925                         [ac_success_extra=yes; break])                         [ac_success_extra=yes; break])
926       done       done
927         AC_LANG_POP(C)dnl
928    
929       if test "$ac_success_extra" = "yes"; then       if test "$ac_success_extra" = "yes"; then
930          ac_cv_f77_mangling="$ac_case case"          ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_case case"
931          if test -z "$ac_underscore"; then          if test -z "$ac_underscore"; then
932             ac_cv_f77_mangling="$ac_cv_f77_mangling, no underscore"             ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no underscore"
933          else          else
934             ac_cv_f77_mangling="$ac_cv_f77_mangling, underscore"             ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, underscore"
935          fi          fi
936          if test -z "$ac_extra"; then          if test -z "$ac_extra"; then
937             ac_cv_f77_mangling="$ac_cv_f77_mangling, no extra underscore"             ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, no extra underscore"
938          else          else
939             ac_cv_f77_mangling="$ac_cv_f77_mangling, extra underscore"             ac_cv_[]_AC_LANG_ABBREV[]_mangling="$ac_cv_[]_AC_LANG_ABBREV[]_mangling, extra underscore"
940          fi          fi
941        else        else
942          ac_cv_f77_mangling="unknown"          ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
943        fi        fi
944    else    else
945       ac_cv_f77_mangling="unknown"       ac_cv_[]_AC_LANG_ABBREV[]_mangling="unknown"
946    fi    fi
947    
948    LIBS=$ac_save_LIBS    LIBS=$ac_save_LIBS
949    AC_LANG_POP(C)dnl    rm -f cfortran_test* conftest*],
   rm -f cf77_test* conftest*],  
950    [AC_MSG_FAILURE([cannot compile a simple Fortran program])])    [AC_MSG_FAILURE([cannot compile a simple Fortran program])])
 AC_LANG_POP(Fortran 77)dnl  
951  ])  ])
952  ])# _AC_F77_NAME_MANGLING  ])# __AC_FC_NAME_MANGLING
953    
954  # The replacement is empty.  # The replacement is empty.
955  AU_DEFUN([AC_F77_NAME_MANGLING], [])  AU_DEFUN([AC_F77_NAME_MANGLING], [])
956    
957    # _AC_F77_NAME_MANGLING
958    # ----------------------
959    AC_DEFUN([_AC_F77_NAME_MANGLING],
960    [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
961    AC_REQUIRE([AC_F77_DUMMY_MAIN])dnl
962    AC_LANG_PUSH(Fortran 77)dnl
963    __AC_FC_NAME_MANGLING
964    AC_LANG_POP(Fortran 77)dnl
965    ])# _AC_F77_NAME_MANGLING
966    
967  # AC_F77_WRAPPERS  # _AC_FC_NAME_MANGLING
968    # ----------------------
969    AC_DEFUN([_AC_FC_NAME_MANGLING],
970    [AC_REQUIRE([AC_FC_LIBRARY_LDFLAGS])dnl
971    AC_REQUIRE([AC_FC_DUMMY_MAIN])dnl
972    AC_LANG_PUSH(Fortran)dnl
973    __AC_FC_NAME_MANGLING
974    AC_LANG_POP(Fortran)dnl
975    ])# _AC_FC_NAME_MANGLING
976    
977    
978    # _AC_FC_WRAPPERS
979  # ---------------  # ---------------
980  # Defines C macros F77_FUNC(name,NAME) and F77_FUNC_(name,NAME) to  # Defines C macros {F77,FC}_FUNC(name,NAME) and {F77,FC}_FUNC_(name,NAME) to
981  # properly mangle the names of C identifiers, and C identifiers with  # properly mangle the names of C identifiers, and C identifiers with
982  # underscores, respectively, so that they match the name mangling  # underscores, respectively, so that they match the name mangling
983  # scheme used by the Fortran 77 compiler.  # scheme used by the Fortran compiler.
984  AC_DEFUN([AC_F77_WRAPPERS],  AC_DEFUN([_AC_FC_WRAPPERS],
985  [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl  [_AC_FORTRAN_ASSERT()dnl
986  AH_TEMPLATE([F77_FUNC],  AH_TEMPLATE(_AC_FC[_FUNC],
987      [Define to a macro mangling the given C identifier (in lower and upper      [Define to a macro mangling the given C identifier (in lower and upper
988       case), which must not contain underscores, for linking with Fortran.])dnl       case), which must not contain underscores, for linking with Fortran.])dnl
989  AH_TEMPLATE([F77_FUNC_],  AH_TEMPLATE(_AC_FC[_FUNC_],
990      [As F77_FUNC, but for C identifiers containing underscores.])dnl      [As ]_AC_FC[_FUNC, but for C identifiers containing underscores.])dnl
991  case $ac_cv_f77_mangling in  case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
992    "lower case, no underscore, no extra underscore")    "lower case, no underscore, no extra underscore")
993            AC_DEFINE([F77_FUNC(name,NAME)],  [name])            AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name])
994            AC_DEFINE([F77_FUNC_(name,NAME)], [name]) ;;            AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name]) ;;
995    "lower case, no underscore, extra underscore")    "lower case, no underscore, extra underscore")
996            AC_DEFINE([F77_FUNC(name,NAME)],  [name])            AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name])
997            AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;            AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
998    "lower case, underscore, no extra underscore")    "lower case, underscore, no extra underscore")
999            AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])            AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name ## _])
1000            AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;            AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## _]) ;;
1001    "lower case, underscore, extra underscore")    "lower case, underscore, extra underscore")
1002            AC_DEFINE([F77_FUNC(name,NAME)],  [name ## _])            AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [name ## _])
1003            AC_DEFINE([F77_FUNC_(name,NAME)], [name ## __]) ;;            AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [name ## __]) ;;
1004    "upper case, no underscore, no extra underscore")    "upper case, no underscore, no extra underscore")
1005            AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])            AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME])
1006            AC_DEFINE([F77_FUNC_(name,NAME)], [NAME]) ;;            AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME]) ;;
1007    "upper case, no underscore, extra underscore")    "upper case, no underscore, extra underscore")
1008            AC_DEFINE([F77_FUNC(name,NAME)],  [NAME])            AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME])
1009            AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;            AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
1010    "upper case, underscore, no extra underscore")    "upper case, underscore, no extra underscore")
1011            AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])            AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME ## _])
1012            AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;            AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## _]) ;;
1013    "upper case, underscore, extra underscore")    "upper case, underscore, extra underscore")
1014            AC_DEFINE([F77_FUNC(name,NAME)],  [NAME ## _])            AC_DEFINE(_AC_FC[_FUNC(name,NAME)],  [NAME ## _])
1015            AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## __]) ;;            AC_DEFINE(_AC_FC[_FUNC_(name,NAME)], [NAME ## __]) ;;
1016    *)    *)
1017            AC_MSG_WARN([unknown Fortran 77 name-mangling scheme])            AC_MSG_WARN([unknown Fortran name-mangling scheme])
1018            ;;            ;;
1019  esac  esac
1020    ])# _AC_FC_WRAPPERS
1021    
1022    # AC_F77_WRAPPERS
1023    # ----------------------
1024    AC_DEFUN([AC_F77_WRAPPERS],
1025    [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
1026    AC_LANG_PUSH(Fortran 77)dnl
1027    _AC_FC_WRAPPERS
1028    AC_LANG_POP(Fortran 77)dnl
1029  ])# AC_F77_WRAPPERS  ])# AC_F77_WRAPPERS
1030    
1031    # AC_FC_WRAPPERS
1032    # ----------------------
1033    AC_DEFUN([AC_FC_WRAPPERS],
1034    [AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl
1035    AC_LANG_PUSH(Fortran)dnl
1036    _AC_FC_WRAPPERS
1037    AC_LANG_POP(Fortran)dnl
1038    ])# AC_FC_WRAPPERS
1039    
1040  # AC_F77_FUNC(NAME, [SHELLVAR = NAME])  
1041    # _AC_FC_FUNC(NAME, [SHELLVAR = NAME])
1042  # ------------------------------------  # ------------------------------------
1043  # For a Fortran subroutine of given NAME, define a shell variable  # For a Fortran subroutine of given NAME, define a shell variable
1044  # $SHELLVAR to the Fortran-77 mangled name.  If the SHELLVAR  # $SHELLVAR to the Fortran-mangled name.  If the SHELLVAR
1045  # argument is not supplied, it defaults to NAME.  # argument is not supplied, it defaults to NAME.
1046  AC_DEFUN([AC_F77_FUNC],  AC_DEFUN([_AC_FC_FUNC],
1047  [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl  [_AC_FORTRAN_ASSERT()dnl
1048  case $ac_cv_f77_mangling in  case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in
1049    upper*) ac_val="m4_toupper([$1])" ;;    upper*) ac_val="m4_toupper([$1])" ;;
1050    lower*) ac_val="m4_tolower([$1])" ;;    lower*) ac_val="m4_tolower([$1])" ;;
1051    *)      ac_val="unknown" ;;    *)      ac_val="unknown" ;;
1052  esac  esac
1053  case $ac_cv_f77_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac  case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac
1054  m4_if(m4_index([$1],[_]),-1,[],  m4_if(m4_index([$1],[_]),-1,[],
1055  [case $ac_cv_f77_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac  [case $ac_cv_[]_AC_LANG_ABBREV[]_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac
1056  ])  ])
1057  m4_default([$2],[$1])="$ac_val"  m4_default([$2],[$1])="$ac_val"
1058    ])# _AC_FC_FUNC
1059    
1060    # AC_F77_FUNC(NAME, [SHELLVAR = NAME])
1061    # ----------------------
1062    AC_DEFUN([AC_F77_FUNC],
1063    [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
1064    AC_LANG_PUSH(Fortran 77)dnl
1065    _AC_FC_FUNC([$1],[$2])
1066    AC_LANG_POP(Fortran 77)dnl
1067  ])# AC_F77_FUNC  ])# AC_F77_FUNC
1068    
1069    # AC_FC_FUNC(NAME, [SHELLVAR = NAME])
1070    # ----------------------
1071    AC_DEFUN([AC_FC_FUNC],
1072    [AC_REQUIRE([_AC_FC_NAME_MANGLING])dnl
1073    AC_LANG_PUSH(Fortran)dnl
1074    _AC_FC_FUNC([$1],[$2])
1075    AC_LANG_POP(Fortran)dnl
1076    ])# AC_FC_FUNC
1077    
1078    # AC_FC_SRCEXT(EXT, [ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
1079    # ----------------------
1080    # Set the source-code extension used in Fortran (FC) tests to EXT (which
1081    # defaults to f).  Also, look for any necessary additional FCFLAGS needed
1082    # to allow this extension, and store them in the output variable
1083    # FCFLAGS_<EXT> (e.g. FCFLAGS_f90 for EXT=f90).  If successful,
1084    # call ACTION-IF-SUCCESS.  If unable to compile source code with EXT,
1085    # call ACTION-IF-FAILURE, which defaults to failing with an error
1086    # message.
1087    #
1088    # (The flags for the current source-code extension, if any, are stored
1089    # in the FCFLAGS_SRCEXT variable and are automatically used in subsequent
1090    # autoconf tests.)
1091    #
1092    # For ordinary extensions like f90, etcetera, the modified FCFLAGS
1093    # are currently needed for IBM's xlf* and Intel's ifc (grrr).  Unfortunately,
1094    * xlf* will only take flags to recognize one extension at a time, so if the
1095    # user wants to compile multiple extensions (.f90 and .f95, say), she
1096    # will need to use the FCFLAGS_F90 and FCFLAGS_F95 individually rather
1097    # than just adding them all to FCFLAGS, for example.
1098    #
1099    # Also, for Intel's ifc compiler (which does not accept .f95 by default in
1100    # some versions), the $FCFLAGS_<EXT> variable *must* go immediately before
1101    # the source file on the command line, unlike other $FCFLAGS.  Ugh.
1102    AC_DEFUN([AC_FC_SRCEXT],
1103    [AC_CACHE_CHECK([for Fortran flag to compile .$1 files],
1104                    ac_cv_fc_srcext_$1,
1105    [AC_LANG_PUSH(Fortran)dnl
1106    ac_ext=$1
1107    ac_fc_srcext_FCFLAGS_SRCEXT_save=$FCFLAGS_SRCEXT
1108    FCFLAGS_SRCEXT=""
1109    ac_cv_fc_srcext_$1=unknown
1110    for ac_flag in none -qsuffix=f=$1 -Tf; do
1111      test "x$ac_flag" != xnone && FCFLAGS_SRCEXT="$ac_flag"
1112      AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_fc_srcext_$1=$ac_flag; break])
1113    done
1114    FCFLAGS_SRCEXT=$ac_fc_srcext_FCFLAGS_SRCEXT_save
1115    AC_LANG_POP(Fortran)dnl
1116    ])
1117    if test "x$ac_cv_fc_srcext_$1" = xunknown; then
1118      m4_default([$3],[AC_MSG_ERROR([Fortran could not compile .$1 files])])
1119    else
1120      FC_SRCEXT=$1
1121      if test "x$ac_cv_fc_srcext_$1" = xnone; then
1122        FCFLAGS_SRCEXT=""
1123        FCFLAGS_[]$1[]=""
1124      else
1125        FCFLAGS_SRCEXT=$ac_cv_fc_srcext_$1
1126        FCFLAGS_[]$1[]=$ac_cv_fc_srcext_$1
1127      fi
1128      AC_SUBST(FCFLAGS_[]$1)
1129      $2
1130    fi
1131    ])# AC_FC_SRCEXT
1132    
1133    # AC_FC_FREEFORM([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE])
1134    # ----------------------
1135    # Look for a compiler flag to make the Fortran (FC) compiler accept
1136    # free-format source code, and adds it to FCFLAGS.  Call
1137    # ACTION-IF-SUCCESS (defaults to nothing) if successful (i.e. can
1138    # compile code using new extension) and ACTION-IF-FAILURE (defaults to
1139    # failing with an error message) if not.  (Defined via DEFUN_ONCE to
1140    # prevent flag from being added to FCFLAGS multiple times.)
1141    AC_DEFUN_ONCE([AC_FC_FREEFORM],
1142    [AC_CACHE_CHECK([for Fortran flag needed to allow free-form source],
1143                    ac_cv_fc_freeform,
1144    [AC_LANG_PUSH(Fortran)dnl
1145    ac_cv_fc_freeform=unknown
1146    ac_fc_freeform_FCFLAGS_save=$FCFLAGS
1147    for ac_flag in none -free -freeform -qfree -Mfree -Mfreeform -FR; do
1148      test "x$ac_flag" != xnone && FCFLAGS="$ac_fc_freeform_FCFLAGS_save $ac_flag"
1149      AC_COMPILE_IFELSE([
1150      program freeform
1151           ! FIXME: how to best confuse non-freeform compilers?
1152           print *, 'Hello ', &
1153               'world.'
1154           end
1155    ], [ac_cv_fc_freeform=$ac_flag; break])
1156    done
1157    FCFLAGS=$ac_fc_freeform_FCFLAGS_save
1158    AC_LANG_POP(Fortran)dnl
1159    ])
1160    if test "x$ac_cv_fc_freeform" = xunknown; then
1161      m4_default([$2],[AC_MSG_ERROR([Fortran does not accept free-form source])])
1162    else
1163      if test "x$ac_cv_fc_freeform" != xnone; then
1164        FCFLAGS="$FCFLAGS $ac_cv_fc_freeform"
1165      fi
1166      $1
1167    fi
1168    ])# AC_FC_FREEFORM

Legend:
Removed from v.1.166  
changed lines
  Added in v.1.167

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26