talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit df8a1d7e766dea1c48a47d6a7766e20922a78cab
parent 9375966944e6fef9cc85820b329c46125a93b3f3
Author: Ricardo Mones <ricardo@mones.org>
Date:   Thu, 30 May 2013 18:29:07 +0200

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.

Diffstat:
Mconfigure.ac | 33++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/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)