source: git/m4/readline-check.m4

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