Hi Zack,
Here are patches to sync autoconf with gnulib:
AC_FUNC_CHOWN chown.m4 -> functions.m4
AC_FUNC_GETGROUPS getgroups.m4 -> functions.m4
AC_FUNC_MBRTOWC mbrtowc.m4 -> functions.m4
AC_TYPE_MBSTATE_T mbstate_t.m4 -> types.m4
AC_FUNC_GETMNTENT mountlist.m4 -> functions.m4
AC_FUNC_OBSTACK obstack.m4 -> functions.m4
The changes are mostly minor; the main purpose is
1) to be able to do this sync more easily in the future,
2) to wrap some of these definitions in
m4_version_prereq([2.70.1], [], [
in Gnulib.
There are still some remaining differences: Gnulib offers a
configure option --enable-cross-guesses={conservative|risky}
that determines how cross-compilation guesses work in case of
unknown platforms. --enable-cross-guesses=conservative is
the default. However, when an operating system developer (on a
platform which is not yet known to gnulib) builds packages for
their platform, they want to expose, not hide, possible platform
bugs; in this case, --enable-cross-guesses=risky is the appropriate
choice. Autoconf does not have such an option.
Bruno
>From f6f709a5d37fa5b8309bfd7d88f2b7f3daeeac1c Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 21 Dec 2020 11:13:17 +0100
Subject: [PATCH 1/6] Port AC_FUNC_CHOWN fixes from Gnulib.
* lib/autoconf/functions.m4 (AC_FUNC_CHOWN): Support compiling without
-loldnames on native Windows. Improve cross-compilation guesses. When
cross-compiling, say "guessing ...".
---
lib/autoconf/functions.m4 | 82 ++++++++++++++++++++++++++++-------------------
1 file changed, 49 insertions(+), 33 deletions(-)
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 12f60b9..a86048f 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -470,39 +470,55 @@ AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA])
# Determine whether chown accepts arguments of -1 for uid and gid.
AN_FUNCTION([chown], [AC_FUNC_CHOWN])
AC_DEFUN([AC_FUNC_CHOWN],
-[AC_REQUIRE([AC_TYPE_UID_T])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
-AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
-[AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
-#include <fcntl.h>
-],
-[[ char *f = "conftest.chown";
- struct stat before, after;
-
- if (creat (f, 0600) < 0)
- return 1;
- if (stat (f, &before) < 0)
- return 1;
- if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
- return 1;
- if (stat (f, &after) < 0)
- return 1;
- return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
-]])],
- [ac_cv_func_chown_works=yes],
- [ac_cv_func_chown_works=no],
- [case "$host_os" in # ((
- # Guess yes on glibc systems.
- *-gnu*) ac_cv_func_chown_works=yes ;;
- # If we don't know, assume the worst.
- *) ac_cv_func_chown_works=no ;;
- esac])
-rm -f conftest.chown
-])
-if test $ac_cv_func_chown_works = yes; then
- AC_DEFINE(HAVE_CHOWN, 1,
- [Define to 1 if your system has a working `chown' function.])
-fi
+[
+ AC_REQUIRE([AC_TYPE_UID_T])dnl
+ AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
+ AC_CACHE_CHECK([for working chown],
+ [ac_cv_func_chown_works],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [AC_INCLUDES_DEFAULT
+ [#include <fcntl.h>
+ #if defined _WIN32 && !defined __CYGWIN__
+ #define creat _creat
+ #endif
+ ]],
+ [[
+ char *f = "conftest.chown";
+ struct stat before, after;
+
+ if (creat (f, 0600) < 0)
+ return 1;
+ if (stat (f, &before) < 0)
+ return 1;
+ if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
+ return 1;
+ if (stat (f, &after) < 0)
+ return 1;
+ return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
+ ]])
+ ],
+ [ac_cv_func_chown_works=yes],
+ [ac_cv_func_chown_works=no],
+ [case "$host_os" in # ((
+ # Guess yes on Linux systems.
+ linux-* | linux) ac_cv_func_chown_works="guessing yes" ;;
+ # Guess yes on glibc systems.
+ *-gnu* | gnu*) ac_cv_func_chown_works="guessing yes" ;;
+ # Guess no on native Windows.
+ mingw*) ac_cv_func_chown_works="guessing no" ;;
+ # If we don't know, assume the worst.
+ *) ac_cv_func_chown_works="guessing no" ;;
+ esac
+ ])
+ rm -f conftest.chown
+ ])
+ case "$ac_cv_func_chown_works" in
+ *yes)
+ AC_DEFINE([HAVE_CHOWN], [1],
+ [Define to 1 if your system has a working `chown' function.])
+ ;;
+ esac
])# AC_FUNC_CHOWN
--
2.7.4
>From 9e34baba2a6ed10b31de343c25bb28e7ac8f290d Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 21 Dec 2020 11:19:05 +0100
Subject: [PATCH 2/6] Port AC_FUNC_GETGROUPS fixes from Gnulib.
* lib/autoconf/functions.m4 (AC_FUNC_GETGROUPS): Improve cross-compilation
guesses.
---
lib/autoconf/functions.m4 | 79 ++++++++++++++++++++++++++---------------------
1 file changed, 43 insertions(+), 36 deletions(-)
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index a86048f..003e9ce 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -689,44 +689,51 @@ fi
# When cross-compiling, assume getgroups is broken.
AN_FUNCTION([getgroups], [AC_FUNC_GETGROUPS])
AC_DEFUN([AC_FUNC_GETGROUPS],
-[AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
-AC_REQUIRE([AC_TYPE_SIZE_T])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
-AC_CHECK_FUNC(getgroups)
+[
+ AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
+ AC_REQUIRE([AC_TYPE_SIZE_T])dnl
+ AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
+ AC_CHECK_FUNC([getgroups])
-# If we don't yet have getgroups, see if it's in -lbsd.
-# This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
-ac_save_LIBS=$LIBS
-if test $ac_cv_func_getgroups = no; then
- AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
-fi
+ # If we don't yet have getgroups, see if it's in -lbsd.
+ # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
+ ac_save_LIBS=$LIBS
+ if test $ac_cv_func_getgroups = no; then
+ AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
+ fi
-# Run the program to test the functionality of the system-supplied
-# getgroups function only if there is such a function.
-if test $ac_cv_func_getgroups = yes; then
- AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
- [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
- [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
- return getgroups (0, 0) == -1;]])],
- [ac_cv_func_getgroups_works=yes],
- [ac_cv_func_getgroups_works=no],
- [case "$host_os" in # ((
- # Guess yes on glibc systems.
- *-gnu*) ac_cv_func_getgroups_works="guessing yes" ;;
- # If we don't know, assume the worst.
- *) ac_cv_func_getgroups_works="guessing no" ;;
- esac])
- ])
-else
- ac_cv_func_getgroups_works=no
-fi
-case "$ac_cv_func_getgroups_works" in
- *yes)
- AC_DEFINE(HAVE_GETGROUPS, 1,
- [Define to 1 if your system has a working `getgroups' function.])
- ;;
-esac
-LIBS=$ac_save_LIBS
+ # Run the program to test the functionality of the system-supplied
+ # getgroups function only if there is such a function.
+ if test $ac_cv_func_getgroups = yes; then
+ AC_CACHE_CHECK([for working getgroups], [ac_cv_func_getgroups_works],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [AC_INCLUDES_DEFAULT],
+ [[/* On NeXTstep 3.2, getgroups (0, 0) always fails. */
+ return getgroups (0, 0) == -1;]])
+ ],
+ [ac_cv_func_getgroups_works=yes],
+ [ac_cv_func_getgroups_works=no],
+ [case "$host_os" in # ((
+ # Guess yes on glibc systems.
+ *-gnu* | gnu*) ac_cv_func_getgroups_works="guessing yes" ;;
+ # Guess yes on musl systems.
+ *-musl*) ac_cv_func_getgroups_works="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) ac_cv_func_getgroups_works="guessing no" ;;
+ esac
+ ])
+ ])
+ else
+ ac_cv_func_getgroups_works=no
+ fi
+ case "$ac_cv_func_getgroups_works" in
+ *yes)
+ AC_DEFINE([HAVE_GETGROUPS], [1],
+ [Define to 1 if your system has a working `getgroups' function.])
+ ;;
+ esac
+ LIBS=$ac_save_LIBS
])# AC_FUNC_GETGROUPS
--
2.7.4
>From 15afcdea97a17a48fff9c8c1bf51b9a1264916b1 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 21 Dec 2020 11:24:29 +0100
Subject: [PATCH 3/6] Port minor AC_FUNC_MBRTOWC fixes from Gnulib.
* lib/autoconf/functions.m4 (AC_FUNC_MBRTOWC): Quote systematically. Don't use
quadrigraphs.
---
lib/autoconf/functions.m4 | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 003e9ce..a74c6c4 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -1016,19 +1016,19 @@ AN_FUNCTION([mbrtowc], [AC_FUNC_MBRTOWC])
AC_DEFUN([AC_FUNC_MBRTOWC],
[
AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
- ac_cv_func_mbrtowc,
+ [ac_cv_func_mbrtowc],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
- [[@%:@include <wchar.h>]],
+ [[#include <wchar.h>]],
[[wchar_t wc;
char const s[] = "";
size_t n = 1;
mbstate_t state;
return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
- ac_cv_func_mbrtowc=yes,
- ac_cv_func_mbrtowc=no)])
+ [ac_cv_func_mbrtowc=yes],
+ [ac_cv_func_mbrtowc=no])])
if test $ac_cv_func_mbrtowc = yes; then
- AC_DEFINE([HAVE_MBRTOWC], 1,
+ AC_DEFINE([HAVE_MBRTOWC], [1],
[Define to 1 if mbrtowc and mbstate_t are properly declared.])
fi
])
--
2.7.4
>From 2191713f6d145ef1c7f889fe01f08ed2b55edec8 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 21 Dec 2020 11:31:37 +0100
Subject: [PATCH 4/6] Provide minor AC_FUNC_GETMNTENT improvements from Gnulib.
* lib/autoconf/functions.m4 (AC_FUNC_GETMNTENT): Drop support for IRIX 4 and
Dynix/ptx.
---
lib/autoconf/functions.m4 | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index a74c6c4..001a165 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -891,13 +891,11 @@ AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
# -----------------
AN_FUNCTION([getmntent], [AC_FUNC_GETMNTENT])
AC_DEFUN([AC_FUNC_GETMNTENT],
-[# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
-# -lseq on Dynix/PTX, -lgen on Unixware.
-AC_SEARCH_LIBS(getmntent, [sun seq gen],
- [ac_cv_func_getmntent=yes
- AC_DEFINE([HAVE_GETMNTENT], 1,
- [Define to 1 if you have the `getmntent' function.])],
- [ac_cv_func_getmntent=no])
+[
+ # getmntent is in the standard C library on most systems, but in -lgen on
+ # Unixware.
+ AC_SEARCH_LIBS([getmntent], [gen])
+ AC_CHECK_FUNCS([getmntent])
])
--
2.7.4
>From eea496940c993b84ef5139846d891276ef0f3117 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 21 Dec 2020 11:37:04 +0100
Subject: [PATCH 5/6] Port AC_FUNC_OBSTACK fixes from Gnulib.
* lib/autoconf/functions.m4 (AC_FUNC_OBSTACK): Do not assume system-supplied
obstack is size_t safe.
---
lib/autoconf/functions.m4 | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index 001a165..c56a71a 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -1444,23 +1444,30 @@ AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
AN_FUNCTION([obstack_init], [AC_FUNC_OBSTACK])
AN_IDENTIFIER([obstack], [AC_FUNC_OBSTACK])
AC_DEFUN([AC_FUNC_OBSTACK],
-[AC_LIBSOURCES([obstack.h, obstack.c])dnl
-AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
-[AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
- [@%:@include "obstack.h"]],
- [[struct obstack mem;
- @%:@define obstack_chunk_alloc malloc
- @%:@define obstack_chunk_free free
- obstack_init (&mem);
- obstack_free (&mem, 0);]])],
- [ac_cv_func_obstack=yes],
- [ac_cv_func_obstack=no])])
-if test $ac_cv_func_obstack = yes; then
- AC_DEFINE(HAVE_OBSTACK, 1, [Define to 1 if libc includes obstacks.])
-else
- AC_LIBOBJ(obstack)
-fi
+[
+ AC_LIBSOURCES([obstack.h, obstack.c])dnl
+ AC_CACHE_CHECK([for obstacks that work with any size object],
+ [ac_cv_func_obstack],
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include "obstack.h"
+ void *obstack_chunk_alloc (size_t n) { return 0; }
+ void obstack_chunk_free (void *p) { }
+ /* Check that an internal function returns size_t, not int. */
+ size_t _obstack_memory_used (struct obstack *);
+ ]],
+ [[struct obstack mem;
+ obstack_init (&mem);
+ obstack_free (&mem, 0);
+ ]])],
+ [ac_cv_func_obstack=yes],
+ [ac_cv_func_obstack=no])])
+ if test "$ac_cv_func_obstack" = yes; then
+ AC_DEFINE([HAVE_OBSTACK], [1],
+ [Define to 1 if the system has obstacks that work with any size object.])
+ else
+ AC_LIBOBJ([obstack])
+ fi
])# AC_FUNC_OBSTACK
--
2.7.4
>From 71692c4b05af76c55bdedd90fb046346a7c84884 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Mon, 21 Dec 2020 11:40:34 +0100
Subject: [PATCH 6/6] Port AC_TYPE_MBSTATE_T fixes from Gnulib.
* lib/autoconf/types.m4 (AC_TYPE_MBSTATE_T): Add support for HP-UX 11.11. Quote
systematically.
---
lib/autoconf/types.m4 | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index fff850a..05ed1d5 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -570,21 +570,25 @@ AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
# AC_TYPE_MBSTATE_T
# -----------------
AC_DEFUN([AC_TYPE_MBSTATE_T],
- [AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
- [AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [AC_INCLUDES_DEFAULT
-# include <wchar.h>],
- [mbstate_t x; return sizeof x;])],
- [ac_cv_type_mbstate_t=yes],
- [ac_cv_type_mbstate_t=no])])
- if test $ac_cv_type_mbstate_t = yes; then
- AC_DEFINE([HAVE_MBSTATE_T], 1,
- [Define to 1 if <wchar.h> declares mbstate_t.])
- else
- AC_DEFINE([mbstate_t], int,
- [Define to a type if <wchar.h> does not define.])
- fi])
+[
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11
+
+ AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [AC_INCLUDES_DEFAULT[
+ #include <wchar.h>]],
+ [[mbstate_t x; return sizeof x;]])],
+ [ac_cv_type_mbstate_t=yes],
+ [ac_cv_type_mbstate_t=no])])
+ if test $ac_cv_type_mbstate_t = yes; then
+ AC_DEFINE([HAVE_MBSTATE_T], [1],
+ [Define to 1 if <wchar.h> declares mbstate_t.])
+ else
+ AC_DEFINE([mbstate_t], [int],
+ [Define to a type if <wchar.h> does not define.])
+ fi
+])
# AC_TYPE_UID_T
--
2.7.4