if test "x$PYTHON_LIB" '!=' "x" -a "x$PYTHON_INCLUDES" '!=' "x";then
PY_VERSION=unknown
else
- # should we support python versions below 2.2?
- if test -f "/usr/lib/python2.2/site-packages/PIL/_imaging.so" -a -f "/usr/include/python2.2/Python.h";then
- PY_VERSION=2.2
+ if test "x$PYTHON_LIB" '!=' "x" -o "x$PYTHON_INCLUDES" '!=' "x";then
+ echo "Set both PYTHON_LIB and PYTHON_INCLUDES, or none at all"
fi
- if test -f "/usr/lib/python2.3/site-packages/PIL/_imaging.so" -a -f "/usr/include/python2.3/Python.h";then
- PY_VERSION=2.3
- fi
- if test -f "/usr/lib/python2.4/site-packages/PIL/_imaging.so" -a -f "/usr/include/python2.4/Python.h";then
- PY_VERSION=2.4
- fi
- # OS X:
- # /System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3/Python.h
- # /Library/Python/2.3/_imaging.so
+ # iterate through version 2.2 to 2.4
+ for v in 2 3 4; do
+ # Linux
+ if test -f "/usr/lib/python2.$v/site-packages/PIL/_imaging.so" -a -f "/usr/include/python2.$v/Python.h";then
+ PY_VERSION=2.$v
+ PYTHON_LIB="-lpython$PY_VERSION /usr/lib/python$PY_VERSION/site-packages/PIL/_imaging.so"
+ PYTHON_INCLUDES="-I/usr/include/python$PY_VERSION"
+ # Mac OS X
+ elif test -f "/System/Library/Frameworks/Python.framework/Versions/2.$v/include/python2.$v/Python.h";then
+ #TODO: test for /System/Library/Frameworks/Python.framework/Versions/2.3/Python ?
+ PY_VERSION=2.$v
+ PYTHON_LIB="-framework Python"
+ if test -f "/Library/Python/2.$v/PIL/_imaging.so";then
+ PYTHON_LIB2="$PYTHON_LIB /Library/Python/2.$v/PIL/_imaging.so"
+ else
+ PYTHON_LIB2="$PYTHON_LIB"
+ fi
+ PYTHON_INCLUDES="-I/System/Library/Frameworks/Python.framework/Versions/2.$v/include/python2.$v/"
+ # Mac OS X [Fink]:
+ elif test "(" -f "/sw/lib/python2.$v/config/libpython2.$v.dylib" \
+ -o -f "/sw/lib/python2.$v/config/libpython2.$v.a" \
+ -o -f "/sw/lib/python2.$v/config/libpython2.$v.so" \
+ ")" \
+ -a -f "/sw/include/python2.$v/Python.h" \
+ -a -f "/sw/lib/python2.$v/site-packages/PIL/_imaging.so";then
+ PY_VERSION=2.$v
+ PYTHON_LIB="-L /sw/lib/python2.$v/config/ -lpython$PY_VERSION /sw/lib/python2.$v/site-packages/PIL/_imaging.so"
+ PYTHON_INCLUDES="-I /sw/include/python2.$v/"
+ fi
+ done
fi
if test "x$PY_VERSION" "!=" "x"; then
AC_MSG_RESULT($PY_VERSION)
- if test "x$PYTHON_LIB" = "x";then
- PYTHON_LIB="-l$PY_VERSION /usr/lib/$PY_VERSION/site-packages/PIL/_imaging.so"
- fi
- if test "x$PYTHON_INCLUDES" = "x";then
- PYTHON_INCLUDES="-I/usr/include/$PY_VERSION"
- fi
export PYTHON_INCLUDES PYTHON_LIB
AC_SUBST(PYTHON_LIB)
AC_SUBST(PYTHON_INCLUDES)
#include <Python.h>
#include <Imaging.h>
-int main(int argn, char*argv[])
+int main()
{
int ret;
- ret = Py_Main(argn, argv);
+ ret = Py_Main(0, 0);
int x; // check also for gcc 2.95.x incompatibilities
return ret;
}
AC_MSG_RESULT(yes)
PYTHON_OK=yes
else
- echo "configure: failed program was:" >&5
- cat conftest.c >&5
- AC_MSG_RESULT(no)
+ ac_link='$CC $CPPFLAGS $CFLAGS $PYTHON_INCLUDES conftest.c $LDFLAGS ${PYTHON_LIB2} $LIBS -o conftest${ac_exeext}'
+ if { (eval echo python.m4: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ AC_MSG_RESULT(yes)
+ PYTHON_LIB="${PYTHON_LIB2}"
+ PYTHON_OK=yes
+ else
+ echo "configure: failed program was:" >&5
+ cat conftest.c >&5
+ AC_MSG_RESULT(no)
+ fi
fi
rm -f conftest*
else