3 AC_REVISION($Revision$)
4 AC_DEFUN(modname,[rlm_python])
6 if test x$with_[]modname != xno; then
11 AC_CHECK_PROGS(PYTHONBIN, [ python2.7 python2.6 python2.5 python2.4 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_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PY_VERSION/config/Makefile"
60 if test -f ${PY_MAKEFILE}; then
61 PY_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
62 PY_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE`
63 PY_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE`
64 PY_OTHER_LDFLAGS=`sed -n -e 's/^LINKFORSHARED=\(.*\)/\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_PREFIX/include/python$PY_VERSION"
71 FR_SMART_CHECK_INCLUDE(Python.h)
74 if test "x$ac_cv_header_Python_h" = "xyes"; then
75 mod_cflags="$SMART_CPPFLAGS"
82 LIBS="$LIBS $PY_LIB_LOC $PY_EXTRA_LIBS -lm"
83 smart_try_dir=$PY_LIB_DIR
84 FR_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 mod_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS $SMART_LIBS -lm"
92 FR_SMART_CHECK_LIB(python${PY_VERSION}m, Py_Initialize)
93 eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}}
94 if test "x$t" = "xyes"; then
95 mod_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS $SMART_LIBS -lm"
99 fail="$fail libpython$PY_VERSION"
105 echo \*\*\* module modname is disabled.
108 if test x"$fail" != x""; then
109 if test x"${enable_strict_dependencies}" = x"yes"; then
110 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
112 AC_MSG_WARN([silently not building ]modname[.])
113 AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]);
118 AC_SUBST(mod_ldflags)