From 2f18531e265a3e2d4c843831820504d18f5c8b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Wed, 13 Apr 2005 18:56:19 +0000 Subject: [PATCH] check for Python presence git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2012 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- bindings/Makefile.am | 4 ++-- configure.ac | 4 +--- macros/python.m4 | 52 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/bindings/Makefile.am b/bindings/Makefile.am index 380bd7965..56103c5c2 100644 --- a/bindings/Makefile.am +++ b/bindings/Makefile.am @@ -90,7 +90,7 @@ python_ltlib = _Hamlib.la pythondir = $(prefix)/lib/python nodist__Hamlib_la_SOURCES = hamlibpy_wrap.c -_Hamlib_la_LDFLAGS = -no-undefined -module -avoid-version +_Hamlib_la_LDFLAGS = -no-undefined -module -avoid-version @PYTHON_LDFLAGS@ _Hamlib_la_LIBADD = $(top_builddir)/src/libhamlib.la _Hamlib_ladir = $(pythondir) @@ -114,7 +114,7 @@ uninstall-py: ########################################## -lib_LTLIBRARIES = $(tcl_ltlib) $(python_ltlib) +EXTRA_LTLIBRARIES = $(tcl_ltlib) $(python_ltlib) all-local: @BINDING_ALL@ diff --git a/configure.ac b/configure.ac index 90d215e78..5dfa35498 100644 --- a/configure.ac +++ b/configure.ac @@ -270,7 +270,6 @@ SC_PATH_TCLCONFIG if test x"${no_tcl}" = x; then SC_LOAD_TCLCONFIG tcl_save_CPPFLAGS=$CPPFLAGS - echo $TCL_INCLUDE_SPEC CPPFLAGS="$CPPFLAGS $TCL_INCLUDE_SPEC" AC_CHECK_HEADERS([tcl.h], [cf_with_tcl=yes]) @@ -303,12 +302,11 @@ AC_SUBST(TCL_SHLIB_SUFFIX) dnl Check for python availability, so we can enable HamlibPy PYTHON_DEVEL -cf_with_python=yes AC_MSG_CHECKING(whether to build python binding and demo) AC_ARG_WITH(python-binding, [ --with-python-binding build python binding and demo], [cf_with_python_binding=$withval], - [cf_with_python_binding=$cf_with_python]) + [cf_with_python_binding=$cf_with_python_devel]) AC_MSG_RESULT($cf_with_python_binding) if test "${cf_with_python_binding}" = "yes" ; then diff --git a/macros/python.m4 b/macros/python.m4 index 12ff14151..acefcd58b 100644 --- a/macros/python.m4 +++ b/macros/python.m4 @@ -47,6 +47,58 @@ AC_DEFUN([PYTHON_DEVEL],[ AC_MSG_WARN([cannot find Python include path]) else AC_SUBST(PYTHON_CPPFLAGS,[-I$python_path]) + + # Check for Python headers usability + python_save_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS" + AC_CHECK_HEADERS([Python.h],, [cf_with_python_devel=no]) + CPPFLAGS="$python_save_CPPFLAGS" + + if test "$cf_with_python_devel" != "no" ; then + + # Check for Python library path + AC_MSG_CHECKING([for Python library path]) + python_path=`echo $PYTHON | sed "s,/bin.*$,,"` + for i in "$python_path/lib/python$PYTHON_VERSION/config/" "$python_path/lib/python$PYTHON_VERSION/" "$python_path/lib/python/config/" "$python_path/lib/python/" "$python_path/" ; do + python_path=`find $i -type f -name libpython$PYTHON_VERSION.* -print | sed "1q"` + if test -n "$python_path" ; then + break + fi + done + python_path=`echo $python_path | sed "s,/libpython.*$,,"` + AC_MSG_RESULT([$python_path]) + if test -z "$python_path" ; then + AC_MSG_WARN([cannot find Python library path]) + fi + AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"]) + # + python_site=`echo $python_path | sed "s/config/site-packages/"` + AC_SUBST([PYTHON_SITE_PKG],[$python_site]) + # + # libraries which must be linked in when embedding + # + AC_MSG_CHECKING(python extra libraries) + PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ + conf = distutils.sysconfig.get_config_var; \ + print conf('LOCALMODLIBS')+' '+conf('LIBS')" + AC_MSG_RESULT($PYTHON_EXTRA_LIBS)` + AC_SUBST(PYTHON_EXTRA_LIBS) + + + # Check for Python library usability + python_save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS" + AC_CHECK_FUNC(PyArg_Parse, + [cf_with_python_devel=yes], + [cf_with_python_devel=no]) + + LDFLAGS="$python_save_LDFLAGS" + + fi + + fi fi + + ])