From b3abd6bbc6049385ec6130039f802da5ba5c6503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20=C3=89LIE?= Date: Sun, 11 Feb 2024 09:16:12 +0100 Subject: [PATCH] Use python-config to find Python link flags Thanks to Matthias Klose for the bug report, and proposal of patch using python-config. Fall back on the previous behaviour when python-config is not installed. Also, remove LOCALMODLIBS as it should not actually be used and breaks the build with recent Python versions. Only keep BASEMODLIBS. close #295 --- m4/python.m4 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/m4/python.m4 b/m4/python.m4 index 0212183eb..a825c52c6 100644 --- a/m4/python.m4 +++ b/m4/python.m4 @@ -130,20 +130,24 @@ AC_DEFUN([INN_LIB_PYTHON], print(" -L".join(sysconfig.get_config_vars("LIBDIR")))'` py_ldlibrary=`$PYTHON -c 'import sysconfig; \ print(sysconfig.get_config_vars("LDLIBRARY")@<:@0@:>@)'` - py_linkage=`$PYTHON -c 'import sysconfig; \ - print(" ".join(sysconfig.get_config_vars( \ - "LIBS", "LIBC", "LIBM", "LOCALMODLIBS", "BASEMODLIBS", \ - "LINKFORSHARED", "LDFLAGS")))'`], + AS_IF([test -x "${PYTHON}-config"], + [py_linkage=`${PYTHON}-config --libs 2>/dev/null`], + [py_linkage=`$PYTHON -c 'import sysconfig; \ + print(" ".join(sysconfig.get_config_vars( \ + "LIBS", "LIBC", "LIBM", "BASEMODLIBS", \ + "LINKFORSHARED", "LDFLAGS")))'`])], [py_include=`$PYTHON -c 'import distutils.sysconfig; \ print(distutils.sysconfig.get_python_inc())'` py_libdir=`$PYTHON -c 'import distutils.sysconfig; \ print(" -L".join(distutils.sysconfig.get_config_vars("LIBDIR")))'` py_ldlibrary=`$PYTHON -c 'import distutils.sysconfig; \ print(distutils.sysconfig.get_config_vars("LDLIBRARY")@<:@0@:>@)'` - py_linkage=`$PYTHON -c 'import distutils.sysconfig; \ - print(" ".join(distutils.sysconfig.get_config_vars( \ - "LIBS", "LIBC", "LIBM", "LOCALMODLIBS", "BASEMODLIBS", \ - "LINKFORSHARED", "LDFLAGS")))'`]) + AS_IF([test -x "${PYTHON}-config"], + [py_linkage=`${PYTHON}-config --libs 2>/dev/null`], + [py_linkage=`$PYTHON -c 'import distutils.sysconfig; \ + print(" ".join(distutils.sysconfig.get_config_vars( \ + "LIBS", "LIBC", "LIBM", "BASEMODLIBS", \ + "LINKFORSHARED", "LDFLAGS")))'`])]) PYTHON_CPPFLAGS="-I$py_include" py_libpython=`AS_ECHO(["$py_ldlibrary"]) \ | sed -e 's/^lib//' -e 's/\.@<:@a-z@:>@*$//'`