summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2011-09-05 15:48:26 +0200
committerDieter Verfaillie <dieterv@optionexplicit.be>2011-09-07 21:37:39 +0200
commita8977bc6c93793fc9a2e9b6d4315c385d5ed4cb9 (patch)
tree4d4a48dfa4a28b057302c670da65b60cdc1aad79
parent4b57f684dac03a57edcff0ee554883eab7f345b3 (diff)
downloadgobject-introspection-a8977bc6c93793fc9a2e9b6d4315c385d5ed4cb9.tar.gz
Windows port: Use an improved python.m4
- AM_CHECK_PYTHON_HEADERS macro now allows PYTHON_INCLUDES to be overridden from an environment variable and - the new AM_CHECK_PYTHON_LIBS macro to check for ability to link against libpython. This also allows PYTHON_LIBS and PYTHON_LIB_LOC to be overridden from their respective environment variables. This allows gobject-introspection to be built with MinGW/MSYS by doing: PYTHON_DIR="/c/Python27" SRC_DIR="/d/dev/gnome.org/checkout/gobject-introspection/src" ... PYTHON_INCLUDES="-I${PYTHON_DIR}/include/" \ PYTHON_LIBS="-L${PYTHON_DIR}/libs/ -lpython${PYTHON_VERSION}" \ PYTHON_LIB_LOC="${PYTHON_DIR}/libs/" \ "${SRC_DIR}/configure" \ https://bugzilla.gnome.org/show_bug.cgi?id=620566
-rw-r--r--Makefile-giscanner.am8
-rw-r--r--configure.ac6
-rw-r--r--m4/python.m432
3 files changed, 34 insertions, 12 deletions
diff --git a/Makefile-giscanner.am b/Makefile-giscanner.am
index 841089f2..8ae523f6 100644
--- a/Makefile-giscanner.am
+++ b/Makefile-giscanner.am
@@ -58,16 +58,14 @@ _giscanner_la_CFLAGS = \
$(PYTHON_INCLUDES) \
$(GOBJECT_CFLAGS) \
-I$(top_srcdir)/giscanner
-_giscanner_la_LIBADD = libgiscanner.la $(GOBJECT_LIBS)
+_giscanner_la_LIBADD = libgiscanner.la $(GOBJECT_LIBS) $(PYTHON_LIBS)
_giscanner_la_LDFLAGS = \
-module -avoid-version -export-symbols-regex init_giscanner
if OS_WIN32
-# Yuck. Probably there is a way to get this from Python, but I don't
-# know how. Use -Wl to avoid libtool crack.
-PYVER= `echo $(PYTHON_VERSION) | sed 's/\.//g'`
-_giscanner_la_LDFLAGS += -Wl,$(pyexecdir)/../../libs/libpython$(PYVER).a -no-undefined
+_giscanner_la_LDFLAGS += \
+ -no-undefined
endif
_giscanner_la_SOURCES = giscanner/giscannermodule.c
diff --git a/configure.ac b/configure.ac
index 570d7562..9e745b43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -248,9 +248,6 @@ AC_CHECK_FUNCS([memchr strchr strspn strstr strtol strtoull])
AC_CHECK_FUNCS([backtrace backtrace_symbols])
# Python
-
-AC_MSG_CHECKING([whether Python support is requested])
-
AM_PATH_PYTHON([2.5])
case "$host" in
*-*-mingw*)
@@ -259,7 +256,8 @@ case "$host" in
pyexecdir=`echo $pyexecdir | tr '\\\\' '/'`
;;
esac
-AM_CHECK_PYTHON_HEADERS(,AC_MSG_ERROR([Python headers not found]))
+AM_CHECK_PYTHON_HEADERS(, AC_MSG_ERROR([Python headers not found]))
+AM_CHECK_PYTHON_LIBS(, AC_MSG_ERROR([Python libs not found]))
# Glib documentation
diff --git a/m4/python.m4 b/m4/python.m4
index aff55371..c939c43b 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -8,9 +8,11 @@ AC_MSG_CHECKING(for headers required to compile python extensions)
dnl deduce PYTHON_INCLUDES
py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
-PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
-if test "$py_prefix" != "$py_exec_prefix"; then
- PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+if test "x$PYTHON_INCLUDES" == x; then
+ PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
+ if test "$py_prefix" != "$py_exec_prefix"; then
+ PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+ fi
fi
AC_SUBST(PYTHON_INCLUDES)
dnl check if the headers exist:
@@ -23,3 +25,27 @@ $1],dnl
$2])
CPPFLAGS="$save_CPPFLAGS"
])
+
+dnl a macro to check for ability to link against libpython
+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 link against libpython)
+dnl deduce PYTHON_LIBS
+if test "x$PYTHON_LIBS" == x; then
+ PYTHON_LIBS="-L${py_prefix}/lib -lpython${PYTHON_VERSION}"
+fi
+if test "x$PYTHON_LIB_LOC" == x; then
+ PYTHON_LIB_LOC="${py_prefix}/lib"
+fi
+AC_SUBST(PYTHON_LIBS)
+AC_SUBST(PYTHON_LIB_LOC)
+dnl check if libpython exist:
+save_LIBS="$LIBS"
+LIBS="$LIBS $PYTHON_LIBS"
+AC_TRY_LINK_FUNC(Py_Initialize, dnl
+ [LIBS="$save_LIBS"; AC_MSG_RESULT(found); $1], dnl
+ [LIBS="$save_LIBS"; AC_MSG_RESULT(not found); $2])
+
+])