configure.ac revision 173682
1128345Stjr# Process this file with autoconf to produce a configure script.
2128345Stjr
3170256Sdelphij# Copyright (C) 1984-2007  Mark Nudelman
4128345Stjr#
5128345Stjr# You may distribute under the terms of either the GNU General Public
6128345Stjr# License or the Less License, as specified in the README file.
7128345Stjr#
8128345Stjr# For more information about less, or for information on how to 
9128345Stjr# contact the author, see the README file.
10128345Stjr
11128345Stjr# Autoconf initialization.
12128345StjrAC_INIT(less, 1)
13128345StjrAC_CONFIG_SRCDIR([forwback.c])
14128345StjrAC_CONFIG_HEADER([defines.h])
15128345Stjr
16128345Stjr# Checks for programs.
17128345StjrAC_PROG_CC
18128345StjrAC_ISC_POSIX
19128345StjrAC_PROG_GCC_TRADITIONAL
20128345StjrAC_PROG_INSTALL
21128345Stjr
22128345Stjr# Checks for compilation model.
23128345StjrAC_SYS_LARGEFILE
24128345Stjr
25128345Stjr# Checks for general libraries.
26173682SdelphijAC_CHECK_LIB(tinfo, tgoto, [have_tinfo=yes], [have_tinfo=no])
27128345StjrAC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
28161475SdelphijAC_CHECK_LIB(ncursesw, initscr, [have_ncursesw=yes], [have_ncursesw=no])
29128345StjrAC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
30128345StjrAC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
31128345StjrAC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
32128345StjrAC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
33128345Stjr# Regular expressions (regcmp) are in -lgen on Solaris 2,
34128345Stjr# and in -lintl on SCO Unix.
35128345StjrAC_CHECK_LIB(gen, regcmp)
36128345StjrAC_CHECK_LIB(intl, regcmp)
37128345StjrAC_CHECK_LIB(PW, regcmp)
38128345Stjr
39128345Stjr# Checks for terminal libraries
40128345StjrAC_MSG_CHECKING([for working terminal libraries])
41128345StjrTERMLIBS=
42128345Stjr
43128345Stjr# Check for systems where curses is broken.
44128345Stjrcurses_broken=0
45128345Stjrif test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then
46128345Stjrif test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then
47128345Stjr   curses_broken=1
48128345Stjrfi
49128345Stjrif test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then
50128345Stjr   curses_broken=1
51128345Stjrfi
52128345Stjrfi
53128345Stjr
54128345Stjrif test $curses_broken = 0; then
55173682Sdelphij
56173682Sdelphij# -- Try tinfo.
57173682Sdelphijif test "x$TERMLIBS" = x; then
58173682Sdelphij  if test $have_tinfo = yes; then
59173682Sdelphij    TERMLIBS="-ltinfo"
60173682Sdelphij    SAVE_LIBS=$LIBS
61173682Sdelphij    LIBS="$LIBS $TERMLIBS"
62173682Sdelphij    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
63173682Sdelphij      [termok=yes], [termok=no])
64173682Sdelphij    LIBS=$SAVE_LIBS
65173682Sdelphij    if test $termok = no; then TERMLIBS=""; fi
66173682Sdelphij  fi
67173682Sdelphijfi
68173682Sdelphij
69128345Stjr# -- Try xcurses.
70128345Stjrif test "x$TERMLIBS" = x; then
71128345Stjr  if test $have_xcurses = yes; then
72128345Stjr    TERMLIBS="-lxcurses"
73128345Stjr    SAVE_LIBS=$LIBS
74128345Stjr    LIBS="$LIBS $TERMLIBS"
75128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
76128345Stjr      [termok=yes], [termok=no])
77128345Stjr    LIBS=$SAVE_LIBS
78128345Stjr    if test $termok = no; then TERMLIBS=""; fi
79128345Stjr  fi
80128345Stjrfi
81128345Stjr
82170256Sdelphij# -- Try ncursesw.
83161475Sdelphijif test "x$TERMLIBS" = x; then
84161475Sdelphij  if test $have_ncursesw = yes; then
85161475Sdelphij    TERMLIBS="-lncursesw"
86161475Sdelphij    SAVE_LIBS=$LIBS
87161475Sdelphij    LIBS="$LIBS $TERMLIBS"
88161475Sdelphij    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
89161475Sdelphij      [termok=yes], [termok=no])
90161475Sdelphij    LIBS=$SAVE_LIBS
91161475Sdelphij    if test $termok = no; then TERMLIBS=""; fi
92161475Sdelphij  fi
93161475Sdelphijfi
94161475Sdelphij
95128345Stjr# -- Try ncurses.
96128345Stjrif test "x$TERMLIBS" = x; then
97128345Stjr  if test $have_ncurses = yes; then
98128345Stjr    TERMLIBS="-lncurses"
99128345Stjr    SAVE_LIBS=$LIBS
100128345Stjr    LIBS="$LIBS $TERMLIBS"
101128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
102128345Stjr      [termok=yes], [termok=no])
103128345Stjr    LIBS=$SAVE_LIBS
104128345Stjr    if test $termok = no; then TERMLIBS=""; fi
105128345Stjr  fi
106128345Stjrfi
107128345Stjr
108128345Stjr# -- Try curses.
109128345Stjrif test "x$TERMLIBS" = x; then
110128345Stjr  if test $have_curses = yes; then
111128345Stjr    TERMLIBS="-lcurses"
112128345Stjr    SAVE_LIBS=$LIBS
113128345Stjr    LIBS="$LIBS $TERMLIBS"
114128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
115128345Stjr      [termok=yes], [termok=no])
116128345Stjr    LIBS=$SAVE_LIBS
117128345Stjr    if test $termok = no; then TERMLIBS=""; fi
118128345Stjr  fi
119128345Stjrfi
120128345Stjr
121128345Stjr# -- Try curses & termcap.
122128345Stjrif test "x$TERMLIBS" = x; then
123128345Stjr  if test $have_curses = yes; then
124128345Stjr  if test $have_termcap = yes; then
125128345Stjr    TERMLIBS="-lcurses -ltermcap"
126128345Stjr    SAVE_LIBS=$LIBS
127128345Stjr    LIBS="$LIBS $TERMLIBS"
128128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
129128345Stjr      [termok=yes], [termok=no])
130128345Stjr    LIBS=$SAVE_LIBS
131128345Stjr    if test $termok = no; then TERMLIBS=""; fi
132128345Stjr  fi
133128345Stjr  fi
134128345Stjrfi
135128345Stjrfi
136128345Stjr
137128345Stjr# -- Try termcap.
138128345Stjrif test "x$TERMLIBS" = x; then
139128345Stjr  if test $have_termcap = yes; then
140128345Stjr    TERMLIBS="-ltermcap"
141128345Stjr    SAVE_LIBS=$LIBS
142128345Stjr    LIBS="$LIBS $TERMLIBS"
143128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
144128345Stjr      [termok=yes], [termok=no])
145128345Stjr    LIBS=$SAVE_LIBS
146128345Stjr    if test $termok = no; then TERMLIBS=""; fi
147128345Stjr  fi
148128345Stjrfi
149128345Stjr
150128345Stjr# -- Try termlib.
151128345Stjrif test "x$TERMLIBS" = x; then
152128345Stjr  if test $have_termlib = yes; then
153128345Stjr    TERMLIBS="-lcurses -ltermlib"
154128345Stjr    SAVE_LIBS=$LIBS
155128345Stjr    LIBS="$LIBS $TERMLIBS"
156128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
157128345Stjr      [termok=yes], [termok=no])
158128345Stjr    LIBS=$SAVE_LIBS
159128345Stjr    if test $termok = no; then TERMLIBS=""; fi
160128345Stjr  fi
161128345Stjrfi
162128345Stjr
163128345Stjrif test "x$TERMLIBS" = x; then
164128345Stjr  AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
165128345Stjr  exit 1
166128345Stjrfi
167128345StjrAC_MSG_RESULT(using $TERMLIBS)
168128345StjrLIBS="$LIBS $TERMLIBS"
169128345Stjr
170128345Stjr# Checks for header files.
171128345StjrAC_HEADER_STDC
172173682SdelphijAC_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 wctype.h])
173128345Stjr
174128345Stjr# Checks for typedefs, structures, and compiler characteristics.
175128345StjrAC_HEADER_STAT
176128345StjrAC_C_CONST
177128345StjrAC_TYPE_OFF_T
178128345StjrAC_TYPE_SIZE_T
179128345StjrAC_HEADER_TIME
180128345Stjr
181128345Stjr# Autoheader templates for symbols defined later by AC_DEFINE.
182128345StjrAH_TEMPLATE([HAVE_POSIX_REGCOMP],
183128345Stjr	[POSIX regcomp() and regex.h])
184128345StjrAH_TEMPLATE([HAVE_PCRE],
185128345Stjr	[PCRE (Perl-compatible regular expression) library])
186128345StjrAH_TEMPLATE([HAVE_RE_COMP],
187128345Stjr	[BSD re_comp()])
188128345StjrAH_TEMPLATE([HAVE_REGCMP],
189128345Stjr	[System V regcmp()])
190128345StjrAH_TEMPLATE([HAVE_V8_REGCOMP],
191128345Stjr	[Henry Spencer V8 regcomp() and regexp.h])
192128345StjrAH_TEMPLATE([NO_REGEX],
193128345Stjr	[pattern matching is supported, but without metacharacters.])
194128345StjrAH_TEMPLATE([HAVE_REGEXEC2],
195128345Stjr	[])
196128345StjrAH_TEMPLATE([HAVE_VOID],
197128345Stjr	[Define HAVE_VOID if your compiler supports the "void" type.])
198128345StjrAH_TEMPLATE([HAVE_CONST],
199128345Stjr	[Define HAVE_CONST if your compiler supports the "const" modifier.])
200173682SdelphijAH_TEMPLATE([HAVE_STAT_INO],
201173682Sdelphij	[Define HAVE_STAT_INO if your struct stat has st_ino and st_dev.])
202128345StjrAH_TEMPLATE([HAVE_TIME_T],
203128345Stjr	[Define HAVE_TIME_T if your system supports the "time_t" type.])
204128345StjrAH_TEMPLATE([HAVE_STRERROR],
205128345Stjr	[Define HAVE_STRERROR if you have the strerror() function.])
206128345StjrAH_TEMPLATE([HAVE_FILENO],
207128345Stjr	[Define HAVE_FILENO if you have the fileno() macro.])
208128345StjrAH_TEMPLATE([HAVE_ERRNO],
209128345Stjr	[Define HAVE_ERRNO if you have the errno variable.])
210128345StjrAH_TEMPLATE([MUST_DEFINE_ERRNO],
211128345Stjr	[Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.])
212128345StjrAH_TEMPLATE([HAVE_SYS_ERRLIST],
213128345Stjr	[Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable.])
214128345StjrAH_TEMPLATE([HAVE_OSPEED],
215128345Stjr	[Define HAVE_OSPEED if your termcap library has the ospeed variable.])
216128345StjrAH_TEMPLATE([MUST_DEFINE_OSPEED],
217128345Stjr	[Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in termcap.h.])
218128345StjrAH_TEMPLATE([HAVE_LOCALE],
219128345Stjr	[Define HAVE_LOCALE if you have locale.h and setlocale.])
220128345StjrAH_TEMPLATE([HAVE_TERMIOS_FUNCS],
221128345Stjr	[Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr.])
222128345StjrAH_TEMPLATE([HAVE_UPPER_LOWER],
223128345Stjr	[Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower.])
224173682SdelphijAH_TEMPLATE([HAVE_WCTYPE],
225173682Sdelphij	[Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower.])
226128345StjrAH_TEMPLATE([HAVE_SIGSET_T],
227128345Stjr	[Define HAVE_SIGSET_T you have the sigset_t type.])
228128345StjrAH_TEMPLATE([HAVE_SIGEMPTYSET],
229128345Stjr	[Define HAVE_SIGEMPTYSET if you have the sigemptyset macro.])
230128345StjrAH_TEMPLATE([EDIT_PGM],
231128345Stjr	[Define EDIT_PGM to your editor.])
232161475SdelphijAH_TEMPLATE([SECURE_COMPILE],
233161475Sdelphij	[Define SECURE_COMPILE=1 to build a secure version of less.])
234128345Stjr
235128345Stjr# Checks for identifiers.
236128345StjrAC_TYPE_OFF_T
237128345StjrAC_MSG_CHECKING(for void)
238128345StjrAC_TRY_COMPILE(, [void *foo = 0;], 
239128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
240128345StjrAC_MSG_CHECKING(for const)
241128345StjrAC_TRY_COMPILE(, [const int foo = 0;], 
242128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
243128345StjrAC_MSG_CHECKING(for time_t)
244128345StjrAC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
245128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
246173682SdelphijAC_MSG_CHECKING(for st_ino in struct stat)
247173682SdelphijAC_TRY_COMPILE([#include <sys/types.h>
248173682Sdelphij#include <sys/stat.h>],
249173682Sdelphij  [struct stat s; dev_t dev = s.st_dev; ino_t ino = s.st_ino;],
250173682Sdelphij  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STAT_INO)], [AC_MSG_RESULT(no)])
251128345Stjr
252128345Stjr# Checks for library functions.
253128345StjrAC_TYPE_SIGNAL
254170256SdelphijAC_CHECK_FUNCS([fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod])
255128345Stjr
256170256Sdelphij# AC_CHECK_FUNCS may not work for inline functions, so test these separately.
257170256SdelphijAC_MSG_CHECKING(for memcpy)
258170256SdelphijAC_TRY_LINK([
259170256Sdelphij#if HAVE_STRING_H
260170256Sdelphij#include <string.h>
261170256Sdelphij#endif], [memcpy(0,0,0);],
262170256Sdelphij  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MEMCPY)], [AC_MSG_RESULT(no)])
263170256Sdelphij
264170256SdelphijAC_MSG_CHECKING(for strchr)
265170256SdelphijAC_TRY_LINK([
266170256Sdelphij#if HAVE_STRING_H
267170256Sdelphij#include <string.h>
268170256Sdelphij#endif], [strchr("x",'x');],
269170256Sdelphij  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRCHR)], [AC_MSG_RESULT(no)])
270170256Sdelphij
271170256SdelphijAC_MSG_CHECKING(for strstr)
272170256SdelphijAC_TRY_LINK([
273170256Sdelphij#if HAVE_STRING_H
274170256Sdelphij#include <string.h>
275170256Sdelphij#endif], [strstr("x","x");],
276170256Sdelphij  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRSTR)], [AC_MSG_RESULT(no)])
277170256Sdelphij
278128345Stjr# Some systems have termios.h but not the corresponding functions.
279128345StjrAC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
280128345Stjr
281128345StjrAC_MSG_CHECKING(for fileno)
282128345StjrAC_TRY_LINK([
283128345Stjr#if HAVE_STDIO_H
284128345Stjr#include <stdio.h>
285128345Stjr#endif], [static int x; x = fileno(stdin);],
286128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
287128345Stjr
288128345StjrAC_MSG_CHECKING(for strerror)
289128345StjrAC_TRY_LINK([
290128345Stjr#if HAVE_STDIO_H
291128345Stjr#include <stdio.h>
292128345Stjr#endif
293128345Stjr#if HAVE_STRING_H
294128345Stjr#include <string.h>
295128345Stjr#endif
296128345Stjr#if HAVE_ERRNO_H
297128345Stjr#include <errno.h>
298128345Stjr#endif], [static char *x; x = strerror(0);],
299128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
300128345Stjr
301128345StjrAC_MSG_CHECKING(for sys_errlist)
302128345StjrAC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], 
303128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
304128345Stjr
305170256SdelphijAC_CHECK_TYPES([sigset_t],,,[#include <signal.h>])
306128345Stjr
307128345StjrAC_MSG_CHECKING(for sigemptyset)
308128345StjrAC_TRY_LINK([
309128345Stjr#include <signal.h>
310128345Stjr], [sigset_t s; sigemptyset(&s);],
311128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)], [AC_MSG_RESULT(no)])
312128345Stjr
313128345Stjrhave_errno=no
314128345StjrAC_MSG_CHECKING(for errno)
315128345StjrAC_TRY_LINK([
316128345Stjr#if HAVE_ERRNO_H
317128345Stjr#include <errno.h>
318128345Stjr#endif], [static int x; x = errno;], 
319128345Stjr  [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
320128345Stjrif test $have_errno = no; then
321128345StjrAC_TRY_LINK([
322128345Stjr#if HAVE_ERRNO_H
323128345Stjr#include <errno.h>
324128345Stjr#endif], [extern int errno; static int x; x = errno;], 
325128345Stjr  [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
326128345Stjr  [AC_MSG_RESULT(no)])
327128345Stjrfi
328128345Stjr
329128345StjrAC_MSG_CHECKING(for locale)
330128345StjrAC_TRY_LINK([#include <locale.h>
331172468Sdelphij#include <ctype.h>
332172468Sdelphij#include <langinfo.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
333128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
334173682Sdelphij
335128345StjrAC_MSG_CHECKING(for ctype functions)
336128345StjrAC_TRY_LINK([
337128345Stjr#if HAVE_CTYPE_H
338128345Stjr#include <ctype.h>
339128345Stjr#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
340128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
341128345Stjr
342173682SdelphijAC_MSG_CHECKING(for wctype functions)
343173682SdelphijAC_TRY_LINK([#include <wctype.h>], [iswlower(0); iswupper(0); towlower(0); towupper(0);],
344173682Sdelphij  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WCTYPE)], [AC_MSG_RESULT(no)])
345173682Sdelphij
346128345Stjr# Checks for external variable ospeed in the termcap library.
347128345Stjrhave_ospeed=no
348128345StjrAC_MSG_CHECKING(termcap for ospeed)
349128345StjrAC_TRY_LINK([
350128345Stjr#include <sys/types.h>
351128345Stjr#if HAVE_TERMIOS_H
352128345Stjr#include <termios.h>
353128345Stjr#endif
354128345Stjr#if HAVE_TERMCAP_H
355128345Stjr#include <termcap.h>
356128345Stjr#endif], [ospeed = 0;],
357128345Stjr[AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
358128345Stjrif test $have_ospeed = no; then
359128345StjrAC_TRY_LINK(, [extern short ospeed; ospeed = 0;], 
360128345Stjr  [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
361128345Stjr  [AC_MSG_RESULT(no)])
362128345Stjrfi
363128345Stjr
364161475Sdelphij# Compile in secure mode?
365161475SdelphijAC_ARG_WITH(secure,
366161475Sdelphij  [  --with-secure  Compile in secure mode],
367161475Sdelphij  AC_DEFINE(SECURE_COMPILE, 1), AC_DEFINE(SECURE_COMPILE, 0))
368161475Sdelphij
369128345Stjr# Checks for regular expression functions.
370128345Stjrhave_regex=no
371128345Stjrhave_posix_regex=unknown
372128345StjrAC_MSG_CHECKING(for regcomp)
373128345Stjr
374161475Sdelphij# Select a regular expression library.
375128345StjrWANT_REGEX=auto
376128345StjrAC_ARG_WITH(regex,
377128345Stjr  [  --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local}  Select a regular expression library  [auto]],
378128345Stjr  WANT_REGEX="$withval")
379128345Stjr
380128345Stjrif test $have_regex = no; then
381128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
382128345Stjr# Some versions of Solaris have a regcomp() function, but it doesn't work!
383128345Stjr# So we run a test program.  If we're cross-compiling, do it the old way.
384128345StjrAC_TRY_RUN([
385128345Stjr#include <sys/types.h>
386128345Stjr#include <regex.h>
387128345Stjrmain() { regex_t r; regmatch_t rm; char *text = "xabcy";
388128345Stjrif (regcomp(&r, "abc", 0)) exit(1);
389128345Stjrif (regexec(&r, text, 1, &rm, 0)) exit(1);
390128345Stjr#ifndef __WATCOMC__
391128345Stjrif (rm.rm_so != 1) exit(1); /* check for correct offset */
392128345Stjr#else
393128345Stjrif (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
394128345Stjr#endif
395128345Stjrexit(0); }],
396128345Stjr  have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
397128345Stjrif test $have_posix_regex = yes; then
398128345Stjr  AC_MSG_RESULT(using POSIX regcomp)
399128345Stjr  AC_DEFINE(HAVE_POSIX_REGCOMP)
400128345Stjr  have_regex=yes
401128345Stjrelif test $have_posix_regex = unknown; then
402128345Stjr  AC_TRY_LINK([
403128345Stjr#include <sys/types.h>
404128345Stjr#include <regex.h>],
405128345Stjr  [regex_t *r; regfree(r);],
406128345Stjr  AC_MSG_RESULT(using POSIX regcomp)
407128345Stjr  AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
408128345Stjrelse
409128345Stjr  AC_MSG_RESULT(no)
410128345Stjrfi
411128345Stjrfi
412128345Stjrfi
413128345Stjr
414128345Stjrif test $have_regex = no; then
415128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
416128345StjrAC_CHECK_LIB(pcre, pcre_compile, 
417128345Stjr[AC_MSG_RESULT(using pcre); AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes], [])
418128345Stjrfi
419128345Stjrfi
420128345Stjr
421128345Stjrif test $have_regex = no; then
422128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
423128345StjrAC_CHECK_FUNC(regcmp, 
424128345StjrAC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
425128345Stjrfi
426128345Stjrfi
427128345Stjr
428128345Stjrif test $have_regex = no; then
429128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
430128345StjrAC_TRY_LINK([
431128345Stjr#include "regexp.h"], [regcomp("");],
432128345StjrAC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
433128345Stjrfi
434128345Stjrfi
435128345Stjr
436128345Stjrif test $have_regex = no && test -f ${srcdir}/regexp.c; then
437128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
438128345StjrAC_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
439128345Stjrfi
440128345Stjrfi
441128345Stjr
442128345Stjrif test $have_regex = no; then
443128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
444128345StjrAC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
445128345Stjrfi
446128345Stjrfi
447128345Stjr
448128345Stjrif test $have_regex = no; then
449128345StjrAC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
450128345Stjrfi
451128345Stjr
452128345StjrAC_ARG_WITH(editor,
453128345Stjr  [  --with-editor=PROGRAM   use PROGRAM as the default editor [vi]],
454128345Stjr  AC_DEFINE_UNQUOTED(EDIT_PGM, "$withval"), AC_DEFINE(EDIT_PGM, "vi"))
455128345Stjr
456128345StjrAH_TOP([
457128345Stjr/* Unix definition file for less.  -*- C -*-
458128345Stjr *
459128345Stjr * This file has 3 sections:
460128345Stjr * User preferences.
461128345Stjr * Settings always true on Unix.
462128345Stjr * Settings automatically determined by configure.
463128345Stjr *
464128345Stjr * * * * * *  WARNING  * * * * * *
465128345Stjr * If you edit defines.h by hand, do "touch stamp-h" before you run make
466128345Stjr * so config.status doesn't overwrite your changes.
467128345Stjr */
468128345Stjr
469128345Stjr/* User preferences.  */
470128345Stjr
471128345Stjr/*
472128345Stjr * SECURE is 1 if you wish to disable a bunch of features in order to
473128345Stjr * be safe to run by unprivileged users.
474161475Sdelphij * SECURE_COMPILE is set by the --with-secure configure option.
475128345Stjr */
476161475Sdelphij#define	SECURE		SECURE_COMPILE
477128345Stjr
478128345Stjr/*
479128345Stjr * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
480128345Stjr * (This is possible only if your system supplies the system() function.)
481128345Stjr */
482128345Stjr#define	SHELL_ESCAPE	(!SECURE)
483128345Stjr
484128345Stjr/*
485128345Stjr * EXAMINE is 1 if you wish to allow examining files by name from within less.
486128345Stjr */
487128345Stjr#define	EXAMINE		(!SECURE)
488128345Stjr
489128345Stjr/*
490128345Stjr * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
491128345Stjr * to complete filenames at prompts.
492128345Stjr */
493128345Stjr#define	TAB_COMPLETE_FILENAME	(!SECURE)
494128345Stjr
495128345Stjr/*
496128345Stjr * CMD_HISTORY is 1 if you wish to allow keys to cycle through
497128345Stjr * previous commands at prompts.
498128345Stjr */
499128345Stjr#define	CMD_HISTORY	1
500128345Stjr
501128345Stjr/*
502128345Stjr * HILITE_SEARCH is 1 if you wish to have search targets to be 
503128345Stjr * displayed in standout mode.
504128345Stjr */
505128345Stjr#define	HILITE_SEARCH	1
506128345Stjr
507128345Stjr/*
508128345Stjr * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
509128345Stjr * (This is possible only if your system supplies the system() function.)
510128345Stjr * EDIT_PGM is the name of the (default) editor to be invoked.
511128345Stjr */
512128345Stjr#define	EDITOR		(!SECURE)
513128345Stjr
514128345Stjr/*
515128345Stjr * TAGS is 1 if you wish to support tag files.
516128345Stjr */
517128345Stjr#define	TAGS		(!SECURE)
518128345Stjr
519128345Stjr/*
520128345Stjr * USERFILE is 1 if you wish to allow a .less file to specify 
521128345Stjr * user-defined key bindings.
522128345Stjr */
523128345Stjr#define	USERFILE	(!SECURE)
524128345Stjr
525128345Stjr/*
526128345Stjr * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
527128345Stjr * This will generally work if your system provides the "popen" function
528128345Stjr * and the "echo" shell command.
529128345Stjr */
530128345Stjr#define	GLOB		(!SECURE)
531128345Stjr
532128345Stjr/*
533128345Stjr * PIPEC is 1 if you wish to have the "|" command
534128345Stjr * which allows the user to pipe data into a shell command.
535128345Stjr */
536128345Stjr#define	PIPEC		(!SECURE)
537128345Stjr
538128345Stjr/*
539128345Stjr * LOGFILE is 1 if you wish to allow the -l option (to create log files).
540128345Stjr */
541128345Stjr#define	LOGFILE		(!SECURE)
542128345Stjr
543128345Stjr/*
544128345Stjr * GNU_OPTIONS is 1 if you wish to support the GNU-style command
545128345Stjr * line options --help and --version.
546128345Stjr */
547128345Stjr#define	GNU_OPTIONS	1
548128345Stjr
549128345Stjr/*
550128345Stjr * ONLY_RETURN is 1 if you want RETURN to be the only input which
551128345Stjr * will continue past an error message.
552128345Stjr * Otherwise, any key will continue past an error message.
553128345Stjr */
554128345Stjr#define	ONLY_RETURN	0
555128345Stjr
556128345Stjr/*
557128345Stjr * LESSKEYFILE is the filename of the default lesskey output file 
558128345Stjr * (in the HOME directory).
559128345Stjr * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
560128345Stjr * DEF_LESSKEYINFILE is the filename of the default lesskey input 
561128345Stjr * (in the HOME directory).
562161475Sdelphij * LESSHISTFILE is the filename of the history file
563161475Sdelphij * (in the HOME directory).
564128345Stjr */
565128345Stjr#define	LESSKEYFILE		".less"
566128345Stjr#define	LESSKEYFILE_SYS		SYSDIR "/sysless"
567128345Stjr#define	DEF_LESSKEYINFILE	".lesskey"
568161475Sdelphij#define LESSHISTFILE		".lesshst"
569128345Stjr
570128345Stjr
571128345Stjr/* Settings always true on Unix.  */
572128345Stjr
573128345Stjr/*
574128345Stjr * Define MSDOS_COMPILER if compiling under Microsoft C.
575128345Stjr */
576128345Stjr#define	MSDOS_COMPILER	0
577128345Stjr
578128345Stjr/*
579128345Stjr * Pathname separator character.
580128345Stjr */
581128345Stjr#define	PATHNAME_SEP	"/"
582128345Stjr
583128345Stjr/*
584170256Sdelphij * The value returned from tgetent on success.
585170256Sdelphij * Some HP-UX systems return 0 on success.
586170256Sdelphij */
587170256Sdelphij#define TGETENT_OK  1
588170256Sdelphij
589170256Sdelphij/*
590128345Stjr * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
591128345Stjr */
592128345Stjr#define HAVE_SYS_TYPES_H	1
593128345Stjr
594128345Stjr/*
595128345Stjr * Define if you have the <sgstat.h> header file.
596128345Stjr */
597128345Stjr#undef HAVE_SGSTAT_H
598128345Stjr
599128345Stjr/*
600128345Stjr * HAVE_PERROR is 1 if your system has the perror() call.
601128345Stjr * (Actually, if it has sys_errlist, sys_nerr and errno.)
602128345Stjr */
603128345Stjr#define	HAVE_PERROR	1
604128345Stjr
605128345Stjr/*
606128345Stjr * HAVE_TIME is 1 if your system has the time() call.
607128345Stjr */
608128345Stjr#define	HAVE_TIME	1
609128345Stjr
610128345Stjr/*
611128345Stjr * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
612128345Stjr */
613128345Stjr#define	HAVE_SHELL	1
614128345Stjr
615128345Stjr/*
616128345Stjr * Default shell metacharacters and meta-escape character.
617128345Stjr */
618170256Sdelphij#define	DEF_METACHARS	"; *?\t\n'\"()<>[]|&^`#\\$%=~"
619128345Stjr#define	DEF_METAESCAPE	"\\"
620128345Stjr
621128345Stjr/* 
622128345Stjr * HAVE_DUP is 1 if your system has the dup() call.
623128345Stjr */
624128345Stjr#define	HAVE_DUP	1
625128345Stjr
626170256Sdelphij/* Define to 1 if you have the memcpy() function. */
627170256Sdelphij#define HAVE_MEMCPY 1
628170256Sdelphij
629170256Sdelphij/* Define to 1 if you have the strchr() function. */
630170256Sdelphij#define HAVE_STRCHR 1
631170256Sdelphij
632170256Sdelphij/* Define to 1 if you have the strstr() function. */
633170256Sdelphij#define HAVE_STRSTR 1
634170256Sdelphij
635128345Stjr/*
636128345Stjr * Sizes of various buffers.
637128345Stjr */
638128345Stjr#define	CMDBUF_SIZE	512	/* Buffer for multichar commands */
639128345Stjr#define	UNGOT_SIZE	100	/* Max chars to unget() */
640128345Stjr#define	LINEBUF_SIZE	1024	/* Max size of line in input file */
641128345Stjr#define	OUTBUF_SIZE	1024	/* Output buffer */
642128345Stjr#define	PROMPT_SIZE	200	/* Max size of prompt string */
643128345Stjr#define	TERMBUF_SIZE	2048	/* Termcap buffer for tgetent */
644128345Stjr#define	TERMSBUF_SIZE	1024	/* Buffer to hold termcap strings */
645128345Stjr#define	TAGLINE_SIZE	512	/* Max size of line in tags file */
646128345Stjr#define	TABSTOP_MAX	32	/* Max number of custom tab stops */
647128345Stjr
648128345Stjr/* Settings automatically determined by configure.  */
649128345Stjr])
650128345Stjr
651128345StjrAC_CONFIG_FILES([Makefile])
652128345StjrAC_OUTPUT
653