diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2013-08-25 17:08:52 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2013-08-25 17:08:52 +0200 |
commit | f54f2ad39caace08e1aa3c37578d117b4d8ce0a6 (patch) | |
tree | 49c0527c967e28a44e4748aa0beeccbca1b3a2c6 | |
parent | 6f614828817112658ccb771a2ed3b5a2eef4801e (diff) |
Add configure test for Python modules
This uses the AX_PYTHON_MODULE test to check for availability of used
Python modules. All third-party modules and modules that are not a
builtin for Python 2.5 are tested.
This also splits the tests for the utils and pynslcd.
-rw-r--r-- | configure.ac | 45 | ||||
-rw-r--r-- | m4/ax_python_module.m4 | 49 |
2 files changed, 87 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac index a586173..1a9dfdb 100644 --- a/configure.ac +++ b/configure.ac @@ -60,8 +60,6 @@ AC_PROG_RANLIB AM_PROG_CC_C_O AC_USE_SYSTEM_EXTENSIONS AC_PROG_LN_S -AM_PATH_PYTHON(2.5,, [:]) -AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != ":"]) AM_PROG_AR # checks for tool to convert docbook to man @@ -72,6 +70,14 @@ then fi AM_CONDITIONAL([GENMAN], [test "x${DOCBOOK2X_MAN}" != x]) +# check for Python and modules +AM_PATH_PYTHON(2.5,, [:]) +AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != ":"]) +if test "x$PYTHON" != "x:" +then + AX_PYTHON_MODULE(argparse) +fi + # check for debugging options AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], @@ -137,11 +143,11 @@ AC_ARG_ENABLE(utils, [enable_utils="auto"]) if test "x$enable_utils" = "xauto" then - if test "x$PYTHON" = "x:" + if test "x$PYTHON" != "x:" && test "$HAVE_PYMOD_ARGPARSE" = "yes" then - enable_utils="no" - else enable_utils="yes" + else + enable_utils="no" fi fi AC_MSG_RESULT($enable_utils) @@ -577,6 +583,18 @@ then LIBS="$pam_save_LIBS" fi +# utils-specific tests +if test "x$enable_utils" = "xyes" +then + # check Python interpreter + AM_PATH_PYTHON(2.5,, AC_MSG_ERROR([Python is required])) + AX_PYTHON_MODULE(argparse) + if test "x$HAVE_PYMOD_ARGPARSE" != "xyes" + then + AC_MSG_ERROR(Required Python modules missing) + fi +fi + # nslcd daemon-specific tests if test "x$enable_nslcd" = "xyes" then @@ -799,11 +817,24 @@ then AC_SUBST(nslcd_LIBS) fi -# Python-specific tests -if test "x$enable_pynslcd" = "xyes" || test "x$enable_utils" = "xyes" +# pynslcd-specific tests +if test "x$enable_pynslcd" = "xyes" then # check Python interpreter AM_PATH_PYTHON(2.5,, AC_MSG_ERROR([Python is required])) + AX_PYTHON_MODULE(daemon) + AX_PYTHON_MODULE(fcntl) + AX_PYTHON_MODULE(fnmatch) + AX_PYTHON_MODULE(ldap) + AX_PYTHON_MODULE(sqlite3) + if test "x$HAVE_PYMOD_DAEMON" != "xyes" || \ + test "x$HAVE_PYMOD_FCNTL" != "xyes" || \ + test "x$HAVE_PYMOD_FNMATCH" != "xyes" || \ + test "x$HAVE_PYMOD_LDAP" != "xyes" || \ + test "x$HAVE_PYMOD_SQLITE3" != "xyes" + then + AC_MSG_ERROR(Required Python modules missing) + fi fi AM_CONDITIONAL([NSS_FLAVOUR_GLIBC], [test "x${with_nss_flavour}" = xglibc]) diff --git a/m4/ax_python_module.m4 b/m4/ax_python_module.m4 new file mode 100644 index 0000000..3afc404 --- /dev/null +++ b/m4/ax_python_module.m4 @@ -0,0 +1,49 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_python_module.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PYTHON_MODULE(modname[, fatal]) +# +# DESCRIPTION +# +# Checks for Python module. +# +# If fatal is non-empty then absence of a module will trigger an error. +# +# LICENSE +# +# Copyright (c) 2008 Andrew Collier +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE]) +AC_DEFUN([AX_PYTHON_MODULE],[ + if test -z $PYTHON; + then + PYTHON="python" + fi + PYTHON_NAME=`basename $PYTHON` + AC_MSG_CHECKING($PYTHON_NAME module: $1) + $PYTHON -c "import $1" 2>/dev/null + if test $? -eq 0; + then + AC_MSG_RESULT(yes) + eval AS_TR_CPP(HAVE_PYMOD_$1)=yes + else + AC_MSG_RESULT(no) + eval AS_TR_CPP(HAVE_PYMOD_$1)=no + # + if test -n "$2" + then + AC_MSG_ERROR(failed to find required module $1) + exit 1 + fi + fi +]) |