From a26da270a4f997eaa52a7b82aa4ea90011461c9e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 20 May 2024 14:55:11 -0700 Subject: [PATCH] getopt-posix: port better to Alpine 3.20.0_rc1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Alpine’s is a stub that issues a deprecation #warning. * m4/getopt.m4 (gl_GETOPT_SUBSTITUTE_HEADER): * m4/sched_h.m4 (gl_SCHED_H): Use the new macro gl_CHECK_HEADER_SYS_CDEFS_H instead of checking independently. * m4/sys_cdefs_h.m4: New file. * modules/getopt-posix, modules/sched (Files): Add m4/sys_cdefs_h.m4. --- ChangeLog | 10 ++++++++++ m4/getopt.m4 | 11 ++--------- m4/sched_h.m4 | 12 +++--------- m4/sys_cdefs_h.m4 | 25 +++++++++++++++++++++++++ modules/getopt-posix | 1 + modules/sched | 1 + 6 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 m4/sys_cdefs_h.m4 diff --git a/ChangeLog b/ChangeLog index 184ebf5824..8b9b73a218 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2024-05-20 Paul Eggert + + getopt-posix: port better to Alpine 3.20.0_rc1 + Alpine’s is a stub that issues a deprecation #warning. + * m4/getopt.m4 (gl_GETOPT_SUBSTITUTE_HEADER): + * m4/sched_h.m4 (gl_SCHED_H): Use the new macro + gl_CHECK_HEADER_SYS_CDEFS_H instead of checking independently. + * m4/sys_cdefs_h.m4: New file. + * modules/getopt-posix, modules/sched (Files): Add m4/sys_cdefs_h.m4. + 2024-05-20 Collin Funk utimensat, utimens: Work around NetBSD 10.0 bugs. diff --git a/m4/getopt.m4 b/m4/getopt.m4 index be812d8459..a3587744bf 100644 --- a/m4/getopt.m4 +++ b/m4/getopt.m4 @@ -1,4 +1,4 @@ -# getopt.m4 serial 49 +# getopt.m4 serial 50 dnl Copyright (C) 2002-2006, 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -365,14 +365,7 @@ dnl is ambiguous with environment values that contain newlines. AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], [ - AC_CHECK_HEADERS_ONCE([sys/cdefs.h]) - if test $ac_cv_header_sys_cdefs_h = yes; then - HAVE_SYS_CDEFS_H=1 - else - HAVE_SYS_CDEFS_H=0 - fi - AC_SUBST([HAVE_SYS_CDEFS_H]) - + gl_CHECK_HEADER_SYS_CDEFS_H AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], [Define to rpl_ if the getopt replacement functions and variables should be used.]) diff --git a/m4/sched_h.m4 b/m4/sched_h.m4 index 2ff821e4c0..32859ea1ff 100644 --- a/m4/sched_h.m4 +++ b/m4/sched_h.m4 @@ -1,4 +1,4 @@ -# sched_h.m4 serial 15 +# sched_h.m4 serial 16 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,8 @@ AC_DEFUN_ONCE([gl_SCHED_H], AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CHECK_HEADERS_ONCE([sys/cdefs.h]) + AC_REQUIRE([gl_CHECK_HEADER_SYS_CDEFS_H]) + AC_CHECK_HEADERS([sched.h], [], [], [[#if HAVE_SYS_CDEFS_H #include @@ -56,13 +57,6 @@ AC_DEFUN_ONCE([gl_SCHED_H], fi AC_SUBST([HAVE_STRUCT_SCHED_PARAM]) - if test "$ac_cv_header_sys_cdefs_h" = yes; then - HAVE_SYS_CDEFS_H=1 - else - HAVE_SYS_CDEFS_H=0 - fi - AC_SUBST([HAVE_SYS_CDEFS_H]) - dnl Ensure the type pid_t gets defined. AC_REQUIRE([AC_TYPE_PID_T]) diff --git a/m4/sys_cdefs_h.m4 b/m4/sys_cdefs_h.m4 new file mode 100644 index 0000000000..22fa6c3849 --- /dev/null +++ b/m4/sys_cdefs_h.m4 @@ -0,0 +1,25 @@ +# sys_cdefs_h.m4 - Is compatible enough with glibc? +# serial 2 +dnl Copyright 2024 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +AC_DEFUN_ONCE([gl_CHECK_HEADER_SYS_CDEFS_H], + [AC_CACHE_CHECK([for glibc-compatible sys/cdefs.h], + [gl_cv_header_sys_cdefs_h], + [AC_COMPILE_IFELSE( + [AC_LANG_DEFINES_PROVIDED + [#include + enum { foo = __GNUC_PREREQ (14, 1) } bar; + ]], + [gl_cv_header_sys_cdefs_h=yes], + [gl_cv_header_sys_cdefs_h=no])]) + if test "$gl_cv_header_sys_cdefs_h" = yes; then + HAVE_SYS_CDEFS_H=1 + else + HAVE_SYS_CDEFS_H=0 + fi + AC_SUBST([HAVE_SYS_CDEFS_H])]) diff --git a/modules/getopt-posix b/modules/getopt-posix index 6305e83c8a..0b50620c4b 100644 --- a/modules/getopt-posix +++ b/modules/getopt-posix @@ -12,6 +12,7 @@ lib/getopt-pfx-core.h lib/getopt-pfx-ext.h lib/getopt_int.h m4/getopt.m4 +m4/sys_cdefs_h.m4 Depends-on: unistd diff --git a/modules/sched b/modules/sched index 042aa8be04..7ce972adf7 100644 --- a/modules/sched +++ b/modules/sched @@ -5,6 +5,7 @@ Files: lib/sched.in.h m4/sched_h.m4 m4/pid_t.m4 +m4/sys_cdefs_h.m4 Depends-on: gen-header -- 2.39.5