From f6661415290811d616563003ec6ad7102f354bf8 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu, 19 Feb 2026 18:23:40 -0500
Subject: [PATCH v7 8/8] Fix libpython configure check for AIX.

This logic didn't believe that "libpythonXXX.a" is a candidate
to be a shared library, but on AIX we'd better accept that.
---
 config/python.m4 | 5 +++++
 configure        | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/config/python.m4 b/config/python.m4
index b295ad3d3a4..ec3c80cf044 100644
--- a/config/python.m4
+++ b/config/python.m4
@@ -97,6 +97,11 @@ python_ldlibrary=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sys
 
 # If LDLIBRARY exists and has a shlib extension, use it verbatim.
 ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dylib$//' -e 's/\.sl$//'`
+if test "$PORTNAME" = "aix"; then
+  # On AIX, '.a' should also be believed to be a shlib.
+  ldlibrary=`echo "${ldlibrary}" | sed -e 's/\.a$//'`
+fi
+
 if test -e "${python_libdir}/${python_ldlibrary}" -a x"${python_ldlibrary}" != x"${ldlibrary}"
 then
 	ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
diff --git a/configure b/configure
index 6a85065279d..bb0b739eb4d 100755
--- a/configure
+++ b/configure
@@ -10705,6 +10705,11 @@ python_ldlibrary=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sys
 
 # If LDLIBRARY exists and has a shlib extension, use it verbatim.
 ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dylib$//' -e 's/\.sl$//'`
+if test "$PORTNAME" = "aix"; then
+  # On AIX, '.a' should also be believed to be a shlib.
+  ldlibrary=`echo "${ldlibrary}" | sed -e 's/\.a$//'`
+fi
+
 if test -e "${python_libdir}/${python_ldlibrary}" -a x"${python_ldlibrary}" != x"${ldlibrary}"
 then
 	ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`
-- 
2.43.7

