~ubuntu-branches/ubuntu/trusty/python-ecore/trusty

« back to all changes in this revision

Viewing changes to m4/python.m4

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-08-17 16:58:12 UTC
  • mfrom: (3.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110817165812-z6acn9kxhr2dhb41
Tags: 0.7.3-1ubuntu1
* Backport from upstream:
  - Make python-ecore build again, and also without apparent warnings.
  - Support Cython 0.14.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl code from pygtk-2.16.0
 
2
## this one is commonly used with AM_PATH_PYTHONDIR ...
 
3
dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
 
4
dnl Check if a module containing a given symbol is visible to python.
 
5
AC_DEFUN([AM_CHECK_PYMOD],
 
6
[AC_REQUIRE([AM_PATH_PYTHON])
 
7
py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
 
8
AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1)
 
9
AC_CACHE_VAL(py_cv_mod_$py_mod_var, [
 
10
ifelse([$2],[], [prog="
 
11
import sys
 
12
try:
 
13
        import $1
 
14
except ImportError:
 
15
        sys.exit(1)
 
16
except:
 
17
        sys.exit(0)
 
18
sys.exit(0)"], [prog="
 
19
import $1
 
20
$1.$2"])
 
21
if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
 
22
  then
 
23
    eval "py_cv_mod_$py_mod_var=yes"
 
24
  else
 
25
    eval "py_cv_mod_$py_mod_var=no"
 
26
  fi
 
27
])
 
28
py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"`
 
29
if test "x$py_val" != xno; then
 
30
  AC_MSG_RESULT(yes)
 
31
  ifelse([$3], [],, [$3
 
32
])dnl
 
33
else
 
34
  AC_MSG_RESULT(no)
 
35
  ifelse([$4], [],, [$4
 
36
])dnl
 
37
fi
 
38
])
 
39
 
 
40
dnl a macro to check for ability to create python extensions
 
41
dnl  AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
 
42
dnl function also defines PYTHON_INCLUDES
 
43
AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
 
44
[AC_REQUIRE([AM_PATH_PYTHON])
 
45
AC_MSG_CHECKING(for headers required to compile python extensions)
 
46
if test -x "$PYTHON_INCLUDES"; then
 
47
PYTHON_INCLUDES="-I$PYTHON_INCLUDES"
 
48
else
 
49
dnl deduce PYTHON_INCLUDES
 
50
py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
 
51
py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
 
52
if test -x "$PYTHON-config"; then
 
53
PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
 
54
else
 
55
PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
 
56
if test "$py_prefix" != "$py_exec_prefix"; then
 
57
  PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
 
58
fi
 
59
fi
 
60
fi
 
61
AC_SUBST(PYTHON_INCLUDES)
 
62
dnl check if the headers exist:
 
63
save_CPPFLAGS="$CPPFLAGS"
 
64
CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
 
65
AC_TRY_CPP([#include <Python.h>],dnl
 
66
[AC_MSG_RESULT(found)
 
67
$1],dnl
 
68
[AC_MSG_RESULT(not found)
 
69
$2])
 
70
CPPFLAGS="$save_CPPFLAGS"
 
71
])