~drizzle-trunk/drizzle/development

779.2.4 by Monty Taylor
Updated some more build stuff.
1
#
2
# SYNOPSIS
3
#
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
4
#   PANDORA_HAVE_LIBREADLINE
779.2.4 by Monty Taylor
Updated some more build stuff.
5
#
6
# DESCRIPTION
7
#
8
#   Searches for a readline compatible library. If found, defines
9
#   `HAVE_LIBREADLINE'. If the found library has the `add_history'
10
#   function, sets also `HAVE_READLINE_HISTORY'. Also checks for the
11
#   locations of the necessary include files and sets `HAVE_READLINE_H'
12
#   or `HAVE_READLINE_READLINE_H' and `HAVE_READLINE_HISTORY_H' or
13
#   'HAVE_HISTORY_H' if the corresponding include files exists.
14
#
15
#   The libraries that may be readline compatible are `libedit',
16
#   `libeditline' and `libreadline'. Sometimes we need to link a
17
#   termcap library for readline to work, this macro tests these cases
18
#   too by trying to link with `libtermcap', `libcurses' or
19
#   `libncurses' before giving up.
20
#
21
#   Here is an example of how to use the information provided by this
22
#   macro to perform the necessary includes or declarations in a C
23
#   file:
24
#
25
#     #ifdef HAVE_LIBREADLINE
26
#     #  if defined(HAVE_READLINE_READLINE_H)
27
#     #    include <readline/readline.h>
28
#     #  elif defined(HAVE_READLINE_H)
29
#     #    include <readline.h>
30
#     #  else /* !defined(HAVE_READLINE_H) */
31
#     extern char *readline ();
32
#     #  endif /* !defined(HAVE_READLINE_H) */
33
#     char *cmdline = NULL;
34
#     #else /* !defined(HAVE_READLINE_READLINE_H) */
35
#       /* no readline */
36
#     #endif /* HAVE_LIBREADLINE */
37
#
38
#     #ifdef HAVE_READLINE_HISTORY
39
#     #  if defined(HAVE_READLINE_HISTORY_H)
40
#     #    include <readline/history.h>
41
#     #  elif defined(HAVE_HISTORY_H)
42
#     #    include <history.h>
43
#     #  else /* !defined(HAVE_HISTORY_H) */
44
#     extern void add_history ();
45
#     extern int write_history ();
46
#     extern int read_history ();
47
#     #  endif /* defined(HAVE_READLINE_HISTORY_H) */
48
#       /* no history */
49
#     #endif /* HAVE_READLINE_HISTORY */
50
#
51
# LAST MODIFICATION
52
#
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
53
#   2009-11-17
54
#
55
# Based on VL_LIB_READLINE from  Ville Laurikari
779.2.4 by Monty Taylor
Updated some more build stuff.
56
#
57
# COPYLEFT
58
#
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
59
#   Copyright (c) 2009 Monty Taylor
779.2.4 by Monty Taylor
Updated some more build stuff.
60
#   Copyright (c) 2002 Ville Laurikari <vl@iki.fi>
61
#
62
#   Copying and distribution of this file, with or without
63
#   modification, are permitted in any medium without royalty provided
64
#   the copyright notice and this notice are preserved.
65
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
66
AC_DEFUN([PANDORA_CHECK_TIOCGWINSZ],[
67
  AC_CACHE_CHECK([for TIOCGWINSZ in sys/ioctl.h],
68
    [pandora_cv_tiocgwinsz_in_ioctl],[
69
    AC_COMPILE_IFELSE([
70
      AC_LANG_PROGRAM([[
71
#include <sys/types.h>
72
#include <sys/ioctl.h>
73
      ]],[[
74
int x= TIOCGWINSZ;
75
      ]])
76
    ],[
77
      pandora_cv_tiocgwinsz_in_ioctl=yes
78
    ],[
79
      pandora_cv_tiocgwinsz_in_ioctl=no
80
    ])
81
  ])
82
  AS_IF([test "$pandora_cv_tiocgwinsz_in_ioctl" = "yes"],[   
83
    AC_DEFINE([GWINSZ_IN_SYS_IOCTL], [1],
84
              [READLINE: your system defines TIOCGWINSZ in sys/ioctl.h.])
85
  ])
86
])
87
88
AC_DEFUN([PANDORA_CHECK_RL_COMPENTRY], [
89
  AC_CACHE_CHECK([defined rl_compentry_func_t], [pandora_cv_rl_compentry],[
90
    AC_COMPILE_IFELSE([
91
      AC_LANG_PROGRAM([[
92
#include "stdio.h"
93
#include "readline/readline.h"
94
      ]],[[
95
rl_compentry_func_t *func2= (rl_compentry_func_t*)0;
96
      ]])
97
    ],[
98
      pandora_cv_rl_compentry=yes
99
    ],[
100
      pandora_cv_rl_compentry=no
101
    ])
102
  ])
103
  AS_IF([test "$pandora_cv_rl_compentry" = "yes"],[
104
    AC_DEFINE([HAVE_RL_COMPENTRY], [1],
105
              [Does system provide rl_compentry_func_t])
106
  ])
107
108
  save_CXXFLAGS="${CXXFLAGS}"
109
  CXXFLAGS="${AM_CXXFLAGS} ${CXXFLAGS}"
1241.9.10 by Monty Taylor
pandora-build v0.85 - Fixed the C++ standard setting in the build checks.
110
  AC_LANG_PUSH(C++)
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
111
  AC_CACHE_CHECK([rl_compentry_func_t works], [pandora_cv_rl_compentry_works],[
112
    AC_COMPILE_IFELSE([
113
      AC_LANG_PROGRAM([[
114
#include "stdio.h"
115
#include "readline/readline.h"
116
      ]],[[
117
rl_completion_entry_function= (rl_compentry_func_t*)NULL;
118
      ]])
119
    ],[
120
      pandora_cv_rl_compentry_works=yes
121
    ],[
122
      pandora_cv_rl_compentry_works=no
123
    ])
124
  ])
125
  AS_IF([test "$pandora_cv_rl_compentry_works" = "yes"],[
126
    AC_DEFINE([HAVE_WORKING_RL_COMPENTRY], [1],
127
              [Does system provide an rl_compentry_func_t that is usable])
128
  ])
129
  CXXFLAGS="${save_CXXFLAGS}"
130
  AC_LANG_POP()
131
])
132
133
134
AC_DEFUN([PANDORA_CHECK_RL_COMPLETION_FUNC], [
135
  AC_CACHE_CHECK([defined rl_completion_func_t], [pandora_cv_rl_completion],[
136
    AC_COMPILE_IFELSE([
137
      AC_LANG_PROGRAM([[
138
#include "stdio.h"
139
#include "readline/readline.h"
140
      ]],[[
141
rl_completion_func_t *func1= (rl_completion_func_t*)0;
142
      ]])
143
    ],[
144
      pandora_cv_rl_completion=yes
145
    ],[
146
      pandora_cv_rl_completion=no
147
    ])
148
  ])
149
  AS_IF([test "$pandora_cv_rl_completion" = "yes"],[
150
    AC_DEFINE([HAVE_RL_COMPLETION], [1],
151
              [Does system provide rl_completion_func_t])
152
  ])
153
])
154
155
AC_DEFUN([_PANDORA_SEARCH_LIBREADLINE], [
156
157
  save_LIBS="${LIBS}"
158
  LIBS=""
159
779.2.4 by Monty Taylor
Updated some more build stuff.
160
  AC_CACHE_CHECK([for a readline compatible library],
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
161
                 ac_cv_libreadline, [
779.2.4 by Monty Taylor
Updated some more build stuff.
162
    ORIG_LIBS="$LIBS"
163
    for readline_lib in readline edit editline; do
164
      for termcap_lib in "" termcap curses ncurses; do
165
        if test -z "$termcap_lib"; then
166
          TRY_LIB="-l$readline_lib"
167
        else
168
          TRY_LIB="-l$readline_lib -l$termcap_lib"
169
        fi
170
        LIBS="$ORIG_LIBS $TRY_LIB"
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
171
        AC_TRY_LINK_FUNC(readline, ac_cv_libreadline="$TRY_LIB")
172
        if test -n "$ac_cv_libreadline"; then
779.2.4 by Monty Taylor
Updated some more build stuff.
173
          break
174
        fi
175
      done
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
176
      if test -n "$ac_cv_libreadline"; then
779.2.4 by Monty Taylor
Updated some more build stuff.
177
        break
178
      fi
179
    done
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
180
    if test -z "$ac_cv_libreadline"; then
181
      ac_cv_libreadline="no"
779.2.4 by Monty Taylor
Updated some more build stuff.
182
      LIBS="$ORIG_LIBS"
183
    fi
184
  ])
185
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
186
  if test "$ac_cv_libreadline" != "no"; then
779.2.4 by Monty Taylor
Updated some more build stuff.
187
    AC_DEFINE(HAVE_LIBREADLINE, 1,
188
              [Define if you have a readline compatible library])
189
    AC_CHECK_HEADERS(readline.h readline/readline.h)
190
    AC_CACHE_CHECK([whether readline supports history],
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
191
                   ac_cv_libreadline_history, [
192
      ac_cv_libreadline_history="no"
193
      AC_TRY_LINK_FUNC(add_history, ac_cv_libreadline_history="yes")
779.2.4 by Monty Taylor
Updated some more build stuff.
194
    ])
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
195
    if test "$ac_cv_libreadline_history" = "yes"; then
779.2.4 by Monty Taylor
Updated some more build stuff.
196
      AC_DEFINE(HAVE_READLINE_HISTORY, 1,
197
                [Define if your readline library has \`add_history'])
198
      AC_CHECK_HEADERS(history.h readline/history.h)
199
    fi
200
  fi
1192.3.28 by Monty Taylor
pandora-build v0.72 - Moved remaining hard-coded tests into pandora-build
201
  PANDORA_CHECK_RL_COMPENTRY  
202
  PANDORA_CHECK_RL_COMPLETION_FUNC
203
  PANDORA_CHECK_TIOCGWINSZ
204
205
206
  READLINE_LIBS="${LIBS}"
207
  LIBS="${save_LIBS}"
208
  AC_SUBST(READLINE_LIBS)
209
210
  AM_CONDITIONAL(HAVE_LIBREADLINE, [test "x${ac_cv_libreadline}" = "xyes"])
211
])
212
213
AC_DEFUN([_PANDORA_HAVE_LIBREADLINE],[
214
215
  AC_ARG_ENABLE([libreadline],
216
    [AS_HELP_STRING([--disable-libreadline],
217
      [Build with libreadline support @<:@default=on@:>@])],
218
    [ac_enable_libreadline="$enableval"],
219
    [ac_enable_libreadline="yes"])
220
221
  _PANDORA_SEARCH_LIBREADLINE
222
])
223
224
225
AC_DEFUN([PANDORA_HAVE_LIBREADLINE],[
226
  AC_REQUIRE([_PANDORA_HAVE_LIBREADLINE])
227
])
228
229
AC_DEFUN([_PANDORA_REQUIRE_LIBREADLINE],[
230
  ac_enable_libreadline="yes"
231
  _PANDORA_SEARCH_LIBREADLINE
232
233
  AS_IF([test "x$ac_cv_libreadline" = "xno"],
234
    AC_MSG_ERROR([libreadline is required for ${PACKAGE}. On Debian this can be found in libreadline5-dev. On RedHat this can be found in readline-devel.]))
235
236
])
237
238
AC_DEFUN([PANDORA_REQUIRE_LIBREADLINE],[
239
  AC_REQUIRE([_PANDORA_REQUIRE_LIBREADLINE])
240
])
241
242