| 1 |
# readline.m4 |
| 2 |
# serial 11 |
| 3 |
dnl Copyright (C) 2005-2006, 2009-2026 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
dnl Written by Simon Josefsson, with help from Bruno Haible and Oskar |
| 10 |
dnl Liljeblad. |
| 11 |
|
| 12 |
AC_DEFUN([gl_FUNC_READLINE], |
| 13 |
[ |
| 14 |
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. |
| 15 |
AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) |
| 16 |
AC_REQUIRE([AC_LIB_RPATH]) |
| 17 |
|
| 18 |
dnl Search for libreadline and define LIBREADLINE, LTLIBREADLINE and |
| 19 |
dnl INCREADLINE accordingly. |
| 20 |
AC_LIB_LINKFLAGS_BODY([readline]) |
| 21 |
|
| 22 |
dnl Add $INCREADLINE to CPPFLAGS before performing the following checks, |
| 23 |
dnl because if the user has installed libreadline and not disabled its use |
| 24 |
dnl via --without-libreadline-prefix, he wants to use it. The AC_LINK_IFELSE |
| 25 |
dnl will then succeed. |
| 26 |
gl_saved_CPPFLAGS="$CPPFLAGS" |
| 27 |
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCREADLINE]) |
| 28 |
|
| 29 |
AC_CACHE_CHECK([for readline], [gl_cv_lib_readline], [ |
| 30 |
gl_cv_lib_readline=no |
| 31 |
gl_saved_LIBS="$LIBS" |
| 32 |
dnl On some systems, -lreadline doesn't link without an additional |
| 33 |
dnl -lncurses or -ltermcap. |
| 34 |
dnl Try -lncurses before -ltermcap, because libtermcap is insecure |
| 35 |
dnl by design and obsolete since 1994. Try -lcurses last, because |
| 36 |
dnl libcurses is unusable on some old Unices. |
| 37 |
for extra_lib in "" ncurses termcap curses; do |
| 38 |
LIBS="$gl_saved_LIBS $LIBREADLINE" |
| 39 |
if test -n "$extra_lib"; then |
| 40 |
LIBS="$LIBS -l$extra_lib" |
| 41 |
fi |
| 42 |
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h> |
| 43 |
#include <readline/readline.h>]], |
| 44 |
[[readline((char*)0);]])], |
| 45 |
[if test -n "$extra_lib"; then |
| 46 |
gl_cv_lib_readline="yes, requires -l$extra_lib" |
| 47 |
else |
| 48 |
gl_cv_lib_readline="yes" |
| 49 |
fi |
| 50 |
]) |
| 51 |
if test "$gl_cv_lib_readline" != no; then |
| 52 |
break |
| 53 |
fi |
| 54 |
done |
| 55 |
LIBS="$gl_saved_LIBS" |
| 56 |
]) |
| 57 |
|
| 58 |
if test "$gl_cv_lib_readline" != no; then |
| 59 |
AC_DEFINE([HAVE_READLINE], [1], [Define if you have the readline library.]) |
| 60 |
extra_lib=`echo "$gl_cv_lib_readline" | sed -n -e 's/yes, requires //p'` |
| 61 |
if test -n "$extra_lib"; then |
| 62 |
LIBREADLINE="$LIBREADLINE $extra_lib" |
| 63 |
LTLIBREADLINE="$LTLIBREADLINE $extra_lib" |
| 64 |
fi |
| 65 |
AC_MSG_CHECKING([how to link with libreadline]) |
| 66 |
AC_MSG_RESULT([$LIBREADLINE]) |
| 67 |
else |
| 68 |
dnl If $LIBREADLINE didn't lead to a usable library, we don't |
| 69 |
dnl need $INCREADLINE either. |
| 70 |
CPPFLAGS="$gl_saved_CPPFLAGS" |
| 71 |
LIBREADLINE= |
| 72 |
LTLIBREADLINE= |
| 73 |
fi |
| 74 |
AC_SUBST([LIBREADLINE]) |
| 75 |
AC_SUBST([LTLIBREADLINE]) |
| 76 |
|
| 77 |
AC_CHECK_HEADERS([readline/readline.h readline/history.h]) |
| 78 |
]) |
| 79 |
|
| 80 |
# Prerequisites of lib/readline.c. |
| 81 |
AC_DEFUN([gl_PREREQ_READLINE], [ |
| 82 |
: |
| 83 |
]) |