[d56ad87] | 1 | # Check for readline |
---|
| 2 | |
---|
| 3 | AC_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 | |
---|
| 14 | AC_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 | |
---|
| 18 | AC_ARG_WITH( |
---|
| 19 | readline, |
---|
| 20 | [ --with-readline=[dynamic,static,no] |
---|
| 21 | do use dynamic/static/no readline for fancy display]) |
---|
| 22 | |
---|
| 23 | AC_CHECK_LIB(ncurses,tgetent,,\ |
---|
| 24 | AC_CHECK_LIB(curses,tgetent,,\ |
---|
| 25 | AC_CHECK_LIB(termcap,tgetent))) |
---|
| 26 | |
---|
| 27 | # readline |
---|
| 28 | if 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 |
---|
| 31 | fi |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | if test "$with_readline" != dynamic && test "$with_readline" != no; then |
---|
| 35 | AC_LANG_SAVE |
---|
| 36 | AC_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 | , |
---|
| 52 | ac_cv_header_readline_readline_h_ok="yes", |
---|
| 53 | ac_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> |
---|
| 62 | extern "C" |
---|
| 63 | { |
---|
| 64 | extern char * rl_readline_name; |
---|
| 65 | extern char *rl_line_buffer; |
---|
| 66 | char *filename_completion_function(); |
---|
| 67 | typedef char **CPPFunction (); |
---|
| 68 | extern char ** completion_matches (); |
---|
| 69 | extern CPPFunction * rl_attempted_completion_function; |
---|
| 70 | extern FILE * rl_outstream; |
---|
| 71 | char * readline (); |
---|
| 72 | void add_history (); |
---|
| 73 | int write_history (); |
---|
| 74 | int read_history(); |
---|
| 75 | } |
---|
| 76 | #ifndef NULL |
---|
| 77 | #define NULL 0 |
---|
| 78 | #endif |
---|
| 79 | , |
---|
| 80 | rl_readline_name=NULL; |
---|
| 81 | *rl_line_buffer=1; |
---|
| 82 | completion_matches(NULL, filename_completion_function); |
---|
| 83 | rl_attempted_completion_function = (CPPFunction *) NULL; |
---|
| 84 | rl_outstream=NULL; |
---|
| 85 | readline(NULL); |
---|
| 86 | add_history(NULL); |
---|
| 87 | read_history(NULL); |
---|
| 88 | write_history(NULL); |
---|
| 89 | , |
---|
| 90 | ac_cv_have_readline="yes" |
---|
| 91 | , |
---|
| 92 | ac_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 |
---|
| 103 | AC_LANG_RESTORE |
---|
| 104 | fi |
---|
| 105 | |
---|
| 106 | AC_MSG_CHECKING(which readline to use) |
---|
| 107 | if test "$ac_cv_with_readline" = dynamic; then |
---|
| 108 | AC_MSG_RESULT(dynamic) |
---|
| 109 | AC_DEFINE([HAVE_DYN_RL], [1], [Use dynamic readline]) |
---|
| 110 | elif test "$ac_cv_have_readline" = yes; then |
---|
| 111 | AC_MSG_RESULT(static) |
---|
| 112 | elif test "$ac_cv_singuname" = PowerMacintosh-darwin; then |
---|
| 113 | AC_MSG_ERROR(building without readline impossible on PowerMacintosh-darwin) |
---|
| 114 | else |
---|
| 115 | AC_MSG_RESULT(none) |
---|
| 116 | AC_MSG_WARN(building without readline: disabling fancy display) |
---|
| 117 | fi |
---|
| 118 | |
---|
| 119 | ]) |
---|