source: git/m4/readline-check.m4 @ 6ed33f

spielwiese
Last change on this file since 6ed33f was 475043, checked in by Hans Schoenemann <hannes@…>, 4 years ago
cross-compile: --with-readline=no -> fgets, =ncurses: try ncurses,curses,termcap
  • Property mode set to 100644
File size: 3.3 KB
Line 
1# Check for readline
2
3AC_DEFUN([SING_CHECK_READLINE],
4[
5## DEFAULT_CHECKING_PATH="/usr /usr/local /sw /opt/local"
6
7#AC_ARG_WITH([readline],
8#  [AS_HELP_STRING([--without-readline],
9#    [disable support for readline])],
10#  [],
11#  [with_readline=yes])
12
13
14AC_CHECK_HEADERS(sys/file.h sys/ioctl.h sys/time.h sys/times.h sys/types.h \
15 sys/stat.h fcntl.h sys/param.h pwd.h asm/sigcontext.h pwd.h termcap.h \
16 termios.h term.h readline/readline.h)
17
18AC_ARG_WITH(
19  readline,
20  [  --with-readline=[dynamic,static,no,ncurses]
21                        use dynamic/static/no readline/ncurses for fancy display])
22
23if test "$with_readline" != no; then
24 AC_CHECK_LIB(ncurses,tgetent,,\
25  AC_CHECK_LIB(curses,tgetent,,\
26   AC_CHECK_LIB(termcap,tgetent)))
27fi
28
29# readline
30if test "$with_readline" = dynamic && test "$ac_have_dl" != yes; then
31  AC_MSG_WARN(can not build dynamic readline without dynamic linking)
32  with_readline=static
33fi
34
35
36if test "$with_readline" != dynamic && test "$with_readline" != no; then
37AC_LANG_SAVE
38AC_LANG_CPLUSPLUS
39   AC_CHECK_LIB(readline, readline)
40   AC_CHECK_HEADERS(readline/readline.h readline/history.h)
41   if test "$ac_cv_lib_readline_readline" = yes && \
42      test "$ac_cv_header_readline_readline_h" = yes; then
43     AC_MSG_CHECKING(whether readline.h is ok)
44     AC_CACHE_VAL(ac_cv_header_readline_readline_h_ok,
45     AC_TRY_LINK(
46#include<unistd.h>
47#include<stdio.h>
48#include<readline/readline.h>
49#ifdef HAVE_READLINE_HISTORY_H
50#include<readline/history.h>
51#endif
52,
53,
54ac_cv_header_readline_readline_h_ok="yes",
55ac_cv_header_readline_readline_h_ok="no",
56))
57    AC_MSG_RESULT($ac_cv_header_readline_readline_h_ok)
58    if test "$ac_cv_header_readline_readline_h_ok" != yes; then
59#not ok -- try once more with explicitly declaring everything
60      AC_MSG_CHECKING(whether or not we nevertheless can use readline)
61      AC_CACHE_VAL(ac_cv_have_readline,
62      AC_TRY_LINK(
63#include <stdio.h>
64extern "C"
65{
66extern char * rl_readline_name;
67extern char *rl_line_buffer;
68char *filename_completion_function();
69typedef char **CPPFunction ();
70extern char ** completion_matches ();
71extern CPPFunction * rl_attempted_completion_function;
72extern FILE * rl_outstream;
73char * readline ();
74void add_history ();
75int write_history ();
76int read_history();
77}
78#ifndef NULL
79#define NULL 0
80#endif
81,
82rl_readline_name=NULL;
83*rl_line_buffer=1;
84completion_matches(NULL, filename_completion_function);
85rl_attempted_completion_function = (CPPFunction *) NULL;
86rl_outstream=NULL;
87readline(NULL);
88add_history(NULL);
89read_history(NULL);
90write_history(NULL);
91,
92ac_cv_have_readline="yes"
93,
94ac_cv_have_readline="no"
95))
96      AC_MSG_RESULT($ac_cv_have_readline)
97    else
98      AC_DEFINE([READLINE_READLINE_H_OK], [1], [Use readline.h])
99      ac_cv_have_readline="yes"
100    fi
101  fi
102  if test "$ac_cv_have_readline" = yes; then
103    AC_DEFINE([HAVE_READLINE], [1], [Use readline])
104  fi
105AC_LANG_RESTORE
106fi
107
108AC_MSG_CHECKING(which readline to use)
109if test "$ac_cv_with_readline" = dynamic; then
110  AC_MSG_RESULT(dynamic)
111  AC_DEFINE([HAVE_DYN_RL], [1], [Use dynamic readline])
112elif test "$ac_cv_have_readline" = yes; then
113  AC_MSG_RESULT(static)
114elif test "$ac_cv_singuname" = PowerMacintosh-darwin; then
115  AC_MSG_ERROR(building without readline impossible on PowerMacintosh-darwin)
116else
117  AC_MSG_RESULT(none)
118  AC_MSG_WARN(building without readline: disabling fancy display)
119fi
120
121])
Note: See TracBrowser for help on using the repository browser.