From 539cfdb9eecb39294cf1b993007db9ba1e5470c6 Mon Sep 17 00:00:00 2001 From: Gilles DAVID Date: Fri, 17 Nov 2017 16:28:43 +0100 Subject: [PATCH] Update python.m4 macro to fix Python libraries detection with native Python --- autotools/m4/python.m4 | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/autotools/m4/python.m4 b/autotools/m4/python.m4 index bba9fab..833f4c9 100644 --- a/autotools/m4/python.m4 +++ b/autotools/m4/python.m4 @@ -37,25 +37,26 @@ dnl a `module'. AC_DEFUN([CHECK_PYTHON], [ + AC_BEFORE([$0],[AM_PATH_PYTHON]) + AC_REQUIRE([AC_LINKER_OPTIONS])dnl + python_ok=yes AM_PATH_PYTHON([3]) - AC_CHECKING([local Python configuration]) - - AC_REQUIRE([AC_LINKER_OPTIONS])dnl - - PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` - PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` - PYTHONHOME=$PYTHON_PREFIX - - changequote(<<, >>)dnl - PYTHON_ABIFLAGS=`$PYTHON -c "import sys; print(sys.abiflags)"` - changequote([, ])dnl - - AC_SUBST(PYTHON_PREFIX) - AC_SUBST(PYTHONHOME) - AC_SUBST(PYTHON_ABIFLAGS) + AC_MSG_NOTICE([local Python configuration]) + + AC_SUBST([python_bin], + [`basename ${PYTHON}`] ) + + AC_SUBST([PYTHON_ABIFLAGS], + [`${PYTHON} -c "import sys; print (sys.abiflags)"`] ) + + AC_SUBST([PYTHON_PREFIX], + [`${PYTHON} -c "import sys; print (sys.prefix)"`] ) + + AC_SUBST([PYTHONHOME], + [`${PYTHON} -c "import sys; print (sys.prefix)"`] ) PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/Makefile if test ! -f "$PY_MAKEFILE"; then @@ -89,6 +90,11 @@ AC_DEFUN([CHECK_PYTHON], PYTHON_LIB=$PYTHON_LIBS PYTHON_LIBA=${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a fi + if test "$PY_MAKEFILE" = "${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os}/Makefile" ; then + PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os} -lpython${PYTHON_VERSION}${PYTHON_ABIFLAGS}" + PYTHON_LIB=$PYTHON_LIBS + PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config-${PYTHON_VERSION}${PYTHON_ABIFLAGS}-${build_cpu}-${build_os}/libpython${PYTHON_VERSION}${PYTHON_ABIFLAGS}.a + fi fi dnl At times (like when building shared libraries) you may want -- 2.39.2