* dbus.service.Object: don't let the user try to export objects on the local
[dbus-python-phuang.git] / acinclude.m4
blobaf7e69a8b5d74808fe1785d8dc035109f685fcc9
1 ## this one is commonly used with AM_PATH_PYTHONDIR ...
2 dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
3 dnl Check if a module containing a given symbol is visible to python.
4 AC_DEFUN([AM_CHECK_PYMOD],
5 [AC_REQUIRE([AM_PATH_PYTHON])
6 py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
7 AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1)
8 AC_CACHE_VAL(py_cv_mod_$py_mod_var, [
9 ifelse([$2],[], [prog="
10 import sys
11 try:
12         import $1
13 except ImportError:
14         sys.exit(1)
15 except:
16         sys.exit(0)
17 sys.exit(0)"], [prog="
18 import $1
19 $1.$2"])
20 if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
21   then
22     eval "py_cv_mod_$py_mod_var=yes"
23   else
24     eval "py_cv_mod_$py_mod_var=no"
25   fi
27 py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"`
28 if test "x$py_val" != xno; then
29   AC_MSG_RESULT(yes)
30   ifelse([$3], [],, [$3
31 ])dnl
32 else
33   AC_MSG_RESULT(no)
34   ifelse([$4], [],, [$4
35 ])dnl
39 dnl a macro to check for ability to create python extensions
40 dnl  AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
41 dnl function also defines PYTHON_INCLUDES
42 AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
43 [AC_REQUIRE([AM_PATH_PYTHON])
44 AC_MSG_CHECKING(for headers required to compile python extensions)
45 dnl deduce PYTHON_INCLUDES
46 py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
47 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
48 PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
49 if test "$py_prefix" != "$py_exec_prefix"; then
50   PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
52 AC_SUBST(PYTHON_INCLUDES)
53 dnl check if the headers exist:
54 save_CPPFLAGS="$CPPFLAGS"
55 CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
56 AC_TRY_CPP([#include <Python.h>],dnl
57 [AC_MSG_RESULT(found)
58 $1],dnl
59 [AC_MSG_RESULT(not found)
60 $2])
61 CPPFLAGS="$save_CPPFLAGS"
64 dnl
65 dnl JH_ADD_CFLAG(FLAG)
66 dnl checks whether the C compiler supports the given flag, and if so, adds
67 dnl it to $CFLAGS.  If the flag is already present in the list, then the
68 dnl check is not performed.
69 AC_DEFUN([JH_ADD_CFLAG],
71 case " $CFLAGS " in
72 *@<:@\  \ @:>@$1@<:@\   \ @:>@*)
73   ;;
75   save_CFLAGS="$CFLAGS"
76   CFLAGS="$CFLAGS $1"
77   AC_MSG_CHECKING([whether [$]CC understands $1])
78   AC_TRY_COMPILE([], [], [jh_has_option=yes], [jh_has_option=no])
79   AC_MSG_RESULT($jh_has_option)
80   if test $jh_has_option = no; then
81     CFLAGS="$save_CFLAGS"
82   fi
83   ;;
84 esac])
86 dnl
87 dnl DBUS_PY_ADD_RST2HTMLFLAG(FLAG)
88 dnl checks whether rst2html supports the given flag, and if so, adds
89 dnl it to $RST2HTMLFLAGS. Same as JH_ADD_CFLAG, really.
90 AC_DEFUN([DBUS_PY_ADD_RST2HTMLFLAG],
92 case " $RST2HTMLFLAGS " in
93 *@<:@\  \ @:>@$1@<:@\   \ @:>@*)
94   ;;
96   save_RST2HTMLFLAGS="$RST2HTMLFLAGS"
97   RST2HTMLFLAGS="$RST2HTMLFLAGS $1"
98   AC_MSG_CHECKING([whether [$]RST2HTML understands $1])
99   if $RST2HTML --strict $RST2HTMLFLAGS /dev/null > /dev/null 2>/dev/null; then
100     dbuspy_has_option=yes
101   else
102     dbuspy_has_option=no
103   fi
104   AC_MSG_RESULT($dbuspy_has_option)
105   if test $dbuspy_has_option = no; then
106     RST2HTMLFLAGS="$save_RST2HTMLFLAGS"
107   fi
108   ;;
109 esac])