]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/autoconf/general.m4 (_AC_INIT_DEFAULTS): Initialize
authorAkim Demaille <akim@epita.fr>
Fri, 7 Jun 2002 07:17:53 +0000 (07:17 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 7 Jun 2002 07:17:53 +0000 (07:17 +0000)
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.

ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/functions.m4
lib/autoconf/general.m4
tests/acfunctions.at
tests/mktests.sh

index b2bdc920e87979e7be9b358426cd691c6b7c52a0..94530f516d40c584c4c61e19d2040733219704aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+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
@@ -30,7 +46,7 @@
        * 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.
diff --git a/NEWS b/NEWS
index a2ed39dc0c65e8d25532cc61b880b3b93096763a..8b6ade7f0e07095f411f8670b48a92a7bf5e6842 100644 (file)
--- a/NEWS
+++ b/NEWS
 - 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
 
index c7504a8a27cf63bb9a1d86530534a26cf80f71b7..dbbbc667a0550ac7cd248fda6a90a2431d144a1c 100644 (file)
@@ -3540,29 +3540,26 @@ If the @code{error_at_line} function is not found, require an
 @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
@@ -3621,7 +3618,7 @@ Ultrix 4.3, where @samp{getgroups (0, 0)} always fails), define
 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
@@ -3638,15 +3635,18 @@ needed to get that function.  This macro runs @code{AC_TYPE_GETGROUPS}.
 @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
@@ -3909,6 +3909,31 @@ is available, you may assume that @code{vfprintf} and @code{vsprintf}
 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
 
@@ -3942,16 +3967,14 @@ execute when one of the functions is found.  You can give it a value of
 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
@@ -4004,6 +4027,22 @@ AC_LIBOBJ($foo_or_bar)
 @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
index 5edd65637f55df61929667db6ef920118d3dbc4d..7337d3176413ab0b6abad8c0e20207c34e6c5b4b 100644 (file)
@@ -342,25 +342,24 @@ fi
 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)
@@ -368,7 +367,7 @@ AC_DEFUN([_AC_FUNC_FNMATCH],
              && 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)
@@ -376,37 +375,69 @@ AC_DEFUN([_AC_FUNC_FNMATCH],
                    && 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
@@ -532,13 +563,9 @@ AC_CHECK_HEADERS(nlist.h,
 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
 
@@ -584,7 +611,7 @@ AC_CHECK_FUNCS(getloadavg, [],
 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],
index 865f3f41d0dbeed5db80ef15fbff194c7c3b34d1..075e936978f93532feee6772e3c83c5e67023dc0 100644 (file)
@@ -443,6 +443,7 @@ exec AS_MESSAGE_FD>&1
 # Initializations.
 #
 ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
 cross_compiling=no
 subdirs=
 MFLAGS=
@@ -2352,9 +2353,18 @@ $3],
 ])# 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)
index dba1f2071b91572bfc794d6447192aac0ea23d16..592cfa5e3153b567bf42577198cf3f53b082f61b 100644 (file)
@@ -12,7 +12,6 @@ AT_CHECK_MACRO([AC_FUNC_FNMATCH_GNU])
 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])
index b84951a4bebb830e18f813422f9910030576adfa..abb1c201ba77682df4fb28434075f2dd3d829f4e 100755 (executable)
@@ -85,6 +85,8 @@ exclude_list='^ac_cv_prog_(gcc|gxx|g77)$
 #   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.
@@ -115,6 +117,7 @@ ac_exclude_list='^AC_ARG_VAR$
 ^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$