1 dnl ---------------------------------------------------------------------------
2 dnl Look for the curses libraries. Older curses implementations may require
3 dnl termcap/termlib to be linked as well.
4 AC_DEFUN([CF_CURSES_LIBS],[
5 AC_CHECK_FUNC(initscr,,[
8 AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
11 AC_CHECK_LIB(cur_colr,initscr,[
12 LIBS="-lcur_colr $LIBS"
13 CFLAGS="-I/usr/include/curses_colr $CFLAGS"
14 ac_cv_func_initscr=yes
16 AC_CHECK_LIB(Hcurses,initscr,[
17 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
18 LIBS="-lHcurses $LIBS"
19 CFLAGS="-D__HP_CURSES -D_HP_CURSES $CFLAGS"
20 ac_cv_func_initscr=yes
23 linux*) # Suse Linux does not follow /usr/lib convention
28 if test ".$With5lib" != ".no" ; then
29 if test -d /usr/5lib ; then
31 CPPFLAGS="$CPPFLAGS -I/usr/5include"
32 LIBS="$LIBS -L/usr/5lib"
36 if test ".$ac_cv_func_initscr" != .yes ; then
41 # Check for library containing tgoto. Do this before curses library
42 # because it may be needed to link the test-case for initscr.
43 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
44 for cf_term_lib in termcap termlib unknown
46 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
50 # Check for library containing initscr
51 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
52 for cf_curs_lib in cursesX curses ncurses xcurses jcurses unknown
54 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
56 test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
58 LIBS="-l$cf_curs_lib $cf_save_LIBS"
59 if test "$cf_term_lib" = unknown ; then
60 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
61 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
65 AC_MSG_RESULT($cf_result)
66 test $cf_result = no && AC_ERROR(Cannot link curses library)
67 elif test "$cf_term_lib" != predefined ; then
68 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
69 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
70 [initscr(); tgoto((char *)0, 0, 0);],
73 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
74 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
79 AC_MSG_RESULT($cf_result)
87 dnl @synopsis AC_LIB_READLINE
89 dnl Searches for a readline compatible library. If found, defines
90 dnl `HAVE_LIBREADLINE'. If the found library has the `add_history'
91 dnl function, sets also `HAVE_READLINE_HISTORY'. Also checks for the
92 dnl locations of the necessary include files and sets `HAVE_READLINE_H'
93 dnl or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
94 dnl 'HAVE_HISTORY_H' if the corresponding include files exists.
96 dnl The libraries that may be readline compatible are `libedit',
97 dnl `libeditline' and `libreadline'. Sometimes we need to link a termcap
98 dnl library for readline to work, this macro tests these cases too by
99 dnl trying to link with `libtermcap', `libcurses' or `libncurses' before
102 dnl Here is an example of how to use the information provided by this
103 dnl macro to perform the necessary includes or declarations in a C file:
105 dnl #include <config.h>
107 dnl #ifdef HAVE_LIBREADLINE
108 dnl #if defined(HAVE_READLINE_READLINE_H)
109 dnl #include <readline/readline.h>
110 dnl #elif defined(HAVE_READLINE_H)
111 dnl #include <readline.h>
112 dnl #else /* !defined(HAVE_READLINE_H) */
113 dnl extern char *readline ();
114 dnl #endif /* !defined(HAVE_READLINE_H) */
115 dnl char *cmdline = NULL;
116 dnl #else /* !defined(HAVE_READLINE_READLINE_H) */
117 dnl /* no readline */
118 dnl #endif /* HAVE_LIBREADLINE */
120 dnl #ifdef HAVE_READLINE_HISTORY
121 dnl #if defined(HAVE_READLINE_HISTORY_H)
122 dnl #include <readline/history.h>
123 dnl #elif defined(HAVE_HISTORY_H)
124 dnl #include <history.h>
125 dnl #else /* !defined(HAVE_HISTORY_H) */
126 dnl extern void add_history ();
127 dnl extern int write_history ();
128 dnl extern int read_history ();
129 dnl #endif /* defined(HAVE_READLINE_HISTORY_H) */
131 dnl #endif /* HAVE_READLINE_HISTORY */
135 dnl @author Ville Laurikari <vl@iki.fi>
137 AC_DEFUN([AC_LIB_READLINE], [
138 AC_CACHE_CHECK([for a readline compatible library],
139 ac_cv_lib_readline, [
141 for readline_lib in readline edit editline; do
142 for termcap_lib in "" termcap curses ncurses; do
143 if test -z "$termcap_lib"; then
144 TRY_LIB="-l$readline_lib"
146 TRY_LIB="-l$readline_lib -l$termcap_lib"
148 LIBS="$ORIG_LIBS $TRY_LIB"
149 AC_TRY_LINK_FUNC(readline, ac_cv_lib_readline="$TRY_LIB")
150 if test -n "$ac_cv_lib_readline"; then
154 if test -n "$ac_cv_lib_readline"; then
158 if test -z "$ac_cv_lib_readline"; then
159 ac_cv_lib_readline="no"
164 if test "$ac_cv_lib_readline" != "no"; then
165 LIBS="$LIBS $ac_cv_lib_readline"
166 AC_DEFINE(HAVE_LIBREADLINE, 1,
167 [Define if you have a readline compatible library])
168 AC_CHECK_HEADERS(readline.h readline/readline.h)
169 AC_CACHE_CHECK([whether readline supports history],
170 ac_cv_lib_readline_history, [
171 ac_cv_lib_readline_history="no"
172 AC_TRY_LINK_FUNC(add_history, ac_cv_lib_readline_history="yes")
174 if test "$ac_cv_lib_readline_history" = "yes"; then
175 AC_DEFINE(HAVE_READLINE_HISTORY, 1,
176 [Define if your readline library has \`add_history'])
177 AC_CHECK_HEADERS(history.h readline/history.h)