]> 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)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 20 May 2024 21:55:11 +0000 (14:55 -0700)
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 dd5b0c4c66c3a3d935280c72020c347fc9a71b96..2e82a08042a8be8f4f0eaaa5e4a24d88d5fab61c 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>
 
        tests: Update expected tests results on NetBSD.
index 297722eae441b323f82311e68a514abcf491eb04..53cab8bef93126239bff3427aeb86bbf961a5e75 100644 (file)
@@ -1,5 +1,5 @@
 # getopt.m4
-# serial 49
+# 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,
@@ -366,14 +366,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 1e022948b508c0da3fe913897aa16c093166c0d6..61c202ef0c164eb560755842c6bfcfc94605d598 100644 (file)
@@ -1,5 +1,5 @@
 # sched_h.m4
-# serial 15
+# 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,
@@ -15,7 +15,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>
@@ -57,13 +58,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..069146d
--- /dev/null
@@ -0,0 +1,25 @@
+# sys_cdefs_h.m4 - Is <sys/cdefs.h> compatible enough with glibc?
+# serial 1
+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([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