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 3.2
12 for v in 2.2 2.3 2.4 2.5 2.6 3.0 3.1 3.2; do
14 if test -f "/usr/include/python$v/Python.h";then
16 PYTHON_LIB="-lpython$PY_VERSION"
17 if test -f "/usr/lib/python$v/site-packages/PIL/_imaging.so";then
18 PYTHON_LIB2="$PYTHON_LIB /usr/lib/python$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 "/Library/Frameworks/Python.framework/Versions/$v/include/python$v/Python.h";then
27 PYTHON_LIB="-framework Python"
28 if test -f "/Library/Frameworks/Python.framework/Versions/$v/site-packages/PIL/_imaging.so";then
29 PYTHON_LIB2="$PYTHON_LIB /Library/Python/$v/PIL/_imaging.so"
30 HAVE_PYTHON_IMAGING_LIB=1
32 PYTHON_LIB2="$PYTHON_LIB"
34 PYTHON_INCLUDES="-I/Library/Frameworks/Python.framework/Versions/$v/include/python$v/"
36 elif test "(" -f "/sw/lib/python$v/config/libpython$v.dylib" \
37 -o -f "/sw/lib/python$v/config/libpython$v.a" \
38 -o -f "/sw/lib/python$v/config/libpython$v.so" \
40 -a -f "/sw/include/python$v/Python.h"; then
42 PYTHON_LIB="-L /sw/lib/python$v/config/ -lpython$PY_VERSION /sw/lib/python$v/site-packages/PIL/_imaging.so"
43 if test -f "/sw/lib/python$v/site-packages/PIL/_imaging.so";then
44 PYTHON_LIB2="$PYTHON_LIB /sw/lib/python$v/site-packages/PIL/_imaging.so"
45 HAVE_PYTHON_IMAGING_LIB=1
47 PYTHON_LIB2="$PYTHON_LIB"
49 PYTHON_INCLUDES="-I /sw/include/python$v/"
54 if test "x$PY_VERSION" "!=" "x"; then
55 AC_MSG_RESULT([$PY_VERSION])
56 export PYTHON_INCLUDES PYTHON_LIB
58 AC_SUBST(PYTHON_INCLUDES)
59 AC_MSG_CHECKING([whether we can compile the python test program])
61 cat > conftest.c << EOF
68 int x; // check also for gcc 2.95.x incompatibilities
73 ac_link='$CC $CPPFLAGS $CFLAGS $PYTHON_INCLUDES conftest.c $LDFLAGS $PYTHON_LIB $LIBS -o conftest${ac_exeext}'
74 if { (eval echo python.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
78 echo "configure: failed program was:" >&5
83 if test "x$PYTHON_OK" = "xyes";then
84 AC_MSG_CHECKING([for Python-Imaging])
85 cat > conftest.c << EOF
95 if test "$HAVE_PYTHON_IMAGING_LIB"; then
96 ac_link='$CC $CPPFLAGS $CFLAGS $PYTHON_INCLUDES conftest.c $LDFLAGS ${PYTHON_LIB2} $LIBS -o conftest${ac_exeext}'
97 if { (eval echo python.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
98 PYTHON_LIB="${PYTHON_LIB2}"
99 AC_DEFINE([HAVE_PYTHON_IMAGING], [1], [whether python-imaging was found])
100 HAVE_PYTHON_IMAGING=yes
101 export HAVE_PYTHON_IMAGING
102 AC_SUBST(HAVE_PYTHON_IMAGING)
105 echo "configure: failed program was:" >&5
110 echo "(didn't find the Python-Imaging libraries)" >&5
116 AC_MSG_RESULT([nope])