ac_config_libobj_dir.
(AC_CONFIG_LIBOBJ_DIR): New.
* lib/autoconf/functions.m4 (_AC_FUNC_FNMATCH): Split into...
(_AC_FUNC_FNMATCH_IF, _AC_LIBOBJ_FNMATCH): these.
Use ac_config_libobj_dir to find the replacement files.
(AC_FUNC_FNMATCH, AC_FUNC_FNMATCH_GNU): Split into...
(AC_FUNC_FNMATCH, AC_FUNC_FNMATCH_GNU, AC_REPLACE_FNMATCH)
(AC_REPLACE_FNMATCH_GNU): these.
(AC_FUNC_GETLOADAVG): Use ac_config_libobj_dir.
* doc/autoconf.texi (Particular Functions, Generic Functions): Adjust.
* tests/mktests.sh (ac_exclude_list): Don't check
AC_FUNC_GETLOADAVG as it requires getloadavg.c which is not shipped.
+2002-06-07 Akim Demaille <akim@epita.fr>
+
+ * lib/autoconf/general.m4 (_AC_INIT_DEFAULTS): Initialize
+ ac_config_libobj_dir.
+ (AC_CONFIG_LIBOBJ_DIR): New.
+ * lib/autoconf/functions.m4 (_AC_FUNC_FNMATCH): Split into...
+ (_AC_FUNC_FNMATCH_IF, _AC_LIBOBJ_FNMATCH): these.
+ Use ac_config_libobj_dir to find the replacement files.
+ (AC_FUNC_FNMATCH, AC_FUNC_FNMATCH_GNU): Split into...
+ (AC_FUNC_FNMATCH, AC_FUNC_FNMATCH_GNU, AC_REPLACE_FNMATCH)
+ (AC_REPLACE_FNMATCH_GNU): these.
+ (AC_FUNC_GETLOADAVG): Use ac_config_libobj_dir.
+ * doc/autoconf.texi (Particular Functions, Generic Functions): Adjust.
+ * tests/mktests.sh (ac_exclude_list): Don't check
+ AC_FUNC_GETLOADAVG as it requires getloadavg.c which is not shipped.
+
2002-06-06 Paul Eggert <eggert@twinsun.com>
* lib/autoconf/status.m4 (_AC_OUTPUT_LINKS): Fall back on cp
* doc/autoconf.texi (Particular Programs): Document them.
(Limitations of Usual Tools): Warn that egrep and fgrep may not exist.
* NEWS: Likewise.
-
+
2002-05-27 Paul Eggert <eggert@twinsun.com>
* lib/autoconf/types.m4 (AC_TYPE_MBSTATE_T): New macro.
- AC_CONFIG_LINKS now makes copies if it can't make links.
- AC_FUNC_FNMATCH now tests only for POSIX compatibility, reverting to
Autoconf 2.13 behavior. The new macro AC_FUNC_FNMATCH_GNU also tests for
- GNU extensions to fnmatch. Both macros now accept an optional argument
- specifying the directory that contains the replacement fnmatch source code.
-- AC_FUNC_GETLOADAVG now has an optional argument specifying the directory
- that contains getloadavg.c, and it tests whether getloadavg.c exists.
+ GNU extensions to fnmatch.
+
- AC_FUNC_SETVBUF_REVERSED no longer fails when cross-compiling.
+
- AC_PROG_CC_STDC is integrated into AC_PROG_CC.
+
- AC_PROG_F77 default search no longer includes cf77 and cfg77.
-- New macros: AC_GNU_SOURCE, AC_PROG_EGREP, AC_PROG_FGREP, AC_TYPE_MBSTATE_T.
+
+- New macros
+ AC_CONFIG_LIBOBJ_DIR, AC_GNU_SOURCE, AC_PROG_EGREP, AC_PROG_FGREP,
+ AC_REPLACE_FNMATCH, AC_REPLACE_FNMATCH_GNU, AC_TYPE_MBSTATE_T.
+
+- AC_FUNC_GETLOADAVG
+ looks for getloadavg.c in the CONFIG_LIBOBJ_DIR.
** Bug fixes
@code{AC_LIBOBJ} replacement of @samp{error}.
@end defmac
-@defmac AC_FUNC_FNMATCH (@ovar{dir})
+@defmac AC_FUNC_FNMATCH
@acindex FUNC_FNMATCH
@c @fuindex fnmatch
@prindex @code{fnmatch}
If the @code{fnmatch} function conforms to @acronym{POSIX}, define
@code{HAVE_FNMATCH}. Detect common implementation bugs, for example,
-the bugs in Solaris 2.4. If @var{dir} is nonempty, the files
-@file{fnmatch.c}, @file{fnmatch_loop.c}, and @file{fnmatch_.h} in the
-directory @var{dor} are assumed to contain a copy of the source code
-of @acronym{GNU} @code{fnmatch}. If necessary, this source code is
-compiled as an @code{AC_LIBOBJ} replacement, and the @file{fnmatch_.h}
-file is linked to @file{fnmatch.h} so that it can be included in place
-of the system @code{<fnmatch.h>}.
+the bugs in Solaris 2.4.
+
+Note that for historical reasons, contrary to the other specific
+@code{AC_FUNC} macros, @code{AC_FUNC_FNMATCH} does not replace
+broken/missing @code{fnmatch}. See @code{AC_REPLACE_FNMATCH} below.
@end defmac
-@defmac AC_FUNC_FNMATCH_GNU (@ovar{dir})
+@defmac AC_FUNC_FNMATCH_GNU
@acindex FUNC_FNMATCH_GNU
@c @fuindex fnmatch
@prindex @code{fnmatch}
-Behave like @code{AC_FUNC_FNMATCH(@var{dir})}, but also test whether
-@code{fnmatch} supports @acronym{GNU} extensions. Detect common
-implementation bugs, for example, the bugs in the @acronym{GNU} C
-Library 2.1.
+Behave like @code{AC_FUNC_FNMATCH}, but also test whether @code{fnmatch}
+supports @acronym{GNU} extensions. Detect common implementation bugs,
+for example, the bugs in the @acronym{GNU} C Library 2.1.
@end defmac
@defmac AC_FUNC_FORK
needed to get that function. This macro runs @code{AC_TYPE_GETGROUPS}.
@end defmac
-@defmac AC_FUNC_GETLOADAVG (@dvar{dir, .})
+@defmac AC_FUNC_GETLOADAVG
@acindex FUNC_GETLOADAVG
@cvindex SVR4
@cvindex DGUX
@ovindex GETLOADAVG_LIBS
@c @fuindex getloadavg
@prindex @code{getloadavg}
-Check how to get the system load averages. If the system has the
-@code{getloadavg} function, define @code{HAVE_GETLOADAVG}, and set
-@code{GETLOADAVG_LIBS} to any libraries needed to get that function.
-Also add @code{GETLOADAVG_LIBS} to @code{LIBS}.
-
-Otherwise, require an @code{AC_LIBOBJ} replacement for
-@samp{getloadavg} with source code in @file{@var{dir}/getloadavg.c},
-and possibly define several other C preprocessor
-macros and output variables:
+Check how to get the system load averages. To perform it tests
+properly, this macro needs the file @file{getloadavg.c}; therefore, be
+sure to set the @code{AC_LIBOBJ} replacement directory properly (see
+@ref{Generic Functions}, @code{AC_CONFIG_LIBOBJ_DIR}).
+
+If the system has the @code{getloadavg} function, define
+@code{HAVE_GETLOADAVG}, and set @code{GETLOADAVG_LIBS} to any libraries
+needed to get that function. Also add @code{GETLOADAVG_LIBS} to
+@code{LIBS}. Otherwise, require an @code{AC_LIBOBJ} replacement for
+@samp{getloadavg} with source code in @file{@var{dir}/getloadavg.c}, and
+possibly define several other C preprocessor macros and output
+variables:
@enumerate
@item
are also available.)
@end defmac
+@defmac AC_REPLACE_FNMATCH
+@acindex REPLACE_FNMATCH
+@c @fuindex fnmatch
+@prindex @code{fnmatch}
+If the @code{fnmatch} function does not conform to @acronym{POSIX} (see
+@code{AC_FUNC_FNMATCH}), ask for its @code{AC_LIBOBJ} replacement.
+
+The files @file{fnmatch.c}, @file{fnmatch_loop.c}, and @file{fnmatch_.h}
+in the @code{AC_LIBOBJ} replacement directory are assumed to contain a
+copy of the source code of @acronym{GNU} @code{fnmatch}. If necessary,
+this source code is compiled as an @code{AC_LIBOBJ} replacement, and the
+@file{fnmatch_.h} file is linked to @file{fnmatch.h} so that it can be
+included in place of the system @code{<fnmatch.h>}.
+@end defmac
+
+@defmac AC_REPLACE_FNMATCH_GNU
+@acindex REPLACE_FNMATCH_GNU
+@c @fuindex fnmatch
+@prindex @code{fnmatch}
+Samr as @code{AC_REPLACE_FNMATCH}, but requiring the @acronym{GNU}
+extensions to @code{fnmatch} (see @code{AC_FUNC_FNMATCH_GNU}).
+@end defmac
+
+
+
@node Generic Functions
@subsection Generic Function Checks
functions is not found.
@end defmac
+@sp 1
+
Autoconf follows a philosophy that was formed over the years by those
who have struggled for portability: isolate the portability issues in
specific files, and then program as if you were in a @sc{posix}
environment. Some functions may be missing or unfixable, and your
package must be ready to replace them.
-Use the first three of the following macros to specify a function to be
-replaced, and the last one (@code{AC_REPLACE_FUNCS}) to check for and
-replace the function if needed.
-
@defmac AC_LIBOBJ (@var{function})
@acindex LIBOBJ
@ovindex LIBOBJS
@end example
@end defmac
+@defmac AC_CONFIG_LIBOBJ_DIR (@var{directory})
+@acindex CONFIG_LIBOBJ_DIR
+Specify that @code{AC_LIBOBJ} replacement files are to be found in
+@var{directory} (which defaults to @samp{.}, the top source directory).
+@command{configure} might need to know where these files are for the
+following reasons: (i) some checks use the replacement files, (ii) some
+macros bypass broken system headers by installing links to the
+replacement headers etc.
+@end defmac
+
+@sp 1
+
+It is common to merely check for the existence of a function, and ask
+for its @code{AC_LIBOBJ} replacement if missing. The following macro is
+a convenient shorthand.
+
@defmac AC_REPLACE_FUNCS (@var{function}@dots{})
@acindex REPLACE_FUNCS
@ovindex LIBOBJS
AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
-# _AC_FUNC_FNMATCH([DIR], STANDARD, SHELL_VAR, VARIABLE)
-# ---------------------------------------------
-AC_DEFUN([_AC_FUNC_FNMATCH],
-[m4_ifval([$1],
- [AC_REQUIRE([AC_C_CONST])
- AC_REQUIRE([AC_FUNC_ALLOCA])
- AC_REQUIRE([AC_TYPE_MBSTATE_T])])
- AC_CACHE_CHECK(
- [for working $2 fnmatch],
- [$3],
- # Some versions of Solaris, SCO, and the GNU C Library
+# _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
+# -------------------------------------------------------------------------
+# If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
+# IF-FALSE. Use CACHE_VAR.
+AC_DEFUN([_AC_FUNC_FNMATCH_IF],
+[AC_CACHE_CHECK(
+ [for working $1 fnmatch],
+ [$2],
+ [# Some versions of Solaris, SCO, and the GNU C Library
# have a broken or incompatible fnmatch.
# So we run a test program. If we are cross-compiling, take no chance.
# Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
- [AC_RUN_IFELSE(
+ AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[#include <fnmatch.h>
# define y(a, b, c) (fnmatch (a, b, c) == 0)
-# define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)],
+# define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
+ ],
[exit
(!(y ("a*", "abc", 0)
&& n ("d*/*1", "d/s/1", FNM_PATHNAME)
&& n ("a\\\\bc", "abc", FNM_NOESCAPE)
&& y ("*x", ".x", 0)
&& n ("*x", ".x", FNM_PERIOD)
- && m4_if([$2], [GNU],
+ && m4_if([$1], [GNU],
[y ("xxXX", "xXxX", FNM_CASEFOLD)
&& y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
&& n ("d*/*1", "d/s/1", FNM_FILE_NAME)
&& y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
&& y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
1)));])],
- [$3=yes],
- [$3=no],
- [$3=cross])])
- if test $$3 = yes; then
- m4_ifval([$1], [rm -f $1/fnmatch.h])
- AC_DEFINE([$4], 1,
- [Define to 1 if your system has a working $2 `fnmatch' function.])
- else
- m4_ifval([$1],
- [AC_CHECK_DECLS([getenv])
- AC_CHECK_FUNCS(mbsrtowcs mempcpy wmempcpy)
- AC_CHECK_HEADERS(wchar.h wctype.h)
- AC_LIBOBJ(fnmatch)
- AC_CONFIG_LINKS([$1/fnmatch.h:$1/fnmatch_.h])
- AC_DEFINE(fnmatch, rpl_fnmatch,
- [Define to rpl_fnmatch if the replacement function should be used.])
- ],
- [:])
- fi
-])# _AC_FUNC_FNMATCH
-
-# AC_FUNC_FNMATCH([DIR])
-# ----------------------
+ [$2=yes],
+ [$2=no],
+ [$2=cross])])
+AS_IF([test $$2 = yes], [$3], [$4])
+])# _AC_FUNC_FNMATCH_IF
+
+
+# AC_FUNC_FNMATCH
+# ---------------
AC_DEFUN([AC_FUNC_FNMATCH],
-[_AC_FUNC_FNMATCH([$1], [POSIX], [ac_cv_func_fnmatch_works], [HAVE_FNMATCH])])
+[_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
+ [AC_DEFINE([HAVE_FNMATCH], 1,
+ [Define to 1 if your system has a working POSIX `fnmatch'
+ function.])])
+])# AC_FUNC_FNMATCH
-# AC_FUNC_FNMATCH_GNU([DIR])
-# --------------------------
+
+# AC_FUNC_FNMATCH_GNU
+# -------------------
AC_DEFUN([AC_FUNC_FNMATCH_GNU],
[AC_REQUIRE([AC_GNU_SOURCE])
- _AC_FUNC_FNMATCH([$1], [GNU], [ac_cv_func_fnmatch_gnu], [HAVE_FNMATCH_GNU])])
+_AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
+ [AC_DEFINE([HAVE_FNMATCH], 1,
+ [Define to 1 if your system has a working GNU `fnmatch'
+ function.])])
+])# AC_FUNC_FNMATCH_GNU
+
+
+# _AC_LIBOBJ_FNMATCH
+# ------------------
+# Prepare the replacement of fnmatch.
+AC_DEFUN([_AC_LIBOBJ_FNMATCH],
+[AC_REQUIRE([AC_C_CONST])dnl
+AC_REQUIRE([AC_FUNC_ALLOCA])dnl
+AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
+AC_CHECK_DECLS([getenv])
+AC_CHECK_FUNCS([mbsrtowcs mempcpy wmempcpy])
+AC_CHECK_HEADERS([wchar.h wctype.h])
+AC_LIBOBJ([fnmatch])
+AC_CONFIG_LINKS([$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h])
+AC_DEFINE(fnmatch, rpl_fnmatch,
+ [Define to rpl_fnmatch if the replacement function should be used.])
+])# _AC_LIBOBJ_FNMATCH
+
+
+# AC_REPLACE_FUNC_FNMATCH
+# -----------------------
+AC_DEFUN([AC_REPLACE_FUNC_FNMATCH],
+[_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
+ [rm -f $ac_config_libobj_dir/fnmatch.h],
+ [_AC_LIBOBJ_FNMATCH])
+])# AC_REPLACE_FUNC_FNMATCH
+
+
+# AC_REPLACE_FUNC_FNMATCH_GNU
+# ---------------------------
+AC_DEFUN([AC_REPLACE_FNMATCH_GNU],
+[AC_REQUIRE([AC_GNU_SOURCE])
+_AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
+ [rm -f $ac_config_libobj_dir/fnmatch.h],
+ [_AC_LIBOBJ_FNMATCH])
+])# AC_REPLACE_FUNC_FNMATCH_GNU
+
# AU::AM_FUNC_FNMATCH
# AU::fp_FUNC_FNMATCH
AC_DEFUN([AC_FUNC_GETLOADAVG],
[ac_have_func=no # yes means we've found a way to get the load average.
-# The directory to find getloadavg.c in.
-ac_lib_dir_getloadavg=$srcdir[]m4_ifval([$1], [/$1])
-
# Make sure getloadavg.c is where it belongs, at configure-time.
-test -f "$ac_lib_dir_getloadavg/getloadavg.c" ||
- AC_MSG_ERROR([$ac_lib_dir_getloadavg/getloadavg.c is missing])
-# FIXME: Add an autoconf-time test, too?
+test -f "$ac_config_libobj_dir/getloadavg.c" ||
+ AC_MSG_ERROR([$ac_config_libobj_dir/getloadavg.c is missing])
ac_save_LIBS=$LIBS
AC_CACHE_CHECK(whether getloadavg requires setgid,
ac_cv_func_getloadavg_setgid,
[AC_EGREP_CPP([Yowza Am I SETGID yet],
-[#include "$ac_lib_dir_getloadavg/getloadavg.c"
+[#include "$ac_config_libobj_dir/getloadavg.c"
#ifdef LDAV_PRIVILEGED
Yowza Am I SETGID yet
@%:@endif],
# Initializations.
#
ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
cross_compiling=no
subdirs=
MFLAGS=
])# AC_CHECK_DECLS
-## -------------------------------- ##
-## Checking for library functions. ##
-## -------------------------------- ##
+
+## ---------------------------------- ##
+## Replacement of library functions. ##
+## ---------------------------------- ##
+
+
+# AC_CONFIG_LIBOBJ_DIR(DIRNAME)
+# -----------------------------
+# Announce LIBOBJ replacement files are in DIRNAME.
+AC_DEFUN_ONCE([AC_CONFIG_LIBOBJ_DIR],
+[m4_divert_text([DEFAULTS], [ac_config_libobj_dir=$1])[]dnl
+])
# AC_LIBSOURCE(FILENAME)
AT_CHECK_MACRO([AC_FUNC_FORK])
AT_CHECK_MACRO([AC_FUNC_FSEEKO])
AT_CHECK_MACRO([AC_FUNC_GETGROUPS])
-AT_CHECK_MACRO([AC_FUNC_GETLOADAVG])
AT_CHECK_MACRO([AC_FUNC_GETMNTENT])
AT_CHECK_MACRO([AC_FUNC_GETPGRP])
AT_CHECK_MACRO([AC_FUNC_MALLOC])
# Performed in the semantics tests.
# - AC_CONFIG
# They fail when the source does not exist.
+# - AC_FUNC_GETLOADAVG
+# Requires a file that is not shipped with Autoconf. But it should.
# - AC_INIT
# AC_INIT includes all the AC_INIT macros. Note that there is an
# infinite m4 recursion if AC_INIT it used twice.
^AC_CHECK_(DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|TOOL|TYPE)S?$
^AC_CONFIG
^AC_F77_FUNC$
+^AC_FUNC_GETLOADAVG$
^AC_INIT
^AC_LANG
^AC_LINKER_OPTION$