fixed .frame numbers, changed .flash name to .flash filename.
[swftools.git] / m4 / python.m4
1 AC_DEFUN(RFX_CHECK_PYTHON,
2 [
3 AC_MSG_CHECKING([for Python.h and PIL])
4
5 if test "x$PYTHON_LIB" '!=' "x" -a "x$PYTHON_INCLUDES" '!=' "x";then
6     PY_VERSION=unknown
7 else
8     if test "x$PYTHON_LIB" '!=' "x" -o "x$PYTHON_INCLUDES" '!=' "x";then
9         echo "Set both PYTHON_LIB and PYTHON_INCLUDES, or none at all"
10     fi
11     # iterate through version 2.2 to 2.4
12     for v in 2 3 4; do
13         # Linux
14         if test -f "/usr/lib/python2.$v/site-packages/PIL/_imaging.so" -a -f "/usr/include/python2.$v/Python.h";then
15             PY_VERSION=2.$v
16             PYTHON_LIB="-lpython$PY_VERSION /usr/lib/python$PY_VERSION/site-packages/PIL/_imaging.so"
17             PYTHON_INCLUDES="-I/usr/include/python$PY_VERSION"
18         # Mac OS X
19         elif test -f "/Library/Python/2.$v/PIL/_imaging.so" \
20                -a -f "/System/Library/Frameworks/Python.framework/Versions/2.$v/include/python2.$v/Python.h";then
21             PY_VERSION=2.$v
22             PYTHON_LIB="-framework Python /Library/Python/2.$v/PIL/_imaging.so"
23             PYTHON_INCLUDES="-I/System/Library/Frameworks/Python.framework/Versions/2.$v/include/python2.$v/"
24         # Mac OS X [Fink]:
25         elif test "(" -f "/sw/lib/python2.$v/config/libpython2.$v.dylib" \
26                    -o -f "/sw/lib/python2.$v/config/libpython2.$v.a" \
27                    -o -f "/sw/lib/python2.$v/config/libpython2.$v.so" \
28                   ")" \
29                -a -f "/sw/include/python2.$v/Python.h" \
30                -a -f "/sw/lib/python2.$v/site-packages/PIL/_imaging.so";then
31             PY_VERSION=2.$v
32             PYTHON_LIB="-L /sw/lib/python2.$v/config/ -lpython$PY_VERSION /sw/lib/python2.$v/site-packages/PIL/_imaging.so"
33             PYTHON_INCLUDES="-I /sw/include/python2.$v/"
34         fi
35     done
36 fi
37
38 if test "x$PY_VERSION" "!=" "x"; then
39     AC_MSG_RESULT($PY_VERSION)
40     export PYTHON_INCLUDES PYTHON_LIB
41     AC_SUBST(PYTHON_LIB)
42     AC_SUBST(PYTHON_INCLUDES)
43     AC_MSG_CHECKING([whether we can compile the python test program])
44     
45     cat > conftest.c << EOF
46 #include <Python.h>
47 #include <Imaging.h>
48
49 int main()
50 {
51     int ret;
52     ret = Py_Main(0, 0);
53     int x; // check also for gcc 2.95.x incompatibilities
54     return ret;
55 }
56 EOF
57     ac_link='$CC $CPPFLAGS $CFLAGS $PYTHON_INCLUDES conftest.c $LDFLAGS $PYTHON_LIB $LIBS -o conftest${ac_exeext}'
58     if { (eval echo python.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
59         AC_MSG_RESULT(yes)
60         PYTHON_OK=yes
61     else
62         echo "configure: failed program was:" >&5
63         cat conftest.c >&5
64         AC_MSG_RESULT(no)
65     fi
66     rm -f conftest*
67 else
68     AC_MSG_RESULT(nope)
69 fi
70 ])