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