configure.ac revision 172468
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.
26128345StjrAC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
27161475SdelphijAC_CHECK_LIB(ncursesw, initscr, [have_ncursesw=yes], [have_ncursesw=no])
28128345StjrAC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
29128345StjrAC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
30128345StjrAC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
31128345StjrAC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
32128345Stjr# Regular expressions (regcmp) are in -lgen on Solaris 2,
33128345Stjr# and in -lintl on SCO Unix.
34128345StjrAC_CHECK_LIB(gen, regcmp)
35128345StjrAC_CHECK_LIB(intl, regcmp)
36128345StjrAC_CHECK_LIB(PW, regcmp)
37128345Stjr
38128345Stjr# Checks for terminal libraries
39128345StjrAC_MSG_CHECKING([for working terminal libraries])
40128345StjrTERMLIBS=
41128345Stjr
42128345Stjr# Check for systems where curses is broken.
43128345Stjrcurses_broken=0
44128345Stjrif test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then
45128345Stjrif test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then
46128345Stjr   curses_broken=1
47128345Stjrfi
48128345Stjrif test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then
49128345Stjr   curses_broken=1
50128345Stjrfi
51128345Stjrfi
52128345Stjr
53128345Stjrif test $curses_broken = 0; then
54128345Stjr# -- Try xcurses.
55128345Stjrif test "x$TERMLIBS" = x; then
56128345Stjr  if test $have_xcurses = yes; then
57128345Stjr    TERMLIBS="-lxcurses"
58128345Stjr    SAVE_LIBS=$LIBS
59128345Stjr    LIBS="$LIBS $TERMLIBS"
60128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
61128345Stjr      [termok=yes], [termok=no])
62128345Stjr    LIBS=$SAVE_LIBS
63128345Stjr    if test $termok = no; then TERMLIBS=""; fi
64128345Stjr  fi
65128345Stjrfi
66128345Stjr
67170256Sdelphij# -- Try ncursesw.
68161475Sdelphijif test "x$TERMLIBS" = x; then
69161475Sdelphij  if test $have_ncursesw = yes; then
70161475Sdelphij    TERMLIBS="-lncursesw"
71161475Sdelphij    SAVE_LIBS=$LIBS
72161475Sdelphij    LIBS="$LIBS $TERMLIBS"
73161475Sdelphij    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
74161475Sdelphij      [termok=yes], [termok=no])
75161475Sdelphij    LIBS=$SAVE_LIBS
76161475Sdelphij    if test $termok = no; then TERMLIBS=""; fi
77161475Sdelphij  fi
78161475Sdelphijfi
79161475Sdelphij
80128345Stjr# -- Try ncurses.
81128345Stjrif test "x$TERMLIBS" = x; then
82128345Stjr  if test $have_ncurses = yes; then
83128345Stjr    TERMLIBS="-lncurses"
84128345Stjr    SAVE_LIBS=$LIBS
85128345Stjr    LIBS="$LIBS $TERMLIBS"
86128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
87128345Stjr      [termok=yes], [termok=no])
88128345Stjr    LIBS=$SAVE_LIBS
89128345Stjr    if test $termok = no; then TERMLIBS=""; fi
90128345Stjr  fi
91128345Stjrfi
92128345Stjr
93128345Stjr# -- Try curses.
94128345Stjrif test "x$TERMLIBS" = x; then
95128345Stjr  if test $have_curses = yes; then
96128345Stjr    TERMLIBS="-lcurses"
97128345Stjr    SAVE_LIBS=$LIBS
98128345Stjr    LIBS="$LIBS $TERMLIBS"
99128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
100128345Stjr      [termok=yes], [termok=no])
101128345Stjr    LIBS=$SAVE_LIBS
102128345Stjr    if test $termok = no; then TERMLIBS=""; fi
103128345Stjr  fi
104128345Stjrfi
105128345Stjr
106128345Stjr# -- Try curses & termcap.
107128345Stjrif test "x$TERMLIBS" = x; then
108128345Stjr  if test $have_curses = yes; then
109128345Stjr  if test $have_termcap = yes; then
110128345Stjr    TERMLIBS="-lcurses -ltermcap"
111128345Stjr    SAVE_LIBS=$LIBS
112128345Stjr    LIBS="$LIBS $TERMLIBS"
113128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
114128345Stjr      [termok=yes], [termok=no])
115128345Stjr    LIBS=$SAVE_LIBS
116128345Stjr    if test $termok = no; then TERMLIBS=""; fi
117128345Stjr  fi
118128345Stjr  fi
119128345Stjrfi
120128345Stjrfi
121128345Stjr
122128345Stjr# -- Try termcap.
123128345Stjrif test "x$TERMLIBS" = x; then
124128345Stjr  if test $have_termcap = yes; then
125128345Stjr    TERMLIBS="-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
133128345Stjrfi
134128345Stjr
135128345Stjr# -- Try termlib.
136128345Stjrif test "x$TERMLIBS" = x; then
137128345Stjr  if test $have_termlib = yes; then
138128345Stjr    TERMLIBS="-lcurses -ltermlib"
139128345Stjr    SAVE_LIBS=$LIBS
140128345Stjr    LIBS="$LIBS $TERMLIBS"
141128345Stjr    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
142128345Stjr      [termok=yes], [termok=no])
143128345Stjr    LIBS=$SAVE_LIBS
144128345Stjr    if test $termok = no; then TERMLIBS=""; fi
145128345Stjr  fi
146128345Stjrfi
147128345Stjr
148128345Stjrif test "x$TERMLIBS" = x; then
149128345Stjr  AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
150128345Stjr  exit 1
151128345Stjrfi
152128345StjrAC_MSG_RESULT(using $TERMLIBS)
153128345StjrLIBS="$LIBS $TERMLIBS"
154128345Stjr
155128345Stjr# Checks for header files.
156128345StjrAC_HEADER_STDC
157170256SdelphijAC_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])
158128345Stjr
159128345Stjr# Checks for typedefs, structures, and compiler characteristics.
160128345StjrAC_HEADER_STAT
161128345StjrAC_C_CONST
162128345StjrAC_TYPE_OFF_T
163128345StjrAC_TYPE_SIZE_T
164128345StjrAC_HEADER_TIME
165128345Stjr
166128345Stjr# Autoheader templates for symbols defined later by AC_DEFINE.
167128345StjrAH_TEMPLATE([HAVE_POSIX_REGCOMP],
168128345Stjr	[POSIX regcomp() and regex.h])
169128345StjrAH_TEMPLATE([HAVE_PCRE],
170128345Stjr	[PCRE (Perl-compatible regular expression) library])
171128345StjrAH_TEMPLATE([HAVE_RE_COMP],
172128345Stjr	[BSD re_comp()])
173128345StjrAH_TEMPLATE([HAVE_REGCMP],
174128345Stjr	[System V regcmp()])
175128345StjrAH_TEMPLATE([HAVE_V8_REGCOMP],
176128345Stjr	[Henry Spencer V8 regcomp() and regexp.h])
177128345StjrAH_TEMPLATE([NO_REGEX],
178128345Stjr	[pattern matching is supported, but without metacharacters.])
179128345StjrAH_TEMPLATE([HAVE_REGEXEC2],
180128345Stjr	[])
181128345StjrAH_TEMPLATE([HAVE_VOID],
182128345Stjr	[Define HAVE_VOID if your compiler supports the "void" type.])
183128345StjrAH_TEMPLATE([HAVE_CONST],
184128345Stjr	[Define HAVE_CONST if your compiler supports the "const" modifier.])
185128345StjrAH_TEMPLATE([HAVE_TIME_T],
186128345Stjr	[Define HAVE_TIME_T if your system supports the "time_t" type.])
187128345StjrAH_TEMPLATE([HAVE_STRERROR],
188128345Stjr	[Define HAVE_STRERROR if you have the strerror() function.])
189128345StjrAH_TEMPLATE([HAVE_FILENO],
190128345Stjr	[Define HAVE_FILENO if you have the fileno() macro.])
191128345StjrAH_TEMPLATE([HAVE_ERRNO],
192128345Stjr	[Define HAVE_ERRNO if you have the errno variable.])
193128345StjrAH_TEMPLATE([MUST_DEFINE_ERRNO],
194128345Stjr	[Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.])
195128345StjrAH_TEMPLATE([HAVE_SYS_ERRLIST],
196128345Stjr	[Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable.])
197128345StjrAH_TEMPLATE([HAVE_OSPEED],
198128345Stjr	[Define HAVE_OSPEED if your termcap library has the ospeed variable.])
199128345StjrAH_TEMPLATE([MUST_DEFINE_OSPEED],
200128345Stjr	[Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in termcap.h.])
201128345StjrAH_TEMPLATE([HAVE_LOCALE],
202128345Stjr	[Define HAVE_LOCALE if you have locale.h and setlocale.])
203128345StjrAH_TEMPLATE([HAVE_TERMIOS_FUNCS],
204128345Stjr	[Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr.])
205128345StjrAH_TEMPLATE([HAVE_UPPER_LOWER],
206128345Stjr	[Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower.])
207128345StjrAH_TEMPLATE([HAVE_SIGSET_T],
208128345Stjr	[Define HAVE_SIGSET_T you have the sigset_t type.])
209128345StjrAH_TEMPLATE([HAVE_SIGEMPTYSET],
210128345Stjr	[Define HAVE_SIGEMPTYSET if you have the sigemptyset macro.])
211128345StjrAH_TEMPLATE([EDIT_PGM],
212128345Stjr	[Define EDIT_PGM to your editor.])
213161475SdelphijAH_TEMPLATE([SECURE_COMPILE],
214161475Sdelphij	[Define SECURE_COMPILE=1 to build a secure version of less.])
215128345Stjr
216128345Stjr# Checks for identifiers.
217128345StjrAC_TYPE_OFF_T
218128345StjrAC_MSG_CHECKING(for void)
219128345StjrAC_TRY_COMPILE(, [void *foo = 0;], 
220128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
221128345StjrAC_MSG_CHECKING(for const)
222128345StjrAC_TRY_COMPILE(, [const int foo = 0;], 
223128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
224128345StjrAC_MSG_CHECKING(for time_t)
225128345StjrAC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
226128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
227128345Stjr
228128345Stjr# Checks for library functions.
229128345StjrAC_TYPE_SIGNAL
230170256SdelphijAC_CHECK_FUNCS([fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod])
231128345Stjr
232170256Sdelphij# AC_CHECK_FUNCS may not work for inline functions, so test these separately.
233170256SdelphijAC_MSG_CHECKING(for memcpy)
234170256SdelphijAC_TRY_LINK([
235170256Sdelphij#if HAVE_STRING_H
236170256Sdelphij#include <string.h>
237170256Sdelphij#endif], [memcpy(0,0,0);],
238170256Sdelphij  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MEMCPY)], [AC_MSG_RESULT(no)])
239170256Sdelphij
240170256SdelphijAC_MSG_CHECKING(for strchr)
241170256SdelphijAC_TRY_LINK([
242170256Sdelphij#if HAVE_STRING_H
243170256Sdelphij#include <string.h>
244170256Sdelphij#endif], [strchr("x",'x');],
245170256Sdelphij  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRCHR)], [AC_MSG_RESULT(no)])
246170256Sdelphij
247170256SdelphijAC_MSG_CHECKING(for strstr)
248170256SdelphijAC_TRY_LINK([
249170256Sdelphij#if HAVE_STRING_H
250170256Sdelphij#include <string.h>
251170256Sdelphij#endif], [strstr("x","x");],
252170256Sdelphij  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRSTR)], [AC_MSG_RESULT(no)])
253170256Sdelphij
254128345Stjr# Some systems have termios.h but not the corresponding functions.
255128345StjrAC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
256128345Stjr
257128345StjrAC_MSG_CHECKING(for fileno)
258128345StjrAC_TRY_LINK([
259128345Stjr#if HAVE_STDIO_H
260128345Stjr#include <stdio.h>
261128345Stjr#endif], [static int x; x = fileno(stdin);],
262128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
263128345Stjr
264128345StjrAC_MSG_CHECKING(for strerror)
265128345StjrAC_TRY_LINK([
266128345Stjr#if HAVE_STDIO_H
267128345Stjr#include <stdio.h>
268128345Stjr#endif
269128345Stjr#if HAVE_STRING_H
270128345Stjr#include <string.h>
271128345Stjr#endif
272128345Stjr#if HAVE_ERRNO_H
273128345Stjr#include <errno.h>
274128345Stjr#endif], [static char *x; x = strerror(0);],
275128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
276128345Stjr
277128345StjrAC_MSG_CHECKING(for sys_errlist)
278128345StjrAC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], 
279128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
280128345Stjr
281170256SdelphijAC_CHECK_TYPES([sigset_t],,,[#include <signal.h>])
282128345Stjr
283128345StjrAC_MSG_CHECKING(for sigemptyset)
284128345StjrAC_TRY_LINK([
285128345Stjr#include <signal.h>
286128345Stjr], [sigset_t s; sigemptyset(&s);],
287128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)], [AC_MSG_RESULT(no)])
288128345Stjr
289128345Stjrhave_errno=no
290128345StjrAC_MSG_CHECKING(for errno)
291128345StjrAC_TRY_LINK([
292128345Stjr#if HAVE_ERRNO_H
293128345Stjr#include <errno.h>
294128345Stjr#endif], [static int x; x = errno;], 
295128345Stjr  [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
296128345Stjrif test $have_errno = no; then
297128345StjrAC_TRY_LINK([
298128345Stjr#if HAVE_ERRNO_H
299128345Stjr#include <errno.h>
300128345Stjr#endif], [extern int errno; static int x; x = errno;], 
301128345Stjr  [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
302128345Stjr  [AC_MSG_RESULT(no)])
303128345Stjrfi
304128345Stjr
305128345StjrAC_MSG_CHECKING(for locale)
306128345StjrAC_TRY_LINK([#include <locale.h>
307172468Sdelphij#include <ctype.h>
308172468Sdelphij#include <langinfo.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
309128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
310128345StjrAC_MSG_CHECKING(for ctype functions)
311128345StjrAC_TRY_LINK([
312128345Stjr#if HAVE_CTYPE_H
313128345Stjr#include <ctype.h>
314128345Stjr#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
315128345Stjr  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
316128345Stjr
317128345Stjr# Checks for external variable ospeed in the termcap library.
318128345Stjrhave_ospeed=no
319128345StjrAC_MSG_CHECKING(termcap for ospeed)
320128345StjrAC_TRY_LINK([
321128345Stjr#include <sys/types.h>
322128345Stjr#if HAVE_TERMIOS_H
323128345Stjr#include <termios.h>
324128345Stjr#endif
325128345Stjr#if HAVE_TERMCAP_H
326128345Stjr#include <termcap.h>
327128345Stjr#endif], [ospeed = 0;],
328128345Stjr[AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
329128345Stjrif test $have_ospeed = no; then
330128345StjrAC_TRY_LINK(, [extern short ospeed; ospeed = 0;], 
331128345Stjr  [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
332128345Stjr  [AC_MSG_RESULT(no)])
333128345Stjrfi
334128345Stjr
335161475Sdelphij# Compile in secure mode?
336161475SdelphijAC_ARG_WITH(secure,
337161475Sdelphij  [  --with-secure  Compile in secure mode],
338161475Sdelphij  AC_DEFINE(SECURE_COMPILE, 1), AC_DEFINE(SECURE_COMPILE, 0))
339161475Sdelphij
340128345Stjr# Checks for regular expression functions.
341128345Stjrhave_regex=no
342128345Stjrhave_posix_regex=unknown
343128345StjrAC_MSG_CHECKING(for regcomp)
344128345Stjr
345161475Sdelphij# Select a regular expression library.
346128345StjrWANT_REGEX=auto
347128345StjrAC_ARG_WITH(regex,
348128345Stjr  [  --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local}  Select a regular expression library  [auto]],
349128345Stjr  WANT_REGEX="$withval")
350128345Stjr
351128345Stjrif test $have_regex = no; then
352128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
353128345Stjr# Some versions of Solaris have a regcomp() function, but it doesn't work!
354128345Stjr# So we run a test program.  If we're cross-compiling, do it the old way.
355128345StjrAC_TRY_RUN([
356128345Stjr#include <sys/types.h>
357128345Stjr#include <regex.h>
358128345Stjrmain() { regex_t r; regmatch_t rm; char *text = "xabcy";
359128345Stjrif (regcomp(&r, "abc", 0)) exit(1);
360128345Stjrif (regexec(&r, text, 1, &rm, 0)) exit(1);
361128345Stjr#ifndef __WATCOMC__
362128345Stjrif (rm.rm_so != 1) exit(1); /* check for correct offset */
363128345Stjr#else
364128345Stjrif (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
365128345Stjr#endif
366128345Stjrexit(0); }],
367128345Stjr  have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
368128345Stjrif test $have_posix_regex = yes; then
369128345Stjr  AC_MSG_RESULT(using POSIX regcomp)
370128345Stjr  AC_DEFINE(HAVE_POSIX_REGCOMP)
371128345Stjr  have_regex=yes
372128345Stjrelif test $have_posix_regex = unknown; then
373128345Stjr  AC_TRY_LINK([
374128345Stjr#include <sys/types.h>
375128345Stjr#include <regex.h>],
376128345Stjr  [regex_t *r; regfree(r);],
377128345Stjr  AC_MSG_RESULT(using POSIX regcomp)
378128345Stjr  AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
379128345Stjrelse
380128345Stjr  AC_MSG_RESULT(no)
381128345Stjrfi
382128345Stjrfi
383128345Stjrfi
384128345Stjr
385128345Stjrif test $have_regex = no; then
386128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
387128345StjrAC_CHECK_LIB(pcre, pcre_compile, 
388128345Stjr[AC_MSG_RESULT(using pcre); AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes], [])
389128345Stjrfi
390128345Stjrfi
391128345Stjr
392128345Stjrif test $have_regex = no; then
393128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
394128345StjrAC_CHECK_FUNC(regcmp, 
395128345StjrAC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
396128345Stjrfi
397128345Stjrfi
398128345Stjr
399128345Stjrif test $have_regex = no; then
400128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
401128345StjrAC_TRY_LINK([
402128345Stjr#include "regexp.h"], [regcomp("");],
403128345StjrAC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
404128345Stjrfi
405128345Stjrfi
406128345Stjr
407128345Stjrif test $have_regex = no && test -f ${srcdir}/regexp.c; then
408128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
409128345StjrAC_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
410128345Stjrfi
411128345Stjrfi
412128345Stjr
413128345Stjrif test $have_regex = no; then
414128345Stjrif test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
415128345StjrAC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
416128345Stjrfi
417128345Stjrfi
418128345Stjr
419128345Stjrif test $have_regex = no; then
420128345StjrAC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
421128345Stjrfi
422128345Stjr
423128345StjrAC_ARG_WITH(editor,
424128345Stjr  [  --with-editor=PROGRAM   use PROGRAM as the default editor [vi]],
425128345Stjr  AC_DEFINE_UNQUOTED(EDIT_PGM, "$withval"), AC_DEFINE(EDIT_PGM, "vi"))
426128345Stjr
427128345StjrAH_TOP([
428128345Stjr/* Unix definition file for less.  -*- C -*-
429128345Stjr *
430128345Stjr * This file has 3 sections:
431128345Stjr * User preferences.
432128345Stjr * Settings always true on Unix.
433128345Stjr * Settings automatically determined by configure.
434128345Stjr *
435128345Stjr * * * * * *  WARNING  * * * * * *
436128345Stjr * If you edit defines.h by hand, do "touch stamp-h" before you run make
437128345Stjr * so config.status doesn't overwrite your changes.
438128345Stjr */
439128345Stjr
440128345Stjr/* User preferences.  */
441128345Stjr
442128345Stjr/*
443128345Stjr * SECURE is 1 if you wish to disable a bunch of features in order to
444128345Stjr * be safe to run by unprivileged users.
445161475Sdelphij * SECURE_COMPILE is set by the --with-secure configure option.
446128345Stjr */
447161475Sdelphij#define	SECURE		SECURE_COMPILE
448128345Stjr
449128345Stjr/*
450128345Stjr * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
451128345Stjr * (This is possible only if your system supplies the system() function.)
452128345Stjr */
453128345Stjr#define	SHELL_ESCAPE	(!SECURE)
454128345Stjr
455128345Stjr/*
456128345Stjr * EXAMINE is 1 if you wish to allow examining files by name from within less.
457128345Stjr */
458128345Stjr#define	EXAMINE		(!SECURE)
459128345Stjr
460128345Stjr/*
461128345Stjr * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
462128345Stjr * to complete filenames at prompts.
463128345Stjr */
464128345Stjr#define	TAB_COMPLETE_FILENAME	(!SECURE)
465128345Stjr
466128345Stjr/*
467128345Stjr * CMD_HISTORY is 1 if you wish to allow keys to cycle through
468128345Stjr * previous commands at prompts.
469128345Stjr */
470128345Stjr#define	CMD_HISTORY	1
471128345Stjr
472128345Stjr/*
473128345Stjr * HILITE_SEARCH is 1 if you wish to have search targets to be 
474128345Stjr * displayed in standout mode.
475128345Stjr */
476128345Stjr#define	HILITE_SEARCH	1
477128345Stjr
478128345Stjr/*
479128345Stjr * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
480128345Stjr * (This is possible only if your system supplies the system() function.)
481128345Stjr * EDIT_PGM is the name of the (default) editor to be invoked.
482128345Stjr */
483128345Stjr#define	EDITOR		(!SECURE)
484128345Stjr
485128345Stjr/*
486128345Stjr * TAGS is 1 if you wish to support tag files.
487128345Stjr */
488128345Stjr#define	TAGS		(!SECURE)
489128345Stjr
490128345Stjr/*
491128345Stjr * USERFILE is 1 if you wish to allow a .less file to specify 
492128345Stjr * user-defined key bindings.
493128345Stjr */
494128345Stjr#define	USERFILE	(!SECURE)
495128345Stjr
496128345Stjr/*
497128345Stjr * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
498128345Stjr * This will generally work if your system provides the "popen" function
499128345Stjr * and the "echo" shell command.
500128345Stjr */
501128345Stjr#define	GLOB		(!SECURE)
502128345Stjr
503128345Stjr/*
504128345Stjr * PIPEC is 1 if you wish to have the "|" command
505128345Stjr * which allows the user to pipe data into a shell command.
506128345Stjr */
507128345Stjr#define	PIPEC		(!SECURE)
508128345Stjr
509128345Stjr/*
510128345Stjr * LOGFILE is 1 if you wish to allow the -l option (to create log files).
511128345Stjr */
512128345Stjr#define	LOGFILE		(!SECURE)
513128345Stjr
514128345Stjr/*
515128345Stjr * GNU_OPTIONS is 1 if you wish to support the GNU-style command
516128345Stjr * line options --help and --version.
517128345Stjr */
518128345Stjr#define	GNU_OPTIONS	1
519128345Stjr
520128345Stjr/*
521128345Stjr * ONLY_RETURN is 1 if you want RETURN to be the only input which
522128345Stjr * will continue past an error message.
523128345Stjr * Otherwise, any key will continue past an error message.
524128345Stjr */
525128345Stjr#define	ONLY_RETURN	0
526128345Stjr
527128345Stjr/*
528128345Stjr * LESSKEYFILE is the filename of the default lesskey output file 
529128345Stjr * (in the HOME directory).
530128345Stjr * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
531128345Stjr * DEF_LESSKEYINFILE is the filename of the default lesskey input 
532128345Stjr * (in the HOME directory).
533161475Sdelphij * LESSHISTFILE is the filename of the history file
534161475Sdelphij * (in the HOME directory).
535128345Stjr */
536128345Stjr#define	LESSKEYFILE		".less"
537128345Stjr#define	LESSKEYFILE_SYS		SYSDIR "/sysless"
538128345Stjr#define	DEF_LESSKEYINFILE	".lesskey"
539161475Sdelphij#define LESSHISTFILE		".lesshst"
540128345Stjr
541128345Stjr
542128345Stjr/* Settings always true on Unix.  */
543128345Stjr
544128345Stjr/*
545128345Stjr * Define MSDOS_COMPILER if compiling under Microsoft C.
546128345Stjr */
547128345Stjr#define	MSDOS_COMPILER	0
548128345Stjr
549128345Stjr/*
550128345Stjr * Pathname separator character.
551128345Stjr */
552128345Stjr#define	PATHNAME_SEP	"/"
553128345Stjr
554128345Stjr/*
555170256Sdelphij * The value returned from tgetent on success.
556170256Sdelphij * Some HP-UX systems return 0 on success.
557170256Sdelphij */
558170256Sdelphij#define TGETENT_OK  1
559170256Sdelphij
560170256Sdelphij/*
561128345Stjr * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
562128345Stjr */
563128345Stjr#define HAVE_SYS_TYPES_H	1
564128345Stjr
565128345Stjr/*
566128345Stjr * Define if you have the <sgstat.h> header file.
567128345Stjr */
568128345Stjr#undef HAVE_SGSTAT_H
569128345Stjr
570128345Stjr/*
571128345Stjr * HAVE_PERROR is 1 if your system has the perror() call.
572128345Stjr * (Actually, if it has sys_errlist, sys_nerr and errno.)
573128345Stjr */
574128345Stjr#define	HAVE_PERROR	1
575128345Stjr
576128345Stjr/*
577128345Stjr * HAVE_TIME is 1 if your system has the time() call.
578128345Stjr */
579128345Stjr#define	HAVE_TIME	1
580128345Stjr
581128345Stjr/*
582128345Stjr * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
583128345Stjr */
584128345Stjr#define	HAVE_SHELL	1
585128345Stjr
586128345Stjr/*
587128345Stjr * Default shell metacharacters and meta-escape character.
588128345Stjr */
589170256Sdelphij#define	DEF_METACHARS	"; *?\t\n'\"()<>[]|&^`#\\$%=~"
590128345Stjr#define	DEF_METAESCAPE	"\\"
591128345Stjr
592128345Stjr/* 
593128345Stjr * HAVE_DUP is 1 if your system has the dup() call.
594128345Stjr */
595128345Stjr#define	HAVE_DUP	1
596128345Stjr
597170256Sdelphij/* Define to 1 if you have the memcpy() function. */
598170256Sdelphij#define HAVE_MEMCPY 1
599170256Sdelphij
600170256Sdelphij/* Define to 1 if you have the strchr() function. */
601170256Sdelphij#define HAVE_STRCHR 1
602170256Sdelphij
603170256Sdelphij/* Define to 1 if you have the strstr() function. */
604170256Sdelphij#define HAVE_STRSTR 1
605170256Sdelphij
606128345Stjr/*
607128345Stjr * Sizes of various buffers.
608128345Stjr */
609128345Stjr#define	CMDBUF_SIZE	512	/* Buffer for multichar commands */
610128345Stjr#define	UNGOT_SIZE	100	/* Max chars to unget() */
611128345Stjr#define	LINEBUF_SIZE	1024	/* Max size of line in input file */
612128345Stjr#define	OUTBUF_SIZE	1024	/* Output buffer */
613128345Stjr#define	PROMPT_SIZE	200	/* Max size of prompt string */
614128345Stjr#define	TERMBUF_SIZE	2048	/* Termcap buffer for tgetent */
615128345Stjr#define	TERMSBUF_SIZE	1024	/* Buffer to hold termcap strings */
616128345Stjr#define	TAGLINE_SIZE	512	/* Max size of line in tags file */
617128345Stjr#define	TABSTOP_MAX	32	/* Max number of custom tab stops */
618128345Stjr
619128345Stjr/* Settings automatically determined by configure.  */
620128345Stjr])
621128345Stjr
622128345StjrAC_CONFIG_FILES([Makefile])
623128345StjrAC_OUTPUT
624