Check if detected libpython.so can be dlopen-ed
A somewhat better solution for the libpython.so detection saga. Unfortunately it has not presented itself and had to be painfully extracted from a series of trial and error experiments. No living beings were harmed in the process, though. Many thanks to Paul for the help with testing this.
This commit is contained in:
parent
9375966944
commit
df8a1d7e76
1 changed files with 18 additions and 15 deletions
33
configure.ac
33
configure.ac
|
@ -1238,25 +1238,28 @@ AM_PATH_PYTHON([2.5], [
|
|||
|
||||
if test x"$HAVE_PYTHON" = xyes; then
|
||||
# libpython.so
|
||||
PYTHON_SO_FILE_LOCATION=`python-config --ldflags|sed 's/-L//'|awk '{print $1}'`
|
||||
PYTHON_SO_FILE="libpython${PYTHON_VERSION}.so"
|
||||
found_libpython_so="no"
|
||||
if test -f "$PYTHON_PREFIX/lib/$PYTHON_SO_FILE"; then
|
||||
found_libpython_so="yes"
|
||||
PYTHON_SHARED_LIB=`python -c "import os,sys; print os.path.basename(os.path.realpath(\"$PYTHON_PREFIX/lib/$PYTHON_SO_FILE\"))"`
|
||||
fi
|
||||
if test x"$found_libpython_so" != x"yes" && test -f "$PYTHON_PREFIX/lib64/$PYTHON_SO_FILE"; then
|
||||
found_libpython_so="yes"
|
||||
PYTHON_SHARED_LIB=`python -c "import os,sys; print os.path.basename(os.path.realpath(\"$PYTHON_PREFIX/lib64/$PYTHON_SO_FILE\"))"`
|
||||
fi
|
||||
if test x"$found_libpython_so" != x"yes" && test -f "$PYTHON_SO_FILE_LOCATION/$PYTHON_SO_FILE"; then
|
||||
found_libpython_so="yes"
|
||||
PYTHON_SHARED_LIB=`python -c "import os,sys; print os.path.basename(os.path.realpath(\"$PYTHON_SO_FILE_LOCATION/$PYTHON_SO_FILE\"))"`
|
||||
fi
|
||||
PYTHON_SHARED_LIB="libpython${PYTHON_VERSION}.so"
|
||||
_save_libs="$LIBS"
|
||||
LIBS="-ldl"
|
||||
AC_MSG_CHECKING([whether to dlopen $PYTHON_SHARED_LIB works])
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[#include <dlfcn.h>
|
||||
#define PYTHON_SO_FILE "${PYTHON_SHARED_LIB}"
|
||||
],
|
||||
[if (!dlopen(PYTHON_SO_FILE, RTLD_NOW | RTLD_GLOBAL)) return 1; return 0;])
|
||||
],
|
||||
[found_libpython_so="yes"],
|
||||
[found_libpython_so="no"],
|
||||
[AC_MSG_FAILURE([cross-compiling not supported])])
|
||||
if test x"$found_libpython_so" != x"yes"; then
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_WARN(Could not find Python shared libary: $PYTHON_SO_FILE does not exist. Maybe you need to install development packages for Python.)
|
||||
HAVE_PYTHON=no
|
||||
else
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
||||
LIBS="$_save_libs";
|
||||
fi
|
||||
if test x"$HAVE_PYTHON" = xyes; then
|
||||
PKG_CHECK_MODULES(PYGTK, pygtk-2.0 >= 2.10.3, [AC_DEFINE(ENABLE_PYTHON, [1], [Enable Python support])], HAVE_PYTHON=no)
|
||||
|
|
Loading…
Reference in a new issue