AC_INIT(rlm_python.c) AC_REVISION($Revision: 1.7 $) AC_DEFUN(modname,[rlm_python]) if test x$with_[]modname != xno; then AC_PROG_CC AC_PROG_CPP AC_CHECK_PROGS(PYTHONBIN, [ python2.3 python2.2 python2.1 python1.5 python ], not-found, [${PATH}:/usr/bin:/usr/local/bin]) if test x$PYTHONBIN = xnot-found; then fail="python-binary" fi dnl extra argument: --with-rlm-python-lib-dir PY_LIB_DIR= AC_ARG_WITH(rlm-python-lib-dir, [ --with-rlm-python-lib-dir=DIR Directory for Python library files []], [ case "$withval" in no) AC_MSG_ERROR(Need rlm-python-lib-dir) ;; yes) ;; *) PY_LIB_DIR="$withval" ;; esac ] ) dnl extra argument: --with-rlm-python-include-dir PY_INC_DIR= AC_ARG_WITH(rlm-python-include-dir, [ --with-rlm-python-include-dir=DIR Directory for Python include files []], [ case "$withval" in no) AC_MSG_ERROR(Need rlm-python-include-dir) ;; yes) ;; *) PY_INC_DIR="$withval" ;; esac ] ) if test x$fail = x; then PY_PREFIX=`${PYTHONBIN} -c 'import sys ; print sys.prefix'` PY_EXEC_PREFIX=`${PYTHONBIN} -c 'import sys ; print sys.exec_prefix'` changequote(<<, >>)dnl PY_VERSION=`${PYTHONBIN} -c 'import sys ; print sys.version[0:3]'` changequote([, ])dnl PY_LIBS="-lpython$PY_VERSION" PY_LIB_DIR="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config" PY_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PY_VERSION/config" PY_INC_DIR="$PY_PREFIX/include/python$PY_VERSION" PY_CFLAGS="-I$PY_PREFIX/include/python$PY_VERSION" PY_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config/Makefile" if test -f ${PY_MAKEFILE}; then PY_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE` PY_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE` PY_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE` fi PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASEMODLIBS $PY_OTHER_LIBS" old_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $PY_CFLAGS" smart_try_dir=$PY_INC_DIR AC_SMART_CHECK_INCLUDE(Python.h) CFLAGS=$old_CFLAGS if test "x$ac_cv_header_Python_h" = "xyes"; then python_cflags=$PY_CFLAGS else fail="$fail Python.h" targetname= fi old_LIBS=$LIBS LIBS="$LIBS $PY_LIB_LOC $PY_EXTRA_LIBS -lm" smart_try_dir=$PY_LIB_DIR AC_SMART_CHECK_LIB(python${PY_VERSION}, Py_Initialize) LIBS=$old_LIBS dnl # If that check fails, try it again having identified threading libraries dnl # in case libpython is threaded if test "x$smart_lib" = "x"; then AC_MSG_NOTICE([Checking to see if libpython may be threaded.]) dnl pthread stuff is usually in -lpthread dnl or in -lc_r, on *BSD dnl FreeBSD uses -pthread libpython_with_threads="yes" case "$host" in *-freebsd*) old_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -pthread" AC_CHECK_FUNC(pthread_create, , [ libpython_with_threads="no" ]) if test "x$libpython_with_threads" = "xno"; then CFLAGS=$old_CFLAGS fi ;; *) AC_CHECK_LIB(pthread, pthread_create, [ LIBS="-lpthread $LIBS" ], AC_CHECK_LIB(c_r, pthread_create, [ LIBS="-lc_r $LIBS" ], [ libpython_with_threads="no" ] ) ) ;; esac if test "x$libpython_with_threads" = "xyes"; then old_LIBS=$LIBS LIBS="$LIBS $PY_LIB_LOC $PY_EXTRA_LIBS -lm" smart_try_dir=$PY_LIB_DIR AC_SMART_CHECK_LIB(python${PY_VERSION}, Py_Initialize) LIBS=$old_LIBS fi fi eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}} if test "x$t" = "xyes"; then python_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS -lpython${PY_VERSION} -lm" targetname=modname else targetname= fail="$fail libpython$PY_VERSION" fi fi else targetname= echo \*\*\* module modname is disabled. fi if test x"$fail" != x""; then if test x"${enable_strict_dependencies}" = x"yes"; then AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.]) else AC_MSG_WARN([silently not building ]modname[.]) AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]); targetname="" fi fi AC_SUBST(python_ldflags) AC_SUBST(python_cflags) AC_SUBST(targetname) AC_OUTPUT(Makefile)