Python and Autoconf

A Meowbot meowbot at meowing.net
Thu May 24 20:48:07 EDT 2001


Glen Starchman <glen at enabledventures.com> wrote:

> Anyone have any more Python-specific autoconf macros? 

Wanna see something _really_ scary?




dnl Libraries and flags for embedded Python.
dnl FIXME: I wish there was a less icky way to get this.
if test x"$DO_PYTHON" = xdefine ; then
    AC_MSG_CHECKING(for Python linkage)
    py_prefix=`$_PATH_PYTHON -c 'import sys; print sys.prefix'`
    py_ver=`$_PATH_PYTHON -c 'import sys; print sys.version[[:3]]'`
    py_libdir="${py_prefix}/lib/python${py_ver}"
    PYTHON_INC="-I${py_prefix}/include/python${py_ver}"
    py_libs=`grep '^LIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
    py_libc=`grep '^LIBC=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
    py_libm=`grep '^LIBM=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
    py_liblocalmod=`grep '^LOCALMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
    py_libbasemod=`grep '^BASEMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
    py_linkforshared=`grep '^LINKFORSHARED=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
    PYTHON_LIB="-L$py_libdir/config $py_libs $py_libc $py_libm -lpython$py_ver $py_liblocalmod $py_libbasemod $py_linkforshared"
    PYTHON_LIB=`echo $PYTHON_LIB | sed -e 's/[ \\t]*/ /g'`
    AC_MSG_RESULT($py_libdir)
else
    PYTHON_LIB=""
    PYTHON_INC=""
fi
AC_SUBST(PYTHON_LIB)
AC_SUBST(PYTHON_INC)



More information about the Python-list mailing list