[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_FUNC_FNMATCH jamboree patch
From: |
Akim Demaille |
Subject: |
Re: AC_FUNC_FNMATCH jamboree patch |
Date: |
07 Jun 2002 08:58:36 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
>>>>> "Paul" == Paul Eggert <address@hidden> writes:
>> From: Akim Demaille <address@hidden> Date: 06 Jun 2002 18:23:12
>> +0200
>>
>> Well, there was trailing code, and AC_GNU_SOURCE was not properly
>> invoked. Sorry.
Paul> No problem.
Paul> One other thought: shouldn't AC_FUNC_GETLOADAVG be modified to
Paul> use the new AC_CONFIG_LIBOBJ_DIR functionality, instead of
Paul> having its argument?
Absolutely. That's ``the other one that...'' I was referring to :)
Paul, BTW, I have always hated AC_FUNC_FNMATCH for not _replacing_ the
function, as do the others. Do we have to reproduce the error to
AC_FUNC_FNMATCH_GNU?
Here is what I'm installing.
Oh, BTW, I was wondering: the fact that you pass the cache variable
name is because you want to provide some form of compatibility?
Otherwise, ac_cv_func_fnmatch_$1 seems ok to me.
Index: ChangeLog
from Akim Demaille <address@hidden>
* 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.
Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.243
diff -u -u -r1.243 NEWS
--- NEWS 29 May 2002 22:31:36 -0000 1.243
+++ NEWS 7 Jun 2002 06:55:11 -0000
@@ -13,14 +13,15 @@
- 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.
+ GNU extensions to fnmatch.
- AC_FUNC_GETLOADAVG now has an optional argument specifying the directory
that contains getloadavg.c, and it tests whether getloadavg.c exists.
- 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.
** Bug fixes
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.629
diff -u -u -r1.629 autoconf.texi
--- doc/autoconf.texi 29 May 2002 22:30:56 -0000 1.629
+++ doc/autoconf.texi 7 Jun 2002 06:55:12 -0000
@@ -3540,29 +3540,26 @@
@code{AC_LIBOBJ} replacement of @samp{error}.
@end defmac
address@hidden AC_FUNC_FNMATCH (@ovar{dir})
address@hidden 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
address@hidden, @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
address@hidden macros, @code{AC_FUNC_FNMATCH} does not replace
+broken/missing @code{fnmatch}. See @code{AC_REPLACE_FNMATCH} below.
@end defmac
address@hidden AC_FUNC_FNMATCH_GNU (@ovar{dir})
address@hidden 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
address@hidden 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
@@ -3909,6 +3906,31 @@
are also available.)
@end defmac
address@hidden AC_REPLACE_FNMATCH
address@hidden REPLACE_FNMATCH
address@hidden @fuindex fnmatch
address@hidden @code{fnmatch}
+If the @code{fnmatch} function does not conform to @acronym{POSIX} (see
address@hidden), 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
address@hidden file is linked to @file{fnmatch.h} so that it can be
+included in place of the system @code{<fnmatch.h>}.
address@hidden defmac
+
address@hidden AC_REPLACE_FNMATCH_GNU
address@hidden REPLACE_FNMATCH_GNU
address@hidden @fuindex fnmatch
address@hidden @code{fnmatch}
+Samr as @code{AC_REPLACE_FNMATCH}, but requiring the @acronym{GNU}
+extensions to @code{fnmatch} (see @code{AC_FUNC_FNMATCH_GNU}).
address@hidden defmac
+
+
+
@node Generic Functions
@subsection Generic Function Checks
@@ -3942,16 +3964,14 @@
functions is not found.
@end defmac
address@hidden 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
@@ -4003,6 +4023,21 @@
AC_LIBOBJ($foo_or_bar)
@end example
@end defmac
+
address@hidden AC_CONFIG_LIBOBJ_DIR (@var{directory})
address@hidden CONFIG_LIBOBJ_DIR
+Specify that @code{AC_LIBOBJ} replacement files are to be found in
address@hidden @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.
address@hidden defmac
+
address@hidden 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 (@address@hidden)
@acindex REPLACE_FUNCS
Index: lib/autoconf/functions.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v
retrieving revision 1.62
diff -u -u -r1.62 functions.m4
--- lib/autoconf/functions.m4 28 May 2002 04:13:59 -0000 1.62
+++ lib/autoconf/functions.m4 7 Jun 2002 06:55:12 -0000
@@ -342,25 +342,24 @@
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 @@
&& 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 @@
&& 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
+ [$2=yes],
+ [$2=no],
+ [$2=cross])])
+AS_IF([test $$2 = yes], [$3], [$4])
+])# _AC_FUNC_FNMATCH_IF
-# AC_FUNC_FNMATCH([DIR])
-# ----------------------
+
+# 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
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.798
diff -u -u -r1.798 general.m4
--- lib/autoconf/general.m4 29 May 2002 22:25:50 -0000 1.798
+++ lib/autoconf/general.m4 7 Jun 2002 06:55:12 -0000
@@ -443,6 +443,7 @@
# Initializations.
#
ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
cross_compiling=no
subdirs=
MFLAGS=
@@ -2352,9 +2353,18 @@
])# 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)
Re: AC_FUNC_FNMATCH jamboree patch, Paul Eggert, 2002/06/06