]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* doc/autoconf.texi (Generating Sources): Document AC_LANG_CALL
authorAkim Demaille <akim@epita.fr>
Sun, 27 Oct 2002 18:21:31 +0000 (18:21 +0000)
committerAkim Demaille <akim@epita.fr>
Sun, 27 Oct 2002 18:21:31 +0000 (18:21 +0000)
and AC_LANG_FUNC_LINK_TRY.
(Examining Libraries): Rename as...
(Running the Linker): this.
Document AC_LINK_IFELSE.
Move the documentation of AC_TRY_LINK and AC_TRY_LINK_FUNC to...
(Obsolete Macros): here.
* lib/autoconf/fortran.m4 (_AC_F77_NAME_MANGLING): Don't use
AC_TRY_LINK_FUNC nor AC_TRY_LINK.
* lib/autoconf/libs.m4 (AC_CHECK_LIB, AC_PATH_XTRA): Likewise.
* lib/autoconf/headers.m4 (AC_USG): Likewise.

ChangeLog
doc/autoconf.texi
lib/autoconf/fortran.m4
lib/autoconf/general.m4
lib/autoconf/headers.m4
lib/autoconf/libs.m4
lib/autoconf/specific.m4
lib/autoconf/types.m4

index 97517da897bcd8b12b658289e1d99924275f42cb..e25770b890948f2b5e1e5a935f1727f2d3aa3f3a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2002-10-27  Akim Demaille  <akim@epita.fr>
+
+       * doc/autoconf.texi (Generating Sources): Document AC_LANG_CALL
+       and AC_LANG_FUNC_LINK_TRY.
+       (Examining Libraries): Rename as...
+       (Running the Linker): this.
+       Document AC_LINK_IFELSE.
+       Move the documentation of AC_TRY_LINK and AC_TRY_LINK_FUNC to...
+       (Obsolete Macros): here.
+       * lib/autoconf/fortran.m4 (_AC_F77_NAME_MANGLING): Don't use
+       AC_TRY_LINK_FUNC nor AC_TRY_LINK.
+       * lib/autoconf/libs.m4 (AC_CHECK_LIB, AC_PATH_XTRA): Likewise.
+       * lib/autoconf/headers.m4 (AC_USG): Likewise.
+
 2002-10-27  Akim Demaille  <akim@epita.fr>
 
        * lib/autoconf/headers.m4 (AC_HEADER_STDC): Don't use AC_TRY_CPP.
index b879d78849de4a5f79904a41477f571af33bed07..5aa517de4315e8bfd073ef46fc325dd399e18821 100644 (file)
@@ -285,7 +285,7 @@ Writing Tests
 * Writing Test Programs::       Forging source files for compilers
 * Running the Preprocessor::    Detecting preprocessor symbols
 * Running the Compiler::        Detecting language or header features
-* Examining Libraries::         Detecting functions and global variables
+* Running the Linker::          Detecting library features
 * Run Time::                    Testing for run-time features
 * Systemology::                 A zoology of operating systems
 * Multiple Cases::              Tests for several possible values
@@ -5630,7 +5630,7 @@ software package, the best thing to do is encapsulate it in a new macro.
 * Writing Test Programs::       Forging source files for compilers
 * Running the Preprocessor::    Detecting preprocessor symbols
 * Running the Compiler::        Detecting language or header features
-* Examining Libraries::         Detecting functions and global variables
+* Running the Linker::          Detecting library features
 * Run Time::                    Testing for run-time features
 * Systemology::                 A zoology of operating systems
 * Multiple Cases::              Tests for several possible values
@@ -5908,6 +5908,34 @@ fputs (hw, stdout);
 @}
 @end example
 
+
+@defmac AC_LANG_CALL (@var{prologue}, @var{function})
+@acindex LANG_CALL
+Expands into a source file which consists of the @var{prologue}, and
+then a call to the @var{function} as body of the main function (e.g.,
+@code{main} in C).  Since it uses @code{AC_LANG_PROGRAMS}, the feature
+of the latter are available.
+
+This function will probably be replaced in the feature by a version
+which would enable specifying the arguments.  The use of this macro is
+not encouraged, as it violates strongly the typing system.
+@end defmac
+
+
+@defmac AC_LANG_FUNC_LINK_TRY (@var{prologue}, @var{function})
+@acindex LANG_FUNC_LINK_TRY
+Expands into a source file which consists of the @var{prologue}, and
+then a pseudo use of the @var{function} as body of the main function
+(e.g., @code{main} in C): a simple (function pointer) assignment.  Since
+it uses @code{AC_LANG_PROGRAMS}, the feature of the latter are
+available.
+
+As @code{AC_LANG_CALL}, this macro is documented only for completeness.
+It is considered to be severely broken, and in the future will be
+removed in favor of actual function calls (with properly typed
+arguments).
+@end defmac
+
 @node Running the Preprocessor
 @section Running the Preprocessor
 
@@ -6014,67 +6042,56 @@ compiling.  If Fortran 77 is the currently selected language then
 @code{FFLAGS} will be used when compiling.
 
 This macro does not try to link; use @code{AC_LINK_IFELSE} if you need
-to do that (@pxref{Examining Libraries}).
+to do that (@pxref{Running the Linker}).
 @end defmac
 
-@node Examining Libraries
-@section Examining Libraries
+@node Running the Linker
+@section Running the Linker
 
 To check for a library, a function, or a global variable, Autoconf
 @command{configure} scripts try to compile and link a small program that
-uses it.  This is unlike Metaconfig, which by default uses @code{nm}
-or @code{ar} on the C library to try to figure out which functions are
+uses it.  This is unlike Metaconfig, which by default uses @code{nm} or
+@code{ar} on the C library to try to figure out which functions are
 available.  Trying to link with the function is usually a more reliable
 approach because it avoids dealing with the variations in the options
 and output formats of @code{nm} and @code{ar} and in the location of the
 standard libraries.  It also allows configuring for cross-compilation or
-checking a function's run-time behavior if needed.  On the other hand, it
-can be slower than scanning the libraries once.
-
-A few systems have linkers that do not return a failure exit status when
-there are unresolved functions in the link.  This bug makes the
-configuration scripts produced by Autoconf unusable on those systems.
-However, some of them can be given options that make the exit status
-correct.  This is a problem that Autoconf does not currently handle
-automatically.  If users encounter this problem, they might be able to
-solve it by setting @code{LDFLAGS} in the environment to pass whatever
-options the linker needs (for example, @option{-Wl,-dn} on @sc{mips
-risc/os}).
-
-@code{AC_TRY_LINK} is used to compile test programs to test for
+checking a function's run-time behavior if needed.  On the other hand,
+it can be slower than scanning the libraries once, but accuracy is more
+important than speed.
+
+@c FIXME: Errr....  I doubt this matters today... --akim, 2002.
+@c A few systems have linkers that do not return a failure exit status when
+@c there are unresolved functions in the link.  This bug makes the
+@c configuration scripts produced by Autoconf unusable on those systems.
+@c However, some of them can be given options that make the exit status
+@c correct.  This is a problem that Autoconf does not currently handle
+@c automatically.  If users encounter this problem, they might be able to
+@c solve it by setting @code{LDFLAGS} in the environment to pass whatever
+@c options the linker needs (for example, @option{-Wl,-dn} on @sc{mips
+@c risc/os}).
+
+@code{AC_LINK_IFELSE} is used to compile test programs to test for
 functions and global variables.  It is also used by @code{AC_CHECK_LIB}
 to check for libraries (@pxref{Libraries}), by adding the library being
 checked for to @code{LIBS} temporarily and trying to link a small
 program.
 
-@defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @ovar{action-if-found}, @ovar{action-if-not-found})
-@acindex TRY_LINK
-Depending on the current language (@pxref{Language Choice}), create a
-test program to see whether a function whose body consists of
-@var{function-body} can be compiled and linked.  If the file compiles
-and links successfully, run shell commands @var{action-if-found},
-otherwise run @var{action-if-not-found}.
-
-This macro double quotes both @var{includes} and @var{function-body}.
 
-For C and C++, @var{includes} is any @code{#include} statements needed
-by the code in @var{function-body} (@var{includes} will be ignored if
-the currently selected language is Fortran 77).  This macro also uses
-@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently
-selected language, as well as @code{CPPFLAGS}, when compiling.  If
-Fortran 77 is the currently selected language then @code{FFLAGS} will be
-used when compiling.  However, both @code{LDFLAGS} and @code{LIBS} will
-be used during linking in all cases.
-@end defmac
+@defmac AC_LINK_IFELSE (@var{input}, @ovar{action-if-found}, @ovar{action-if-not-found})
+@acindex LINK_IFELSE
+Run the compiler and the linker of the current language (@pxref{Language
+Choice}) on the @var{input}, run the shell commands @var{action-if-true}
+on success, @var{action-if-false} otherwise. The @var{input} can be made
+by @code{AC_LANG_PROGRAM} and friends.
 
-@defmac AC_TRY_LINK_FUNC (@var{function}, @ovar{action-if-found}, @ovar{action-if-not-found})
-@acindex TRY_LINK_FUNC
-Depending on the current language (@pxref{Language Choice}), create a
-test program to see whether a program whose body consists of
-a prototype of and a call to @var{function} can be compiled and linked.
+This macro uses @code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is
+the currently selected language, as well as @code{CPPFLAGS}, when
+compiling.  If Fortran 77 is the currently selected language then
+@code{FFLAGS} will be used when compiling.
 
-If the file compiles and links successfully, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.
+This macro does not try to execute the program; use @code{AC_RUN_IFELSE}
+if you need to do that (@pxref{Run Time}).
 @end defmac
 
 
@@ -12402,8 +12419,8 @@ Same as @samp{AC_MSG_NOTICE([checking @var{feature-description}@dots{}]}.
 
 @defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found}, @ovar{action-if-not-found})
 @acindex COMPILE_CHECK
-This is an obsolete version of @code{AC_TRY_LINK} (@pxref{Examining
-Libraries}), with the addition that it prints @samp{checking for
+This is an obsolete version of @code{AC_TRY_COMPILE} (@pxref{Running the
+Compiler}), with the addition that it prints @samp{checking for
 @var{echo-text}} to the standard output first, if @var{echo-text} is
 non-empty.  Use @code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT} instead
 to print messages (@pxref{Printing Messages}).
@@ -12963,7 +12980,7 @@ issue.
 
 @defmac AC_TEST_CPP
 @acindex TEST_CPP
-@code{AC_TRY_CPP}
+@code{AC_TRY_CPP}, replaced with @code{AC_PREPROC_IFELSE}.
 @end defmac
 
 @defmac AC_TEST_PROGRAM
@@ -13007,6 +13024,40 @@ Preprocessor}).
 This macro double quotes the @var{input}.
 @end defmac
 
+@defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @ovar{action-if-found}, @ovar{action-if-not-found})
+@acindex TRY_LINK
+Same as @samp{AC_LINK_IFELSE([AC_LANG_SOURCE([[@var{includes}]],
+[[@var{function-body}]])], [@var{action-if-true}],
+[@var{action-if-false}])} (@pxref{Running the Compiler}).
+
+This macro double quotes both @var{includes} and @var{function-body}.
+
+Depending on the current language (@pxref{Language Choice}), create a
+test program to see whether a function whose body consists of
+@var{function-body} can be compiled and linked.  If the file compiles
+and links successfully, run shell commands @var{action-if-found},
+otherwise run @var{action-if-not-found}.
+
+This macro double quotes both @var{includes} and @var{function-body}.
+
+For C and C++, @var{includes} is any @code{#include} statements needed
+by the code in @var{function-body} (@var{includes} will be ignored if
+the currently selected language is Fortran 77).  This macro also uses
+@code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is the currently
+selected language, as well as @code{CPPFLAGS}, when compiling.  If
+Fortran 77 is the currently selected language then @code{FFLAGS} will be
+used when compiling.  However, both @code{LDFLAGS} and @code{LIBS} will
+be used during linking in all cases.
+@end defmac
+
+@defmac AC_TRY_LINK_FUNC (@var{function}, @ovar{action-if-found}, @ovar{action-if-not-found})
+@acindex TRY_LINK_FUNC
+This macro is equivalent to
+@samp{AC_LINK_IFELSE([AC_LANG_CALL([[@var{includes}]],
+[[@var{function-body}]])], [@var{action-if-true}],
+[@var{action-if-false}])}.
+@end defmac
+
 @defmac AC_UID_T
 @acindex UID_T
 @code{AC_TYPE_UID_T}
index 2820666987be7cc9e9d5f1e78fb865423934152f..7efd54bf5de5570335bb5187d87f073b292951ab 100644 (file)
@@ -690,8 +690,8 @@ AC_COMPILE_IFELSE(
   for ac_foobar in foobar FOOBAR; do
     for ac_underscore in "" "_"; do
       ac_func="$ac_foobar$ac_underscore"
-      AC_TRY_LINK_FUNC($ac_func,
-         [ac_success=yes; break 2])
+      AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
+                     [ac_success=yes; break 2])
     done
   done
 
@@ -710,8 +710,8 @@ AC_COMPILE_IFELSE(
      ac_success_extra=no
      for ac_extra in "" "_"; do
         ac_func="$ac_foo_bar$ac_underscore$ac_extra"
-        AC_TRY_LINK_FUNC($ac_func,
-        [ac_success_extra=yes; break])
+        AC_LINK_IFELSE([AC_LANG_CALL([], [$ac_func])],
+                       [ac_success_extra=yes; break])
      done
 
      if test "$ac_success_extra" = "yes"; then
index eaef76f0be5380d9d3dd66fd3739d164aa21fe94..1b2244c3cd034aaa0267e10090144e3950b4cec9 100644 (file)
@@ -2226,13 +2226,7 @@ _AC_LINK_IFELSE($@)])
 # AC_TRY_LINK(INCLUDES, FUNCTION-BODY,
 #             [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # -----------------------------------------------------
-# Should the INCLUDES be defaulted here?
 # Contrarily to AC_LINK_IFELSE, this macro double quote its first two args.
-# FIXME: WARNING: The code to compile was different in the case of
-# Fortran between AC_TRY_COMPILE and AC_TRY_LINK, though they should
-# equivalent as far as I can tell from the semantics and the docs.  In
-# the former, $[2] is used as is, in the latter, it is `call' ed.
-# Remove these FIXME: once truth established.
 AU_DEFUN([AC_TRY_LINK],
 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4])])
 
index 654c81f8e87c9a85c662b9548b8274348eda9c47..1594de18d659087db1b26ac37f73ff38d9358de2 100644 (file)
@@ -729,16 +729,19 @@ AU_DEFUN([AC_UNISTD_H],
 # Define `USG' if string functions are in strings.h.
 AU_DEFUN([AC_USG],
 [AC_DIAGNOSE([obsolete],
-[$0: Remove `AC_MSG_CHECKING', `AC_TRY_LINK' and this `AC_WARNING'
+[$0: Remove `AC_MSG_CHECKING', `AC_LINK_IFELSE' and this `AC_WARNING'
 when you adjust your code to use HAVE_STRING_H.])dnl
 AC_MSG_CHECKING([for BSD string and memory functions])
-AC_TRY_LINK([@%:@include <strings.h>], [rindex(0, 0); bzero(0, 0);],
-  [AC_MSG_RESULT(yes)],
-  [AC_MSG_RESULT(no)
-   AC_DEFINE(USG, 1,
-       [Define to 1 if you do not have <strings.h>, index, bzero, etc...
-        This symbol is obsolete, you should not depend upon it.])])
-AC_CHECK_HEADERS(string.h)])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <strings.h>]],
+                                [[rindex(0, 0); bzero(0, 0);]])],
+               [AC_MSG_RESULT(yes)],
+               [AC_MSG_RESULT(no)
+                AC_DEFINE(USG, 1,
+                          [Define to 1 if you do not have <strings.h>, index,
+                           bzero, etc... This symbol is obsolete, you should
+                           not depend upon it.])])
+AC_CHECK_HEADERS(string.h)
+])# AU::AC_USG
 
 
 # AU::AC_MEMORY_H
index aef77af4d0bdd045b8066fd5c38b09bec85df156..e886aae4124357bbede94abe03a64b6c1a190597 100644 (file)
@@ -70,12 +70,13 @@ AC_DEFUN([AC_SEARCH_LIBS],
 [AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
 [ac_func_search_save_LIBS=$LIBS
 ac_cv_search_$1=no
-AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
+AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
+               [ac_cv_search_$1="none required"])
 if test "$ac_cv_search_$1" = no; then
   for ac_lib in $2; do
     LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
-    AC_TRY_LINK_FUNC([$1],
-                     [ac_cv_search_$1="-l$ac_lib"
+    AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
+                   [ac_cv_search_$1="-l$ac_lib"
 break])
   done
 fi
@@ -120,9 +121,9 @@ AS_LITERAL_IF([$1],
 AC_CACHE_CHECK([for $2 in -l$1], ac_Lib,
 [ac_check_lib_save_LIBS=$LIBS
 LIBS="-l$1 $5 $LIBS"
-AC_TRY_LINK_FUNC([$2],
-                 [AS_VAR_SET(ac_Lib, yes)],
-                 [AS_VAR_SET(ac_Lib, no)])
+AC_LINK_IFELSE([AC_LANG_CALL([], [$2])],
+               [AS_VAR_SET(ac_Lib, yes)],
+               [AS_VAR_SET(ac_Lib, no)])
 LIBS=$ac_check_lib_save_LIBS])
 AS_IF([test AS_VAR_GET(ac_Lib) = yes],
       [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
@@ -277,11 +278,12 @@ if test "$ac_x_libraries" = no; then
   # Don't add to $LIBS permanently.
   ac_save_LIBS=$LIBS
   LIBS="-lXt $LIBS"
-  AC_TRY_LINK([@%:@include <X11/Intrinsic.h>], [XtMalloc (0)],
-[LIBS=$ac_save_LIBS
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <X11/Intrinsic.h>],
+                                  [XtMalloc (0)])],
+                 [LIBS=$ac_save_LIBS
 # We can link X programs with no special library path.
 ac_x_libraries=],
-[LIBS=$ac_save_LIBS
+                 [LIBS=$ac_save_LIBS
 for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
 do
   # Don't even attempt the hair of trying to link an X program!
@@ -416,7 +418,8 @@ dnl FIXME: banish uname from this macro!
     # libraries were built with DECnet support.  And Karl Berry says
     # the Alpha needs dnet_stub (dnet does not exist).
     ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
-    AC_TRY_LINK_FUNC(XOpenDisplay, ,
+    AC_LINK_IFELSE([AC_LANG_CALL([], [XOpenDisplay])],
+                   [],
     [AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
index 50d071de2298a4eff683a6d3f75ec72917c781c3..c4aff8dae8d8172bbfa174752b91b2205aeef7a1 100644 (file)
@@ -309,11 +309,12 @@ fi
 # --------------------
 AC_DEFUN([AC_SYS_POSIX_TERMIOS],
 [AC_CACHE_CHECK([POSIX termios], ac_cv_sys_posix_termios,
-[AC_TRY_LINK([#include <sys/types.h>
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
 #include <unistd.h>
-@%:@include <termios.h>],
+#include <termios.h>
+]],
              [/* SunOS 4.0.3 has termios.h but not the library calls.  */
-   tcgetattr(0, 0);],
+   tcgetattr(0, 0);])],
              ac_cv_sys_posix_termios=yes,
              ac_cv_sys_posix_termios=no)])
 ])# AC_SYS_POSIX_TERMIOS
index f45f7e2c5bc7010664b63b977b28b98b231fd269..86d48b7267e52ba03978824287d05a4a051c97d4 100644 (file)
@@ -605,13 +605,15 @@ if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
              `HAVE_STRUCT_TM_TM_ZONE' instead.])
 else
   AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
-[AC_TRY_LINK(
-[#include <time.h>
+[AC_LINK_IFELSE([AC_LANG_PROGRAM(
+[[#include <time.h>
 #ifndef tzname /* For SGI.  */
 extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
 #endif
-],
-[atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
+]],
+[atoi(*tzname);])],
+                [ac_cv_var_tzname=yes],
+                [ac_cv_var_tzname=no])])
   if test $ac_cv_var_tzname = yes; then
     AC_DEFINE(HAVE_TZNAME, 1,
               [Define to 1 if you don't have `tm_zone' but do have the external