configure.in simplification..

parent 69daaf60
2006-02-19 Gustavo J. A. M. Carneiro <gjc@gnome.org>
* src/Makefile.am: Update to use PYTHON_LIBS/PYTHON_LIB_LOC.
* m4/python.m4: Define also PYTHON_LIB_LOC.
* configure.in: Use AM_CHECK_PYTHON_LIBS and remove a large chunk
of code that is not really needed.
* m4/python.m4: Copy-paste AM_CHECK_PYTHON_LIBS from gnome-python.
* configure.in: Fix PY_LIB_LOC to point to $PY_EXEC_PREFIX/lib,
which is where a normal (i.e. not distribution patched) python
installation puts the shared library.
......
......@@ -28,103 +28,12 @@ if test "x$HAVE_PKGCONFIG" = "xno"; then
AC_MSG_ERROR(you need to have pkgconfig installed !)
fi
AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
dnl **************************************************
dnl * Check for Python
dnl **************************************************
try_python=true
try_pygtk=false
python_msg=no
AC_ARG_WITH(python,
[--{with,without}-python Compile the Python plugin loader],
if test "x$withval" = xno; then
python_msg="Disabled by request"
try_python=false
else
python_prog="$withval"
fi
)
if $try_python; then
if test "x$python_prog" = xyes -o "x$python_prog" = x ; then
python_prog=python
fi
python_val=
python_msg="unable to find python"
AC_CHECK_PROG(python_val, "$python_prog", true, false)
if $python_val; then
AC_MSG_CHECKING(for python >= 2.3)
PY_PREFIX=`$python_prog -c 'import sys ; print sys.prefix'`
PY_EXEC_PREFIX=`$python_prog -c 'import sys ; print sys.exec_prefix'`
changequote(<<, >>)dnl
PY_VERSION=`$python_prog -c 'import sys ; print sys.version[0:3]'`
broken_py_initialize=`$python_prog -c \
'import sys
if int(sys.version[0]) < 2:
print "yes"
else:
print "no"'`
changequote([, ])dnl
if test "x$broken_py_initialize" = "xyes"; then
AC_MSG_RESULT(no)
python_val=false
python_msg="NO. Python version is too old."
else
AC_MSG_RESULT(yes)
fi
fi
if $python_val; then
AC_MSG_CHECKING(Look for $PY_PREFIX/include/python$PY_VERSION/Python.h)
if test -f $PY_PREFIX/include/python$PY_VERSION/Python.h; then
AC_MSG_RESULT(yes)
PY_LIBS="python$PY_VERSION"
PY_LIB_LOC="$PY_EXEC_PREFIX/lib"
PY_CFLAGS="-I$PY_PREFIX/include/python$PY_VERSION"
PY_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config/Makefile"
PY_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
PY_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
PY_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE`
PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASEMODLIBS $PY_OTHER_LIBS"
AC_SUBST(PY_LIBS)
AC_SUBST(PY_LIB_LOC)
AC_SUBST(PY_CFLAGS)
AC_SUBST(PY_EXTRA_LIBS)
else
AC_MSG_RESULT(no)
python_val=false
fi
fi
if $python_val; then
AC_MSG_CHECKING(if we can build a shared library depending on libpython)
rm -rf testpython
mkdir testpython
cd testpython
cat > testpython.c <<EOF
#include <Python.h>
int testpython (void)
{
Py_Exit (0);
}
EOF
if /bin/sh ../libtool --mode=compile ${CC} $PY_CFLAGS -c testpython.c >/dev/null 2>&1 && \
/bin/sh ../libtool --mode=link ${CC} -o testpython.la -rpath `pwd` -module -avoid-version $PY_LIB_LOC testpython.lo -l$PY_LIBS $PY_EXTRA_LIBS >/dev/null 2>&1 && \
grep 'dlname.*testpython' testpython.la >/dev/null 2>&1; then
AC_MSG_RESULT(yes)
python_msg="yes"
else
AC_MSG_RESULT(no)
python_val=false
python_msg="unable to link to python"
fi
cd ..
rm -rf testpython
fi
AM_CONDITIONAL(WITH_PYTHON, $python_val)
else
AC_MSG_ERROR(you need to have python installed !)
fi
AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
AM_CHECK_PYTHON_LIBS(,[AC_MSG_ERROR(could not find Python lib)])
PKG_CHECK_MODULES(NAUTILUS_PYTHON, [pygtk-2.0 >= $PYGTK_REQUIRED
gnome-python-2.0 >= $GNOME_PYTHON_REQUIRED
......
......@@ -60,3 +60,24 @@ $1],dnl
$2])
CPPFLAGS="$save_CPPFLAGS"
])
dnl a macro to check for ability to embed python
dnl AM_CHECK_PYTHON_LIBS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
dnl function also defines PYTHON_LIBS
AC_DEFUN([AM_CHECK_PYTHON_LIBS],
[AC_REQUIRE([AM_CHECK_PYTHON_HEADERS])
AC_MSG_CHECKING(for libraries required to embed python)
dnl deduce PYTHON_LIBS
py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
PYTHON_LIBS="-L${py_prefix}/lib -lpython${PYTHON_VERSION}"
PYTHON_LIB_LOC="${py_prefix}/lib"
AC_SUBST(PYTHON_LIBS)
AC_SUBST(PYTHON_LIB_LOC)
dnl check if the headers exist:
save_LIBS="$LIBS"
LIBS="$LIBS $PYTHON_LIBS"
AC_TRY_LINK_FUNC(Py_Initialize, dnl
[LIBS="$save_LIBS"; AC_MSG_RESULT(yes); $1], dnl
[LIBS="$save_LIBS"; AC_MSG_RESULT(no); $2])
])
......@@ -7,13 +7,8 @@ INCLUDES = \
$(DISABLE_DEPRECATED_CFLAGS) \
$(NAUTILUS_PYTHON_CFLAGS) \
-DPYTHON_VERSION=\"$(PYTHON_VERSION)\" \
-DPY_LIB_LOC="\"$(PY_LIB_LOC)\"" \
$(PY_CFLAGS)
PYTHON_LIBS = \
-L$(PY_LIB_LOC) -l$(PY_LIBS) \
$(PY_OTHER_LIBS) \
$(PY_EXTRA_LIBS)
-DPY_LIB_LOC="\"$(PYTHON_LIB_LOC)\"" \
$(PYTHON_INCLUDES)
nautilus_extensiondir=$(NAUTILUS_LIBDIR)/nautilus/extensions-1.0
......@@ -25,7 +20,7 @@ libnautilus_python_la_SOURCES = \
nautilus-python-object.c \
nautilus-python-object.h
libnautilus_python_la_LDFLAGS = -module -avoid-version $(PY_LIB_LOC)
libnautilus_python_la_LDFLAGS = -module -avoid-version
libnautilus_python_la_LIBADD = $(NAUTILUS_PYTHON_LIBS) $(PYTHON_LIBS)
pyexec_LTLIBRARIES = nautilus.la
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment