diff --git a/plugins/pyloader/m4/ac_python_devel.m4 b/plugins/pyloader/m4/ac_python_devel.m4 index 0623ce8..39da07f 100644 --- a/plugins/pyloader/m4/ac_python_devel.m4 +++ b/plugins/pyloader/m4/ac_python_devel.m4 @@ -148,8 +148,34 @@ $ac_distutils_result]) PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \ from string import join; \ - print '-L' + get_python_lib(0,1), \ - '-lpython';"`$py_version + print '-L' + get_python_lib(0,1);"` + + # We could have a versioned library, or an unversioned one, + # even if the second case is discouraged. So, let's check for + # the versioned one first, and fallback on the second later. + LIBS="$ac_save_LIBS $PYTHON_LDFLAGS" + CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" + + AC_LANG_PUSH([C]) + AC_CHECK_LIB([python$py_version], [Py_Initialize], + [PYTHON_LDFLAGS="$PYTHON_LDFLAGS -lpython$py_version"], + AC_CHECK_LIB([python], [Py_Initialize], + [PYTHON_LDFLAGS="$PYTHON_LDFLAGS -lpython"], + [PYTHON_LDFLAGS=""]) + ) + AC_LANG_POP + + if test -z "$PYTHON_LDFLAGS"; then + AC_MSG_ERROR([ + Could not link test program to Python. Maybe the main Python library has been + installed in some non-standard library path. If so, pass it to configure, + via the LDFLAGS environment variable. + Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" + ]) + fi + + CPPFLAGS="$ac_save_CPPFLAGS" + LIBS="$ac_save_LIBS" fi AC_MSG_RESULT([$PYTHON_LDFLAGS]) AC_SUBST([PYTHON_LDFLAGS]) @@ -205,16 +231,14 @@ $ac_distutils_result]) AC_MSG_RESULT([$pythonexists]) - if test ! "$pythonexists" = "yes"; then + if test ! "$pythonexists" = "yes"; then AC_MSG_ERROR([ - Could not link test program to Python. Maybe the main Python library has been - installed in some non-standard library path. If so, pass it to configure, - via the LDFLAGS environment variable. - Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" ============================================================================ ERROR! You probably have to install the development version of the Python package for your distribution. The exact name of this package varies among them. + Take also a look to config.log. If everything looks all right, please + report the problem to the macro maintainer. ============================================================================ ]) PYTHON_VERSION=""