>From 4a06d4967666dad844b91560a2394db5d0ea4b5d Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Wed, 3 Dec 2025 11:35:37 +0900
Subject: [PATCH] build: Add support for IBM z/OS, fixing -lpthread check with
 glibc.

* configure.ac: Care about PRINTABLE_OS_NAME for IBM z/OS.
Handle have_pthread for IBM z/OS.
No check with -lpthread when we know about have_pthread.

--

The variable have_pthread in configure script is whether or not the
pthread API is available on the host.  Linking is handled with
libgpg-error using GPG_ERROR_MT_LIBS.

Signed-off-by: Sachin T <sachin.t@ibm.com>
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
---
 configure.ac | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index f5e78077..39b20163 100644
--- a/configure.ac
+++ b/configure.ac
@@ -241,6 +241,11 @@ have_pthread=no
 
 # Setup some stuff depending on host.
 case "${host}" in
+    *-*-linux*)
+        # It makes no sense to check with -lpthread for libgcrypt.
+        have_pthread=yes
+        ;;
+
     *-*-mingw32*)
       ac_cv_have_dev_random=no
       have_w32_system=yes
@@ -290,8 +295,17 @@ case "${host}" in
                   [defined if we use posix_spawn in test program])
         AC_CHECK_HEADERS(spawn.h)
         ;;
+
+    *-openedition*)
+        # The z/OS C runtime includes pthread support, and linking is
+        # handled automatically at build time.
+        have_pthread=yes
+        # mmap is not fully supported on z/OS.
+        ac_cv_func_mmap=no
+        ;;
+
     *)
-      ;;
+        ;;
 esac
 
 if test "$have_w32_system" = yes; then
@@ -318,6 +332,10 @@ case "${host}" in
         PRINTABLE_OS_NAME="GNU/Linux"
         ;;
 
+    *-openedition*)
+        PRINTABLE_OS_NAME="IBM z/OS"
+        ;;
+
     *)
         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
         ;;
@@ -821,13 +839,12 @@ AM_CONDITIONAL(USE_GPGRT_CONFIG, [test -n "$GPGRT_CONFIG" \
 #
 # Check whether pthreads is available
 #
-if test "$have_w32_system" != yes; then
+if test "$have_w32_system" != yes && test "$have_pthread" != yes; then
   AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes)
-  if test "$have_pthread" = yes; then
-    AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.])
-  fi
 fi
-
+if test "$have_pthread" = yes; then
+  AC_DEFINE(HAVE_PTHREAD, 1 ,[Define if we have pthread.])
+fi
 
 # Solaris needs -lsocket and -lnsl. Unisys system includes
 # gethostbyname in libsocket but needs libnsl for socket.
-- 
2.47.2

