From 8b9cd578867c22faca8d9873168fa4cbfc4f55c7 Mon Sep 17 00:00:00 2001 From: David MacKenzie Date: Sun, 23 Oct 1994 02:08:04 +0000 Subject: [PATCH] add AC_TRY_COMPILE --- NEWS | 19 +++++----- acgeneral.m4 | 39 +++++++++++++++++--- acspecific.m4 | 38 ++++++++++--------- autoconf.texi | 80 ++++++++++++++++++++++++++-------------- doc/autoconf.texi | 80 ++++++++++++++++++++++++++-------------- lib/autoconf/general.m4 | 39 +++++++++++++++++--- lib/autoconf/specific.m4 | 38 ++++++++++--------- 7 files changed, 224 insertions(+), 109 deletions(-) diff --git a/NEWS b/NEWS index cbb01101..eaab9430 100644 --- a/NEWS +++ b/NEWS @@ -46,19 +46,20 @@ Major changes in release 2.0: * AC_CONFIG_AUX_DIR, AC_CANONICAL_SYSTEM, AC_CANONICAL_HOST, AC_LINK_FILES to support deciding unguessable features based on the host and target types. * AC_CONFIG_SUBDIRS to recursively configure a source tree. -* AC_ARG_PROGRAM, which uses the options --program-prefix, +* AC_ARG_PROGRAM to use the options --program-prefix, --program-suffix, and --program-transform-name to change the names of programs being installed. -* AC_PREFIX_DEFAULT, to change the default prefix. -* AC_CHECK_TYPE, which checks whether sys/types.h defines a given type. -* AC_CHECK_LIB, which checks for a particular function in a library. +* AC_PREFIX_DEFAULT to change the default prefix. +* AC_TRY_COMPILE to compile a test program without linking it. +* AC_CHECK_TYPE to check whether sys/types.h defines a given type. +* AC_CHECK_LIB to check for a particular function in a library. * AC_MSG_CHECKING and AC_MSG_RESULT to print test results, on a single line, whether or not the test succeeds. They obsolete AC_CHECKING and AC_VERBOSE. -* AC_SUBST_FILE, to insert one file into another. -* AC_FUNC_MEMCMP, to check whether memcmp is 8-bit clean. -* AC_FUNC_STRFTIME, to find strftime even if it's in -lintl. -* AC_FUNC_GETMNTENT, to find getmntent even if it's in -lsun or -lseq. -* AC_HEADER_SYS_WAIT, to check whether sys/wait.h is POSIX.1 compatible. +* AC_SUBST_FILE to insert one file into another. +* AC_FUNC_MEMCMP to check whether memcmp is 8-bit clean. +* AC_FUNC_STRFTIME to find strftime even if it's in -lintl. +* AC_FUNC_GETMNTENT to find getmntent even if it's in -lsun or -lseq. +* AC_HEADER_SYS_WAIT to check whether sys/wait.h is POSIX.1 compatible. ** Changed macros: * Many macros renamed systematically, but old names are accepted for diff --git a/acgeneral.m4 b/acgeneral.m4 index ab3298b5..d3a93057 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -51,7 +51,7 @@ dnl divert(-1)dnl Throw away output until AC_INIT is called. changequote([, ]) -define(AC_ACVERSION, 1.124) +define(AC_ACVERSION, 1.125) dnl Some old m4's don't support m4exit. But they provide dnl equivalent functionality by core dumping because of the @@ -1008,6 +1008,7 @@ AC_DEFUN(AC_LANG_C, ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} $CFLAGS $CPPFLAGS conftest.$ac_ext -c 1>&AC_FD_CC 2>&AC_FD_CC' ac_link='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC' ]) @@ -1017,6 +1018,7 @@ AC_DEFUN(AC_LANG_CPLUSPLUS, ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='${CXX-gcc} $CXXFLAGS $CPPFLAGS conftest.$ac_ext -c 1>&AC_FD_CC 2>&AC_FD_CC' ac_link='${CXX-gcc} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC' ]) @@ -1291,13 +1293,42 @@ rm -f conftest* ]) +dnl ### Examining syntax + + +dnl AC_TRY_COMPILE(INCLUDES, FUNCTION-BODY, +dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) +AC_DEFUN(AC_TRY_COMPILE, +[cat > conftest.$ac_ext < +[AC_TRY_COMPILE([#include #include <$1>], [DIR *dirp = 0;], eval "ac_cv_header_dirent_$ac_safe=yes", eval "ac_cv_header_dirent_$ac_safe=no")])dnl @@ -615,7 +616,7 @@ fi AC_DEFUN(AC_DECL_SYS_SIGLIST, [AC_MSG_CHECKING([for sys_siglist declaration in signal.h or unistd.h]) AC_CACHE_VAL(ac_cv_decl_sys_siglist, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include /* NetBSD declares sys_siglist in unistd.h. */ #ifdef HAVE_UNISTD_H @@ -631,7 +632,7 @@ fi AC_DEFUN(AC_HEADER_SYS_WAIT, [AC_MSG_CHECKING([for sys/wait.h that is POSIX.1 compatible]) AC_CACHE_VAL(ac_cv_header_sys_wait_h, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include #ifndef WEXITSTATUS #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) @@ -722,7 +723,7 @@ dnl Note that identifiers starting with SIG are reserved by ANSI C. AC_DEFUN(AC_TYPE_SIGNAL, [AC_MSG_CHECKING([return type of signal handlers]) AC_CACHE_VAL(ac_cv_type_signal, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include #ifdef signal #undef signal @@ -1132,7 +1133,7 @@ AC_CHECK_HEADER(nlist.h, [AC_DEFINE(NLIST_STRUCT) AC_MSG_CHECKING([for n_un in struct nlist]) AC_CACHE_VAL(ac_cv_struct_nlist_n_un, -[AC_TRY_LINK([#include ], +[AC_TRY_COMPILE([#include ], [struct nlist n; n.n_un.n_name = 0;], ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])dnl AC_MSG_RESULT($ac_cv_struct_nlist_n_un) @@ -1270,7 +1271,7 @@ dnl ### Checks for structure members AC_DEFUN(AC_HEADER_TIME, [AC_MSG_CHECKING([whether time.h and sys/time.h may both be included]) AC_CACHE_VAL(ac_cv_header_time, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include #include ], [struct tm *tp;], ac_cv_header_time=yes, ac_cv_header_time=no)])dnl @@ -1283,7 +1284,7 @@ fi AC_DEFUN(AC_STRUCT_TM, [AC_MSG_CHECKING([whether struct tm is in sys/time.h or time.h]) AC_CACHE_VAL(ac_cv_struct_tm, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include ], [struct tm *tp; tp->tm_sec;], ac_cv_struct_tm=time.h, ac_cv_struct_tm=sys/time.h)])dnl @@ -1297,7 +1298,7 @@ AC_DEFUN(AC_STRUCT_TIMEZONE, [AC_REQUIRE([AC_STRUCT_TM])dnl AC_MSG_CHECKING([for tm_zone in struct tm]) AC_CACHE_VAL(ac_cv_struct_tm_zone, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;], ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])dnl AC_MSG_RESULT($ac_cv_struct_tm_zone) @@ -1324,7 +1325,7 @@ fi AC_DEFUN(AC_STRUCT_ST_BLOCKS, [AC_MSG_CHECKING([for st_blocks in struct stat]) AC_CACHE_VAL(ac_cv_struct_st_blocks, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include ], [struct stat s; s.st_blocks;], ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])dnl AC_MSG_RESULT($ac_cv_struct_st_blocks) @@ -1339,7 +1340,7 @@ AC_SUBST(LIBOBJS)dnl AC_DEFUN(AC_STRUCT_ST_BLKSIZE, [AC_MSG_CHECKING([for st_blksize in struct stat]) AC_CACHE_VAL(ac_cv_struct_st_blksize, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include ], [struct stat s; s.st_blksize;], ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)])dnl AC_MSG_RESULT($ac_cv_struct_st_blksize) @@ -1351,7 +1352,7 @@ fi AC_DEFUN(AC_STRUCT_ST_RDEV, [AC_MSG_CHECKING([for st_rdev in struct stat]) AC_CACHE_VAL(ac_cv_struct_st_rdev, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include ], [struct stat s; s.st_rdev;], ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)])dnl AC_MSG_RESULT($ac_cv_struct_st_rdev) @@ -1458,7 +1459,7 @@ AC_DEFUN(AC_C_INLINE, [AC_MSG_CHECKING([for inline]) AC_CACHE_VAL(ac_cv_c_inline, [if test "$GCC" = yes; then -AC_TRY_LINK(, [} inline foo() {], ac_cv_c_inline=yes, ac_cv_c_inline=no) +AC_TRY_COMPILE(, [} inline foo() {], ac_cv_c_inline=yes, ac_cv_c_inline=no) else ac_cv_c_inline=no fi])dnl @@ -1473,7 +1474,7 @@ AC_DEFUN(AC_C_CONST, dnl and with the result message. AC_MSG_CHECKING([for working const]) AC_CACHE_VAL(ac_cv_c_const, -[AC_TRY_LINK(, +[AC_TRY_COMPILE(, changequote(<<, >>)dnl << /* Ultrix mips cc rejects this. */ @@ -1870,7 +1871,8 @@ dnl These are kludges which should be replaced by a single POSIX check. AC_DEFUN(AC_AIX, -[AC_BEFORE([$0], [AC_TRY_LINK])dnl +[AC_BEFORE([$0], [AC_TRY_COMPILE])dnl +AC_BEFORE([$0], [AC_TRY_LINK])dnl AC_BEFORE([$0], [AC_TRY_RUN])dnl AC_MSG_CHECKING(for AIX) AC_EGREP_CPP(yes, @@ -1881,7 +1883,8 @@ AC_EGREP_CPP(yes, ]) AC_DEFUN(AC_MINIX, -[AC_BEFORE([$0], [AC_TRY_LINK])dnl +[AC_BEFORE([$0], [AC_TRY_COMPILE])dnl +AC_BEFORE([$0], [AC_TRY_LINK])dnl AC_BEFORE([$0], [AC_TRY_RUN])dnl AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=) if test "$MINIX" = yes; then @@ -1893,6 +1896,7 @@ fi AC_DEFUN(AC_ISC_POSIX, [AC_BEFORE([$0], [AC_TRY_LINK])dnl +AC_BEFORE([$0], [AC_TRY_LINK])dnl AC_BEFORE([$0], [AC_TRY_RUN])dnl AC_MSG_CHECKING(for POSIXized ISC) if test -d /etc/conf/kconfig.d && diff --git a/autoconf.texi b/autoconf.texi index 568fade4..32185412 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -6,8 +6,8 @@ @c @setchapternewpage odd @c %**end of header -@set EDITION 1.124 -@set VERSION 1.124 +@set EDITION 1.125 +@set VERSION 1.125 @set UPDATED October 1994 @iftex @@ -184,6 +184,7 @@ Typedefs Writing Tests * Examining Declarations:: Detecting header files and declarations. +* Examining Syntax:: Detecting language syntax features. * Examining Libraries:: Detecting functions and global variables. * Run Time:: Testing for run-time features. * Portable Shell:: Shell script portability pitfalls. @@ -490,14 +491,18 @@ checks for system services When calling macros that take arguments, there must not be any blank space between the macro name and the open parenthesis. Arguments can be more than one line long if they are enclosed within the @code{m4} quote -characters @samp{[} and @samp{]}. Some macros handle two cases: what -to do if the given condition is met, and what to do if the condition is -not met. In some places you might want to do something if a -condition is true but do nothing if it's false, or vice versa. To omit -the true case, pass an empty value for the @var{action-if-found} -argument to the macro. To omit the false case, omit the -@var{action-if-not-found} argument to the macro, including the comma -before it. +characters @samp{[} and @samp{]}. If you have a long line such as a +list of file names, you can generally use a backslash at the end of a +line to continue it logically on the next line (this is implemented by +the shell, not by anything special that Autoconf does). + +Some macros handle two cases: what to do if the given condition is met, +and what to do if the condition is not met. In some places you might +want to do something if a condition is true but do nothing if it's +false, or vice versa. To omit the true case, pass an empty value for +the @var{action-if-found} argument to the macro. To omit the false +case, omit the @var{action-if-not-found} argument to the macro, +including the comma before it. You can include comments in @file{configure.in} files by starting them with the @code{m4} builtin macro @code{dnl}, which discards text up @@ -2146,9 +2151,9 @@ is executed when one of the header files is not found. @section Structures The following macros check for certain structures or structure members. -To check structures not listed here, you can use @code{AC_EGREP_CPP} -(@pxref{Examining Declarations}) or @code{AC_TRY_LINK} (@pxref{Examining -Libraries}) +To check structures not listed here, use @code{AC_EGREP_CPP} +(@pxref{Examining Declarations}) or @code{AC_TRY_COMPILE} +(@pxref{Examining Syntax}). @defmac AC_HEADER_STAT @maindex HEADER_STAT @@ -2326,9 +2331,9 @@ builtin type @var{default}; e.g., @samp{short} or @samp{unsigned}. @section Compiler Characteristics The following macros check for C compiler or machine architecture -features. You can use @code{AC_TRY_LINK} (@pxref{Examining Libraries}) -or @code{AC_TRY_RUN} (@pxref{Run Time}) to check for -characteristics not listed here. +features. To check for characteristics not listed here, use +@code{AC_TRY_COMPILE} (@pxref{Examining Syntax}) or @code{AC_TRY_RUN} +(@pxref{Run Time}) @defmac AC_C_BIGENDIAN @maindex C_BIGENDIAN @@ -2560,6 +2565,7 @@ about what they're checking for. @menu * Examining Declarations:: Detecting header files and declarations. +* Examining Syntax:: Detecting language syntax features. * Examining Libraries:: Detecting functions and global variables. * Run Time:: Testing for run-time features. * Portable Shell:: Shell script portability pitfalls. @@ -2568,7 +2574,7 @@ about what they're checking for. * Language Choice:: Selecting which language to use for testing. @end menu -@node Examining Declarations, Examining Libraries, , Writing Tests +@node Examining Declarations, Examining Syntax, , Writing Tests @section Examining Declarations The macro @code{AC_TRY_CPP} is used to check whether particular header @@ -2628,7 +2634,27 @@ on which language is current, @pxref{Language Choice}), if it hasn't been called already. @end defmac -@node Examining Libraries, Run Time, Examining Declarations, Writing Tests +@node Examining Syntax, Examining Libraries, Examining Declarations, Writing Tests +@section Examining Syntax + +To check for a syntax feature of the C or C++ compiler, such as whether +it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to try to +compile a small program that uses that feature. You can also use it to +check for structures and structure members that are not present on all +systems. + +@defmac AC_TRY_COMPILE (@var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) +@maindex TRY_COMPILE +Create a test C program to see whether a function whose body consists of +@var{function-body} can be compiled; @var{includes} is any +@code{#include} statements needed by the code in @var{function-body}. +If the file compiles successfully, run shell commands +@var{action-if-found}, otherwise run @var{action-if-not-found}. This +macro uses @code{CFLAGS} or @code{CXXFLAGS}, and @code{CPPFLAGS}, when +compiling. +@end defmac + +@node Examining Libraries, Run Time, Examining Syntax, Writing Tests @section Examining Libraries To check for a library, a function, or a global variable, Autoconf @@ -2649,12 +2675,11 @@ 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. -The below macro is used to compile test programs to test for functions -and global variables. It is also used to check for libraries, by adding -the library being checked for to @code{LIBS} temporarily and trying to -link a small program. And it is used to check matters of C syntax, such -as whether a particular keyword is recognized---a test program using a -keyword does not compile on systems that don't support it. +@code{AC_TRY_LINK} 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, 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}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) @maindex TRY_LINK @@ -3094,13 +3119,14 @@ newlines. @defmac AC_SUBST_FILE (@var{variable}) @maindex SUBST_FILE -Another way to create an output variable from a shell variable. -Make @code{AC_OUTPUT} substitute the contents of the file named by shell +Another way to create an output variable from a shell variable. Make +@code{AC_OUTPUT} substitute the contents of the file named by shell variable @var{variable} into output files (typically one or more @file{Makefile}s). This means that @code{AC_OUTPUT} will replace instances of @samp{@@@var{variable}@@} in the @file{Makefile.in} files with the contents of the file that the shell variable @var{variable} -names when @code{AC_OUTPUT} is called. +names when @code{AC_OUTPUT} is called. Set the variable to +@file{/dev/null} for cases which do not have a file to insert. This macro is useful for inserting @file{Makefile} fragments containing special dependencies or other @code{make} directives for particular host diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 568fade4..32185412 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -6,8 +6,8 @@ @c @setchapternewpage odd @c %**end of header -@set EDITION 1.124 -@set VERSION 1.124 +@set EDITION 1.125 +@set VERSION 1.125 @set UPDATED October 1994 @iftex @@ -184,6 +184,7 @@ Typedefs Writing Tests * Examining Declarations:: Detecting header files and declarations. +* Examining Syntax:: Detecting language syntax features. * Examining Libraries:: Detecting functions and global variables. * Run Time:: Testing for run-time features. * Portable Shell:: Shell script portability pitfalls. @@ -490,14 +491,18 @@ checks for system services When calling macros that take arguments, there must not be any blank space between the macro name and the open parenthesis. Arguments can be more than one line long if they are enclosed within the @code{m4} quote -characters @samp{[} and @samp{]}. Some macros handle two cases: what -to do if the given condition is met, and what to do if the condition is -not met. In some places you might want to do something if a -condition is true but do nothing if it's false, or vice versa. To omit -the true case, pass an empty value for the @var{action-if-found} -argument to the macro. To omit the false case, omit the -@var{action-if-not-found} argument to the macro, including the comma -before it. +characters @samp{[} and @samp{]}. If you have a long line such as a +list of file names, you can generally use a backslash at the end of a +line to continue it logically on the next line (this is implemented by +the shell, not by anything special that Autoconf does). + +Some macros handle two cases: what to do if the given condition is met, +and what to do if the condition is not met. In some places you might +want to do something if a condition is true but do nothing if it's +false, or vice versa. To omit the true case, pass an empty value for +the @var{action-if-found} argument to the macro. To omit the false +case, omit the @var{action-if-not-found} argument to the macro, +including the comma before it. You can include comments in @file{configure.in} files by starting them with the @code{m4} builtin macro @code{dnl}, which discards text up @@ -2146,9 +2151,9 @@ is executed when one of the header files is not found. @section Structures The following macros check for certain structures or structure members. -To check structures not listed here, you can use @code{AC_EGREP_CPP} -(@pxref{Examining Declarations}) or @code{AC_TRY_LINK} (@pxref{Examining -Libraries}) +To check structures not listed here, use @code{AC_EGREP_CPP} +(@pxref{Examining Declarations}) or @code{AC_TRY_COMPILE} +(@pxref{Examining Syntax}). @defmac AC_HEADER_STAT @maindex HEADER_STAT @@ -2326,9 +2331,9 @@ builtin type @var{default}; e.g., @samp{short} or @samp{unsigned}. @section Compiler Characteristics The following macros check for C compiler or machine architecture -features. You can use @code{AC_TRY_LINK} (@pxref{Examining Libraries}) -or @code{AC_TRY_RUN} (@pxref{Run Time}) to check for -characteristics not listed here. +features. To check for characteristics not listed here, use +@code{AC_TRY_COMPILE} (@pxref{Examining Syntax}) or @code{AC_TRY_RUN} +(@pxref{Run Time}) @defmac AC_C_BIGENDIAN @maindex C_BIGENDIAN @@ -2560,6 +2565,7 @@ about what they're checking for. @menu * Examining Declarations:: Detecting header files and declarations. +* Examining Syntax:: Detecting language syntax features. * Examining Libraries:: Detecting functions and global variables. * Run Time:: Testing for run-time features. * Portable Shell:: Shell script portability pitfalls. @@ -2568,7 +2574,7 @@ about what they're checking for. * Language Choice:: Selecting which language to use for testing. @end menu -@node Examining Declarations, Examining Libraries, , Writing Tests +@node Examining Declarations, Examining Syntax, , Writing Tests @section Examining Declarations The macro @code{AC_TRY_CPP} is used to check whether particular header @@ -2628,7 +2634,27 @@ on which language is current, @pxref{Language Choice}), if it hasn't been called already. @end defmac -@node Examining Libraries, Run Time, Examining Declarations, Writing Tests +@node Examining Syntax, Examining Libraries, Examining Declarations, Writing Tests +@section Examining Syntax + +To check for a syntax feature of the C or C++ compiler, such as whether +it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to try to +compile a small program that uses that feature. You can also use it to +check for structures and structure members that are not present on all +systems. + +@defmac AC_TRY_COMPILE (@var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) +@maindex TRY_COMPILE +Create a test C program to see whether a function whose body consists of +@var{function-body} can be compiled; @var{includes} is any +@code{#include} statements needed by the code in @var{function-body}. +If the file compiles successfully, run shell commands +@var{action-if-found}, otherwise run @var{action-if-not-found}. This +macro uses @code{CFLAGS} or @code{CXXFLAGS}, and @code{CPPFLAGS}, when +compiling. +@end defmac + +@node Examining Libraries, Run Time, Examining Syntax, Writing Tests @section Examining Libraries To check for a library, a function, or a global variable, Autoconf @@ -2649,12 +2675,11 @@ 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. -The below macro is used to compile test programs to test for functions -and global variables. It is also used to check for libraries, by adding -the library being checked for to @code{LIBS} temporarily and trying to -link a small program. And it is used to check matters of C syntax, such -as whether a particular keyword is recognized---a test program using a -keyword does not compile on systems that don't support it. +@code{AC_TRY_LINK} 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, 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}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) @maindex TRY_LINK @@ -3094,13 +3119,14 @@ newlines. @defmac AC_SUBST_FILE (@var{variable}) @maindex SUBST_FILE -Another way to create an output variable from a shell variable. -Make @code{AC_OUTPUT} substitute the contents of the file named by shell +Another way to create an output variable from a shell variable. Make +@code{AC_OUTPUT} substitute the contents of the file named by shell variable @var{variable} into output files (typically one or more @file{Makefile}s). This means that @code{AC_OUTPUT} will replace instances of @samp{@@@var{variable}@@} in the @file{Makefile.in} files with the contents of the file that the shell variable @var{variable} -names when @code{AC_OUTPUT} is called. +names when @code{AC_OUTPUT} is called. Set the variable to +@file{/dev/null} for cases which do not have a file to insert. This macro is useful for inserting @file{Makefile} fragments containing special dependencies or other @code{make} directives for particular host diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index ab3298b5..d3a93057 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -51,7 +51,7 @@ dnl divert(-1)dnl Throw away output until AC_INIT is called. changequote([, ]) -define(AC_ACVERSION, 1.124) +define(AC_ACVERSION, 1.125) dnl Some old m4's don't support m4exit. But they provide dnl equivalent functionality by core dumping because of the @@ -1008,6 +1008,7 @@ AC_DEFUN(AC_LANG_C, ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} $CFLAGS $CPPFLAGS conftest.$ac_ext -c 1>&AC_FD_CC 2>&AC_FD_CC' ac_link='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC' ]) @@ -1017,6 +1018,7 @@ AC_DEFUN(AC_LANG_CPLUSPLUS, ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='${CXX-gcc} $CXXFLAGS $CPPFLAGS conftest.$ac_ext -c 1>&AC_FD_CC 2>&AC_FD_CC' ac_link='${CXX-gcc} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC' ]) @@ -1291,13 +1293,42 @@ rm -f conftest* ]) +dnl ### Examining syntax + + +dnl AC_TRY_COMPILE(INCLUDES, FUNCTION-BODY, +dnl ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) +AC_DEFUN(AC_TRY_COMPILE, +[cat > conftest.$ac_ext < +[AC_TRY_COMPILE([#include #include <$1>], [DIR *dirp = 0;], eval "ac_cv_header_dirent_$ac_safe=yes", eval "ac_cv_header_dirent_$ac_safe=no")])dnl @@ -615,7 +616,7 @@ fi AC_DEFUN(AC_DECL_SYS_SIGLIST, [AC_MSG_CHECKING([for sys_siglist declaration in signal.h or unistd.h]) AC_CACHE_VAL(ac_cv_decl_sys_siglist, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include /* NetBSD declares sys_siglist in unistd.h. */ #ifdef HAVE_UNISTD_H @@ -631,7 +632,7 @@ fi AC_DEFUN(AC_HEADER_SYS_WAIT, [AC_MSG_CHECKING([for sys/wait.h that is POSIX.1 compatible]) AC_CACHE_VAL(ac_cv_header_sys_wait_h, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include #ifndef WEXITSTATUS #define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) @@ -722,7 +723,7 @@ dnl Note that identifiers starting with SIG are reserved by ANSI C. AC_DEFUN(AC_TYPE_SIGNAL, [AC_MSG_CHECKING([return type of signal handlers]) AC_CACHE_VAL(ac_cv_type_signal, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include #ifdef signal #undef signal @@ -1132,7 +1133,7 @@ AC_CHECK_HEADER(nlist.h, [AC_DEFINE(NLIST_STRUCT) AC_MSG_CHECKING([for n_un in struct nlist]) AC_CACHE_VAL(ac_cv_struct_nlist_n_un, -[AC_TRY_LINK([#include ], +[AC_TRY_COMPILE([#include ], [struct nlist n; n.n_un.n_name = 0;], ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])dnl AC_MSG_RESULT($ac_cv_struct_nlist_n_un) @@ -1270,7 +1271,7 @@ dnl ### Checks for structure members AC_DEFUN(AC_HEADER_TIME, [AC_MSG_CHECKING([whether time.h and sys/time.h may both be included]) AC_CACHE_VAL(ac_cv_header_time, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include #include ], [struct tm *tp;], ac_cv_header_time=yes, ac_cv_header_time=no)])dnl @@ -1283,7 +1284,7 @@ fi AC_DEFUN(AC_STRUCT_TM, [AC_MSG_CHECKING([whether struct tm is in sys/time.h or time.h]) AC_CACHE_VAL(ac_cv_struct_tm, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include ], [struct tm *tp; tp->tm_sec;], ac_cv_struct_tm=time.h, ac_cv_struct_tm=sys/time.h)])dnl @@ -1297,7 +1298,7 @@ AC_DEFUN(AC_STRUCT_TIMEZONE, [AC_REQUIRE([AC_STRUCT_TM])dnl AC_MSG_CHECKING([for tm_zone in struct tm]) AC_CACHE_VAL(ac_cv_struct_tm_zone, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;], ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])dnl AC_MSG_RESULT($ac_cv_struct_tm_zone) @@ -1324,7 +1325,7 @@ fi AC_DEFUN(AC_STRUCT_ST_BLOCKS, [AC_MSG_CHECKING([for st_blocks in struct stat]) AC_CACHE_VAL(ac_cv_struct_st_blocks, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include ], [struct stat s; s.st_blocks;], ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])dnl AC_MSG_RESULT($ac_cv_struct_st_blocks) @@ -1339,7 +1340,7 @@ AC_SUBST(LIBOBJS)dnl AC_DEFUN(AC_STRUCT_ST_BLKSIZE, [AC_MSG_CHECKING([for st_blksize in struct stat]) AC_CACHE_VAL(ac_cv_struct_st_blksize, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include ], [struct stat s; s.st_blksize;], ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)])dnl AC_MSG_RESULT($ac_cv_struct_st_blksize) @@ -1351,7 +1352,7 @@ fi AC_DEFUN(AC_STRUCT_ST_RDEV, [AC_MSG_CHECKING([for st_rdev in struct stat]) AC_CACHE_VAL(ac_cv_struct_st_rdev, -[AC_TRY_LINK([#include +[AC_TRY_COMPILE([#include #include ], [struct stat s; s.st_rdev;], ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)])dnl AC_MSG_RESULT($ac_cv_struct_st_rdev) @@ -1458,7 +1459,7 @@ AC_DEFUN(AC_C_INLINE, [AC_MSG_CHECKING([for inline]) AC_CACHE_VAL(ac_cv_c_inline, [if test "$GCC" = yes; then -AC_TRY_LINK(, [} inline foo() {], ac_cv_c_inline=yes, ac_cv_c_inline=no) +AC_TRY_COMPILE(, [} inline foo() {], ac_cv_c_inline=yes, ac_cv_c_inline=no) else ac_cv_c_inline=no fi])dnl @@ -1473,7 +1474,7 @@ AC_DEFUN(AC_C_CONST, dnl and with the result message. AC_MSG_CHECKING([for working const]) AC_CACHE_VAL(ac_cv_c_const, -[AC_TRY_LINK(, +[AC_TRY_COMPILE(, changequote(<<, >>)dnl << /* Ultrix mips cc rejects this. */ @@ -1870,7 +1871,8 @@ dnl These are kludges which should be replaced by a single POSIX check. AC_DEFUN(AC_AIX, -[AC_BEFORE([$0], [AC_TRY_LINK])dnl +[AC_BEFORE([$0], [AC_TRY_COMPILE])dnl +AC_BEFORE([$0], [AC_TRY_LINK])dnl AC_BEFORE([$0], [AC_TRY_RUN])dnl AC_MSG_CHECKING(for AIX) AC_EGREP_CPP(yes, @@ -1881,7 +1883,8 @@ AC_EGREP_CPP(yes, ]) AC_DEFUN(AC_MINIX, -[AC_BEFORE([$0], [AC_TRY_LINK])dnl +[AC_BEFORE([$0], [AC_TRY_COMPILE])dnl +AC_BEFORE([$0], [AC_TRY_LINK])dnl AC_BEFORE([$0], [AC_TRY_RUN])dnl AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=) if test "$MINIX" = yes; then @@ -1893,6 +1896,7 @@ fi AC_DEFUN(AC_ISC_POSIX, [AC_BEFORE([$0], [AC_TRY_LINK])dnl +AC_BEFORE([$0], [AC_TRY_LINK])dnl AC_BEFORE([$0], [AC_TRY_RUN])dnl AC_MSG_CHECKING(for POSIXized ISC) if test -d /etc/conf/kconfig.d &&