3 AC_REVISION($Revision$)
4 AC_DEFUN(modname,[rlm_python])
6 if test x$with_[]modname != xno; then
11 dnl extra argument: --with-rlm-python-bin
13 AC_ARG_WITH(rlm-python-bin,
14 [ --with-rlm-python-bin=PATH Path to python binary []],
17 AC_MSG_ERROR(Need rlm-python-bin)
27 if test "x$PYTHON_BIN" = x; then
28 AC_CHECK_PROGS(PYTHON_BIN, [ python2.7 python2.6 python ], not-found, [${PATH}:/usr/bin:/usr/local/bin])
31 if test "x$PYTHON_BIN" = "xnot-found"; then
35 dnl extra argument: --with-rlm-python-lib-dir
37 AC_ARG_WITH(rlm-python-lib-dir,
38 [ --with-rlm-python-lib-dir=DIR Directory for Python library files []],
41 AC_MSG_ERROR(Need rlm-python-lib-dir)
51 dnl extra argument: --with-rlm-python-include-dir
53 AC_ARG_WITH(rlm-python-include-dir,
54 [ --with-rlm-python-include-dir=DIR Directory for Python include files []],
57 AC_MSG_ERROR(Need rlm-python-include-dir)
67 if test x$fail = x; then
68 PY_PREFIX=`${PYTHON_BIN} -c 'import sys ; print(sys.prefix)'`
69 AC_MSG_NOTICE([Python sys.prefix \"${PY_PREFIX}\"])
71 PY_EXEC_PREFIX=`${PYTHON_BIN} -c 'import sys ; print(sys.exec_prefix)'`
72 AC_MSG_NOTICE([Python sys.exec_prefix \"${PY_EXEC_PREFIX}\"])
74 PY_SYS_VERSION=`${PYTHON_BIN} -c 'import sys ; print(sys.version[[0:3]])'`
75 AC_MSG_NOTICE([Python sys.version \"${PY_SYS_VERSION}\"])
77 PY_LIB_DIR="$PY_EXEC_PREFIX/lib/python${PY_SYS_VERSION}/config"
78 PY_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python${PY_SYS_VERSION}/config"
80 PY_MAKEFILE="$PY_EXEC_PREFIX/lib/python${PY_SYS_VERSION}/config/Makefile"
81 if test -f ${PY_MAKEFILE}; then
82 PY_LOCAL_MOD_LIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[[:blank:]]]/ /g;s/^ *//;s/ *$//'`
83 AC_MSG_NOTICE([Python local_mod_libs \"${PY_LOCAL_MOD_LIBS}\"])
85 PY_BASE_MOD_LIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[[:blank:]]]/ /g;s/^ *//;s/ *$//'`
86 AC_MSG_NOTICE([Python base_mod_libs \"${PY_BASE_MOD_LIBS}\"])
88 PY_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[[:blank:]]]/ /g;s/ / /g;s/^ *//;s/ *$//'`
89 PY_OTHER_LDFLAGS=`sed -n -e 's/^LINKFORSHARED=\(.*\)/\1/p' $PY_MAKEFILE | sed -e 's/[[[:blank:]]]/ /g;s/ / /g;s/^ *//;s/ *$//'`
90 AC_MSG_NOTICE([Python other_libs \"${PY_OTHER_LDFLAGS} ${PY_OTHER_LIBS}\"])
92 PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASE_MOD_LIBS $PY_OTHER_LIBS"
95 CFLAGS="$CFLAGS $PY_CFLAGS"
96 smart_try_dir="$PY_PREFIX/include/python$PY_SYS_VERSION"
97 FR_SMART_CHECK_INCLUDE(Python.h)
100 if test "x$ac_cv_header_Python_h" = "xyes"; then
101 mod_cflags="$SMART_CPPFLAGS"
103 fail="$fail Python.h"
108 LIBS="$LIBS $PY_LIB_LOC $PY_EXTRA_LIBS -lm"
109 smart_try_dir=$PY_LIB_DIR
110 FR_SMART_CHECK_LIB(python${PY_SYS_VERSION}, Py_Initialize)
113 eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}}
114 if test "x$t" = "xyes"; then
115 mod_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS $SMART_LIBS -lm"
118 FR_SMART_CHECK_LIB(python${PY_SYS_VERSION}m, Py_Initialize)
119 eval t=\${ac_cv_lib_${sm_lib_safe}_${sm_func_safe}}
120 if test "x$t" = "xyes"; then
121 mod_ldflags="$PY_LIB_LOC $PY_EXTRA_LIBS $SMART_LIBS -lm"
125 fail="$fail libpython$PY_SYS_VERSION"
131 echo \*\*\* module modname is disabled.
134 if test x"$fail" != x""; then
135 if test x"${enable_strict_dependencies}" = x"yes"; then
136 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
138 AC_MSG_WARN([silently not building ]modname[.])
139 AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]);
144 AC_SUBST(mod_ldflags)