1 AC_DEFUN([RFX_CHECK_PYTHON],
3 AC_MSG_CHECKING([for Python.h])
5 if test "x$PYTHON_LIB" '!=' "x" -a "x$PYTHON_INCLUDES" '!=' "x";then
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"
11 # iterate through version 2.2 to 2.5
14 if test -f "/usr/include/python2.$v/Python.h";then
16 PYTHON_LIB="-lpython$PY_VERSION"
17 if test -f "/usr/lib/python2.$v/site-packages/PIL/_imaging.so";then
18 PYTHON_LIB2="$PYTHON_LIB /usr/lib/python2.$v/site-packages/PIL/_imaging.so"
19 HAVE_PYTHON_IMAGING_LIB=1
21 PYTHON_LIB2="$PYTHON_LIB"
23 PYTHON_INCLUDES="-I/usr/include/python$PY_VERSION"
25 elif test -f "/System/Library/Frameworks/Python.framework/Versions/2.$v/include/python2.$v/Python.h";then
26 #TODO: test for /System/Library/Frameworks/Python.framework/Versions/2.3/Python ?
28 PYTHON_LIB="-framework Python"
29 if test -f "/Library/Python/2.$v/PIL/_imaging.so";then
30 PYTHON_LIB2="$PYTHON_LIB /Library/Python/2.$v/PIL/_imaging.so"
31 HAVE_PYTHON_IMAGING_LIB=1
33 PYTHON_LIB2="$PYTHON_LIB"
35 PYTHON_INCLUDES="-I/System/Library/Frameworks/Python.framework/Versions/2.$v/include/python2.$v/"
37 elif test "(" -f "/sw/lib/python2.$v/config/libpython2.$v.dylib" \
38 -o -f "/sw/lib/python2.$v/config/libpython2.$v.a" \
39 -o -f "/sw/lib/python2.$v/config/libpython2.$v.so" \
41 -a -f "/sw/include/python2.$v/Python.h"; then
43 PYTHON_LIB="-L /sw/lib/python2.$v/config/ -lpython$PY_VERSION /sw/lib/python2.$v/site-packages/PIL/_imaging.so"
44 if test -f "/sw/lib/python2.$v/site-packages/PIL/_imaging.so";then
45 PYTHON_LIB2="$PYTHON_LIB /sw/lib/python2.$v/site-packages/PIL/_imaging.so"
46 HAVE_PYTHON_IMAGING_LIB=1
48 PYTHON_LIB2="$PYTHON_LIB"
50 PYTHON_INCLUDES="-I /sw/include/python2.$v/"
55 if test "x$PY_VERSION" "!=" "x"; then
56 AC_MSG_RESULT([$PY_VERSION])
57 export PYTHON_INCLUDES PYTHON_LIB
59 AC_SUBST(PYTHON_INCLUDES)
60 AC_MSG_CHECKING([whether we can compile the python test program])
62 cat > conftest.c << EOF
69 int x; // check also for gcc 2.95.x incompatibilities
74 ac_link='$CC $CPPFLAGS $CFLAGS $PYTHON_INCLUDES conftest.c $LDFLAGS $PYTHON_LIB $LIBS -o conftest${ac_exeext}'
75 if { (eval echo python.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
79 echo "configure: failed program was:" >&5
84 if test "x$PYTHON_OK" = "xyes";then
85 AC_MSG_CHECKING([for Python-Imaging])
86 cat > conftest.c << EOF
96 if test "$HAVE_PYTHON_IMAGING_LIB"; then
97 ac_link='$CC $CPPFLAGS $CFLAGS $PYTHON_INCLUDES conftest.c $LDFLAGS ${PYTHON_LIB2} $LIBS -o conftest${ac_exeext}'
98 if { (eval echo python.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
99 PYTHON_LIB="${PYTHON_LIB2}"
100 AC_DEFINE([HAVE_PYTHON_IMAGING], [1], [whether python-imaging was found])
101 HAVE_PYTHON_IMAGING=yes
102 export HAVE_PYTHON_IMAGING
103 AC_SUBST(HAVE_PYTHON_IMAGING)
106 echo "configure: failed program was:" >&5
111 echo "(didn't find the Python-Imaging libraries)" >&5
117 AC_MSG_RESULT([nope])