dnl -*- mode: Autoconf; -*- dnl ---------------------------------------------------------------------------- dnl --SECTION-- READLINE dnl ---------------------------------------------------------------------------- AC_MSG_NOTICE([--------------------------------------------------------------------------------]) AC_MSG_NOTICE([CHECKING FOR READLINE]) AC_MSG_NOTICE([--------------------------------------------------------------------------------]) AC_LANG(C) AC_ARG_ENABLE(readline, AS_HELP_STRING([--enable-readline], [enable readline support (default: yes)]), tr_READLINE="$enableval", tr_READLINE="maybe" ) AC_ARG_WITH(readline, AS_HELP_STRING([--with-readline=DIR], [where the readline library and includes are located]), [READLINE_CPPFLAGS="-I$withval/include" READLINE_LDFLAGS="-L$withval/lib" READLINE="$withval"] ) AC_ARG_WITH(readline-lib, AS_HELP_STRING([--with-readline-lib=DIR], [where the readline library is located]), [READLINE_LDFLAGS="-L$withval"] ) dnl ---------------------------------------------------------------------------- dnl checks for the READLINE library dnl ---------------------------------------------------------------------------- if test "x$READLINE_CPPFLAGS" != x; then TR_INCLUDE([READLINE_CPPFLAGS]) fi dnl ---------------------------------------------------------------------------- dnl save flags dnl ---------------------------------------------------------------------------- SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $READLINE_CPPFLAGS" SAVE_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $READLINE_LDFLAGS" SAVE_LIBS="$LIBS" dnl ---------------------------------------------------------------------------- dnl check for header and library dnl ---------------------------------------------------------------------------- if test "x$tr_READLINE" = xyes -o "x$tr_READLINE" = xmaybe; then ch_READLINE="$tr_READLINE" AC_CHECK_HEADERS(readline/readline.h, [tr_READLINE="yes"], [tr_READLINE="no"]) if test "x$tr_READLINE" = xyes; then AC_CHECK_LIB([readline], [readline], [READLINE_LIBS="-lreadline" tr_READLINE="yes"], [tr_READLINE="no"]) fi if test "x$tr_READLINE" != xyes; then if test "x$ch_READLINE" = xyes; then AC_MSG_ERROR([Please install readline support]) fi fi fi if test "x$tr_READLINE" = xno; then AC_MSG_ERROR([Please install readline support]) fi dnl ---------------------------------------------------------------------------- dnl grep readline version number dnl ---------------------------------------------------------------------------- if test "x$tr_READLINE" = xyes; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include main () { #if defined(RL_VERSION_MAJOR) && defined(RL_VERSION_MINOR) long sdnhg36ed = RL_VERSION_MAJOR RL_VERSION_MINOR ; #else long sdnhg36ed = RL_READLINE_VERSION hex ; #endif } _ACEOF AC_MSG_CHECKING([READLINE version]) eval "$ac_cpp conftest.$ac_ext" | fgrep "long sdnhg36ed" | awk '{print $4 "." $5}' > conftest.output TRI_READLINE_VERSION=`cat conftest.output` if test -z "$TRI_READLINE_VERSION"; then AC_MSG_ERROR([Readline support is not working. Please re-install readline support]) fi AC_MSG_RESULT([$TRI_READLINE_VERSION]) rm -f conftest* fi dnl ---------------------------------------------------------------------------- dnl restore flags dnl ---------------------------------------------------------------------------- LIBS="$SAVE_LIBS" LDFLAGS="$SAVE_LDFLAGS" CPPFLAGS="$SAVE_CPPFLAGS" if test "x$tr_READLINE" = xyes; then CPPFLAGS="$CPPFLAGS -DHAVE_READLINE=1" READLINE_CPPFLAGS="${READLINE_CPPFLAGS} -DTRI_READLINE_VERSION='\"${TRI_READLINE_VERSION}\"'" fi dnl ---------------------------------------------------------------------------- dnl add substitutions dnl ---------------------------------------------------------------------------- AM_CONDITIONAL(ENABLE_READLINE, test "x$tr_READLINE" = xyes) AC_SUBST(READLINE_CPPFLAGS) AC_SUBST(READLINE_LDFLAGS) AC_SUBST(READLINE_LIBS) dnl ---------------------------------------------------------------------------- dnl informational output dnl ---------------------------------------------------------------------------- if test "x$tr_READLINE" = xyes; then LIB_INFO="$LIB_INFO|READLINE VERSION: ${TRI_READLINE_VERSION}" LIB_INFO="$LIB_INFO|READLINE_CPPLIBS: ${READLINE_CPPLIBS}" LIB_INFO="$LIB_INFO|READLINE_LDLIBS: ${READLINE_LDLIBS}" LIB_INFO="$LIB_INFO|READLINE_LIBS: ${READLINE_LIBS}" else LIB_INFO="$LIB_INFO|READLINE VERSION: disabled" fi LIB_INFO="$LIB_INFO|." dnl ---------------------------------------------------------------------------- dnl --SECTION-- END-OF-FILE dnl ---------------------------------------------------------------------------- dnl Local Variables: dnl mode: outline-minor dnl outline-regexp: "^\\(dnl --SECTION--\\)" dnl End: