diff --git a/NEWS b/NEWS index 73f70f4c..fbe009b5 100644 --- a/NEWS +++ b/NEWS @@ -44,6 +44,8 @@ Major changes in release 2.0: * AC_DEFINE no longer prints anything, because of the new result reporting mechanism (AC_MSG_CHECKING and AC_MSG_RESULT). * AC_VERBOSE pays attention to --quiet/--silent, not --verbose. +* AC_CHECK_FUNCS and AC_CHECK_HEADERS take an optional arg to execute + on a match. ** New utilities: * autoscan to generate a preliminary configure.in for a package by diff --git a/acgeneral.m4 b/acgeneral.m4 index 207489e6..d0e1a310 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -799,6 +799,8 @@ dnl Allow a site initialization script to override cache values. # Ultrix sh set writes to stderr and can't be redirected directly. (set) 2>&1 | sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1-'\2'}/p" >> $cache_file changequote([, ])dnl +else +echo "not updating unwritable cache $cache_file" fi ])dnl dnl @@ -1309,18 +1311,18 @@ ifelse([$3], , , [$3 fi ])dnl dnl -dnl AC_CHECK_FUNCS(FUNCTION...) +dnl AC_CHECK_FUNCS(FUNCTION... [, ACTION]) AC_DEFUN(AC_CHECK_FUNCS, [for ac_func in $1 do changequote(, )dnl ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` changequote([, ])dnl -AC_CHECK_FUNC(${ac_func}, AC_DEFINE(${ac_tr_func}))dnl +AC_CHECK_FUNC(${ac_func}, AC_DEFINE(${ac_tr_func}) $2)dnl done ])dnl dnl -dnl AC_CHECK_HEADERS(HEADER-FILE...) +dnl AC_CHECK_HEADERS(HEADER-FILE... [, ACTION]) AC_DEFUN(AC_CHECK_HEADERS, [AC_REQUIRE_CPP()dnl Make sure the cpp check happens outside the loop. for ac_hdr in $1 @@ -1328,7 +1330,7 @@ do changequote(, )dnl ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./' '[A-Z]__'` changequote([, ])dnl -AC_CHECK_HEADER(${ac_hdr}, AC_DEFINE(${ac_tr_hdr}))dnl +AC_CHECK_HEADER(${ac_hdr}, AC_DEFINE(${ac_tr_hdr}) $2)dnl done ])dnl dnl diff --git a/acspecific.m4 b/acspecific.m4 index 8c70890b..447cee9e 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -456,28 +456,14 @@ esac ])dnl dnl AC_DEFUN(AC_HEADER_DIRENT, -[AC_MSG_CHECKING(for directory library header) -dnl We don't use AC_CHECK_HEADERS so we can stop when we get a match. -AC_CACHE_VAL(ac_cv_header_dir, -[ac_cv_header_dir=no -for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do - AC_MSG_CHECKING([for $ac_hdr]) -AC_TRY_LINK([#include -#include <$ac_hdr>], [DIR *dirp = 0;], ac_cv_header_dir=$ac_hdr; break) -done])dnl - -AC_MSG_RESULT($ac_cv_header_dir) -case "$ac_cv_header_dir" in -dirent.h) AC_DEFINE(HAVE_DIRENT_H) ;; -sys/ndir.h) AC_DEFINE(HAVE_SYS_NDIR_H) ;; -sys/dir.h) AC_DEFINE(HAVE_SYS_DIR_H) ;; -ndir.h) AC_DEFINE(HAVE_NDIR_H) ;; -esac +[ac_header_dir=no +AC_CHECK_HEADERS(dirent.h sys/ndir.h sys/dir.h ndir.h, + [ac_header_dir=$ac_hdr; break]) AC_MSG_CHECKING(whether closedir returns void) AC_CACHE_VAL(ac_cv_func_closedir_void, [AC_TRY_RUN([#include -#include <$ac_cv_header_dir> +#include <$ac_header_dir> int closedir(); main() { exit(closedir(opendir(".")) != 0); }], ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes)])dnl AC_MSG_RESULT($ac_cv_func_closedir_void) @@ -488,17 +474,12 @@ fi dnl dnl Obsolete. AC_DEFUN(AC_DIR_HEADER, -[AC_MSG_CHECKING(for directory library header) -AC_CACHE_VAL(ac_cv_header_dir, -[ac_cv_header_dir=no +[ac_header_dir=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do - AC_MSG_CHECKING([for $ac_hdr]) -AC_TRY_LINK([#include -#include <$ac_hdr>], [DIR *dirp = 0;], ac_cv_header_dir=$ac_hdr; break) -done])dnl + AC_CHECK_HEADER($ac_hdr, [ac_header_dir=$ac_hdr; break]) +done -AC_MSG_RESULT($ac_cv_header_dir) -case "$ac_cv_header_dir" in +case "$ac_header_dir" in dirent.h) AC_DEFINE(DIRENT) ;; sys/ndir.h) AC_DEFINE(SYSNDIR) ;; sys/dir.h) AC_DEFINE(SYSDIR) ;; @@ -508,7 +489,7 @@ esac AC_MSG_CHECKING(whether closedir returns void) AC_CACHE_VAL(ac_cv_func_closedir_void, [AC_TRY_RUN([#include -#include <$ac_cv_header_dir> +#include <$ac_header_dir> int closedir(); main() { exit(closedir(opendir(".")) != 0); }], ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes)])dnl AC_MSG_RESULT($ac_cv_func_closedir_void) diff --git a/autoconf.texi b/autoconf.texi index d706bde4..f28d30b4 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -2092,13 +2092,16 @@ define a symbol if the function is available, consider using @code{AC_CHECK_FUNCS} instead. @end defmac -@defmac AC_CHECK_FUNCS (@var{function}@dots{}) +@defmac AC_CHECK_FUNCS (@var{function}@dots{} @r{[}, @var{action}@r{]}) @maindex CHECK_FUNCS @vindex HAVE_@var{function} For each given @var{function} in the whitespace-separated argument list that is available, define @code{HAVE_@var{function}} (in all caps). @xref{Specific Tests}, for a precise definition of ``define'' as it -is used here. If the functions might be in libraries other than the +is used here. If @var{action} is given, it is shell code to execute +when one of the functions is found. You can give an @var{action} of +@samp{break} to break out of the loop on the first match. +If the functions might be in libraries other than the default C library, first call @code{AC_CHECK_LIB} for those libraries. @end defmac @@ -2110,13 +2113,16 @@ you just want to define a symbol if the header file is available, consider using @code{AC_CHECK_HEADERS} instead. @end defmac -@defmac AC_CHECK_HEADERS (@var{header-file}@dots{}) +@defmac AC_CHECK_HEADERS (@var{header-file}@dots{} @r{[}, @var{action}@r{]}) @maindex CHECK_HEADERS @vindex HAVE_@var{header} For each given system header file @var{header-file} in the whitespace-separated argument list that exists, define @code{HAVE_@var{header-file}} (in all caps). @xref{Specific Tests}, for a precise definition of ``define'' as it is used here. +If @var{action} is given, it is shell code to execute +when one of the header files is found. You can give an @var{action} of +@samp{break} to break out of the loop on the first match. @end defmac @defmac AC_CHECK_SIZEOF (@var{type}) diff --git a/doc/autoconf.texi b/doc/autoconf.texi index d706bde4..f28d30b4 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -2092,13 +2092,16 @@ define a symbol if the function is available, consider using @code{AC_CHECK_FUNCS} instead. @end defmac -@defmac AC_CHECK_FUNCS (@var{function}@dots{}) +@defmac AC_CHECK_FUNCS (@var{function}@dots{} @r{[}, @var{action}@r{]}) @maindex CHECK_FUNCS @vindex HAVE_@var{function} For each given @var{function} in the whitespace-separated argument list that is available, define @code{HAVE_@var{function}} (in all caps). @xref{Specific Tests}, for a precise definition of ``define'' as it -is used here. If the functions might be in libraries other than the +is used here. If @var{action} is given, it is shell code to execute +when one of the functions is found. You can give an @var{action} of +@samp{break} to break out of the loop on the first match. +If the functions might be in libraries other than the default C library, first call @code{AC_CHECK_LIB} for those libraries. @end defmac @@ -2110,13 +2113,16 @@ you just want to define a symbol if the header file is available, consider using @code{AC_CHECK_HEADERS} instead. @end defmac -@defmac AC_CHECK_HEADERS (@var{header-file}@dots{}) +@defmac AC_CHECK_HEADERS (@var{header-file}@dots{} @r{[}, @var{action}@r{]}) @maindex CHECK_HEADERS @vindex HAVE_@var{header} For each given system header file @var{header-file} in the whitespace-separated argument list that exists, define @code{HAVE_@var{header-file}} (in all caps). @xref{Specific Tests}, for a precise definition of ``define'' as it is used here. +If @var{action} is given, it is shell code to execute +when one of the header files is found. You can give an @var{action} of +@samp{break} to break out of the loop on the first match. @end defmac @defmac AC_CHECK_SIZEOF (@var{type}) diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 207489e6..d0e1a310 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -799,6 +799,8 @@ dnl Allow a site initialization script to override cache values. # Ultrix sh set writes to stderr and can't be redirected directly. (set) 2>&1 | sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1-'\2'}/p" >> $cache_file changequote([, ])dnl +else +echo "not updating unwritable cache $cache_file" fi ])dnl dnl @@ -1309,18 +1311,18 @@ ifelse([$3], , , [$3 fi ])dnl dnl -dnl AC_CHECK_FUNCS(FUNCTION...) +dnl AC_CHECK_FUNCS(FUNCTION... [, ACTION]) AC_DEFUN(AC_CHECK_FUNCS, [for ac_func in $1 do changequote(, )dnl ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` changequote([, ])dnl -AC_CHECK_FUNC(${ac_func}, AC_DEFINE(${ac_tr_func}))dnl +AC_CHECK_FUNC(${ac_func}, AC_DEFINE(${ac_tr_func}) $2)dnl done ])dnl dnl -dnl AC_CHECK_HEADERS(HEADER-FILE...) +dnl AC_CHECK_HEADERS(HEADER-FILE... [, ACTION]) AC_DEFUN(AC_CHECK_HEADERS, [AC_REQUIRE_CPP()dnl Make sure the cpp check happens outside the loop. for ac_hdr in $1 @@ -1328,7 +1330,7 @@ do changequote(, )dnl ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./' '[A-Z]__'` changequote([, ])dnl -AC_CHECK_HEADER(${ac_hdr}, AC_DEFINE(${ac_tr_hdr}))dnl +AC_CHECK_HEADER(${ac_hdr}, AC_DEFINE(${ac_tr_hdr}) $2)dnl done ])dnl dnl diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 8c70890b..447cee9e 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -456,28 +456,14 @@ esac ])dnl dnl AC_DEFUN(AC_HEADER_DIRENT, -[AC_MSG_CHECKING(for directory library header) -dnl We don't use AC_CHECK_HEADERS so we can stop when we get a match. -AC_CACHE_VAL(ac_cv_header_dir, -[ac_cv_header_dir=no -for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do - AC_MSG_CHECKING([for $ac_hdr]) -AC_TRY_LINK([#include -#include <$ac_hdr>], [DIR *dirp = 0;], ac_cv_header_dir=$ac_hdr; break) -done])dnl - -AC_MSG_RESULT($ac_cv_header_dir) -case "$ac_cv_header_dir" in -dirent.h) AC_DEFINE(HAVE_DIRENT_H) ;; -sys/ndir.h) AC_DEFINE(HAVE_SYS_NDIR_H) ;; -sys/dir.h) AC_DEFINE(HAVE_SYS_DIR_H) ;; -ndir.h) AC_DEFINE(HAVE_NDIR_H) ;; -esac +[ac_header_dir=no +AC_CHECK_HEADERS(dirent.h sys/ndir.h sys/dir.h ndir.h, + [ac_header_dir=$ac_hdr; break]) AC_MSG_CHECKING(whether closedir returns void) AC_CACHE_VAL(ac_cv_func_closedir_void, [AC_TRY_RUN([#include -#include <$ac_cv_header_dir> +#include <$ac_header_dir> int closedir(); main() { exit(closedir(opendir(".")) != 0); }], ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes)])dnl AC_MSG_RESULT($ac_cv_func_closedir_void) @@ -488,17 +474,12 @@ fi dnl dnl Obsolete. AC_DEFUN(AC_DIR_HEADER, -[AC_MSG_CHECKING(for directory library header) -AC_CACHE_VAL(ac_cv_header_dir, -[ac_cv_header_dir=no +[ac_header_dir=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do - AC_MSG_CHECKING([for $ac_hdr]) -AC_TRY_LINK([#include -#include <$ac_hdr>], [DIR *dirp = 0;], ac_cv_header_dir=$ac_hdr; break) -done])dnl + AC_CHECK_HEADER($ac_hdr, [ac_header_dir=$ac_hdr; break]) +done -AC_MSG_RESULT($ac_cv_header_dir) -case "$ac_cv_header_dir" in +case "$ac_header_dir" in dirent.h) AC_DEFINE(DIRENT) ;; sys/ndir.h) AC_DEFINE(SYSNDIR) ;; sys/dir.h) AC_DEFINE(SYSDIR) ;; @@ -508,7 +489,7 @@ esac AC_MSG_CHECKING(whether closedir returns void) AC_CACHE_VAL(ac_cv_func_closedir_void, [AC_TRY_RUN([#include -#include <$ac_cv_header_dir> +#include <$ac_header_dir> int closedir(); main() { exit(closedir(opendir(".")) != 0); }], ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes)])dnl AC_MSG_RESULT($ac_cv_func_closedir_void)