source: git/m4/readline-check.m4 @ 84b294

spielwiese
Last change on this file since 84b294 was d56ad87, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
ADD: readline detection / usage
  • Property mode set to 100644
File size: 3.2 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]
21                        do use dynamic/static/no readline for fancy display])
22
23AC_CHECK_LIB(ncurses,tgetent,,\
24 AC_CHECK_LIB(curses,tgetent,,\
25  AC_CHECK_LIB(termcap,tgetent)))
26
27# readline
28if test "$with_readline" = dynamic && test "$ac_have_dl" != yes; then
29  AC_MSG_WARN(can not build dynamic readline without dynamic linking)
30  with_readline=static
31fi
32
33
34if test "$with_readline" != dynamic && test "$with_readline" != no; then
35AC_LANG_SAVE
36AC_LANG_CPLUSPLUS
37   AC_CHECK_LIB(readline, readline)
38   AC_CHECK_HEADERS(readline/readline.h readline/history.h)
39   if test "$ac_cv_lib_readline_readline" = yes && \
40      test "$ac_cv_header_readline_readline_h" = yes; then
41     AC_MSG_CHECKING(whether readline.h is ok)
42     AC_CACHE_VAL(ac_cv_header_readline_readline_h_ok,
43     AC_TRY_LINK(
44#include<unistd.h>
45#include<stdio.h>
46#include<readline/readline.h>
47#ifdef HAVE_READLINE_HISTORY_H
48#include<readline/history.h>
49#endif
50,
51,
52ac_cv_header_readline_readline_h_ok="yes",
53ac_cv_header_readline_readline_h_ok="no",
54))
55    AC_MSG_RESULT($ac_cv_header_readline_readline_h_ok)
56    if test "$ac_cv_header_readline_readline_h_ok" != yes; then
57#not ok -- try once more with explicitly declaring everything
58      AC_MSG_CHECKING(whether or not we nevertheless can use readline)
59      AC_CACHE_VAL(ac_cv_have_readline,
60      AC_TRY_LINK(
61#include <stdio.h>
62extern "C"
63{
64extern char * rl_readline_name;
65extern char *rl_line_buffer;
66char *filename_completion_function();
67typedef char **CPPFunction ();
68extern char ** completion_matches ();
69extern CPPFunction * rl_attempted_completion_function;
70extern FILE * rl_outstream;
71char * readline ();
72void add_history ();
73int write_history ();
74int read_history();
75}
76#ifndef NULL
77#define NULL 0
78#endif
79,
80rl_readline_name=NULL;
81*rl_line_buffer=1;
82completion_matches(NULL, filename_completion_function);
83rl_attempted_completion_function = (CPPFunction *) NULL;
84rl_outstream=NULL;
85readline(NULL);
86add_history(NULL);
87read_history(NULL);
88write_history(NULL);
89,
90ac_cv_have_readline="yes"
91,
92ac_cv_have_readline="no"
93))
94      AC_MSG_RESULT($ac_cv_have_readline)
95    else
96      AC_DEFINE([READLINE_READLINE_H_OK], [1], [Use readline.h])
97      ac_cv_have_readline="yes"
98    fi
99  fi
100  if test "$ac_cv_have_readline" = yes; then
101    AC_DEFINE([HAVE_READLINE], [1], [Use readline])
102  fi
103AC_LANG_RESTORE
104fi
105
106AC_MSG_CHECKING(which readline to use)
107if test "$ac_cv_with_readline" = dynamic; then
108  AC_MSG_RESULT(dynamic)
109  AC_DEFINE([HAVE_DYN_RL], [1], [Use dynamic readline])
110elif test "$ac_cv_have_readline" = yes; then
111  AC_MSG_RESULT(static)
112elif test "$ac_cv_singuname" = PowerMacintosh-darwin; then
113  AC_MSG_ERROR(building without readline impossible on PowerMacintosh-darwin)
114else
115  AC_MSG_RESULT(none)
116  AC_MSG_WARN(building without readline: disabling fancy display)
117fi
118
119])
Note: See TracBrowser for help on using the repository browser.