]> Savannah Git Hosting - gnulib.git/commitdiff
getopt-posix: port better to Alpine 3.20.0_rc1
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 20 May 2024 21:55:11 +0000 (14:55 -0700)
committerBruno Haible <bruno@clisp.org>
Wed, 22 May 2024 09:04:25 +0000 (11:04 +0200)
Alpine’s <sys/cdefs.h> 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
m4/getopt.m4
m4/sched_h.m4
m4/sys_cdefs_h.m4 [new file with mode: 0644]
modules/getopt-posix
modules/sched

index 3f43c80d928d288bc9de3786c0b363b8877ccf3d..d28c01b3801c39afd2f58bec4c47f30b21a66f88 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-05-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+       getopt-posix: port better to Alpine 3.20.0_rc1
+       Alpine’s <sys/cdefs.h> 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  <collin.funk1@gmail.com>
 
        utimensat, utimens: Work around NetBSD 10.0 bugs.
index 7981a09552ba92dee3c6cb678e9e145b48ec8213..be37d037579706ace74756fee86326ba356a5c68 100644 (file)
@@ -1,5 +1,5 @@
-# getopt.m4 serial 48
-dnl Copyright (C) 2002-2006, 2008-2023 Free Software Foundation, Inc.
+# getopt.m4 serial 48.1
+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,
 dnl with or without modifications, as long as this notice is preserved.
@@ -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.])
index 980d2564b985fc2dae17ff409ce52fbfad4da371..32859ea1ff46b825fc342630872fa89f7a620fbf 100644 (file)
@@ -1,5 +1,5 @@
-# sched_h.m4 serial 15
-dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
+# 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,
 dnl with or without modifications, as long as this notice is preserved.
@@ -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 <sys/cdefs.h>
@@ -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 (file)
index 0000000..22fa6c3
--- /dev/null
@@ -0,0 +1,25 @@
+# sys_cdefs_h.m4 - Is <sys/cdefs.h> 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 <sys/cdefs.h>
+          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])])
index 6305e83c8ab40467d3da491071fb286c2c3082ea..0b50620c4b2e18c6ffbf55b4977f2dae6603b306 100644 (file)
@@ -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
index 042aa8be04f7446ed76706e0759926bffaf3838d..7ce972adf70d7d2fb0e955511db09bffed266a8f 100644 (file)
@@ -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