Check if detected libpython.so can be dlopen-ed
[claws.git] / configure.ac
index fe73e85bb596dc68568e2703323b7e54a766a611..f57dea12c9ae6c79c9dbecef482d767cde1358b3 100644 (file)
@@ -18,9 +18,10 @@ if test \( -d .git \); then
        AC_MSG_ERROR([*** git not found. See http://git-scm.com/])
     else
        GIT_VERSION=`git describe --abbrev=6 --dirty --always`
+       echo "echo ${GIT_VERSION}" > ./version
     fi
 else
-    GIT_VERSION=`sh -c '. ./version'`
+    GIT_VERSION=`sh -c ". ./$srcdir/version"`
 fi
 MAJOR_VERSION=${GIT_VERSION%%.*}
 MINOR_VERSION=${GIT_VERSION#*.}
@@ -1107,14 +1108,17 @@ AC_SUBST(WEBKIT_LIBS)
 AC_SUBST(WEBKIT_CFLAGS)
 
 dnl libsoup ********************************************************************
-PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4)
+PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4, HAVE_LIBSOUP=yes, HAVE_LIBSOUP=no)
+if test x"$HAVE_LIBSOUP" = xyes; then
+       AC_DEFINE(HAVE_LIBSOUP, 1, [Define if libsoup is available])
+fi
 AC_SUBST(LIBSOUP_CFLAGS)
 AC_SUBST(LIBSOUP_LIBS)
 
 dnl libsoup-gnome **************************************************************
 PKG_CHECK_MODULES(LIBSOUP_GNOME, libsoup-gnome-2.4 >= 2.26, HAVE_LIBSOUP_GNOME=yes, HAVE_LIBSOUP_GNOME=no)
 if test x"$HAVE_LIBSOUP_GNOME" = xyes; then
-       AC_DEFINE(HAVE_LIBSOUP_GNOME, 1, [Define if libsoup is available])
+       AC_DEFINE(HAVE_LIBSOUP_GNOME, 1, [Define if libsoup_gnome is available])
 fi
 AC_SUBST(LIBSOUP_GNOME_CFLAGS)
 AC_SUBST(LIBSOUP_GNOME_LIBS)
@@ -1180,7 +1184,6 @@ fi
 if test x"$HAVE_PERL" = xyes; then
        AC_MSG_CHECKING(for Perl compile flags)
        PERL_CFLAGS=`perl -MExtUtils::Embed -e ccopts`
-       PERL_CFLAGS=`perl -MExtUtils::Embed -e ccopts`
        PERL_CFLAGS=`echo $PERL_CFLAGS | sed 's/-D_FILE_OFFSET_BITS=[[0-9]]*//'`
        PERL_LDFLAGS=`perl -MExtUtils::Embed -e ldopts |sed 's/-lgdbm//'`
        PERL_LDFLAGS=`echo $PERL_LDFLAGS |sed 's/-ldb//'`
@@ -1193,6 +1196,17 @@ if test x"$HAVE_PERL" = xyes; then
                AC_CHECK_LIB(perl,perl_alloc,[AC_DEFINE(HAVE_LIBPERL, 1, Check for libperl.)], 
                                             [ HAVE_LIBPERL=no ])
        fi
+       if test x"$HAVE_LIBPERL" = xno; then
+               LIBPERL_PREFIX=`perl -MExtUtils::Embed -e perl_inc`
+               LIBPERL_PREFIX=`echo $LIBPERL_PREFIX |sed 's/-I//'`
+               AC_MSG_CHECKING([for libperl.so])
+               if test -f "$LIBPERL_PREFIX/libperl.so"; then
+                       AC_MSG_RESULT(yes)
+                       HAVE_LIBPERL=yes
+               else
+                       AC_MSG_RESULT(no)
+               fi      
+       fi
        PERL="perl"
        AC_SUBST(PERL)
        AC_SUBST(PERL_CFLAGS)
@@ -1224,20 +1238,28 @@ AM_PATH_PYTHON([2.5], [
 
        if test x"$HAVE_PYTHON" = xyes; then
                # libpython.so
-               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 -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
+               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)
@@ -1460,6 +1482,7 @@ else
        AC_MSG_RESULT(no)
 fi
 
+AC_MSG_CHECKING([whether to build geolocation plugin])
 if test x"$enable_geolocation_plugin" != xno; then
        dependencies_missing=""
 
@@ -1950,7 +1973,6 @@ manual/de/dist/ps/Makefile
 manual/de/dist/html/Makefile
 manual/de/dist/txt/Makefile
 claws-mail.pc
-version
 ])
 
 dnl Output the configuration summary