2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_python])
5 if test x$with_[]modname != xno; then
10 AC_CHECK_PROGS(PYTHONBIN, [ python2.3 python2.2 python2.1 python1.5 python ], not-found, [${PATH}:/usr/bin:/usr/local/bin])
12 if test x$PYTHONBIN = xnot-found; then
16 dnl extra argument: --with-rlm-python-lib-dir
18 AC_ARG_WITH(rlm-python-lib-dir,
19 [ --with-rlm-python-lib-dir=DIR Directory for Python library files []],
22 AC_MSG_ERROR(Need rlm-python-lib-dir)
32 dnl extra argument: --with-rlm-python-include-dir
34 AC_ARG_WITH(rlm-python-include-dir,
35 [ --with-rlm-python-include-dir=DIR Directory for Python include files []],
38 AC_MSG_ERROR(Need rlm-python-include-dir)
48 if test x$fail = x; then
50 PY_PREFIX=`${PYTHONBIN} -c 'import sys ; print sys.prefix'`
51 PY_EXEC_PREFIX=`${PYTHONBIN} -c 'import sys ; print sys.exec_prefix'`
52 changequote(<<, >>)dnl
53 PY_VERSION=`${PYTHONBIN} -c 'import sys ; print sys.version[0:3]'`
55 PY_LIBS="-lpython$PY_VERSION"
56 PY_LIB_DIR="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config"
57 PY_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PY_VERSION/config"
58 PY_INC_DIR="$PY_PREFIX/include/python$PY_VERSION"
59 PY_CFLAGS="-I$PY_PREFIX/include/python$PY_VERSION"
60 PY_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config/Makefile"
61 if test -f ${PY_MAKEFILE}; then
62 PY_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
63 PY_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
64 PY_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE`
66 PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASEMODLIBS $PY_OTHER_LIBS"
69 CFLAGS="$CFLAGS $PY_CFLAGS"
70 smart_try_dir=$PY_INC_DIR
71 AC_SMART_CHECK_INCLUDE(Python.h)
74 if test "x$ac_cv_header_Python_h" = "xyes"; then
75 python_cflags=$PY_CFLAGS
82 LIBS="$LIBS $PY_LIB_LOC $PY_EXTRA_LIBS -lm"
83 smart_try_dir=$PY_LIB_DIR
84 AC_SMART_CHECK_LIB(python${PY_VERSION}, Py_Initialize)
87 eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}}
88 if test "x$t" = "xyes"; then
89 python_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS -lpython${PY_VERSION} -lm"
93 fail="$fail libpython$PY_VERSION"
99 echo \*\*\* module modname is disabled.
102 if test x"$fail" != x""; then
103 if test x"${enable_strict_dependencies}" = x"yes"; then
104 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
106 AC_MSG_WARN([silently not building ]modname[.])
107 AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]);
112 AC_SUBST(python_ldflags)
113 AC_SUBST(python_cflags)