x_ac_readline.m4 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ##*****************************************************************************
  2. # AUTHOR:
  3. # Jim Garlick <garlick@llnl.gov>
  4. #
  5. # SYNOPSIS:
  6. # AC_READLINE
  7. #
  8. # DESCRIPTION:
  9. # Adds support for --without-readline. Exports READLINE_LIBS if found
  10. #
  11. #
  12. # WARNINGS:
  13. # This macro must be placed after AC_PROG_CC and X_AC_CURSES.
  14. ##*****************************************************************************
  15. AC_DEFUN([X_AC_READLINE],
  16. [
  17. AC_MSG_CHECKING([for whether to include readline suport])
  18. AC_ARG_WITH([readline],
  19. AS_HELP_STRING(--without-readline,compile without readline support),
  20. [ case "$withval" in
  21. yes) ac_with_readline=yes ;;
  22. no) ac_with_readline=no ;;
  23. *) AC_MSG_RESULT([doh!])
  24. AC_MSG_ERROR([bad value "$withval" for --without-readline]) ;;
  25. esac
  26. ]
  27. )
  28. AC_MSG_RESULT([${ac_with_readline=yes}])
  29. if test "$ac_with_readline" = "yes"; then
  30. saved_LIBS="$LIBS"
  31. READLINE_LIBS="-lreadline -lhistory $NCURSES"
  32. LIBS="$saved_LIBS $READLINE_LIBS"
  33. AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h>
  34. #include <readline/readline.h>
  35. #include <readline/history.h>]], [[
  36. readline("in:");]])],[AC_DEFINE([HAVE_READLINE], [1],
  37. [Define if you are compiling with readline.])],[READLINE_LIBS=""])
  38. LIBS="$saved_LIBS"
  39. if test "$READLINE_LIBS" = ""; then
  40. AC_MSG_WARN([configured for readline support, but couldn't find libraries]);
  41. fi
  42. fi
  43. AC_SUBST(READLINE_LIBS)
  44. ])