mirror of
git://git.sv.gnu.org/autoconf
synced 2025-01-30 11:01:45 +08:00
* 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.
This commit is contained in:
parent
b2504ea98a
commit
459078b633
14
ChangeLog
14
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.
|
||||
|
@ -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.
|
||||
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.
|
||||
|
||||
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}).
|
||||
@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_TRY_LINK} is used to compile test programs to test for
|
||||
@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}.
|
||||
@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.
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
@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.
|
||||
|
||||
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}
|
||||
|
@ -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
|
||||
|
@ -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])])
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user