3 AC_REVISION($Revision$)
4 AC_DEFUN(modname,[rlm_python])
6 if test x$with_[]modname != xno; then
11 AC_CHECK_PROGS(PYTHONBIN, [ python2.3 python2.2 python2.1 python1.5 python ], not-found, [${PATH}:/usr/bin:/usr/local/bin])
13 if test x$PYTHONBIN = xnot-found; then
17 dnl extra argument: --with-rlm-python-lib-dir
19 AC_ARG_WITH(rlm-python-lib-dir,
20 [ --with-rlm-python-lib-dir=DIR Directory for Python library files []],
23 AC_MSG_ERROR(Need rlm-python-lib-dir)
33 dnl extra argument: --with-rlm-python-include-dir
35 AC_ARG_WITH(rlm-python-include-dir,
36 [ --with-rlm-python-include-dir=DIR Directory for Python include files []],
39 AC_MSG_ERROR(Need rlm-python-include-dir)
49 if test x$fail = x; then
51 PY_PREFIX=`${PYTHONBIN} -c 'import sys ; print sys.prefix'`
52 PY_EXEC_PREFIX=`${PYTHONBIN} -c 'import sys ; print sys.exec_prefix'`
53 changequote(<<, >>)dnl
54 PY_VERSION=`${PYTHONBIN} -c 'import sys ; print sys.version[0:3]'`
56 PY_LIBS="-lpython$PY_VERSION"
57 PY_LIB_DIR="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config"
58 PY_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PY_VERSION/config"
59 PY_INC_DIR="$PY_PREFIX/include/python$PY_VERSION"
60 PY_CFLAGS="-I$PY_PREFIX/include/python$PY_VERSION"
61 PY_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config/Makefile"
62 if test -f ${PY_MAKEFILE}; then
63 PY_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
64 PY_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
65 PY_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE`
67 PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASEMODLIBS $PY_OTHER_LIBS"
70 CFLAGS="$CFLAGS $PY_CFLAGS"
71 smart_try_dir=$PY_INC_DIR
72 FR_SMART_CHECK_INCLUDE(Python.h)
75 if test "x$ac_cv_header_Python_h" = "xyes"; then
76 python_cflags=$PY_CFLAGS
83 LIBS="$LIBS $PY_LIB_LOC $PY_EXTRA_LIBS -lm"
84 smart_try_dir=$PY_LIB_DIR
85 FR_SMART_CHECK_LIB(python${PY_VERSION}, Py_Initialize)
88 eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}}
89 if test "x$t" = "xyes"; then
90 python_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS -lpython${PY_VERSION} -lm"
94 fail="$fail libpython$PY_VERSION"
100 echo \*\*\* module modname is disabled.
103 if test x"$fail" != x""; then
104 if test x"${enable_strict_dependencies}" = x"yes"; then
105 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
107 AC_MSG_WARN([silently not building ]modname[.])
108 AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]);
113 AC_SUBST(python_ldflags)
114 AC_SUBST(python_cflags)