1
dnl Process this file with autoconf to produce a configure script.
3
AC_CONFIG_HEADER(defines.h)
5
dnl Checks for programs.
8
AC_PROG_GCC_TRADITIONAL
11
dnl Check for compilation model.
12
dnl AC_SYS_LARGEFILE is not supported in all versions of autoconf.
13
dnl Remove the dnl comment on the next line to use large (64 bit) files.
16
dnl Checks for libraries.
17
AC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
18
AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
19
AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
20
AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
21
AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
22
dnl Regular expressions (regcmp) are in -lgen on Solaris 2,
23
dnl and in -lintl on SCO Unix.
24
AC_CHECK_LIB(gen, regcmp)
25
AC_CHECK_LIB(intl, regcmp)
26
AC_CHECK_LIB(PW, regcmp)
27
dnl Checks for terminal libraries
29
AC_MSG_CHECKING(for working terminal libraries)
32
dnl Check for systems where curses is broken.
34
if test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then
35
if test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then
38
if test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then
43
if test $curses_broken = 0; then
45
if test "x$TERMLIBS" = x; then
46
if test $have_xcurses = yes; then
49
LIBS="$LIBS $TERMLIBS"
50
AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
51
[termok=yes], [termok=no])
53
if test $termok = no; then TERMLIBS=""; fi
58
if test "x$TERMLIBS" = x; then
59
if test $have_ncurses = yes; then
62
LIBS="$LIBS $TERMLIBS"
63
AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
64
[termok=yes], [termok=no])
66
if test $termok = no; then TERMLIBS=""; fi
71
if test "x$TERMLIBS" = x; then
72
if test $have_curses = yes; then
75
LIBS="$LIBS $TERMLIBS"
76
AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
77
[termok=yes], [termok=no])
79
if test $termok = no; then TERMLIBS=""; fi
83
dnl -- Try curses & termcap.
84
if test "x$TERMLIBS" = x; then
85
if test $have_curses = yes; then
86
if test $have_termcap = yes; then
87
TERMLIBS="-lcurses -ltermcap"
89
LIBS="$LIBS $TERMLIBS"
90
AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
91
[termok=yes], [termok=no])
93
if test $termok = no; then TERMLIBS=""; fi
100
if test "x$TERMLIBS" = x; then
101
if test $have_termcap = yes; then
104
LIBS="$LIBS $TERMLIBS"
105
AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
106
[termok=yes], [termok=no])
108
if test $termok = no; then TERMLIBS=""; fi
113
if test "x$TERMLIBS" = x; then
114
if test $have_termlib = yes; then
115
TERMLIBS="-lcurses -ltermlib"
117
LIBS="$LIBS $TERMLIBS"
118
AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
119
[termok=yes], [termok=no])
121
if test $termok = no; then TERMLIBS=""; fi
125
if test "x$TERMLIBS" = x; then
126
AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
129
AC_MSG_RESULT(using $TERMLIBS)
130
LIBS="$LIBS $TERMLIBS"
133
dnl Checks for header files.
134
AC_CHECK_HEADERS(ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h)
136
dnl Checks for identifiers.
138
AC_MSG_CHECKING(for void)
139
AC_TRY_COMPILE(, [void *foo = 0;],
140
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
141
AC_MSG_CHECKING(for const)
142
AC_TRY_COMPILE(, [const int foo = 0;],
143
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
144
AC_MSG_CHECKING(for time_t)
145
AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
146
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
148
dnl Checks for functions and external variables.
150
AC_CHECK_FUNCS(fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr strstr system)
152
dnl Some systems have termios.h but not the corresponding functions.
153
AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
155
AC_MSG_CHECKING(for fileno)
159
#endif], [static int x; x = fileno(stdin);],
160
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
162
AC_MSG_CHECKING(for strerror)
172
#endif], [static char *x; x = strerror(0);],
173
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
175
AC_MSG_CHECKING(for sys_errlist)
176
AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;],
177
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
179
AC_MSG_CHECKING(for sigset_t)
182
], [sigset_t s; s = 0;],
183
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGSET_T)], [AC_MSG_RESULT(no)])
185
AC_MSG_CHECKING(for sigemptyset)
188
], [sigset_t s; sigemptyset(&s);],
189
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)], [AC_MSG_RESULT(no)])
192
AC_MSG_CHECKING(for errno)
196
#endif], [static int x; x = errno;],
197
[AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
198
if test $have_errno = no; then
202
#endif], [extern int errno; static int x; x = errno;],
203
[AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
207
AC_MSG_CHECKING(for locale)
208
AC_TRY_LINK([#include <locale.h>
209
#include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
210
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
211
AC_MSG_CHECKING(for ctype functions)
215
#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
216
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
218
dnl Checks for external variable ospeed in the termcap library.
220
AC_MSG_CHECKING(termcap for ospeed)
222
#include <sys/types.h>
228
#endif], [ospeed = 0;],
229
[AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
230
if test $have_ospeed = no; then
231
AC_TRY_LINK(, [extern short ospeed; ospeed = 0;],
232
[AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
236
dnl Checks for regular expression functions.
238
have_posix_regex=unknown
239
AC_MSG_CHECKING(for regcomp)
243
[ --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local} Select a regular expression library [auto]],
244
WANT_REGEX="$withval")
246
if test $have_regex = no; then
247
if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
248
dnl Some versions of Solaris have a regcomp() function, but it doesn't work!
249
dnl So we run a test program. If we're cross-compiling, do it the old way.
251
#include <sys/types.h>
253
main() { regex_t r; regmatch_t rm; char *text = "xabcy";
254
if (regcomp(&r, "abc", 0)) exit(1);
255
if (regexec(&r, text, 1, &rm, 0)) exit(1);
257
if (rm.rm_so != 1) exit(1); /* check for correct offset */
259
if (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
262
have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
263
if test $have_posix_regex = yes; then
264
AC_MSG_RESULT(using POSIX regcomp)
265
AC_DEFINE(HAVE_POSIX_REGCOMP)
267
elif test $have_posix_regex = unknown; then
269
#include <sys/types.h>
271
[regex_t *r; regfree(r);],
272
AC_MSG_RESULT(using POSIX regcomp)
273
AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
280
if test $have_regex = no; then
281
if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
282
AC_CHECK_LIB(pcre, pcre_compile,
283
[AC_MSG_RESULT(using pcre); AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes], [])
287
if test $have_regex = no; then
288
if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
289
AC_CHECK_FUNC(regcmp,
290
AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
294
if test $have_regex = no; then
295
if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
297
#include "regexp.h"], [regcomp("");],
298
AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
302
if test $have_regex = no && test -f ${srcdir}/regexp.c; then
303
if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
304
AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) AC_DEFINE(HAVE_REGEXEC2) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes
308
if test $have_regex = no; then
309
if test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
310
AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
314
if test $have_regex = no; then
315
AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
319
[ --with-editor=PROGRAM use PROGRAM as the default editor [vi]],
320
AC_DEFINE_UNQUOTED(EDIT_PGM, "$withval"))