1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Programming languages support.
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.
55 # 1. Language selection
56 # and routines to produce programs in a given language.
62 # 2. Producing programs in a given language.
68 # 3. Looking for a compiler
69 # And possibly the associated preprocessor.
70 # a. Generic routines.
75 # 4. Compilers' characteristics.
76 # a. Generic routines.
83 ## ----------------------- ##
84 ## 1. Language selection. ##
85 ## ----------------------- ##
89 # -------------------------------- #
90 # 1a. Generic language selection. #
91 # -------------------------------- #
93 # AC_LANG_CASE(LANG1, IF-LANG1, LANG2, IF-LANG2, ..., DEFAULT)
94 # ------------------------------------------------------------
95 # Expand into IF-LANG1 if the current language is LANG1 etc. else
97 m4_define([AC_LANG_CASE],
98 [m4_case(_AC_LANG, $@)])
101 # _AC_LANG_DISPATCH(MACRO, LANG, ARGS)
102 # ------------------------------------
103 # Call the specialization of MACRO for LANG with ARGS. Complain if
105 m4_define([_AC_LANG_DISPATCH],
107 [m4_indir([$1($2)], m4_shiftn(2, $@))],
108 [AC_FATAL([$1: unknown language: $2])])])
111 # _AC_LANG_SET(OLD, NEW)
112 # ----------------------
113 # Output the shell code needed to switch from OLD language to NEW language.
114 # Do not try to optimize like this:
116 # m4_defun([_AC_LANG_SET],
117 # [m4_if([$1], [$2], [],
118 # [_AC_LANG_DISPATCH([AC_LANG], [$2])])])
120 # as it can introduce differences between the sh-current language and the
121 # m4-current-language when m4_require is used. Something more subtle
122 # might be possible, but at least for the time being, play it safe.
123 m4_defun([_AC_LANG_SET],
124 [_AC_LANG_DISPATCH([AC_LANG], [$2])])
129 # Set the current language to LANG.
131 [_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]),
133 m4_define([_AC_LANG], [$1])])
138 # Save the current language, and use LANG.
139 m4_defun([AC_LANG_PUSH],
140 [_AC_LANG_SET(m4_ifdef([_AC_LANG], [m4_defn([_AC_LANG])]),
142 m4_pushdef([_AC_LANG], [$1])])
145 # AC_LANG_POP([LANG])
146 # -------------------
147 # If given, check that the current language is LANG, and restore the
149 m4_defun([AC_LANG_POP],
151 [m4_if([$1], m4_defn([_AC_LANG]), [],
152 [m4_fatal([$0($1): unexpected current language: ]m4_defn([_AC_LANG]))])])dnl
153 m4_pushdef([$0 OLD], m4_defn([_AC_LANG]))dnl
154 m4_popdef([_AC_LANG])dnl
155 _AC_LANG_SET(m4_defn([$0 OLD]), m4_defn([_AC_LANG]))dnl
156 m4_popdef([$0 OLD])dnl
162 # Save the current language, but don't change language.
163 AU_DEFUN([AC_LANG_SAVE],
164 [AC_DIAGNOSE([obsolete],
165 [instead of using `AC_LANG', `AC_LANG_SAVE',
166 and `AC_LANG_RESTORE', you should use `AC_LANG_PUSH' and `AC_LANG_POP'.])
167 m4_pushdef([_AC_LANG], _AC_LANG)])
172 # Restore the current language from the stack.
173 AU_DEFUN([AC_LANG_RESTORE], [AC_LANG_POP($@)])
178 # Return a short signature of _AC_LANG which can be used in shell
179 # variable names, or in M4 macro names.
180 m4_defun([_AC_LANG_ABBREV],
181 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
184 # AC_LANG_ASSERT(LANG)
185 # --------------------
186 # Current language must be LANG.
187 m4_defun([AC_LANG_ASSERT],
188 [m4_if(_AC_LANG, $1, [],
189 [m4_fatal([$0: current language is not $1: ] _AC_LANG)])])
193 # -------------------- #
194 # 1b. The C language. #
195 # -------------------- #
200 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
201 m4_define([AC_LANG(C)],
203 ac_cpp='$CPP $CPPFLAGS'
204 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
205 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
206 ac_compiler_gnu=$ac_cv_c_compiler_gnu
212 AU_DEFUN([AC_LANG_C], [AC_LANG(C)])
217 m4_define([_AC_LANG_ABBREV(C)], [c])
220 # ---------------------- #
221 # 1c. The C++ language. #
222 # ---------------------- #
227 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
228 m4_define([AC_LANG(C++)],
230 ac_cpp='$CXXCPP $CPPFLAGS'
231 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
232 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
233 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
239 AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])
242 # _AC_LANG_ABBREV(C++)
243 # --------------------
244 m4_define([_AC_LANG_ABBREV(C++)], [cxx])
247 # ----------------------------- #
248 # 1d. The Fortran 77 language. #
249 # ----------------------------- #
252 # AC_LANG(Fortran 77)
253 # -------------------
254 m4_define([AC_LANG(Fortran 77)],
256 ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
257 ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
258 ac_compiler_gnu=$ac_cv_f77_compiler_gnu
264 AU_DEFUN([AC_LANG_FORTRAN77], [AC_LANG(Fortran 77)])
267 # _AC_LANG_ABBREV(Fortran 77)
268 # ---------------------------
269 m4_define([_AC_LANG_ABBREV(Fortran 77)], [f77])
273 ## ---------------------- ##
274 ## 2.Producing programs. ##
275 ## ---------------------- ##
278 # ---------------------- #
279 # 2a. Generic routines. #
280 # ---------------------- #
283 # AC_LANG_CONFTEST(BODY)
284 # ----------------------
285 # Save the BODY in `conftest.$ac_ext'. Add a trailing new line.
286 m4_define([AC_LANG_CONFTEST],
287 [cat >conftest.$ac_ext <<_ACEOF
292 # AC_LANG_SOURCE(BODY)
293 # --------------------
294 # Produce a valid source for the current language, which includes the
295 # BODY, and as much as possible `confdefs.h' and the `#line' sync
297 AC_DEFUN([AC_LANG_SOURCE],
298 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
301 # AC_LANG_PROGRAM([PROLOGUE], [BODY])
302 # -----------------------------------
303 # Produce a valid source for the current language. Prepend the
304 # PROLOGUE (typically CPP directives and/or declarations) to an
305 # execution the BODY (typically glued inside the `main' function, or
307 AC_DEFUN([AC_LANG_PROGRAM],
308 [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
311 # AC_LANG_CALL(PROLOGUE, FUNCTION)
312 # --------------------------------
314 AC_DEFUN([AC_LANG_CALL],
315 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
318 # AC_LANG_FUNC_LINK_TRY(FUNCTION)
319 # -------------------------------
320 # Produce a source which links correctly iff the FUNCTION exists.
321 AC_DEFUN([AC_LANG_FUNC_LINK_TRY],
322 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
325 # AC_LANG_BOOL_COMPILE_TRY(PROLOGUE, EXPRESSION)
326 # ----------------------------------------------
327 # Produce a program that compiles with success iff the boolean EXPRESSION
328 # evaluates to true at compile time.
329 AC_DEFUN([AC_LANG_BOOL_COMPILE_TRY],
330 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
333 # AC_LANG_INT_SAVE(PROLOGUE, EXPRESSION)
334 # --------------------------------------
335 # Produce a program that saves the runtime evaluation of the integer
336 # EXPRESSION into `conftest.val'.
337 AC_DEFUN([AC_LANG_INT_SAVE],
338 [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
345 # AC_LANG_SOURCE(C)(BODY)
346 # -----------------------
347 # This sometimes fails to find confdefs.h, for some reason.
348 # #line __oline__ "$[0]"
349 m4_define([AC_LANG_SOURCE(C)],
350 [#line __oline__ "configure"
351 #include "confdefs.h"
355 # AC_LANG_PROGRAM(C)([PROLOGUE], [BODY])
356 # --------------------------------------
357 # If AC_F77_DUMMY_MAIN was run, then any C/C++ program might be linked
358 # against Fortran code, hence a dummy main might be needed.
359 m4_define([AC_LANG_PROGRAM(C)],
361 m4_ifdef([_AC_LANG_PROGRAM_C_F77_HOOKS], [_AC_LANG_PROGRAM_C_F77_HOOKS()])dnl
365 dnl Do *not* indent the following line: there may be CPP directives.
366 dnl Don't move the `;' right after for the same reason.
373 # AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
374 # -----------------------------------
375 # Avoid conflicting decl of main.
376 m4_define([AC_LANG_CALL(C)],
378 m4_if([$2], [main], ,
379 [/* Override any gcc2 internal prototype to avoid an error. */
383 /* We use char because int might match the return type of a gcc2
384 builtin and then its argument prototype would still apply. */
385 char $2 ();])], [$2 ();])])
388 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
389 # ----------------------------------
390 # Don't include <ctype.h> because on OSF/1 3.0 it includes
391 # <sys/types.h> which includes <sys/select.h> which contains a
392 # prototype for select. Similarly for bzero.
393 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
395 [/* System header to define __stub macros and hopefully few prototypes,
396 which can conflict with char $1 (); below. */
398 /* Override any gcc2 internal prototype to avoid an error. */
402 /* We use char because int might match the return type of a gcc2
403 builtin and then its argument prototype would still apply. */
407 [/* The GNU C library defines this for functions which it implements
408 to always fail with ENOSYS. Some functions are actually named
409 something starting with __ and the normal name is an alias. */
410 #if defined (__stub_$1) || defined (__stub___$1)
418 # AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
419 # -------------------------------------------------
420 m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],
421 [AC_LANG_PROGRAM([$1], [int _array_ @<:@1 - 2 * !($2)@:>@])])
424 # AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
425 # -----------------------------------------
426 # We need `stdio.h' to open a `FILE', so the prologue defaults to the
427 # inclusion of `stdio.h'.
428 m4_define([AC_LANG_INT_SAVE(C)],
429 [AC_LANG_PROGRAM([m4_default([$1], [@%:@include <stdio.h>])],
430 [FILE *f = fopen ("conftest.val", "w");
433 fprintf (f, "%d", ($2));
437 # ----------------- #
439 # ----------------- #
441 # AC_LANG_SOURCE(C++)(BODY)
442 # -------------------------
443 m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
446 # AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
447 # ----------------------------------------
448 m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
451 # AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
452 # -------------------------------------
453 m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
456 # AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
457 # ------------------------------------
458 m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
461 # AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
462 # ---------------------------------------------------
463 m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
466 # AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
467 # -------------------------------------------
468 m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
472 # ------------------------ #
473 # 2d. Fortran 77 sources. #
474 # ------------------------ #
476 # AC_LANG_SOURCE(Fortran 77)(BODY)
477 # --------------------------------
478 # FIXME: Apparently, according to former AC_TRY_COMPILER, the CPP
479 # directives must not be included. But AC_TRY_RUN_NATIVE was not
481 m4_define([AC_LANG_SOURCE(Fortran 77)],
485 # AC_LANG_PROGRAM(Fortran 77)([PROLOGUE], [BODY])
486 # -----------------------------------------------
487 # Yes, we discard the PROLOGUE.
488 m4_define([AC_LANG_PROGRAM(Fortran 77)],
490 [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])dnl
496 # AC_LANG_CALL(Fortran 77)(PROLOGUE, FUNCTION)
497 # --------------------------------------------
498 # FIXME: This is a guess, help!
499 m4_define([AC_LANG_CALL(Fortran 77)],
500 [AC_LANG_PROGRAM([$1],
506 ## -------------------------------------------- ##
507 ## 3. Looking for Compilers and Preprocessors. ##
508 ## -------------------------------------------- ##
510 # ----------------------------------------------------- #
511 # 3a. Generic routines in compilers and preprocessors. #
512 # ----------------------------------------------------- #
516 # Find a compiler for the current LANG. Be sure to be run before
519 # Note that because we might AC_REQUIRE `AC_LANG_COMPILER(C)' for
520 # instance, the latter must be AC_DEFUN'd, not just define'd.
521 m4_define([AC_LANG_COMPILER],
522 [AC_BEFORE([AC_LANG_COMPILER(]_AC_LANG[)],
523 [AC_LANG_PREPROC(]_AC_LANG[)])dnl
524 _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
527 # AC_LANG_COMPILER_REQUIRE
528 # ------------------------
529 # Ensure we have a compiler for the current LANG.
530 AC_DEFUN([AC_LANG_COMPILER_REQUIRE],
531 [m4_require([AC_LANG_COMPILER(]_AC_LANG[)],
532 [AC_LANG_COMPILER])])
536 # _AC_LANG_COMPILER_GNU
537 # ---------------------
538 # Check whether the compiler for the current language is GNU.
540 # It doesn't seem necessary right now to have a different source
541 # according to the current language, since this works fine. Some day
542 # it might be needed. Nevertheless, pay attention to the fact that
543 # the position of `choke me' on the seventh column is meant: otherwise
544 # some Fortran compilers (e.g., SGI) might consider it's a
545 # continuation line, and warn instead of reporting an error.
546 m4_define([_AC_LANG_COMPILER_GNU],
547 [AC_CACHE_CHECK([whether we are using the GNU _AC_LANG compiler],
548 [ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu],
549 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __GNUC__
553 [ac_compiler_gnu=yes],
554 [ac_compiler_gnu=no])
555 ac_cv_[]_AC_LANG_ABBREV[]_compiler_gnu=$ac_compiler_gnu
556 ])])# _AC_LANG_COMPILER_GNU
561 # Find a preprocessor for the current language. Note that because we
562 # might AC_REQUIRE `AC_LANG_PREPROC(C)' for instance, the latter must
563 # be AC_DEFUN'd, not just define'd. Since the preprocessor depends
564 # upon the compiler, look for the compiler.
565 m4_define([AC_LANG_PREPROC],
566 [AC_LANG_COMPILER_REQUIRE()dnl
567 _AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
570 # AC_LANG_PREPROC_REQUIRE
571 # -----------------------
572 # Ensure we have a preprocessor for the current language.
573 AC_DEFUN([AC_LANG_PREPROC_REQUIRE],
574 [m4_require([AC_LANG_PREPROC(]_AC_LANG[)],
580 # Require the preprocessor for the current language.
581 # FIXME: AU_ALIAS once AC_LANG is officially documented (2.51?).
582 AC_DEFUN([AC_REQUIRE_CPP],
583 [AC_LANG_PREPROC_REQUIRE])
589 # FIXME: The GCC team has specific needs which the current Autoconf
590 # framework cannot solve elegantly. This macro implements a dirty
591 # hack until Autoconf is abble to provide the services its users
594 # Several of the support libraries that are often built with GCC can't
595 # assume the tool-chain is already capable of linking a program: the
596 # compiler often expects to be able to link with some of such
599 # In several of these libraries, work-arounds have been introduced to
600 # avoid the AC_PROG_CC_WORKS test, that would just abort their
601 # configuration. The introduction of AC_EXEEXT, enabled either by
602 # libtool or by CVS autoconf, have just made matters worse.
603 AC_DEFUN_ONCE([AC_NO_EXECUTABLES],
604 [m4_divert_push([KILL])
606 AC_BEFORE([$0], [_AC_COMPILER_EXEEXT_WORKS])
607 AC_BEFORE([$0], [_AC_COMPILER_EXEEXT])
609 m4_define([_AC_COMPILER_EXEEXT_WORKS],
610 [cross_compiling=maybe
613 m4_define([_AC_COMPILER_EXEEXT],
617 m4_define([AC_LINK_IFELSE],
618 [AC_FATAL([All the tests involving linking were disabled by $0])])
621 ])# AC_NO_EXECUTABLES
625 # ----------------------------- #
626 # Computing EXEEXT and OBJEXT. #
627 # ----------------------------- #
632 # Ignore .d files produced by CFLAGS=-MD.
634 # On UWIN (which uses a cc wrapper for MSVC), the compiler also generates
637 # When the w32 free Borland C++ command line compiler links a program
638 # (conftest.exe), it also produces a file named `conftest.tds' in
639 # addition to `conftest.obj'
642 # We must not AU define them, because autoupdate would then remove
643 # them, which is right, but Automake 1.4 would remove the support for
645 # FIXME: Remove this once Automake fixed.
646 AC_DEFUN([AC_EXEEXT], [])
647 AC_DEFUN([AC_OBJEXT], [])
650 # _AC_COMPILER_EXEEXT_DEFAULT
651 # ---------------------------
652 # Check for the extension used for the default name for executables.
653 # Beware of `expr' that may return `0' or `'. Since this macro is
654 # the first one in touch with the compiler, it should also check that
655 # it compiles properly.
656 m4_define([_AC_COMPILER_EXEEXT_DEFAULT],
657 [# Try to create an executable without -o first, disregard a.out.
658 # It will help us diagnose broken compilers, and finding out an intuition
660 AC_MSG_CHECKING([for _AC_LANG compiler default output])
661 ac_link_default=`echo "$ac_link" | sed ['s/ -o *conftest[^ ]*//']`
662 AS_IF([AC_TRY_EVAL(ac_link_default)],
663 [# Find the output, starting from the most likely. This scheme is
664 # not robust to junk in `.', hence go to wildcards (a.*) only as a last
666 for ac_file in `ls a.exe conftest.exe 2>/dev/null;
667 ls a.out conftest 2>/dev/null;
668 ls a.* conftest.* 2>/dev/null`; do
670 *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
671 a.out ) # We found the default executable, but exeext='' is most
674 *.* ) ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
675 # FIXME: I believe we export ac_cv_exeext for Libtool --akim.
681 [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
682 cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
683 AC_MSG_ERROR([_AC_LANG compiler cannot create executables], 77)])
684 ac_exeext=$ac_cv_exeext
685 AC_MSG_RESULT([$ac_file])
686 ])# _AC_COMPILER_EXEEXT_DEFAULT
689 # _AC_COMPILER_EXEEXT_WORKS
690 # -------------------------
691 m4_define([_AC_COMPILER_EXEEXT_WORKS],
692 [# Check the compiler produces executables we can run. If not, either
693 # the compiler is broken, or we cross compile.
694 AC_MSG_CHECKING([whether the _AC_LANG compiler works])
695 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
696 # If not cross compiling, check that we can run a simple program.
697 if test "$cross_compiling" != yes; then
698 if AC_TRY_COMMAND([./$ac_file]); then
701 if test "$cross_compiling" = maybe; then
704 AC_MSG_ERROR([cannot run _AC_LANG compiled programs.
705 If you meant to cross compile, use `--host'.])
710 ])# _AC_COMPILER_EXEEXT_WORKS
713 # _AC_COMPILER_EXEEXT_CROSS
714 # -------------------------
715 m4_define([_AC_COMPILER_EXEEXT_CROSS],
716 [# Check the compiler produces executables we can run. If not, either
717 # the compiler is broken, or we cross compile.
718 AC_MSG_CHECKING([whether we are cross compiling])
719 AC_MSG_RESULT([$cross_compiling])
720 ])# _AC_COMPILER_EXEEXT_CROSS
723 # _AC_COMPILER_EXEEXT_O
724 # ---------------------
725 # Check for the extension used when `-o foo'. Try to see if ac_cv_exeext,
726 # as computed by _AC_COMPILER_EXEEXT_DEFAULT is OK.
727 m4_define([_AC_COMPILER_EXEEXT_O],
728 [AC_MSG_CHECKING([for executable suffix])
729 AS_IF([AC_TRY_EVAL(ac_link)],
730 [# If both `conftest.exe' and `conftest' are `present' (well, observable)
731 # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
732 # work properly (i.e., refer to `conftest.exe'), while it won't with
734 for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do
736 *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
737 *.* ) ac_cv_exeext=`expr "$ac_file" : ['[^.]*\(\..*\)']`
743 [AC_MSG_ERROR([cannot compute EXEEXT: cannot compile and link])])
744 rm -f conftest$ac_cv_exeext
745 AC_MSG_RESULT([$ac_cv_exeext])
746 ])# _AC_COMPILER_EXEEXT_O
749 # _AC_COMPILER_EXEEXT
750 # -------------------
751 # Check for the extension used for executables. It compiles a test
752 # executable. If this is called, the executable extensions will be
753 # automatically used by link commands run by the configure script.
755 # Note that some compilers (cross or not), strictly obey to `-o foo' while
756 # the host requires `foo.exe', so we should not depend upon `-o' to
757 # test EXEEXT. But then, be sure no to destroy user files.
759 # Must be run before _AC_COMPILER_OBJEXT because _AC_COMPILER_EXEEXT_DEFAULT
760 # checks whether the compiler works.
761 m4_define([_AC_COMPILER_EXEEXT],
762 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
763 ac_clean_files_save=$ac_clean_files
764 ac_clean_files="$ac_clean_files a.out a.exe"
765 _AC_COMPILER_EXEEXT_DEFAULT
766 _AC_COMPILER_EXEEXT_WORKS
767 rm -f a.out a.exe conftest$ac_cv_exeext
768 ac_clean_files=$ac_clean_files_save
769 _AC_COMPILER_EXEEXT_CROSS
770 _AC_COMPILER_EXEEXT_O
771 rm -f conftest.$ac_ext
772 AC_SUBST([EXEEXT], [$ac_cv_exeext])dnl
774 ])# _AC_COMPILER_EXEEXT
777 # _AC_COMPILER_OBJEXT
778 # -------------------
779 # Check the object extension used by the compiler: typically `.o' or
780 # `.obj'. If this is called, some other behaviour will change,
781 # determined by ac_objext.
783 # This macro is called by AC_LANG_COMPILER, the latter being required
784 # by the AC_COMPILE_IFELSE macros, so use _AC_COMPILE_IFELSE. And in fact,
785 # don't, since _AC_COMPILE_IFELSE needs to know ac_objext for the `test -s'
786 # it includes. So do it by hand.
787 m4_define([_AC_COMPILER_OBJEXT],
788 [AC_CACHE_CHECK([for object suffix], ac_cv_objext,
789 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
790 rm -f conftest.o conftest.obj
791 AS_IF([AC_TRY_EVAL(ac_compile)],
792 [for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
794 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;;
795 *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
799 [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
800 cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
801 AC_MSG_ERROR([cannot compute OBJEXT: cannot compile])])
802 rm -f conftest.$ac_cv_objext conftest.$ac_ext])
803 AC_SUBST([OBJEXT], [$ac_cv_objext])dnl
805 ])# _AC_COMPILER_OBJEXT
808 # -------------------- #
809 # 3b. The C compiler. #
810 # -------------------- #
813 # _AC_ARG_VAR_CPPFLAGS
814 # --------------------
815 # Document and register CPPFLAGS, which is used by
816 # AC_PROG_{CC, CPP, CXX, CXXCPP}.
817 AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
818 [AC_ARG_VAR([CPPFLAGS],
819 [C/C++ preprocessor flags, e.g. -I<include dir> if you have
820 headers in a nonstandard directory <include dir>])])
823 # _AC_ARG_VAR_LDFLAGS
824 # -------------------
825 # Document and register LDFLAGS, which is used by
826 # AC_PROG_{CC, CXX, F77}.
827 AC_DEFUN([_AC_ARG_VAR_LDFLAGS],
828 [AC_ARG_VAR([LDFLAGS],
829 [linker flags, e.g. -L<lib dir> if you have libraries in a
830 nonstandard directory <lib dir>])])
835 # -------------------
836 # Find the C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
837 AC_DEFUN([AC_LANG_PREPROC(C)],
838 [AC_REQUIRE([AC_PROG_CPP])])
841 # _AC_PROG_PREPROC_WORKS_IFELSE(IF-WORKS, IF-NOT)
842 # -----------------------------------------------
843 # Check if $ac_cpp is a working preprocessor that can flag absent
844 # includes either by the exit status or by warnings.
845 # Set ac_cpp_err to a non-empty value if the preprocessor failed.
846 # This macro is for all languages, not only C.
847 AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],
849 for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
851 # Use a header file that comes with gcc, so configuring glibc
852 # with a fresh cross-compiler works.
853 # On the NeXT, cc -E runs the code through the compiler's parser,
854 # not just through cpp. "Syntax error" is here to catch this case.
855 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <assert.h>
858 [# Broken: fails on valid input.
861 # OK, works on sane cases. Now check whether non-existent headers
862 # can be detected and how.
863 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
864 [# Broken: success on invalid input.
866 [# Passes both tests.
871 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
872 rm -f conftest.err conftest.$ac_ext
873 AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
878 # Find a working C preprocessor.
879 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
880 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CC.
881 AC_DEFUN([AC_PROG_CPP],
882 [AC_REQUIRE([AC_PROG_CC])dnl
883 AC_ARG_VAR([CPP], [C preprocessor])dnl
884 _AC_ARG_VAR_CPPFLAGS()dnl
886 AC_MSG_CHECKING([how to run the C preprocessor])
887 # On Suns, sometimes $CPP names a directory.
888 if test -n "$CPP" && test -d "$CPP"; then
891 if test -z "$CPP"; then
892 AC_CACHE_VAL([ac_cv_prog_CPP],
894 # Double quotes because CPP needs to be expanded
895 for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
897 _AC_PROG_PREPROC_WORKS_IFELSE([break])
905 AC_MSG_RESULT([$CPP])
906 _AC_PROG_PREPROC_WORKS_IFELSE([],
907 [AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])])
913 # AC_LANG_COMPILER(C)
914 # -------------------
915 # Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
916 AC_DEFUN([AC_LANG_COMPILER(C)],
917 [AC_REQUIRE([AC_PROG_CC])])
922 # We used to name the cache variable this way.
923 AU_DEFUN([ac_cv_prog_gcc],
924 [ac_cv_c_compiler_gnu])
927 # AC_PROG_CC([COMPILER ...])
928 # --------------------------
929 # COMPILER ... is a space separated list of C compilers to search for.
930 # This just gives the user an opportunity to specify an alternative
931 # search list for the C compiler.
932 AC_DEFUN([AC_PROG_CC],
934 AC_ARG_VAR([CC], [C compiler command])dnl
935 AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
936 _AC_ARG_VAR_LDFLAGS()dnl
937 _AC_ARG_VAR_CPPFLAGS()dnl
939 [AC_CHECK_TOOLS(CC, [$1])],
940 [AC_CHECK_TOOL(CC, gcc)
941 if test -z "$CC"; then
942 AC_CHECK_TOOL(CC, cc)
944 if test -z "$CC"; then
945 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
947 if test -z "$CC"; then
948 AC_CHECK_TOOLS(CC, cl)
952 test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
954 # Provide some information about the compiler.
955 echo "$as_me:__oline__:" \
956 "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
957 ac_compiler=`set X $ac_compile; echo $[2]`
958 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
959 _AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
960 _AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
962 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
963 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
964 _AC_LANG_COMPILER_GNU
965 GCC=`test $ac_compiler_gnu = yes && echo yes`
967 # Some people use a C++ compiler to compile C. Since we use `exit',
968 # in C++ we need to declare it. In case someone uses the same compiler
969 # for both compiling C and C++ we need to have the C++ compiler decide
970 # the declaration of exit, since it's the most demanding environment.
971 _AC_COMPILE_IFELSE([@%:@ifndef __cplusplus
974 [_AC_PROG_CXX_EXIT_DECLARATION])
981 # Check whether -g works, even if CFLAGS is set, in case the package
982 # plays around with CFLAGS (such as to build both debugging and normal
983 # versions of a library), tasteless as that idea is.
984 m4_define([_AC_PROG_CC_G],
985 [ac_test_CFLAGS=${CFLAGS+set}
986 ac_save_CFLAGS=$CFLAGS
988 AC_CACHE_CHECK(whether $CC accepts -g, ac_cv_prog_cc_g,
989 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_prog_cc_g=yes],
990 [ac_cv_prog_cc_g=no])])
991 if test "$ac_test_CFLAGS" = set; then
992 CFLAGS=$ac_save_CFLAGS
993 elif test $ac_cv_prog_cc_g = yes; then
994 if test "$GCC" = yes; then
1000 if test "$GCC" = yes; then
1009 # AC_PROG_GCC_TRADITIONAL
1010 # -----------------------
1011 AC_DEFUN([AC_PROG_GCC_TRADITIONAL],
1012 [if test $ac_cv_c_compiler_gnu = yes; then
1013 AC_CACHE_CHECK(whether $CC needs -traditional,
1014 ac_cv_prog_gcc_traditional,
1015 [ ac_pattern="Autoconf.*'x'"
1016 AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
1018 ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
1020 if test $ac_cv_prog_gcc_traditional = no; then
1021 AC_EGREP_CPP($ac_pattern, [#include <termio.h>
1023 ac_cv_prog_gcc_traditional=yes)
1025 if test $ac_cv_prog_gcc_traditional = yes; then
1026 CC="$CC -traditional"
1029 ])# AC_PROG_GCC_TRADITIONAL
1034 AC_DEFUN([AC_PROG_CC_C_O],
1035 [AC_REQUIRE([AC_PROG_CC])dnl
1036 if test "x$CC" != xcc; then
1037 AC_MSG_CHECKING([whether $CC and cc understand -c and -o together])
1039 AC_MSG_CHECKING([whether cc understands -c and -o together])
1041 set dummy $CC; ac_cc=`echo $[2] |
1042 sed 's/[[^a-zA-Z0-9_]]/_/g;s/^[[0-9]]/_/'`
1043 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
1044 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
1045 # Make sure it works both with $CC and with simple cc.
1046 # We do the test twice because some compilers refuse to overwrite an
1047 # existing .o file with -o, though they will create one.
1048 ac_try='$CC -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
1049 if AC_TRY_EVAL(ac_try) &&
1050 test -f conftest.$ac_objext && AC_TRY_EVAL(ac_try);
1052 eval ac_cv_prog_cc_${ac_cc}_c_o=yes
1053 if test "x$CC" != xcc; then
1054 # Test first that cc exists at all.
1055 if AC_TRY_COMMAND(cc -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD); then
1056 ac_try='cc -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
1057 if AC_TRY_EVAL(ac_try) &&
1058 test -f conftest.$ac_objext && AC_TRY_EVAL(ac_try);
1063 # cc exists but doesn't like -o.
1064 eval ac_cv_prog_cc_${ac_cc}_c_o=no
1069 eval ac_cv_prog_cc_${ac_cc}_c_o=no
1073 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
1074 AC_MSG_RESULT([yes])
1077 AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
1078 [Define if your C compiler doesn't accept -c and -o together.])
1083 # ---------------------- #
1084 # 3c. The C++ compiler. #
1085 # ---------------------- #
1088 # AC_LANG_PREPROC(C++)
1089 # ---------------------
1090 # Find the C++ preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
1091 AC_DEFUN([AC_LANG_PREPROC(C++)],
1092 [AC_REQUIRE([AC_PROG_CXXCPP])])
1097 # Find a working C++ preprocessor.
1098 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
1099 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CXX.
1100 AC_DEFUN([AC_PROG_CXXCPP],
1101 [AC_REQUIRE([AC_PROG_CXX])dnl
1102 AC_ARG_VAR([CXXCPP], [C++ preprocessor])dnl
1103 _AC_ARG_VAR_CPPFLAGS()dnl
1104 AC_LANG_PUSH(C++)dnl
1105 AC_MSG_CHECKING([how to run the C++ preprocessor])
1106 if test -z "$CXXCPP"; then
1107 AC_CACHE_VAL(ac_cv_prog_CXXCPP,
1109 # Double quotes because CXXCPP needs to be expanded
1110 for CXXCPP in "$CXX -E" "/lib/cpp"
1112 _AC_PROG_PREPROC_WORKS_IFELSE([break])
1114 ac_cv_prog_CXXCPP=$CXXCPP
1116 CXXCPP=$ac_cv_prog_CXXCPP
1118 ac_cv_prog_CXXCPP=$CXXCPP
1120 AC_MSG_RESULT([$CXXCPP])
1121 _AC_PROG_PREPROC_WORKS_IFELSE([],
1122 [AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])])
1128 # AC_LANG_COMPILER(C++)
1129 # ---------------------
1130 # Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
1131 AC_DEFUN([AC_LANG_COMPILER(C++)],
1132 [AC_REQUIRE([AC_PROG_CXX])])
1137 # We used to name the cache variable this way.
1138 AU_DEFUN([ac_cv_prog_gxx],
1139 [ac_cv_cxx_compiler_gnu])
1142 # AC_PROG_CXX([LIST-OF-COMPILERS])
1143 # --------------------------------
1144 # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
1145 # for (if not specified, a default list is used). This just gives the
1146 # user an opportunity to specify an alternative search list for the C++
1148 # aCC HP-UX C++ compiler much better than `CC', so test before.
1149 # FCC Fujitsu C++ compiler
1150 # KCC KAI C++ compiler
1152 # xlC_r AIX C Set++ (with support for reentrant code)
1154 AC_DEFUN([AC_PROG_CXX],
1155 [AC_LANG_PUSH(C++)dnl
1156 AC_ARG_VAR([CXX], [C++ compiler command])dnl
1157 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
1158 _AC_ARG_VAR_LDFLAGS()dnl
1159 _AC_ARG_VAR_CPPFLAGS()dnl
1161 [$CCC m4_default([$1],
1162 [g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC])],
1165 # Provide some information about the compiler.
1166 echo "$as_me:__oline__:" \
1167 "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
1168 ac_compiler=`set X $ac_compile; echo $[2]`
1169 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
1170 _AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
1171 _AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
1173 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
1174 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
1175 _AC_LANG_COMPILER_GNU
1176 GXX=`test $ac_compiler_gnu = yes && echo yes`
1178 _AC_PROG_CXX_EXIT_DECLARATION
1185 # Check whether -g works, even if CXXFLAGS is set, in case the package
1186 # plays around with CXXFLAGS (such as to build both debugging and
1187 # normal versions of a library), tasteless as that idea is.
1188 m4_define([_AC_PROG_CXX_G],
1189 [ac_test_CXXFLAGS=${CXXFLAGS+set}
1190 ac_save_CXXFLAGS=$CXXFLAGS
1192 AC_CACHE_CHECK(whether $CXX accepts -g, ac_cv_prog_cxx_g,
1193 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1194 [ac_cv_prog_cxx_g=yes],
1195 [ac_cv_prog_cxx_g=no])])
1196 if test "$ac_test_CXXFLAGS" = set; then
1197 CXXFLAGS=$ac_save_CXXFLAGS
1198 elif test $ac_cv_prog_cxx_g = yes; then
1199 if test "$GXX" = yes; then
1205 if test "$GXX" = yes; then
1214 # _AC_PROG_CXX_EXIT_DECLARATION
1215 # -----------------------------
1216 # Find a valid prototype for exit and declare it in confdefs.h.
1217 m4_define([_AC_PROG_CXX_EXIT_DECLARATION],
1218 [for ac_declaration in \
1220 '#include <stdlib.h>' \
1221 'extern "C" void std::exit (int) throw (); using std::exit;' \
1222 'extern "C" void std::exit (int); using std::exit;' \
1223 'extern "C" void exit (int) throw ();' \
1224 'extern "C" void exit (int);' \
1227 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <stdlib.h>
1232 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration],
1237 if test -n "$ac_declaration"; then
1238 echo '#ifdef __cplusplus' >>confdefs.h
1239 echo $ac_declaration >>confdefs.h
1240 echo '#endif' >>confdefs.h
1242 ])# _AC_PROG_CXX_EXIT_DECLARATION
1245 # ----------------------------- #
1246 # 3d. The Fortran 77 compiler. #
1247 # ----------------------------- #
1250 # AC_LANG_PREPROC(Fortran 77)
1251 # ---------------------------
1252 # Find the Fortran 77 preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
1253 AC_DEFUN([AC_LANG_PREPROC(Fortran 77)],
1255 [$0: No preprocessor defined for ]_AC_LANG)])
1258 # AC_LANG_COMPILER(Fortran 77)
1259 # ----------------------------
1260 # Find the Fortran 77 compiler. Must be AC_DEFUN'd to be
1262 AC_DEFUN([AC_LANG_COMPILER(Fortran 77)],
1263 [AC_REQUIRE([AC_PROG_F77])])
1268 # We used to name the cache variable this way.
1269 AU_DEFUN([ac_cv_prog_g77],
1270 [ac_cv_f77_compiler_gnu])
1273 # AC_PROG_F77([COMPILERS...])
1274 # ---------------------------
1275 # COMPILERS is a space separated list of Fortran 77 compilers to search
1277 # Fortran 95 isn't strictly backwards-compatiable with Fortran 77, but
1278 # `f95' is worth trying.
1280 # Compilers are ordered by
1282 # 2. Good/tested native compilers, bad/untested native compilers
1283 # 3. Wrappers around f2c go last.
1285 # `fort77' and `fc' are wrappers around `f2c', `fort77' being better.
1286 # It is believed that under HP-UX `fort77' is the name of the native
1287 # compiler. On some Cray systems, fort77 is a native compiler.
1288 # cf77 and cft77 are (older) Cray F77 compilers.
1289 # frt is the Fujitsu F77 compiler.
1290 # pgf77 and pgf90 are the Portland Group F77 and F90 compilers.
1291 # xlf/xlf90/xlf95 are IBM (AIX) F77/F90/F95 compilers.
1292 # lf95 is the Lahey-Fujitsu compiler.
1293 # fl32 is the Microsoft Fortran "PowerStation" compiler.
1294 # af77 is the Apogee F77 compiler for Intergraph hardware running CLIX.
1295 # epcf90 is the "Edinburgh Portable Compiler" F90.
1296 # fort is the Compaq Fortran 90 (now 95) compiler for Tru64 and Linux/Alpha.
1297 AC_DEFUN([AC_PROG_F77],
1298 [AC_LANG_PUSH(Fortran 77)dnl
1299 AC_ARG_VAR([F77], [Fortran 77 compiler command])dnl
1300 AC_ARG_VAR([FFLAGS], [Fortran 77 compiler flags])dnl
1301 _AC_ARG_VAR_LDFLAGS()dnl
1304 [g77 f77 xlf cf77 cft77 frt pgf77 fl32 af77 fort77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 lf95 g95 fc])])
1306 # Provide some information about the compiler.
1307 echo "$as_me:__oline__:" \
1308 "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
1309 ac_compiler=`set X $ac_compile; echo $[2]`
1310 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
1311 _AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
1312 _AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
1314 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
1315 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
1316 # If we don't use `.F' as extension, the preprocessor is not run on the
1320 _AC_LANG_COMPILER_GNU
1322 G77=`test $ac_compiler_gnu = yes && echo yes`
1324 AC_LANG_POP(Fortran 77)dnl
1330 # Check whether -g works, even if FFLAGS is set, in case the package
1331 # plays around with FFLAGS (such as to build both debugging and normal
1332 # versions of a library), tasteless as that idea is.
1333 m4_define([_AC_PROG_F77_G],
1334 [ac_test_FFLAGS=${FFLAGS+set}
1335 ac_save_FFLAGS=$FFLAGS
1337 AC_CACHE_CHECK(whether $F77 accepts -g, ac_cv_prog_f77_g,
1339 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1340 [ac_cv_prog_f77_g=yes],
1341 [ac_cv_prog_f77_g=no])
1343 if test "$ac_test_FFLAGS" = set; then
1344 FFLAGS=$ac_save_FFLAGS
1345 elif test $ac_cv_prog_f77_g = yes; then
1346 if test "$G77" = yes; then
1352 if test "$G77" = yes; then
1363 # Test if the Fortran 77 compiler accepts the options `-c' and `-o'
1364 # simultaneously, and define `F77_NO_MINUS_C_MINUS_O' if it does not.
1366 # The usefulness of this macro is questionable, as I can't really see
1367 # why anyone would use it. The only reason I include it is for
1368 # completeness, since a similar test exists for the C compiler.
1369 AC_DEFUN([AC_PROG_F77_C_O],
1370 [AC_REQUIRE([AC_PROG_F77])dnl
1371 AC_CACHE_CHECK([whether $F77 understand -c and -o together],
1372 [ac_cv_prog_f77_c_o],
1373 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
1374 # We test twice because some compilers refuse to overwrite an existing
1375 # `.o' file with `-o', although they will create one.
1376 ac_try='$F77 $FFLAGS -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
1377 if AC_TRY_EVAL(ac_try) &&
1378 test -f conftest.$ac_objext &&
1379 AC_TRY_EVAL(ac_try); then
1380 ac_cv_prog_f77_c_o=yes
1382 ac_cv_prog_f77_c_o=no
1385 if test $ac_cv_prog_f77_c_o = no; then
1386 AC_DEFINE(F77_NO_MINUS_C_MINUS_O, 1,
1387 [Define if your Fortran 77 compiler doesn't accept -c and -o together.])
1395 ## ------------------------------- ##
1396 ## 4. Compilers' characteristics. ##
1397 ## ------------------------------- ##
1400 # -------------------------------- #
1401 # 4b. C compiler characteristics. #
1402 # -------------------------------- #
1406 # If the C compiler in not in ANSI C mode by default, try to add an
1407 # option to output variable @code{CC} to make it so. This macro tries
1408 # various options that select ANSI C on some system or another. It
1409 # considers the compiler to be in ANSI C mode if it handles function
1410 # prototypes correctly.
1411 AC_DEFUN([AC_PROG_CC_STDC],
1412 [AC_REQUIRE([AC_PROG_CC])dnl
1413 AC_BEFORE([$0], [AC_C_INLINE])dnl
1414 AC_BEFORE([$0], [AC_C_CONST])dnl
1415 dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
1416 dnl a magic option to avoid problems with ANSI preprocessor commands
1418 dnl FIXME: can't do this because then AC_AIX won't work due to a
1419 dnl circular dependency.
1420 dnl AC_BEFORE([$0], [AC_PROG_CPP])
1421 AC_MSG_CHECKING([for $CC option to accept ANSI C])
1422 AC_CACHE_VAL(ac_cv_prog_cc_stdc,
1423 [ac_cv_prog_cc_stdc=no
1425 AC_LANG_CONFTEST([AC_LANG_PROGRAM(
1426 [[#include <stdarg.h>
1428 #include <sys/types.h>
1429 #include <sys/stat.h>
1430 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
1431 struct buf { int x; };
1432 FILE * (*rcsopen) (struct buf *, struct stat *, int);
1433 static char *e (p, i)
1439 static char *f (char * (*g) (char **, int), char **p, ...)
1444 s = g (p, va_arg (v,int));
1448 int test (int i, double x);
1449 struct s1 {int (*f) (int a);};
1450 struct s2 {int (*f) (double a);};
1451 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
1454 [[return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];]])])
1455 # Don't try gcc -ansi; that turns off useful extensions and
1456 # breaks some systems' header files.
1457 # AIX -qlanglvl=ansi
1458 # Ultrix and OSF/1 -std1
1459 # HP-UX 10.20 and later -Ae
1460 # HP-UX older versions -Aa -D_HPUX_SOURCE
1461 # SVR4 -Xc -D__EXTENSIONS__
1462 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
1464 CC="$ac_save_CC $ac_arg"
1465 AC_COMPILE_IFELSE([],
1466 [ac_cv_prog_cc_stdc=$ac_arg
1469 rm -f conftest.$ac_ext conftest.$ac_objext
1472 case "x$ac_cv_prog_cc_stdc" in
1474 AC_MSG_RESULT([none needed]) ;;
1476 AC_MSG_RESULT([$ac_cv_prog_cc_stdc])
1477 CC="$CC $ac_cv_prog_cc_stdc" ;;
1484 # Has been merged into AC_PROG_CC.
1485 AU_DEFUN([AC_C_CROSS], [])
1488 # AC_C_CHAR_UNSIGNED
1489 # ------------------
1490 AC_DEFUN([AC_C_CHAR_UNSIGNED],
1491 [AH_VERBATIM([__CHAR_UNSIGNED__],
1492 [/* Define if type `char' is unsigned and you are not using gcc. */
1493 #ifndef __CHAR_UNSIGNED__
1494 # undef __CHAR_UNSIGNED__
1496 AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
1497 [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([])],
1498 [((char) -1) < 0])],
1499 ac_cv_c_char_unsigned=no, ac_cv_c_char_unsigned=yes)])
1500 if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
1501 AC_DEFINE(__CHAR_UNSIGNED__)
1503 ])# AC_C_CHAR_UNSIGNED
1508 AC_DEFUN([AC_C_LONG_DOUBLE],
1509 [AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
1510 [if test "$GCC" = yes; then
1511 ac_cv_c_long_double=yes
1517 /* The Stardent Vistra knows sizeof(long double), but does not
1519 long double foo = 0.0;
1520 /* On Ultrix 4.3 cc, long double is 4 and double is 8. */
1521 exit (sizeof (long double) < sizeof (double));
1523 ac_cv_c_long_double=yes, ac_cv_c_long_double=no)
1525 if test $ac_cv_c_long_double = yes; then
1526 AC_DEFINE(HAVE_LONG_DOUBLE, 1,
1527 [Define if the `long double' type works.])
1529 ])# AC_C_LONG_DOUBLE
1534 AC_DEFUN([AC_C_BIGENDIAN],
1535 [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
1536 [ac_cv_c_bigendian=unknown
1537 # See if sys/param.h defines the BYTE_ORDER macro.
1538 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
1539 #include <sys/param.h>
1541 [#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
1545 [# It does; now see whether it defined to BIG_ENDIAN or not.
1546 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
1547 #include <sys/param.h>
1548 ], [#if BYTE_ORDER != BIG_ENDIAN
1551 ])], [ac_cv_c_bigendian=yes],
1552 [ac_cv_c_bigendian=no])])
1553 if test $ac_cv_c_bigendian = unknown; then
1558 /* Are we little or big endian? From Harbison&Steele. */
1562 char c[sizeof (long)];
1565 exit (u.c[sizeof (long) - 1] == 1);
1566 }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)
1568 if test $ac_cv_c_bigendian = yes; then
1569 AC_DEFINE(WORDS_BIGENDIAN, 1,
1570 [Define if your processor stores words with the most significant
1571 byte first (like Motorola and SPARC, unlike Intel and VAX).])
1578 # Do nothing if the compiler accepts the inline keyword.
1579 # Otherwise define inline to __inline__ or __inline if one of those work,
1580 # otherwise define inline to be empty.
1581 AC_DEFUN([AC_C_INLINE],
1582 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
1583 AC_CACHE_CHECK([for inline], ac_cv_c_inline,
1585 for ac_kw in inline __inline__ __inline; do
1586 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1587 [#ifndef __cplusplus
1588 static $ac_kw int static_foo () {return 0; }
1589 $ac_kw int foo () {return 0; }
1592 [ac_cv_c_inline=$ac_kw; break])
1595 case $ac_cv_c_inline in
1597 no) AC_DEFINE(inline,,
1598 [Define as `__inline' if that's what the C compiler calls it,
1599 or to nothing if it is not supported.]) ;;
1600 *) AC_DEFINE_UNQUOTED(inline, $ac_cv_c_inline) ;;
1607 AC_DEFUN([AC_C_CONST],
1608 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
1609 AC_CACHE_CHECK([for an ANSI C-conforming const], ac_cv_c_const,
1610 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
1611 [[/* FIXME: Include the comments suggested by Paul. */
1613 /* Ultrix mips cc rejects this. */
1614 typedef int charset[2];
1616 /* SunOS 4.1.1 cc rejects this. */
1617 char const *const *ccp;
1619 /* NEC SVR4.0.2 mips cc rejects this. */
1620 struct point {int x, y;};
1621 static struct point const zero = {0,0};
1622 /* AIX XL C 1.02.0.0 rejects this.
1623 It does not let you subtract one const X* pointer from another in
1624 an arm of an if-expression whose if-part is not a constant
1626 const char *g = "string";
1627 ccp = &g + (g ? g-g : 0);
1628 /* HPUX 7.0 cc rejects these. */
1631 ccp = (char const *const *) p;
1632 { /* SCO 3.2v4 cc rejects this. */
1634 char const *s = 0 ? (char *) 0 : (char const *) 0;
1638 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
1640 const int *foo = &x[0];
1643 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
1644 typedef const int *iptr;
1648 { /* AIX XL C 1.02.0.0 rejects this saying
1649 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
1650 struct s { int j; const int *ap[3]; };
1651 struct s *b; b->j = 5;
1653 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
1658 [ac_cv_c_const=yes],
1659 [ac_cv_c_const=no])])
1660 if test $ac_cv_c_const = no; then
1662 [Define to empty if `const' does not conform to ANSI C.])
1669 # Note that, unlike const, #defining volatile to be the empty string can
1670 # actually turn a correct program into an incorrect one, since removing
1671 # uses of volatile actually grants the compiler permission to perform
1672 # optimizations that could break the user's code. So, do not #define
1673 # volatile away unless it is really necessary to allow the user's code
1674 # to compile cleanly. Benign compiler failures should be tolerated.
1675 AC_DEFUN([AC_C_VOLATILE],
1676 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
1677 AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
1678 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1680 int * volatile y;])],
1681 [ac_cv_c_volatile=yes],
1682 [ac_cv_c_volatile=no])])
1683 if test $ac_cv_c_volatile = no; then
1684 AC_DEFINE(volatile,,
1685 [Define to empty if the keyword `volatile' does not work.
1686 Warning: valid code using `volatile' can become incorrect
1687 without. Disable with care.])
1694 # Checks if `#' can be used to glue strings together at the CPP level.
1695 # Defines HAVE_STRINGIZE if positive.
1696 AC_DEFUN([AC_C_STRINGIZE],
1697 [AC_CACHE_CHECK([for preprocessor stringizing operator],
1698 [ac_cv_c_stringize],
1699 [AC_EGREP_CPP([@%:@teststring],
1702 char *s = x(teststring);],
1703 [ac_cv_c_stringize=no],
1704 [ac_cv_c_stringize=yes])])
1705 if test $ac_cv_c_stringize = yes; then
1706 AC_DEFINE(HAVE_STRINGIZE, 1,
1707 [Define if cpp supports the ANSI @%:@ stringizing operator.])
1714 # Check if the C compiler supports prototypes, included if it needs
1716 AC_DEFUN([AC_C_PROTOTYPES],
1717 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
1718 AC_MSG_CHECKING([for function prototypes])
1719 if test "$ac_cv_prog_cc_stdc" != no; then
1720 AC_MSG_RESULT([yes])
1721 AC_DEFINE(PROTOTYPES, 1,
1722 [Define if the C compiler supports function prototypes.])
1731 # ---------------------------------------- #
1732 # 4d. Fortan 77 compiler characteristics. #
1733 # ---------------------------------------- #
1736 # _AC_PROG_F77_V_OUTPUT([FLAG = $ac_cv_prog_f77_v])
1737 # -------------------------------------------------
1738 # Link a trivial Fortran program, compiling with a verbose output FLAG
1739 # (which default value, $ac_cv_prog_f77_v, is computed by
1740 # _AC_PROG_F77_V), and return the output in $ac_f77_v_output. This
1741 # output is processed in the way expected by AC_F77_LIBRARY_LDFLAGS,
1742 # so that any link flags that are echoed by the compiler appear as
1743 # space-separated items.
1744 AC_DEFUN([_AC_PROG_F77_V_OUTPUT],
1745 [AC_REQUIRE([AC_PROG_F77])dnl
1746 AC_LANG_PUSH(Fortran 77)dnl
1748 AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
1750 # Compile and link our simple test program by passing a flag (argument
1751 # 1 to this macro) to the Fortran 77 compiler in order to get
1752 # "verbose" output that we can then parse for the Fortran 77 linker
1754 ac_save_FFLAGS=$FFLAGS
1755 FFLAGS="$FFLAGS m4_default([$1], [$ac_cv_prog_f77_v])"
1756 (eval echo $as_me:__oline__: \"$ac_link\") >&AS_MESSAGE_LOG_FD
1757 ac_f77_v_output=`eval $ac_link AS_MESSAGE_LOG_FD>&1 2>&1 | grep -v 'Driving:'`
1758 echo "$ac_f77_v_output" >&AS_MESSAGE_LOG_FD
1759 FFLAGS=$ac_save_FFLAGS
1762 AC_LANG_POP(Fortran 77)dnl
1764 # If we are using xlf then replace all the commas with spaces.
1765 if echo $ac_f77_v_output | grep xlfentry >/dev/null 2>&1; then
1766 ac_f77_v_output=`echo $ac_f77_v_output | sed 's/,/ /g'`
1769 # If we are using Cray Fortran then delete quotes.
1770 # Use "\"" instead of '"' for font-lock-mode.
1771 # FIXME: a more general fix for quoted arguments with spaces?
1772 if echo $ac_f77_v_output | grep cft90 >/dev/null 2>&1; then
1773 ac_f77_v_output=`echo $ac_f77_v_output | sed "s/\"//g"`
1775 ])# _AC_PROG_F77_V_OUTPUT
1781 # Determine the flag that causes the Fortran 77 compiler to print
1782 # information of library and object files (normally -v)
1783 # Needed for AC_F77_LIBRARY_FLAGS
1784 # Some compilers don't accept -v (Lahey: -verbose, xlf: -V, Fujitsu: -###)
1785 AC_DEFUN([_AC_PROG_F77_V],
1786 [AC_CACHE_CHECK([how to get verbose linking output from $F77],
1788 [AC_LANG_ASSERT(Fortran 77)
1789 AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1791 # Try some options frequently used verbose output
1792 for ac_verb in -v -verbose --verbose -V -\#\#\#; do
1793 _AC_PROG_F77_V_OUTPUT($ac_verb)
1794 # look for -l* and *.a constructs in the output
1795 for ac_arg in $ac_f77_v_output; do
1797 [[\\/]]*.a | ?:[[\\/]]*.a | -[[lLRu]]*)
1798 ac_cv_prog_f77_v=$ac_verb
1803 if test -z "$ac_cv_prog_f77_v"; then
1804 AC_MSG_WARN([cannot determine how to obtain linking information from $F77])
1806 [AC_MSG_WARN([compilation failed])])
1807 ])])# _AC_PROG_F77_V
1810 # AC_F77_LIBRARY_LDFLAGS
1811 # ----------------------
1813 # Determine the linker flags (e.g. "-L" and "-l") for the Fortran 77
1814 # intrinsic and run-time libraries that are required to successfully
1815 # link a Fortran 77 program or shared library. The output variable
1816 # FLIBS is set to these flags.
1818 # This macro is intended to be used in those situations when it is
1819 # necessary to mix, e.g. C++ and Fortran 77, source code into a single
1820 # program or shared library.
1822 # For example, if object files from a C++ and Fortran 77 compiler must
1823 # be linked together, then the C++ compiler/linker must be used for
1824 # linking (since special C++-ish things need to happen at link time
1825 # like calling global constructors, instantiating templates, enabling
1826 # exception support, etc.).
1828 # However, the Fortran 77 intrinsic and run-time libraries must be
1829 # linked in as well, but the C++ compiler/linker doesn't know how to
1830 # add these Fortran 77 libraries. Hence, the macro
1831 # "AC_F77_LIBRARY_LDFLAGS" was created to determine these Fortran 77
1834 # This macro was packaged in its current form by Matthew D. Langston.
1835 # However, nearly all of this macro came from the "OCTAVE_FLIBS" macro
1836 # in "octave-2.0.13/aclocal.m4", and full credit should go to John
1837 # W. Eaton for writing this extremely useful macro. Thank you John.
1838 AC_DEFUN([AC_F77_LIBRARY_LDFLAGS],
1839 [AC_LANG_PUSH(Fortran 77)dnl
1841 AC_CACHE_CHECK([for Fortran 77 libraries], ac_cv_flibs,
1842 [if test "x$FLIBS" != "x"; then
1843 ac_cv_flibs="$FLIBS" # Let the user override the test.
1846 _AC_PROG_F77_V_OUTPUT
1850 # Save positional arguments (if any)
1851 ac_save_positional="$[@]"
1853 set X $ac_f77_v_output
1854 while test $[@%:@] != 1; do
1858 [[\\/]]*.a | ?:[[\\/]]*.a)
1859 AC_LIST_MEMBER_OF($ac_arg, $ac_cv_flibs, ,
1860 ac_cv_flibs="$ac_cv_flibs $ac_arg")
1863 AC_LIST_MEMBER_OF($ac_arg, $ac_cv_flibs, ,
1864 [AC_LINKER_OPTION([$ac_arg], ac_cv_flibs)])
1866 # Ignore these flags.
1867 -lang* | -lcrt0.o | -lc | -lgcc | -LANG:=*)
1870 test x"$CYGWIN" != xyes && ac_cv_flibs="$ac_cv_flibs $ac_arg"
1873 # These flags, when seen by themselves, take an argument.
1874 # We remove the space between option and argument and re-iterate
1875 # unless we find an empty arg or a new option (starting with -)
1879 ac_arg="$ac_arg$[2]"
1881 set X $ac_arg "$[@]"
1886 for ac_j in `echo $ac_arg | sed -e 's/-YP,/-L/;s/:/ -L/g'`; do
1887 AC_LIST_MEMBER_OF($ac_j, $ac_cv_flibs, ,
1888 [ac_arg="$ac_arg $ac_j"
1889 ac_cv_flibs="$ac_cv_flibs $ac_j"])
1893 AC_LIST_MEMBER_OF($ac_arg, $ac_cv_flibs, ,
1894 ac_cv_flibs="$ac_cv_flibs $ac_arg")
1896 # Ignore everything else.
1899 # restore positional arguments
1900 set X $ac_save_positional; shift
1902 # We only consider "LD_RUN_PATH" on Solaris systems. If this is seen,
1903 # then we insist that the "run path" must be an absolute path (i.e. it
1904 # must begin with a "/").
1905 case `(uname -sr) 2>/dev/null` in
1907 ac_ld_run_path=`echo $ac_f77_v_output |
1908 sed -n 's,^.*LD_RUN_PATH *= *\(/[[^ ]]*\).*$,-R\1,p'`
1909 test "x$ac_ld_run_path" != x &&
1910 AC_LINKER_OPTION([$ac_ld_run_path], ac_cv_flibs)
1913 fi # test "x$FLIBS" = "x"
1915 FLIBS="$ac_cv_flibs"
1917 AC_LANG_POP(Fortran 77)dnl
1918 ])# AC_F77_LIBRARY_LDFLAGS
1921 # AC_F77_DUMMY_MAIN([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1922 # -----------------------------------------------------------
1924 # Detect name of dummy main routine required by the Fortran libraries,
1925 # (if any) and define F77_DUMMY_MAIN to this name (which should be
1926 # used for a dummy declaration, if it is defined). On some systems,
1927 # linking a C program to the Fortran library does not work unless you
1928 # supply a dummy function called something like MAIN__.
1930 # Execute ACTION-IF-NOT-FOUND if no way of successfully linking a C
1931 # program with the F77 libs is found; default to exiting with an error
1932 # message. Execute ACTION-IF-FOUND if a dummy routine name is needed
1933 # and found or if it is not needed (default to defining F77_DUMMY_MAIN
1936 # What is technically happening is that the Fortran libraries provide
1937 # their own main() function, which usually initializes Fortran I/O and
1938 # similar stuff, and then calls MAIN__, which is the entry point of
1939 # your program. Usually, a C program will override this with its own
1940 # main() routine, but the linker sometimes complain if you don't
1941 # provide a dummy (never-called) MAIN__ routine anyway.
1943 # Of course, programs that want to allow Fortran subroutines to do
1944 # I/O, etcetera, should call their main routine MAIN__() (or whatever)
1945 # instead of main(). A separate autoconf test (AC_F77_MAIN) checks
1946 # for the routine to use in this case (since the semantics of the test
1947 # are slightly different). To link to e.g. purely numerical
1948 # libraries, this is normally not necessary, however, and most C/C++
1949 # programs are reluctant to turn over so much control to Fortran. =)
1951 # The name variants we check for are (in order):
1952 # MAIN__ (g77, MAIN__ required on some systems; IRIX, MAIN__ optional)
1953 # MAIN_, __main (SunOS)
1954 # MAIN _MAIN __MAIN main_ main__ _main (we follow DDD and try these too)
1955 AC_DEFUN([AC_F77_DUMMY_MAIN],
1956 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
1957 m4_define([_AC_LANG_PROGRAM_C_F77_HOOKS],
1958 [#ifdef F77_DUMMY_MAIN
1962 int F77_DUMMY_MAIN() { return 1; }
1965 AC_CACHE_CHECK([for dummy main to link with Fortran 77 libraries],
1966 ac_cv_f77_dummy_main,
1968 ac_f77_dm_save_LIBS=$LIBS
1971 # First, try linking without a dummy main:
1973 ac_cv_f77_dummy_main=none,
1974 ac_cv_f77_dummy_main=unknown)
1976 if test $ac_cv_f77_dummy_main = unknown; then
1977 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
1978 AC_TRY_LINK([@%:@define F77_DUMMY_MAIN $ac_func],
1979 [], [ac_cv_f77_dummy_main=$ac_func; break])
1983 LIBS=$ac_f77_dm_save_LIBS
1986 F77_DUMMY_MAIN=$ac_cv_f77_dummy_main
1987 AS_IF([test "$F77_DUMMY_MAIN" != unknown],
1989 [if test $F77_DUMMY_MAIN != none; then
1990 AC_DEFINE_UNQUOTED([F77_DUMMY_MAIN], $F77_DUMMY_MAIN,
1991 [Define to dummy `main' function (if any) required to
1992 link to the Fortran 77 libraries.])
1995 [AC_MSG_ERROR([Linking to Fortran libraries from C fails.])])])
1996 ])# AC_F77_DUMMY_MAIN
2001 # Define F77_MAIN to name of alternate main() function for use with
2002 # the Fortran libraries. (Typically, the libraries may define their
2003 # own main() to initialize I/O, etcetera, that then call your own
2004 # routine called MAIN__ or whatever.) See AC_F77_DUMMY_MAIN, above.
2005 # If no such alternate name is found, just define F77_MAIN to main.
2007 AC_DEFUN([AC_F77_MAIN],
2008 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
2009 AC_CACHE_CHECK([for alternate main to link with Fortran 77 libraries],
2012 ac_f77_m_save_LIBS=$LIBS
2014 ac_cv_f77_main="main" # default entry point name
2016 for ac_func in MAIN__ MAIN_ __main MAIN _MAIN __MAIN main_ main__ _main; do
2017 AC_TRY_LINK([#undef F77_DUMMY_MAIN
2018 @%:@define main $ac_func], [], [ac_cv_f77_main=$ac_func; break])
2021 LIBS=$ac_f77_m_save_LIBS
2024 AC_DEFINE_UNQUOTED([F77_MAIN], $ac_cv_f77_main,
2025 [Define to alternate name for `main' routine that is
2026 called from a `main' in the Fortran libraries.])
2030 # _AC_F77_NAME_MANGLING
2031 # ---------------------
2032 # Test for the name mangling scheme used by the Fortran 77 compiler.
2034 # Sets ac_cv_f77_mangling. The value contains three fields, separated
2037 # lower case / upper case:
2038 # case translation of the Fortan 77 symbols
2039 # underscore / no underscore:
2040 # whether the compiler appends "_" to symbol names
2041 # extra underscore / no extra underscore:
2042 # whether the compiler appends an extra "_" to symbol names already
2043 # containing at least one underscore
2045 AC_DEFUN([_AC_F77_NAME_MANGLING],
2046 [AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])dnl
2047 AC_REQUIRE([AC_F77_DUMMY_MAIN])dnl
2048 AC_CACHE_CHECK([for Fortran 77 name-mangling scheme],
2050 [AC_LANG_PUSH(Fortran 77)dnl
2052 [ subroutine foobar()
2055 subroutine foo_bar()
2058 [mv conftest.$ac_objext cf77_test.$ac_objext
2063 LIBS="cf77_test.$ac_objext $LIBS $FLIBS"
2066 for ac_foobar in foobar FOOBAR; do
2067 for ac_underscore in "" "_"; do
2068 ac_func="$ac_foobar$ac_underscore"
2069 AC_TRY_LINK_FUNC($ac_func,
2070 [ac_success=yes; break 2])
2074 if test "$ac_success" = "yes"; then
2087 for ac_extra in "" "_"; do
2088 ac_func="$ac_foo_bar$ac_underscore$ac_extra"
2089 AC_TRY_LINK_FUNC($ac_func,
2090 [ac_success_extra=yes; break])
2093 if test "$ac_success_extra" = "yes"; then
2094 ac_cv_f77_mangling="$ac_case case"
2095 if test -z "$ac_underscore"; then
2096 ac_cv_f77_mangling="$ac_cv_f77_mangling, no underscore"
2098 ac_cv_f77_mangling="$ac_cv_f77_mangling, underscore"
2100 if test -z "$ac_extra"; then
2101 ac_cv_f77_mangling="$ac_cv_f77_mangling, no extra underscore"
2103 ac_cv_f77_mangling="$ac_cv_f77_mangling, extra underscore"
2106 ac_cv_f77_mangling="unknown"
2109 ac_cv_f77_mangling="unknown"
2114 rm -f cf77_test* conftest*])
2115 AC_LANG_POP(Fortran 77)dnl
2117 ])# _AC_F77_NAME_MANGLING
2119 # The replacement is empty.
2120 AU_DEFUN([AC_F77_NAME_MANGLING], [])
2125 # Defines C macros F77_FUNC(name,NAME) and F77_FUNC_(name,NAME) to
2126 # properly mangle the names of C identifiers, and C identifiers with
2127 # underscores, respectively, so that they match the name mangling
2128 # scheme used by the Fortran 77 compiler.
2129 AC_DEFUN([AC_F77_WRAPPERS],
2130 [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
2131 AH_TEMPLATE([F77_FUNC],
2132 [Define to a macro mangling the given C identifier (in lower and upper
2133 case), which must not contain underscores, for linking with Fortran.])dnl
2134 AH_TEMPLATE([F77_FUNC_],
2135 [As F77_FUNC, but for C identifiers containing underscores.])dnl
2136 case $ac_cv_f77_mangling in
2137 "lower case, no underscore, no extra underscore")
2138 AC_DEFINE([F77_FUNC(name,NAME)], [name])
2139 AC_DEFINE([F77_FUNC_(name,NAME)], [name]) ;;
2140 "lower case, no underscore, extra underscore")
2141 AC_DEFINE([F77_FUNC(name,NAME)], [name])
2142 AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
2143 "lower case, underscore, no extra underscore")
2144 AC_DEFINE([F77_FUNC(name,NAME)], [name ## _])
2145 AC_DEFINE([F77_FUNC_(name,NAME)], [name ## _]) ;;
2146 "lower case, underscore, extra underscore")
2147 AC_DEFINE([F77_FUNC(name,NAME)], [name ## _])
2148 AC_DEFINE([F77_FUNC_(name,NAME)], [name ## __]) ;;
2149 "upper case, no underscore, no extra underscore")
2150 AC_DEFINE([F77_FUNC(name,NAME)], [NAME])
2151 AC_DEFINE([F77_FUNC_(name,NAME)], [NAME]) ;;
2152 "upper case, no underscore, extra underscore")
2153 AC_DEFINE([F77_FUNC(name,NAME)], [NAME])
2154 AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
2155 "upper case, underscore, no extra underscore")
2156 AC_DEFINE([F77_FUNC(name,NAME)], [NAME ## _])
2157 AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## _]) ;;
2158 "upper case, underscore, extra underscore")
2159 AC_DEFINE([F77_FUNC(name,NAME)], [NAME ## _])
2160 AC_DEFINE([F77_FUNC_(name,NAME)], [NAME ## __]) ;;
2162 AC_MSG_WARN([unknown Fortran 77 name-mangling scheme])
2168 # AC_F77_FUNC(NAME, [SHELLVAR = NAME])
2169 # ------------------------------------
2170 # For a Fortran subroutine of given NAME, define a shell variable
2171 # $SHELLVAR to the Fortran-77 mangled name. If the SHELLVAR
2172 # argument is not supplied, it defaults to NAME.
2173 AC_DEFUN([AC_F77_FUNC],
2174 [AC_REQUIRE([_AC_F77_NAME_MANGLING])dnl
2175 case $ac_cv_f77_mangling in
2176 upper*) ac_val="m4_toupper([$1])" ;;
2177 lower*) ac_val="m4_tolower([$1])" ;;
2178 *) ac_val="unknown" ;;
2180 case $ac_cv_f77_mangling in *," underscore"*) ac_val="$ac_val"_ ;; esac
2181 m4_if(m4_index([$1],[_]),-1,[],
2182 [case $ac_cv_f77_mangling in *," extra underscore"*) ac_val="$ac_val"_ ;; esac
2184 m4_default([$2],[$1])="$ac_val"