initial revision.
[swftools.git] / m4 / python.m4
1 AC_DEFUN(RFX_CHECK_PYTHON,
2 [
3 AC_MSG_CHECKING([for Python.h and PIL])
4 # should we support python versions below 2.2?
5 if test -f "/usr/lib/python2.2/site-packages/PIL/_imaging.so" -a -f "/usr/include/python2.2/Python.h";then
6     PY_VERSION=2.2
7 fi
8 if test -f "/usr/lib/python2.3/site-packages/PIL/_imaging.so" -a -f "/usr/include/python2.3/Python.h";then
9     PY_VERSION=2.3
10 fi
11 if test -f "/usr/lib/python2.4/site-packages/PIL/_imaging.so" -a -f "/usr/include/python2.4/Python.h";then
12     PY_VERSION=2.4
13 fi
14
15 if test "x$PY_VERSION" "!=" "x"; then
16     AC_MSG_RESULT(python$PY_VERSION)
17     if test "x$PYTHON_LIB" = "x";then
18         PYTHON_LIB="-lpython$PY_VERSION /usr/lib/python$PY_VERSION/site-packages/PIL/_imaging.so"
19     fi
20     if test "x$PYTHON_INCLUDES" = "x";then
21         PYTHON_INCLUDES="-I/usr/include/python$PY_VERSION"
22     fi
23     export PYTHON_INCLUDES PYTHON_LIB
24     AC_SUBST(PYTHON_LIB)
25     AC_SUBST(PYTHON_INCLUDES)
26     AC_MSG_CHECKING([whether we can compile the python test program])
27     
28     cat > conftest.c << EOF
29 #include <Python.h>
30 #include <Imaging.h>
31
32 int main(int argn, char*argv[])
33 {
34     return Py_Main(argn, argv);
35 }
36 bli bla blo
37 EOF
38     ac_link='$CC $CPPFLAGS $CFLAGS $PYTHON_INCLUDES conftest.c $LDFLAGS $PYTHON_LIB $LIBS -o conftest${ac_exeext}'
39     if { (eval echo python.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
40         AC_MSG_RESULT(yes)
41         PYTHON_OK=yes
42     else
43         echo "configure: failed program was:" >&5
44         cat conftest.c >&5
45         AC_MSG_RESULT(no)
46     fi
47     rm -f conftest*
48 else
49     AC_MSG_RESULT(nope)
50 fi
51 ])