configure.ac revision 240121
10Sduke# Process this file with autoconf to produce a configure script.
20Sduke
30Sduke# Copyright (C) 1984-2011  Mark Nudelman
40Sduke#
50Sduke# You may distribute under the terms of either the GNU General Public
60Sduke# License or the Less License, as specified in the README file.
70Sduke#
80Sduke# For more information about less, or for information on how to 
90Sduke# contact the author, see the README file.
100Sduke
110Sduke# Autoconf initialization.
120SdukeAC_INIT(less, 1)
130SdukeAC_CONFIG_SRCDIR([forwback.c])
140SdukeAC_CONFIG_HEADER([defines.h])
150Sduke
160Sduke# Checks for programs.
170SdukeAC_PROG_CC
180SdukeAC_ISC_POSIX
190SdukeAC_PROG_GCC_TRADITIONAL
200SdukeAC_PROG_INSTALL
210Sduke
220Sduke# Checks for compilation model.
230SdukeAC_SYS_LARGEFILE
240Sduke
250Sduke# Checks for general libraries.
265SohairAC_CHECK_LIB(tinfo, tgoto, [have_tinfo=yes], [have_tinfo=no])
275SohairAC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
280SdukeAC_CHECK_LIB(ncursesw, initscr, [have_ncursesw=yes], [have_ncursesw=no])
290SdukeAC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
300SdukeAC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
310SdukeAC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
320SdukeAC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
330Sduke# Regular expressions (regcmp) are in -lgen on Solaris 2, (but in libc
340Sduke# at least on Solaris 10 (2.10)) and in -lintl on SCO Unix.
350SdukeAC_SEARCH_LIBS([regcmp], [gen intl PW])
360Sduke
370Sduke# Checks for terminal libraries
380SdukeAC_MSG_CHECKING([for working terminal libraries])
390SdukeTERMLIBS=
400Sduke
410Sduke# Check for systems where curses is broken.
420Sdukecurses_broken=0
430Sdukeif test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then
440Sdukeif test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then
450Sduke   curses_broken=1
460Sdukefi
474Sohairif test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then
484Sohair   curses_broken=1
494Sohairfi
504Sohairfi
514Sohair
524Sohairif test $curses_broken = 0; then
534Sohair
544Sohair# -- Try tinfo.
554Sohairif test "x$TERMLIBS" = x; then
564Sohair  if test $have_tinfo = yes; then
574Sohair    TERMLIBS="-ltinfo"
580Sduke    SAVE_LIBS=$LIBS
590Sduke    LIBS="$LIBS $TERMLIBS"
600Sduke    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
610Sduke      [termok=yes], [termok=no])
620Sduke    LIBS=$SAVE_LIBS
630Sduke    if test $termok = no; then TERMLIBS=""; fi
640Sduke  fi
650Sdukefi
660Sduke
670Sduke# -- Try xcurses.
680Sdukeif test "x$TERMLIBS" = x; then
690Sduke  if test $have_xcurses = yes; then
700Sduke    TERMLIBS="-lxcurses"
715Sohair    SAVE_LIBS=$LIBS
720Sduke    LIBS="$LIBS $TERMLIBS"
730Sduke    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
740Sduke      [termok=yes], [termok=no])
750Sduke    LIBS=$SAVE_LIBS
760Sduke    if test $termok = no; then TERMLIBS=""; fi
770Sduke  fi
780Sdukefi
790Sduke
800Sduke# -- Try ncursesw.
810Sdukeif test "x$TERMLIBS" = x; then
820Sduke  if test $have_ncursesw = yes; then
830Sduke    TERMLIBS="-lncursesw"
840Sduke    SAVE_LIBS=$LIBS
850Sduke    LIBS="$LIBS $TERMLIBS"
860Sduke    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
870Sduke      [termok=yes], [termok=no])
880Sduke    LIBS=$SAVE_LIBS
890Sduke    if test $termok = no; then TERMLIBS=""; fi
900Sduke  fi
910Sdukefi
920Sduke
930Sduke# -- Try ncurses.
940Sdukeif test "x$TERMLIBS" = x; then
950Sduke  if test $have_ncurses = yes; then
960Sduke    TERMLIBS="-lncurses"
970Sduke    SAVE_LIBS=$LIBS
984Sohair    LIBS="$LIBS $TERMLIBS"
990Sduke    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
1000Sduke      [termok=yes], [termok=no])
1014Sohair    LIBS=$SAVE_LIBS
1025Sohair    if test $termok = no; then TERMLIBS=""; fi
1034Sohair  fi
1044Sohairfi
1054Sohair
1064Sohair# -- Try curses.
1074Sohairif test "x$TERMLIBS" = x; then
1084Sohair  if test $have_curses = yes; then
1094Sohair    TERMLIBS="-lcurses"
1104Sohair    SAVE_LIBS=$LIBS
1114Sohair    LIBS="$LIBS $TERMLIBS"
1124Sohair    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
1134Sohair      [termok=yes], [termok=no])
1144Sohair    LIBS=$SAVE_LIBS
1154Sohair    if test $termok = no; then TERMLIBS=""; fi
1164Sohair  fi
1170Sdukefi
1180Sduke
1190Sduke# -- Try curses & termcap.
1200Sdukeif test "x$TERMLIBS" = x; then
1210Sduke  if test $have_curses = yes; then
1220Sduke  if test $have_termcap = yes; then
1230Sduke    TERMLIBS="-lcurses -ltermcap"
1240Sduke    SAVE_LIBS=$LIBS
1250Sduke    LIBS="$LIBS $TERMLIBS"
1260Sduke    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
1270Sduke      [termok=yes], [termok=no])
1280Sduke    LIBS=$SAVE_LIBS
1290Sduke    if test $termok = no; then TERMLIBS=""; fi
1300Sduke  fi
1310Sduke  fi
1320Sdukefi
1330Sdukefi
1340Sduke
1350Sduke# -- Try termcap.
1360Sdukeif test "x$TERMLIBS" = x; then
1370Sduke  if test $have_termcap = yes; then
1380Sduke    TERMLIBS="-ltermcap"
1390Sduke    SAVE_LIBS=$LIBS
1400Sduke    LIBS="$LIBS $TERMLIBS"
1410Sduke    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
1420Sduke      [termok=yes], [termok=no])
1430Sduke    LIBS=$SAVE_LIBS
1440Sduke    if test $termok = no; then TERMLIBS=""; fi
1450Sduke  fi
1460Sdukefi
1470Sduke
1480Sduke# -- Try termlib.
1490Sdukeif test "x$TERMLIBS" = x; then
1500Sduke  if test $have_termlib = yes; then
1510Sduke    TERMLIBS="-lcurses -ltermlib"
1520Sduke    SAVE_LIBS=$LIBS
1530Sduke    LIBS="$LIBS $TERMLIBS"
1540Sduke    AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
1550Sduke      [termok=yes], [termok=no])
1560Sduke    LIBS=$SAVE_LIBS
1570Sduke    if test $termok = no; then TERMLIBS=""; fi
1580Sduke  fi
1590Sdukefi
1600Sduke
1610Sdukeif test "x$TERMLIBS" = x; then
1620Sduke  AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
1630Sduke  exit 1
1640Sdukefi
1650SdukeAC_MSG_RESULT(using $TERMLIBS)
1660SdukeLIBS="$LIBS $TERMLIBS"
1670Sduke
1680Sduke# Checks for header files.
1690SdukeAC_HEADER_STDC
1700SdukeAC_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])
1710Sduke
1720Sduke# Checks for typedefs, structures, and compiler characteristics.
1735SohairAC_HEADER_STAT
1740SdukeAC_C_CONST
1750SdukeAC_TYPE_OFF_T
1760SdukeAC_TYPE_SIZE_T
1770SdukeAC_HEADER_TIME
1780Sduke
1790Sduke# Autoheader templates for symbols defined later by AC_DEFINE.
1800SdukeAH_TEMPLATE([HAVE_GNU_REGEX],
1810Sduke	[GNU regex library])
1820SdukeAH_TEMPLATE([HAVE_POSIX_REGCOMP],
1830Sduke	[POSIX regcomp() and regex.h])
1840SdukeAH_TEMPLATE([HAVE_PCRE],
1850Sduke	[PCRE (Perl-compatible regular expression) library])
1860SdukeAH_TEMPLATE([HAVE_RE_COMP],
1870Sduke	[BSD re_comp()])
1880SdukeAH_TEMPLATE([HAVE_REGCMP],
1890Sduke	[System V regcmp()])
1900SdukeAH_TEMPLATE([HAVE_V8_REGCOMP],
1910Sduke	[Henry Spencer V8 regcomp() and regexp.h])
1920SdukeAH_TEMPLATE([NO_REGEX],
1930Sduke	[pattern matching is supported, but without metacharacters.])
1940SdukeAH_TEMPLATE([HAVE_REGEXEC2],
1950Sduke	[])
1960SdukeAH_TEMPLATE([HAVE_VOID],
1970Sduke	[Define HAVE_VOID if your compiler supports the "void" type.])
1980SdukeAH_TEMPLATE([HAVE_FLOAT],
1990Sduke	[Define HAVE_FLOAT if your compiler supports the "double" type.])
2000SdukeAH_TEMPLATE([HAVE_CONST],
2010Sduke	[Define HAVE_CONST if your compiler supports the "const" modifier.])
2020SdukeAH_TEMPLATE([HAVE_STAT_INO],
2030Sduke	[Define HAVE_STAT_INO if your struct stat has st_ino and st_dev.])
2040SdukeAH_TEMPLATE([HAVE_TIME_T],
2050Sduke	[Define HAVE_TIME_T if your system supports the "time_t" type.])
2060SdukeAH_TEMPLATE([HAVE_STRERROR],
2070Sduke	[Define HAVE_STRERROR if you have the strerror() function.])
2080SdukeAH_TEMPLATE([HAVE_FILENO],
2090Sduke	[Define HAVE_FILENO if you have the fileno() macro.])
2100SdukeAH_TEMPLATE([HAVE_ERRNO],
2110Sduke	[Define HAVE_ERRNO if you have the errno variable.])
2120SdukeAH_TEMPLATE([MUST_DEFINE_ERRNO],
2130Sduke	[Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.])
2140SdukeAH_TEMPLATE([HAVE_SYS_ERRLIST],
2150Sduke	[Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable.])
2160SdukeAH_TEMPLATE([HAVE_OSPEED],
2170Sduke	[Define HAVE_OSPEED if your termcap library has the ospeed variable.])
2180SdukeAH_TEMPLATE([MUST_DEFINE_OSPEED],
2190Sduke	[Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in termcap.h.])
2204SohairAH_TEMPLATE([HAVE_LOCALE],
2214Sohair	[Define HAVE_LOCALE if you have locale.h and setlocale.])
2224SohairAH_TEMPLATE([HAVE_TERMIOS_FUNCS],
2234Sohair	[Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr.])
2244SohairAH_TEMPLATE([HAVE_UPPER_LOWER],
2254Sohair	[Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower.])
2264SohairAH_TEMPLATE([HAVE_WCTYPE],
2274Sohair	[Define HAVE_WCTYPE if you have iswupper, iswlower, towupper, towlower.])
2284SohairAH_TEMPLATE([HAVE_SIGSET_T],
2294Sohair	[Define HAVE_SIGSET_T you have the sigset_t type.])
2304SohairAH_TEMPLATE([HAVE_SIGEMPTYSET],
2314Sohair	[Define HAVE_SIGEMPTYSET if you have the sigemptyset macro.])
2324SohairAH_TEMPLATE([EDIT_PGM],
2330Sduke	[Define EDIT_PGM to your editor.])
2340SdukeAH_TEMPLATE([SECURE_COMPILE],
2354Sohair	[Define SECURE_COMPILE=1 to build a secure version of less.])
2364Sohair
2374Sohair# Checks for identifiers.
2384SohairAC_TYPE_OFF_T
2394SohairAC_MSG_CHECKING(for void)
2404SohairAC_TRY_COMPILE(, [void *foo = 0;], 
2414Sohair  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
2424SohairAC_MSG_CHECKING(for const)
2434SohairAC_TRY_COMPILE(, [const int foo = 0;], 
2444Sohair  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
2454SohairAC_MSG_CHECKING(for time_t)
2464SohairAC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
2474Sohair  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
2484SohairAC_MSG_CHECKING(for st_ino in struct stat)
2494SohairAC_TRY_COMPILE([#include <sys/types.h>
2504Sohair#include <sys/stat.h>],
2510Sduke  [struct stat s; dev_t dev = s.st_dev; ino_t ino = s.st_ino;],
2520Sduke  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STAT_INO)], [AC_MSG_RESULT(no)])
2530Sduke
2544Sohair# Checks for library functions.
2550SdukeAC_TYPE_SIGNAL
2560SdukeAC_CHECK_FUNCS([fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod])
2574Sohair
2584Sohair# AC_CHECK_FUNCS may not work for inline functions, so test these separately.
2594SohairAC_MSG_CHECKING(for memcpy)
2604SohairAC_TRY_LINK([
2614Sohair#if HAVE_STRING_H
2624Sohair#include <string.h>
2634Sohair#endif], [memcpy(0,0,0);],
2644Sohair  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MEMCPY)], [AC_MSG_RESULT(no)])
2654Sohair
2664SohairAC_MSG_CHECKING(for strchr)
2670SdukeAC_TRY_LINK([
2684Sohair#if HAVE_STRING_H
2690Sduke#include <string.h>
2704Sohair#endif], [strchr("x",'x');],
2714Sohair  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRCHR)], [AC_MSG_RESULT(no)])
2724Sohair
2734SohairAC_MSG_CHECKING(for strstr)
2744SohairAC_TRY_LINK([
2754Sohair#if HAVE_STRING_H
2764Sohair#include <string.h>
2774Sohair#endif], [strstr("x","x");],
2780Sduke  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRSTR)], [AC_MSG_RESULT(no)])
2790Sduke
2800Sduke# Some systems have termios.h but not the corresponding functions.
2810SdukeAC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
2820Sduke
2830SdukeAC_MSG_CHECKING(for fileno)
2840SdukeAC_TRY_LINK([
2850Sduke#if HAVE_STDIO_H
2860Sduke#include <stdio.h>
2870Sduke#endif], [static int x; x = fileno(stdin);],
2880Sduke  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
2890Sduke
2900SdukeAC_MSG_CHECKING(for strerror)
2910SdukeAC_TRY_LINK([
2920Sduke#if HAVE_STDIO_H
2930Sduke#include <stdio.h>
2940Sduke#endif
2950Sduke#if HAVE_STRING_H
2960Sduke#include <string.h>
2970Sduke#endif
2980Sduke#if HAVE_ERRNO_H
2990Sduke#include <errno.h>
3000Sduke#endif], [static char *x; x = strerror(0);],
3010Sduke  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
3020Sduke
3030SdukeAC_MSG_CHECKING(for sys_errlist)
3040SdukeAC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], 
3050Sduke  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
3060Sduke
3070SdukeAC_CHECK_TYPES([sigset_t],,,[#include <signal.h>])
3080Sduke
3090SdukeAC_MSG_CHECKING(for sigemptyset)
3100SdukeAC_TRY_LINK([
3110Sduke#include <signal.h>
3120Sduke], [sigset_t s; sigemptyset(&s);],
3130Sduke  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)], [AC_MSG_RESULT(no)])
3140Sduke
3150Sdukehave_errno=no
3160SdukeAC_MSG_CHECKING(for errno)
3170SdukeAC_TRY_LINK([
3180Sduke#if HAVE_ERRNO_H
3190Sduke#include <errno.h>
3200Sduke#endif], [static int x; x = errno;], 
3210Sduke  [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
3220Sdukeif test $have_errno = no; then
3230SdukeAC_TRY_LINK([
3240Sduke#if HAVE_ERRNO_H
3250Sduke#include <errno.h>
3260Sduke#endif], [extern int errno; static int x; x = errno;], 
3270Sduke  [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
3280Sduke  [AC_MSG_RESULT(no)])
3290Sdukefi
3300Sduke
3310SdukeAC_MSG_CHECKING(for locale)
3320SdukeAC_TRY_LINK([#include <locale.h>
3330Sduke#include <ctype.h>
3340Sduke#include <langinfo.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
3350Sduke  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
3360Sduke
3370SdukeAC_MSG_CHECKING(for ctype functions)
3380SdukeAC_TRY_LINK([
3390Sduke#if HAVE_CTYPE_H
3400Sduke#include <ctype.h>
3410Sduke#endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
3420Sduke  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
3430Sduke
3440SdukeAC_MSG_CHECKING(for wctype functions)
3450SdukeAC_TRY_LINK([#include <wctype.h>], [iswlower(0); iswupper(0); towlower(0); towupper(0);],
3460Sduke  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_WCTYPE)], [AC_MSG_RESULT(no)])
3470Sduke
3480Sduke# Checks for external variable ospeed in the termcap library.
3490Sdukehave_ospeed=no
3500SdukeAC_MSG_CHECKING(termcap for ospeed)
3510SdukeAC_TRY_LINK([
3520Sduke#include <sys/types.h>
3530Sduke#if HAVE_TERMIOS_H
3540Sduke#include <termios.h>
3550Sduke#endif
3560Sduke#if HAVE_TERMCAP_H
3570Sduke#include <termcap.h>
3580Sduke#endif], [ospeed = 0;],
3590Sduke[AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
3600Sdukeif test $have_ospeed = no; then
3610SdukeAC_TRY_LINK(, [extern short ospeed; ospeed = 0;], 
3620Sduke  [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
3630Sduke  [AC_MSG_RESULT(no)])
3640Sdukefi
3650Sduke
3660Sduke# Compile in secure mode?
3670SdukeAC_ARG_WITH(secure,
3680Sduke  [  --with-secure  Compile in secure mode],
3690Sduke  AC_DEFINE(SECURE_COMPILE, 1), AC_DEFINE(SECURE_COMPILE, 0))
3700Sduke
3710Sduke# Should we use floating point?
3720SdukeAC_MSG_CHECKING(for floating point)
3730SdukeAC_ARG_WITH(no-float,
3740Sduke  [  --with-no-float  Do not use floating point],
3750Sduke  WANT_NO_FLOAT=1, WANT_NO_FLOAT=0)
3760Sdukeif test $WANT_NO_FLOAT = 0; then
3770Sduke  AC_TRY_LINK(, [double f1 = 12.5; double f2 = f1*f1/2.5;], 
3780Sduke    [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FLOAT)], [AC_MSG_RESULT(no)])
3790Sdukeelse
3800Sduke  AC_MSG_RESULT(disabled by user)
3810Sdukefi
3820Sduke
3830Sduke# Checks for regular expression functions.
3840Sdukehave_regex=no
3850Sdukehave_posix_regex=unknown
3860SdukeAC_MSG_CHECKING(for regcomp)
3870Sduke
3880Sduke# Select a regular expression library.
3890SdukeWANT_REGEX=auto
3900SdukeAC_ARG_WITH(regex,
3910Sduke  [  --with-regex={auto,gnu,pcre,posix,regcmp,re_comp,regcomp,regcomp-local,none}  Select a regular expression library  [auto]],
3920Sduke  WANT_REGEX="$withval")
3930Sduke
3940Sdukeif test $have_regex = no; then
3950Sdukeif test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
3960Sduke# Some versions of Solaris have a regcomp() function, but it doesn't work!
3970Sduke# So we run a test program.  If we're cross-compiling, do it the old way.
3980SdukeAC_TRY_RUN([
3990Sduke#include <sys/types.h>
4000Sduke#include <regex.h>
4010Sdukemain() { regex_t r; regmatch_t rm; char *text = "xabcy";
4020Sdukeif (regcomp(&r, "abc", 0)) exit(1);
4030Sdukeif (regexec(&r, text, 1, &rm, 0)) exit(1);
4040Sduke#ifndef __WATCOMC__
4050Sdukeif (rm.rm_so != 1) exit(1); /* check for correct offset */
4060Sduke#else
4070Sdukeif (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
4080Sduke#endif
4090Sdukeexit(0); }],
4100Sduke  have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
4110Sdukeif test $have_posix_regex = yes; then
4120Sduke  AC_MSG_RESULT(using POSIX regcomp)
4130Sduke  AC_DEFINE(HAVE_POSIX_REGCOMP)
4140Sduke  have_regex=yes
4150Sdukeelif test $have_posix_regex = unknown; then
4160Sduke  AC_TRY_LINK([
4170Sduke#include <sys/types.h>
4180Sduke#include <regex.h>],
4190Sduke  [regex_t *r; regfree(r);],
4200Sduke  AC_MSG_RESULT(using POSIX regcomp)
4210Sduke  AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
4220Sdukeelse
4230Sduke  AC_MSG_RESULT(no)
4240Sdukefi
4250Sdukefi
4260Sdukefi
4270Sduke
4280Sdukeif test $have_regex = no; then
4290Sdukeif test $WANT_REGEX = auto -o $WANT_REGEX = gnu; then
4300SdukeAC_CHECK_LIB(c, re_compile_pattern, 
4310Sduke[AC_MSG_RESULT(using gnu); AC_DEFINE(HAVE_GNU_REGEX) have_regex=yes], [])
4320Sdukefi
4330Sdukefi
4340Sduke
4350Sdukeif test $have_regex = no; then
4360Sdukeif test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
4370SdukeAC_CHECK_LIB(pcre, pcre_compile, 
4380Sduke[AC_MSG_RESULT(using pcre); AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes], [])
4390Sdukefi
4400Sdukefi
4410Sduke
4420Sdukeif test $have_regex = no; then
4430Sdukeif test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
4440SdukeAC_CHECK_FUNC(regcmp, 
4450SdukeAC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
4460Sdukefi
4470Sdukefi
4480Sduke
4490Sdukeif test $have_regex = no; then
4500Sdukeif test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
4510SdukeAC_TRY_LINK([
4520Sduke#include "regexp.h"], [regcomp("");],
4530SdukeAC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
4540Sdukefi
4550Sdukefi
4560Sduke
4570Sdukeif test $have_regex = no && test -f ${srcdir}/regexp.c; then
4580Sdukeif test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
4590SdukeAC_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
4600Sdukefi
4610Sdukefi
4620Sduke
4630Sdukeif test $have_regex = no; then
4640Sdukeif test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
4650SdukeAC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
4660Sdukefi
4670Sdukefi
4680Sduke
4690Sdukeif test $have_regex = no; then
4700Sdukeif test $WANT_REGEX = auto -o $WANT_REGEX = none; then
4710SdukeAC_MSG_RESULT(using no regex); have_regex=yes;
4720Sdukefi
4730Sdukefi
4740Sduke
4750Sdukeif test $have_regex = no; then
4760SdukeAC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
4770Sdukefi
4780Sduke
4790SdukeAC_ARG_WITH(editor,
4804Sohair  [  --with-editor=PROGRAM   use PROGRAM as the default editor [vi]],
4810Sduke  AC_DEFINE_UNQUOTED(EDIT_PGM, "$withval"), AC_DEFINE(EDIT_PGM, "vi"))
4820Sduke
4834SohairAH_TOP([
4844Sohair/* Unix definition file for less.  -*- C -*-
4850Sduke *
4860Sduke * This file has 3 sections:
4870Sduke * User preferences.
4880Sduke * Settings always true on Unix.
4890Sduke * Settings automatically determined by configure.
4900Sduke *
4910Sduke * * * * * *  WARNING  * * * * * *
4920Sduke * If you edit defines.h by hand, do "touch stamp-h" before you run make
4930Sduke * so config.status doesn't overwrite your changes.
4940Sduke */
4950Sduke
4960Sduke/* User preferences.  */
4970Sduke
4980Sduke/*
4990Sduke * SECURE is 1 if you wish to disable a bunch of features in order to
5000Sduke * be safe to run by unprivileged users.
5010Sduke * SECURE_COMPILE is set by the --with-secure configure option.
5020Sduke */
5030Sduke#define	SECURE		SECURE_COMPILE
5045Sohair
5055Sohair/*
5065Sohair * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
507 * (This is possible only if your system supplies the system() function.)
508 */
509#define	SHELL_ESCAPE	(!SECURE)
510
511/*
512 * EXAMINE is 1 if you wish to allow examining files by name from within less.
513 */
514#define	EXAMINE		(!SECURE)
515
516/*
517 * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
518 * to complete filenames at prompts.
519 */
520#define	TAB_COMPLETE_FILENAME	(!SECURE)
521
522/*
523 * CMD_HISTORY is 1 if you wish to allow keys to cycle through
524 * previous commands at prompts.
525 */
526#define	CMD_HISTORY	1
527
528/*
529 * HILITE_SEARCH is 1 if you wish to have search targets to be 
530 * displayed in standout mode.
531 */
532#define	HILITE_SEARCH	1
533
534/*
535 * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
536 * (This is possible only if your system supplies the system() function.)
537 * EDIT_PGM is the name of the (default) editor to be invoked.
538 */
539#define	EDITOR		(!SECURE)
540
541/*
542 * TAGS is 1 if you wish to support tag files.
543 */
544#define	TAGS		(!SECURE)
545
546/*
547 * USERFILE is 1 if you wish to allow a .less file to specify 
548 * user-defined key bindings.
549 */
550#define	USERFILE	(!SECURE)
551
552/*
553 * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
554 * This will generally work if your system provides the "popen" function
555 * and the "echo" shell command.
556 */
557#define	GLOB		(!SECURE)
558
559/*
560 * PIPEC is 1 if you wish to have the "|" command
561 * which allows the user to pipe data into a shell command.
562 */
563#define	PIPEC		(!SECURE)
564
565/*
566 * LOGFILE is 1 if you wish to allow the -l option (to create log files).
567 */
568#define	LOGFILE		(!SECURE)
569
570/*
571 * GNU_OPTIONS is 1 if you wish to support the GNU-style command
572 * line options --help and --version.
573 */
574#define	GNU_OPTIONS	1
575
576/*
577 * ONLY_RETURN is 1 if you want RETURN to be the only input which
578 * will continue past an error message.
579 * Otherwise, any key will continue past an error message.
580 */
581#define	ONLY_RETURN	0
582
583/*
584 * LESSKEYFILE is the filename of the default lesskey output file 
585 * (in the HOME directory).
586 * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
587 * DEF_LESSKEYINFILE is the filename of the default lesskey input 
588 * (in the HOME directory).
589 * LESSHISTFILE is the filename of the history file
590 * (in the HOME directory).
591 */
592#define	LESSKEYFILE		".less"
593#define	LESSKEYFILE_SYS		SYSDIR "/sysless"
594#define	DEF_LESSKEYINFILE	".lesskey"
595#define LESSHISTFILE		".lesshst"
596
597
598/* Settings always true on Unix.  */
599
600/*
601 * Define MSDOS_COMPILER if compiling under Microsoft C.
602 */
603#define	MSDOS_COMPILER	0
604
605/*
606 * Pathname separator character.
607 */
608#define	PATHNAME_SEP	"/"
609
610/*
611 * The value returned from tgetent on success.
612 * Some HP-UX systems return 0 on success.
613 */
614#define TGETENT_OK  1
615
616/*
617 * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
618 */
619#define HAVE_SYS_TYPES_H	1
620
621/*
622 * Define if you have the <sgstat.h> header file.
623 */
624#undef HAVE_SGSTAT_H
625
626/*
627 * HAVE_PERROR is 1 if your system has the perror() call.
628 * (Actually, if it has sys_errlist, sys_nerr and errno.)
629 */
630#define	HAVE_PERROR	1
631
632/*
633 * HAVE_TIME is 1 if your system has the time() call.
634 */
635#define	HAVE_TIME	1
636
637/*
638 * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
639 */
640#define	HAVE_SHELL	1
641
642/*
643 * Default shell metacharacters and meta-escape character.
644 */
645#define	DEF_METACHARS	"; *?\t\n'\"()<>[]|&^`#\\$%=~"
646#define	DEF_METAESCAPE	"\\"
647
648/* 
649 * HAVE_DUP is 1 if your system has the dup() call.
650 */
651#define	HAVE_DUP	1
652
653/* Define to 1 if you have the memcpy() function. */
654#define HAVE_MEMCPY 1
655
656/* Define to 1 if you have the strchr() function. */
657#define HAVE_STRCHR 1
658
659/* Define to 1 if you have the strstr() function. */
660#define HAVE_STRSTR 1
661
662/*
663 * Sizes of various buffers.
664 */
665#define	CMDBUF_SIZE	512	/* Buffer for multichar commands */
666#define	UNGOT_SIZE	100	/* Max chars to unget() */
667#define	LINEBUF_SIZE	1024	/* Max size of line in input file */
668#define	OUTBUF_SIZE	1024	/* Output buffer */
669#define	PROMPT_SIZE	200	/* Max size of prompt string */
670#define	TERMBUF_SIZE	2048	/* Termcap buffer for tgetent */
671#define	TERMSBUF_SIZE	1024	/* Buffer to hold termcap strings */
672#define	TAGLINE_SIZE	512	/* Max size of line in tags file */
673#define	TABSTOP_MAX	32	/* Max number of custom tab stops */
674
675/* Settings automatically determined by configure.  */
676])
677
678AC_CONFIG_FILES([Makefile])
679AC_OUTPUT
680