X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=m4%2Fpython.m4;h=ce0bff2b54eff02999baad38f47d10811ef3e8b8;hp=daaa796d6b28b4cef6bbc939a9439c3c7b4e54da;hb=b9e9d6ddd0438ec3e2ce30e88629f80da0d224ed;hpb=55d0da52b189b233d0d6f0d9798918e6d8c42dd4 diff --git a/m4/python.m4 b/m4/python.m4 index daaa796..ce0bff2 100644 --- a/m4/python.m4 +++ b/m4/python.m4 @@ -1,26 +1,58 @@ -AC_DEFUN(RFX_CHECK_PYTHON, +AC_DEFUN([RFX_CHECK_PYTHON], [ -AC_MSG_CHECKING([for Python.h and PIL]) -# 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 -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 +AC_MSG_CHECKING([for Python.h]) + +if test "x$PYTHON_LIB" '!=' "x" -a "x$PYTHON_INCLUDES" '!=' "x";then + PY_VERSION=unknown +else + 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 + # iterate through version 2.2 to 2.6 + for v in 2 3 4 5 6; do + # Linux + if test -f "/usr/include/python2.$v/Python.h";then + PY_VERSION=2.$v + PYTHON_LIB="-lpython$PY_VERSION" + if test -f "/usr/lib/python2.$v/site-packages/PIL/_imaging.so";then + PYTHON_LIB2="$PYTHON_LIB /usr/lib/python2.$v/site-packages/PIL/_imaging.so" + HAVE_PYTHON_IMAGING_LIB=1 + else + PYTHON_LIB2="$PYTHON_LIB" + fi + PYTHON_INCLUDES="-I/usr/include/python$PY_VERSION" + # Mac OS X + elif test -f "/Library/Frameworks/Python.framework/Versions/2.$v/include/python2.$v/Python.h";then + PY_VERSION=2.$v + PYTHON_LIB="-framework Python" + if test -f "/Library/Frameworks/Python.framework/Versions/2.$v/site-packages/PIL/_imaging.so";then + PYTHON_LIB2="$PYTHON_LIB /Library/Python/2.$v/PIL/_imaging.so" + HAVE_PYTHON_IMAGING_LIB=1 + else + PYTHON_LIB2="$PYTHON_LIB" + fi + PYTHON_INCLUDES="-I/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"; 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" + if test -f "/sw/lib/python2.$v/site-packages/PIL/_imaging.so";then + PYTHON_LIB2="$PYTHON_LIB /sw/lib/python2.$v/site-packages/PIL/_imaging.so" + HAVE_PYTHON_IMAGING_LIB=1 + else + PYTHON_LIB2="$PYTHON_LIB" + fi + PYTHON_INCLUDES="-I /sw/include/python2.$v/" + fi + done fi if test "x$PY_VERSION" "!=" "x"; then - AC_MSG_RESULT(python$PY_VERSION) - pythonrfxswf="lib/python/Makefile" - if test "x$PYTHON_LIB" = "x";then - PYTHON_LIB="-lpython$PY_VERSION /usr/lib/python$PY_VERSION/site-packages/PIL/_imaging.so" - fi - if test "x$PYTHON_INCLUDES" = "x";then - PYTHON_INCLUDES="-I/usr/include/python$PY_VERSION" - fi + AC_MSG_RESULT([$PY_VERSION]) export PYTHON_INCLUDES PYTHON_LIB AC_SUBST(PYTHON_LIB) AC_SUBST(PYTHON_INCLUDES) @@ -28,24 +60,59 @@ if test "x$PY_VERSION" "!=" "x"; then cat > conftest.c << EOF #include -#include -int main(int argn, char*argv[]) +int main() { - return Py_Main(argn, argv); + int ret; + ret = Py_Main(0, 0); + int x; // check also for gcc 2.95.x incompatibilities + return ret; } EOF + ac_link='$CC $CPPFLAGS $CFLAGS $PYTHON_INCLUDES conftest.c $LDFLAGS $PYTHON_LIB $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_OK=yes else - echo "configure: failed program was:" >&5 - cat conftest.c >&5 - AC_MSG_RESULT(no) + echo "configure: failed program was:" >&5 + cat conftest.c >&5 + AC_MSG_RESULT(no) + fi + rm -f conftest* + if test "x$PYTHON_OK" = "xyes";then + AC_MSG_CHECKING([for Python-Imaging]) + cat > conftest.c << EOF +#include +#include + +int main() +{ + Py_Main(0, 0); + return 0; +} +EOF + if test "$HAVE_PYTHON_IMAGING_LIB"; then + 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 + PYTHON_LIB="${PYTHON_LIB2}" + AC_DEFINE([HAVE_PYTHON_IMAGING], [1], [whether python-imaging was found]) + HAVE_PYTHON_IMAGING=yes + export HAVE_PYTHON_IMAGING + AC_SUBST(HAVE_PYTHON_IMAGING) + AC_MSG_RESULT(yes) + else + echo "configure: failed program was:" >&5 + cat conftest.c >&5 + AC_MSG_RESULT(no) + fi + else + echo "(didn't find the Python-Imaging libraries)" >&5 + AC_MSG_RESULT(no) + fi fi rm -f conftest* else - AC_MSG_RESULT(nope) + AC_MSG_RESULT([nope]) fi ])