root/pygtkimageview/acinclude.m4

Revision 360, 4.2 kB (checked in by bjourne, 1 year ago)

Fix autogen.sh. You definitely do need gnome-autogen.sh still. Who
would otherwise create the configure script? Also add the acinclude.m4
file with the PYTHON m4 macros.

Line 
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
26 ])
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
36 fi
37 ])
38
39
40 dnl
41 dnl JH_ADD_CFLAG(FLAG)
42 dnl checks whether the C compiler supports the given flag, and if so, adds
43 dnl it to $CFLAGS.  If the flag is already present in the list, then the
44 dnl check is not performed.
45 AC_DEFUN([JH_ADD_CFLAG],
46 [
47 case " $CFLAGS " in
48 *@<:@\  \ @:>@$1@<:@\   \ @:>@*)
49   ;;
50 *)
51   save_CFLAGS="$CFLAGS"
52   CFLAGS="$CFLAGS $1"
53   AC_MSG_CHECKING([whether [$]CC understands $1])
54   AC_TRY_COMPILE([], [], [jh_has_option=yes], [jh_has_option=no])
55   AC_MSG_RESULT($jh_has_option)
56   if test $jh_has_option = no; then
57     CFLAGS="$save_CFLAGS"
58   fi
59   ;;
60 esac])
61
62 dnl a macro to check for ability to create python extensions
63 dnl  AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
64 dnl function also defines PYTHON_INCLUDES
65 AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
66 [AC_REQUIRE([AM_PATH_PYTHON])
67
68 AC_SUBST(PYTHON_INCLUDES)
69 AC_SUBST(PYTHON_LIBS)
70 AC_SUBST(PYTHON_EMBED_LIBS)
71 AC_SUBST(PYTHON_LDFLAGS)
72 AC_SUBST(PYTHON_CC)
73
74 AC_MSG_CHECKING(for headers required to compile python extensions)
75 dnl deduce PYTHON_INCLUDES
76 py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
77 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
78 if test -x "$PYTHON-config"; then
79   PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
80 else
81   PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
82   if test "$py_prefix" != "$py_exec_prefix"; then
83     PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
84   fi
85 fi
86 dnl check if the headers exist:
87 save_CPPFLAGS="$CPPFLAGS"
88 CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
89 AC_TRY_CPP([#include <Python.h>],dnl
90 [AC_MSG_RESULT(found)
91
92 AC_MSG_CHECKING(for python libraries)
93
94
95 dnl Check whether python was compiled as shared library
96 link_pymodules_libpython=false;
97 if egrep "^#define Py_ENABLE_SHARED" "${py_exec_prefix}/include/python${PYTHON_VERSION}/pyconfig.h" > /dev/null ; then
98   if test x`uname -s` != xDarwin; then
99       PYTHON_LDFLAGS="-no-undefined"
100       link_pymodules_libpython=true;
101   fi
102 fi
103
104 dnl use distutils to get some python configuration variables..
105 PYTHON_CC=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_config_var('CC')"`
106 PYTHON_LIB_DEPS=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_config_var('SYSLIBS'), sysconfig.get_config_var('SHLIBS')"`
107 PYTHON_LIBDIR=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_config_var('LIBDIR')"`
108 PYTHON_LIBPL=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_config_var('LIBPL')"`
109
110 save_CC="$CC"
111 save_LIBS="$LIBS"
112
113 PYTHON_EMBED_LIBS="-L${PYTHON_LIBDIR} ${PYTHON_LIB_DEPS} -lpython${PYTHON_VERSION}"
114
115 CC="$PYTHON_CC"
116 LIBS="$LIBS $PYTHON_EMBED_LIBS"
117 AC_TRY_LINK_FUNC(Py_Initialize, dnl
118          [
119             LIBS="$save_LIBS";
120             if $link_pymodules_libpython; then
121                 PYTHON_LIBS="$PYTHON_EMBED_LIBS";
122             fi
123             AC_MSG_RESULT([$PYTHON_EMBED_LIBS]);
124             $1], dnl
125 [
126
127   PYTHON_EMBED_LIBS="-L${PYTHON_LIBPL} ${PYTHON_LIB_DEPS} -lpython${PYTHON_VERSION}"
128
129   LIBS="$save_LIBS $PYTHON_EMBED_LIBS";
130   AC_TRY_LINK_FUNC(Py_Initialize, dnl
131          [
132             LIBS="$save_LIBS";
133             if $link_pymodules_libpython; then
134                 PYTHON_LIBS="$PYTHON_EMBED_LIBS";
135             fi
136             AC_MSG_RESULT([$PYTHON_EMBED_LIBS]);
137             $1], dnl
138          AC_MSG_RESULT(not found); $2)
139 ])
140 CC="$save_CC"
141
142 $1],dnl
143 [AC_MSG_RESULT(not found)
144 $2])
145 CPPFLAGS="$save_CPPFLAGS"
146 ])
147
Note: See TracBrowser for help on using the browser.