+CXXFLAGS="$CXXFLAGS $DEBUG"
+
+# Check for Python
+AC_ARG_WITH([python],
+ [ --with-python=path Set location of Python executable],
+ [PYTHON="$withval"],
+ [PYTHON=])
+
+# Find the python bin
+if ! test "$PYTHON"; then
+ AC_CHECK_PROGS(PYTHON, $prefix/bin/python python python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4)
+fi
+if ! test "$PYTHON"; then
+ AC_MSG_ERROR([Openbox requires the use of Python. This is its secret special formula for extreme sexiness.
+See http://www.python.org
+])
+fi
+
+# Find our python paths
+AC_MSG_CHECKING([for Python version])
+# Need to do this hack since autoconf replaces __file__ with the name of the configure file
+filehack="file__"
+PYVERSION=`($PYTHON -c "import string,operator; print operator.getitem(string.split(string.__$filehack,'/'),-2)")`
+AC_MSG_RESULT([$PYVERSION])
+
+AC_MSG_CHECKING([for Python prefix])
+PYPREFIX=`($PYTHON -c "import sys; print sys.prefix") 2>/dev/null`
+AC_MSG_RESULT([$PYPREFIX])
+AC_MSG_CHECKING([for Python exec-prefix])
+PYEPREFIX=`($PYTHON -c "import sys; print sys.exec_prefix") 2>/dev/null`
+AC_MSG_RESULT([$PYEPREFIX])
+
+# Find the include directory
+AC_MSG_CHECKING([for Python header files])
+if test -r "$PYPREFIX/include/$PYVERSION/Python.h"; then
+ PYTHON_CFLAGS="-I$PYPREFIX/include/$PYVERSION"
+fi
+if test -z "$PYTHON_CFLAGS"; then
+ if test -r "$PYPREFIX/include/Py/Python.h"; then
+ PYTHON_CFLAGS="-I$PYPREFIX/include/Py"
+ fi
+fi
+if ! test "$PYTHON_CFLAGS"; then
+ AC_MSG_ERROR([Not found])
+else
+ AC_MSG_RESULT([$PYTHON_CFLAGS])
+fi
+
+# Set the library directory blindly. This probably won't work with older versions
+AC_MSG_CHECKING([for Python library])
+dirs="$PYVERSION/config $PYVERSION/lib python/lib"
+for i in $dirs; do
+ if test -d "$PYEPREFIX/lib/$i"; then
+ PYLIB="$PYEPREFIX/lib/$i"
+ break
+ fi
+done
+if ! test "$PYLIB"; then
+ AC_MSG_ERROR([Not found])
+else
+ AC_MSG_RESULT([$PYLIB])
+fi
+
+# Check for really old versions
+if test -r "$PYLIB/libPython.a"; then
+ PYTHON_LIBS="-L$PYLIB -lModules -lPython -lObjects -lParser"
+else
+ PYTHON_LIBS="-L$PYLIB -l$PYVERSION"
+fi
+
+AC_SUBST([PYTHON_CFLAGS])
+AC_SUBST([PYTHON_LIBS])