dnl dnl this macro uses the python version specified (required) to extract dnl the information needed to configure the app dnl variables named with _cv_ are automatically stored in the cache dnl AC_DEFUN([rlr_PROG_PYTHON], [ _with_python="" AC_ARG_WITH(python, [ --with-python=DIR Find bin/python in DIR], _with_python=$withval) dnl dnl look for python in /usr if not specified with --with-python dnl if test "x$_with_python" = "x" ; then if test -r "/usr/bin/python" ; then _with_python="/usr" else AC_MSG_ERROR([/usr/bin/python not readable...must specify Python install with --with-python flag]) fi fi dnl dnl if flag not saved in cache, set cache value to command-line flag and dnl reset any associated vars dnl (NOTE: not using AC_CACHE_CHECK since the cached value will be printed, dnl but not necessarily used if the command-line overrides it...cache can be dnl simply checked by looking at _cv_ vars loaded during AC_INIT) dnl AC_MSG_CHECKING( [Python] ) _cachedMsg="" if test "x${_with_python_cv_}" = "x" ; then _with_python_cv_=${_with_python} PYTHON_cv_="" PYTHON_INCLUDES_cv_="" PYTHON_LIB_NAME_cv_="" PYTHON_LIB_DIR_cv_="" else dnl dnl if flag was defined in the cache, check that it is the same as dnl what was given on the command-line...if not, set cached value to dnl that of the command-line and reset any associated vars dnl if test "${_with_python_cv_}" != "${_with_python}" ; then _with_python_cv_=${_with_python} PYTHON_cv_="" PYTHON_INCLUDES_cv_="" PYTHON_LIB_NAME_cv_="" PYTHON_LIB_DIR_cv_="" else _cachedMsg="(cached) " fi fi AC_MSG_RESULT( [${_cachedMsg}${_with_python_cv_}] ) dnl dnl check and define (if necessary) PYTHON dnl if test "x${PYTHON_cv_}" = "x" ; then if test -r "${_with_python}/bin/python" ; then PYTHON_cv_="${_with_python}/bin/python" else AC_MSG_ERROR([${_with_python}/bin/python does not run]) fi fi PYTHON=${PYTHON_cv_} dnl dnl check and define (if necessary) PYTHON_INCLUDES dnl if test "x${PYTHON_INCLUDES_cv_}" = "x" ; then PYTHON_INCLUDES_cv_=`unset PYTHONHOME; unset PYTHONPATH; ${PYTHON} -c "import distutils.sysconfig ; print distutils.sysconfig.get_python_inc()"` if test "x${PYTHON_INCLUDES_cv_}" = "x" ; then AC_MSG_ERROR([there was a problem with the version of Python specified...make sure it runs and the module distutils is present]) fi fi PYTHON_INCLUDES=${PYTHON_INCLUDES_cv_} dnl dnl check and define (if necessary) PYTHON_LIB_NAME dnl if test "x${PYTHON_LIB_NAME_cv_}" = "x" ; then PYTHON_LIB_PATH=`unset PYTHONHOME; unset PYTHONPATH; ${PYTHON} -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"LIBPL\")"` if test "x${PYTHON_LIB_PATH}" = "x" ; then AC_MSG_ERROR([there was a problem with the version of Python specified...make sure it runs and the module distutils is present]) fi PYTHON_LIB_NAME=`unset PYTHONHOME; unset PYTHONPATH; ${PYTHON} -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"LIBRARY\")"` if test "x${PYTHON_LIB_NAME}" = "x" ; then AC_MSG_ERROR([there was a problem with the version of Python specified...make sure it runs and the module distutils is present]) fi PYTHON_LIB_NAME_cv_="${PYTHON_LIB_PATH}/${PYTHON_LIB_NAME}" fi PYTHON_LIB_NAME=${PYTHON_LIB_NAME_cv_} dnl dnl check and define (if necessary) PYTHON_LIB_DIR & PYTHON_PATH dnl if test "x${PYTHON_LIB_DIR_cv_}" = "x" ; then PYTHON_LIB_DIR_cv_=`unset PYTHONHOME; unset PYTHONPATH; ${PYTHON} -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"LIBDEST\")"` if test "x${PYTHON_LIB_DIR_cv_}" = "x" ; then AC_MSG_ERROR([there was a problem with the version of Python specified...make sure it runs and the module distutils is present]) fi fi PYTHON_LIB_DIR=${PYTHON_LIB_DIR_cv_} PYTHON_PATH=${PYTHON_LIB_DIR_cv_} dnl dnl check and define (if necessary) PYTHON_LINK_LIBS dnl if test "x${PYTHON_LINK_LIBS_cv_}" = "x" ; then PYTHONLIBS=`unset PYTHONHOME; unset PYTHONPATH; ${PYTHON} -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"LIBS\")"` if test "x${PYTHONLIBS}" = "x" ; then AC_MSG_ERROR([there was a problem with the version of Python specified...make sure it runs and the module distutils is present]) fi PYTHON_LINK_LIBS_cv_=${PYTHONLIBS} PYTHONLIBS=`unset PYTHONHOME; unset PYTHONPATH; ${PYTHON} -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"SYSLIBS\")"` PYTHON_LINK_LIBS_cv_="${PYTHON_LINK_LIBS_cv_} ${PYTHONLIBS}" PYTHONLIBS=`unset PYTHONHOME; unset PYTHONPATH; ${PYTHON} -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"MODLIBS\")"` PYTHON_LINK_LIBS_cv_="${PYTHON_LINK_LIBS_cv_} ${PYTHONLIBS}" PYTHONLIBS=`unset PYTHONHOME; unset PYTHONPATH; ${PYTHON} -c "import distutils.sysconfig ; print distutils.sysconfig.get_config_var(\"LINKFORSHARED\")"` PYTHON_LINK_LIBS_cv_="${PYTHON_LINK_LIBS_cv_} ${PYTHONLIBS}" fi LIBS="${LIBS} ${PYTHON_LINK_LIBS_cv_}" dnl dnl export results of tests dnl AC_SUBST(PYTHON) AC_SUBST(PYTHON_INCLUDES) AC_SUBST(PYTHON_LIB_NAME) AC_SUBST(PYTHON_LIB_DIR) AC_SUBST(PYTHON_PATH) ] )