autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

04-ac-link.patch


From: Akim Demaille
Subject: 04-ac-link.patch
Date: Sun, 27 Oct 2002 19:15:03 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * 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.

Index: doc/autoconf.texi
--- doc/autoconf.texi Sun, 27 Oct 2002 17:17:47 +0100 akim
+++ doc/autoconf.texi Sun, 27 Oct 2002 18:04:56 +0100 akim
@@ -285,7 +285,7 @@ @node Top
 * 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 @@ @node 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
@@ -5908,6 +5908,34 @@ @node Generating Sources
 @}
 @end example

+
address@hidden AC_LANG_CALL (@var{prologue}, @var{function})
address@hidden 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.,
address@hidden 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.
address@hidden defmac
+
+
address@hidden AC_LANG_FUNC_LINK_TRY (@var{prologue}, @var{function})
address@hidden 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).
address@hidden defmac
+
 @node Running the Preprocessor
 @section Running the Preprocessor

@@ -6014,67 +6042,56 @@ @node Running the Compiler
 @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

address@hidden Examining Libraries
address@hidden Examining Libraries
address@hidden Running the Linker
address@hidden 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
address@hidden 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.
+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.
+
address@hidden FIXME: Errr....  I doubt this matters today... --akim, 2002.
address@hidden A few systems have linkers that do not return a failure exit 
status when
address@hidden there are unresolved functions in the link.  This bug makes the
address@hidden configuration scripts produced by Autoconf unusable on those 
systems.
address@hidden However, some of them can be given options that make the exit 
status
address@hidden correct.  This is a problem that Autoconf does not currently 
handle
address@hidden automatically.  If users encounter this problem, they might be 
able to
address@hidden solve it by setting @code{LDFLAGS} in the environment to pass 
whatever
address@hidden options the linker needs (for example, @option{-Wl,-dn} on 
@sc{mips
address@hidden risc/os}).

-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}).
-
address@hidden is used to compile test programs to test for
address@hidden 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.

address@hidden AC_TRY_LINK (@var{includes}, @var{function-body}, 
@ovar{action-if-found}, @ovar{action-if-not-found})
address@hidden TRY_LINK
-Depending on the current language (@pxref{Language Choice}), create a
-test program to see whether a function whose body consists of
address@hidden 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
address@hidden 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.
address@hidden defmac
address@hidden AC_LINK_IFELSE (@var{input}, @ovar{action-if-found}, 
@ovar{action-if-not-found})
address@hidden 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.

address@hidden AC_TRY_LINK_FUNC (@var{function}, @ovar{action-if-found}, 
@ovar{action-if-not-found})
address@hidden 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
address@hidden will be used when compiling.

-If the file compiles and links successfully, run shell commands
address@hidden, 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 @@ @node Obsolete Macros

 @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 @@ is:

 @defmac AC_TEST_CPP
 @acindex TEST_CPP
address@hidden
address@hidden, replaced with @code{AC_PREPROC_IFELSE}.
 @end defmac

 @defmac AC_TEST_PROGRAM
@@ -13005,6 +13022,40 @@ is:
 Preprocessor}).

 This macro double quotes the @var{input}.
address@hidden defmac
+
address@hidden AC_TRY_LINK (@var{includes}, @var{function-body}, 
@ovar{action-if-found}, @ovar{action-if-not-found})
address@hidden TRY_LINK
+Same as @samp{AC_LINK_IFELSE([AC_LANG_SOURCE(address@hidden,
address@hidden)], address@hidden,
address@hidden)} (@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
address@hidden 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
address@hidden 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.
address@hidden defmac
+
address@hidden AC_TRY_LINK_FUNC (@var{function}, @ovar{action-if-found}, 
@ovar{action-if-not-found})
address@hidden TRY_LINK_FUNC
+This macro is equivalent to
address@hidden([AC_LANG_CALL(address@hidden,
address@hidden)], address@hidden,
address@hidden)}.
 @end defmac

 @defmac AC_UID_T
Index: lib/autoconf/fortran.m4
--- lib/autoconf/fortran.m4 Sun, 27 Oct 2002 17:17:47 +0100 akim
+++ lib/autoconf/fortran.m4 Sun, 27 Oct 2002 18:00:22 +0100 akim
@@ -690,8 +690,8 @@ AC_DEFUN([_AC_F77_NAME_MANGLING],
   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_DEFUN([_AC_F77_NAME_MANGLING],
      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: lib/autoconf/general.m4
--- lib/autoconf/general.m4 Sun, 27 Oct 2002 17:17:47 +0100 akim
+++ lib/autoconf/general.m4 Sun, 27 Oct 2002 17:25:39 +0100 akim
@@ -2226,13 +2226,7 @@ AC_DEFUN([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: lib/autoconf/headers.m4
--- lib/autoconf/headers.m4 Sun, 27 Oct 2002 17:17:47 +0100 akim
+++ lib/autoconf/headers.m4 Sun, 27 Oct 2002 18:02:41 +0100 akim
@@ -729,16 +729,19 @@ AC_DEFUN([AC_HEADER_TIOCGWINSZ],
 # 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(address@hidden:@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(address@hidden:@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: lib/autoconf/libs.m4
--- lib/autoconf/libs.m4 Sat, 28 Sep 2002 17:01:27 +0200 akim
+++ lib/autoconf/libs.m4 Sun, 27 Oct 2002 18:02:02 +0100 akim
@@ -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 @@ AC_DEFUN([AC_CHECK_LIB],
 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 @@ m4_define([_AC_PATH_X_DIRECT],
   # Don't add to $LIBS permanently.
   ac_save_LIBS=$LIBS
   LIBS="-lXt $LIBS"
-  AC_TRY_LINK(address@hidden:@include <X11/Intrinsic.h>], [XtMalloc (0)],
-[LIBS=$ac_save_LIBS
+  AC_LINK_IFELSE([AC_LANG_PROGRAM(address@hidden:@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 @@ AC_DEFUN([AC_PATH_XTRA],
     # 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: lib/autoconf/specific.m4
--- lib/autoconf/specific.m4 Sun, 13 Oct 2002 10:08:25 +0200 akim
+++ lib/autoconf/specific.m4 Sun, 27 Oct 2002 18:00:22 +0100 akim
@@ -309,11 +309,12 @@ AC_DEFUN([AC_SYS_RESTARTABLE_SYSCALLS],
 # --------------------
 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>
address@hidden:@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: lib/autoconf/types.m4
--- lib/autoconf/types.m4 Sun, 27 Oct 2002 17:17:47 +0100 akim
+++ lib/autoconf/types.m4 Sun, 27 Oct 2002 18:00:10 +0100 akim
@@ -605,13 +605,15 @@ AC_DEFUN([AC_STRUCT_TIMEZONE],
              `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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]