From 46fd6ad2075870ae63e36d362bf8d6deef277c53 Mon Sep 17 00:00:00 2001 From: infirit Date: Mon, 29 Jun 2015 19:27:07 +0200 Subject: python: use pkgconfig for compiler and linker flags We need python to bump to 2.7 for the pkgconfig file. --- configure.ac | 53 ++++++--------------------------- m4/python.m4 | 86 ------------------------------------------------------ python/Makefile.am | 2 +- 3 files changed, 10 insertions(+), 131 deletions(-) delete mode 100644 m4/python.m4 diff --git a/configure.ac b/configure.ac index 05a7e5f..2210f54 100644 --- a/configure.ac +++ b/configure.ac @@ -76,57 +76,22 @@ AC_SUBST(DEBUG_CFLAGS) AC_ARG_ENABLE(python, [AC_HELP_STRING([--enable-python], - [build python bindings @<:@default=auto@:>@])], - [enable_deprecations=$enableval], - [enable_deprecations=auto]) + [build python bindings])], + [enable_python=$enableval], + [enable_python=yes]) # Detect if we can build Python bindings (need python and python headers) -if test "x$enable_python" = "xno" ; then - have_python=no +if test "x$enable_python" = "xyes" ; then + AM_PATH_PYTHON(2.7) + PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}], [have_python=yes], [have_python=no]) else - AC_MSG_NOTICE([Checking to see if we can build Python bindings]) - have_python=no - AM_PATH_PYTHON(2.3) - - if test "x$PYTHON" = "x" ; then - AC_MSG_WARN([Python not found]) - else - AM_CHECK_PYTHON_HEADERS(have_python_headers=yes, have_python_headers=no) - if test "x$have_python_headers" = "xyes" ; then - have_python=yes - fi - fi - - if test "x$have_python" = "xno" ; then - if test "x$enable_python" = "xyes" ; then - AC_MSG_ERROR([Building python explicitly requested, but can't build python bindings]) - else - AC_MSG_WARN([Couldn't find the Python headers, not building Python bindings]) - fi - fi + have_python=no fi +AC_SUBST(PYTHON_LIBS) +AC_SUBST(PYTHON_CFLAGS) AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes) -# Because of the way Python implements polymorphism, we get the following warning: -# "warning: dereferencing type-punned pointer will break strict-aliasing rules" -# -fno-strict-aliasing (as used in Python build) switches warnings off -NO_STRICT_ALIASING_CFLAGS="" -if test "x$GCC" = "xyes" ; then - AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing) - ac_save_cc="$CC" - CC="$CC -fno-strict-aliasing" - AC_TRY_RUN([int main() { return 0; }], - ac_cv_no_strict_aliasing_ok=yes, - ac_cv_no_strict_aliasing_ok=no, - ac_cv_no_strict_aliasing_ok=no) - CC="$ac_save_cc" - AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok) - if test "x$ac_cv_no_strict_aliasing_ok" = "xyes" ; then - NO_STRICT_ALIASING_CFLAGS="-fno-strict-aliasing" - fi -fi -AC_SUBST(NO_STRICT_ALIASING_CFLAGS) GOBJECT_INTROSPECTION_CHECK([0.6.7]) diff --git a/m4/python.m4 b/m4/python.m4 deleted file mode 100644 index dc2e750..0000000 --- a/m4/python.m4 +++ /dev/null @@ -1,86 +0,0 @@ -dnl a macro to check for ability to create python extensions -dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) -dnl function also defines PYTHON_INCLUDES -AC_DEFUN([AM_CHECK_PYTHON_HEADERS], -[AC_REQUIRE([AM_PATH_PYTHON]) - -AC_SUBST(PYTHON_INCLUDES) -AC_SUBST(PYTHON_LIBS) -AC_SUBST(PYTHON_EMBED_LIBS) -AC_SUBST(PYTHON_LDFLAGS) -AC_SUBST(PYTHON_CC) - -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"` -if test -x "$PYTHON-config"; then - PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null` -else - 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 -dnl check if the headers exist: -save_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" -AC_TRY_CPP([#include ],dnl -[AC_MSG_RESULT(found) - -AC_MSG_CHECKING(for python libraries) - - -dnl Check whether python was compiled as shared library -link_pymodules_libpython=false; -py_enable_shared=`$PYTHON -c "from distutils.sysconfig import get_config_var; print repr(get_config_var('Py_ENABLE_SHARED'))"` -if test $py_enable_shared = 1 ; then - if test x`uname -s` != xDarwin; then - PYTHON_LDFLAGS="-no-undefined" - link_pymodules_libpython=true; - fi -fi - -dnl use distutils to get some python configuration variables.. -PYTHON_CC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_config_var('CC')"` -PYTHON_LIB_DEPS=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_config_var('SYSLIBS'), sysconfig.get_config_var('SHLIBS')"` -PYTHON_LIBDIR=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_config_var('LIBDIR')"` -PYTHON_LIBPL=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_config_var('LIBPL')"` - -save_CC="$CC" -save_LIBS="$LIBS" - -PYTHON_EMBED_LIBS="-L${PYTHON_LIBDIR} ${PYTHON_LIB_DEPS} -lpython${PYTHON_VERSION}" - -CC="$PYTHON_CC" -LIBS="$LIBS $PYTHON_EMBED_LIBS" -AC_TRY_LINK_FUNC(Py_Initialize, dnl - [ - LIBS="$save_LIBS"; - if $link_pymodules_libpython; then - PYTHON_LIBS="$PYTHON_EMBED_LIBS"; - fi - AC_MSG_RESULT([$PYTHON_EMBED_LIBS]); - $1], dnl -[ - - PYTHON_EMBED_LIBS="-L${PYTHON_LIBPL} ${PYTHON_LIB_DEPS} -lpython${PYTHON_VERSION}" - - LIBS="$save_LIBS $PYTHON_EMBED_LIBS"; - AC_TRY_LINK_FUNC(Py_Initialize, dnl - [ - LIBS="$save_LIBS"; - if $link_pymodules_libpython; then - PYTHON_LIBS="$PYTHON_EMBED_LIBS"; - fi - AC_MSG_RESULT([$PYTHON_EMBED_LIBS]); - $1], dnl - AC_MSG_RESULT(not found); $2) -]) -CC="$save_CC" - -$1],dnl -[AC_MSG_RESULT(not found) -$2]) -CPPFLAGS="$save_CPPFLAGS" -]) diff --git a/python/Makefile.am b/python/Makefile.am index 0f55476..1cb750a 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = \ $(GLIB_CFLAGS) \ - $(PYTHON_INCLUDES) \ + $(PYTHON_CFLAGS) \ -I$(srcdir)/../libmenu \ -DMATEMENU_I_KNOW_THIS_IS_UNSTABLE \ $(DISABLE_DEPRECATED_CFLAGS) \ -- cgit v1.2.1