1 # Process this file with autoconf to produce a configure script.
3 # Copyright (C) 1984-2004 Mark Nudelman
5 # You may distribute under the terms of either the GNU General Public
6 # License or the Less License, as specified in the README file.
8 # For more information about less, or for information on how to
9 # contact the author, see the README file.
11 # Autoconf initialization.
13 AC_CONFIG_SRCDIR([forwback.c])
14 AC_CONFIG_HEADER([defines.h])
16 # Checks for programs.
19 AC_PROG_GCC_TRADITIONAL
22 # Checks for compilation model.
25 # Checks for general libraries.
26 AC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
27 AC_CHECK_LIB(ncursesw, initscr, [have_ncursesw=yes], [have_ncursesw=no])
28 AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
29 AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
30 AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
31 AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
32 # Regular expressions (regcmp) are in -lgen on Solaris 2,
33 # and in -lintl on SCO Unix.
34 AC_CHECK_LIB(gen, regcmp)
35 AC_CHECK_LIB(intl, regcmp)
36 AC_CHECK_LIB(PW, regcmp)
38 # Checks for terminal libraries
39 AC_MSG_CHECKING([for working terminal libraries])
42 # Check for systems where curses is broken.
44 if test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then
45 if test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then
48 if test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then
53 if test $curses_broken = 0; then
55 if test "x$TERMLIBS" = x; then
56 if test $have_xcurses = yes; then
59 LIBS="$LIBS $TERMLIBS"
60 AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
61 [termok=yes], [termok=no])
63 if test $termok = no; then TERMLIBS=""; fi
68 if test "x$TERMLIBS" = x; then
69 if test $have_ncursesw = yes; then
72 LIBS="$LIBS $TERMLIBS"
73 AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
74 [termok=yes], [termok=no])
76 if test $termok = no; then TERMLIBS=""; fi
81 if test "x$TERMLIBS" = x; then
82 if test $have_ncurses = yes; then
85 LIBS="$LIBS $TERMLIBS"
86 AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
87 [termok=yes], [termok=no])
89 if test $termok = no; then TERMLIBS=""; fi
94 if test "x$TERMLIBS" = x; then
95 if test $have_curses = yes; then
98 LIBS="$LIBS $TERMLIBS"
99 AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
100 [termok=yes], [termok=no])
102 if test $termok = no; then TERMLIBS=""; fi
106 # -- Try curses & termcap.
107 if test "x$TERMLIBS" = x; then
108 if test $have_curses = yes; then
109 if test $have_termcap = yes; then
110 TERMLIBS="-lcurses -ltermcap"
112 LIBS="$LIBS $TERMLIBS"
113 AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
114 [termok=yes], [termok=no])
116 if test $termok = no; then TERMLIBS=""; fi
123 if test "x$TERMLIBS" = x; then
124 if test $have_termcap = yes; then
127 LIBS="$LIBS $TERMLIBS"
128 AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
129 [termok=yes], [termok=no])
131 if test $termok = no; then TERMLIBS=""; fi
136 if test "x$TERMLIBS" = x; then
137 if test $have_termlib = yes; then
138 TERMLIBS="-lcurses -ltermlib"
140 LIBS="$LIBS $TERMLIBS"
141 AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
142 [termok=yes], [termok=no])
144 if test $termok = no; then TERMLIBS=""; fi
148 if test "x$TERMLIBS" = x; then
149 AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
152 AC_MSG_RESULT(using $TERMLIBS)
153 LIBS="$LIBS $TERMLIBS"
155 # Checks for header files.
157 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])
159 # Checks for typedefs, structures, and compiler characteristics.
166 # Autoheader templates for symbols defined later by AC_DEFINE.
167 AH_TEMPLATE([HAVE_POSIX_REGCOMP],
168 [POSIX regcomp() and regex.h])
169 AH_TEMPLATE([HAVE_PCRE],
170 [PCRE (Perl-compatible regular expression) library])
171 AH_TEMPLATE([HAVE_RE_COMP],
173 AH_TEMPLATE([HAVE_REGCMP],
175 AH_TEMPLATE([HAVE_V8_REGCOMP],
176 [Henry Spencer V8 regcomp() and regexp.h])
177 AH_TEMPLATE([NO_REGEX],
178 [pattern matching is supported, but without metacharacters.])
179 AH_TEMPLATE([HAVE_REGEXEC2],
181 AH_TEMPLATE([HAVE_VOID],
182 [Define HAVE_VOID if your compiler supports the "void" type.])
183 AH_TEMPLATE([HAVE_CONST],
184 [Define HAVE_CONST if your compiler supports the "const" modifier.])
185 AH_TEMPLATE([HAVE_TIME_T],
186 [Define HAVE_TIME_T if your system supports the "time_t" type.])
187 AH_TEMPLATE([HAVE_STRERROR],
188 [Define HAVE_STRERROR if you have the strerror() function.])
189 AH_TEMPLATE([HAVE_FILENO],
190 [Define HAVE_FILENO if you have the fileno() macro.])
191 AH_TEMPLATE([HAVE_ERRNO],
192 [Define HAVE_ERRNO if you have the errno variable.])
193 AH_TEMPLATE([MUST_DEFINE_ERRNO],
194 [Define MUST_DEFINE_ERRNO if you have errno but it is not define in errno.h.])
195 AH_TEMPLATE([HAVE_SYS_ERRLIST],
196 [Define HAVE_SYS_ERRLIST if you have the sys_errlist[] variable.])
197 AH_TEMPLATE([HAVE_OSPEED],
198 [Define HAVE_OSPEED if your termcap library has the ospeed variable.])
199 AH_TEMPLATE([MUST_DEFINE_OSPEED],
200 [Define MUST_DEFINE_OSPEED if you have ospeed but it is not defined in termcap.h.])
201 AH_TEMPLATE([HAVE_LOCALE],
202 [Define HAVE_LOCALE if you have locale.h and setlocale.])
203 AH_TEMPLATE([HAVE_TERMIOS_FUNCS],
204 [Define HAVE_TERMIOS_FUNCS if you have tcgetattr/tcsetattr.])
205 AH_TEMPLATE([HAVE_UPPER_LOWER],
206 [Define HAVE_UPPER_LOWER if you have isupper, islower, toupper, tolower.])
207 AH_TEMPLATE([HAVE_SIGSET_T],
208 [Define HAVE_SIGSET_T you have the sigset_t type.])
209 AH_TEMPLATE([HAVE_SIGEMPTYSET],
210 [Define HAVE_SIGEMPTYSET if you have the sigemptyset macro.])
211 AH_TEMPLATE([EDIT_PGM],
212 [Define EDIT_PGM to your editor.])
213 AH_TEMPLATE([SECURE_COMPILE],
214 [Define SECURE_COMPILE=1 to build a secure version of less.])
216 # Checks for identifiers.
218 AC_MSG_CHECKING(for void)
219 AC_TRY_COMPILE(, [void *foo = 0;],
220 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
221 AC_MSG_CHECKING(for const)
222 AC_TRY_COMPILE(, [const int foo = 0;],
223 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
224 AC_MSG_CHECKING(for time_t)
225 AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
226 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
228 # Checks for library functions.
230 AC_CHECK_FUNCS([fsync memcpy popen _setjmp sigprocmask sigsetmask snprintf stat strchr strstr system fchmod])
232 # Some systems have termios.h but not the corresponding functions.
233 AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
235 AC_MSG_CHECKING(for fileno)
239 #endif], [static int x; x = fileno(stdin);],
240 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
242 AC_MSG_CHECKING(for strerror)
252 #endif], [static char *x; x = strerror(0);],
253 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
255 AC_MSG_CHECKING(for sys_errlist)
256 AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;],
257 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
259 AC_MSG_CHECKING(for sigset_t)
262 ], [sigset_t s; s = 0;],
263 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGSET_T)], [AC_MSG_RESULT(no)])
265 AC_MSG_CHECKING(for sigemptyset)
268 ], [sigset_t s; sigemptyset(&s);],
269 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)], [AC_MSG_RESULT(no)])
272 AC_MSG_CHECKING(for errno)
276 #endif], [static int x; x = errno;],
277 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
278 if test $have_errno = no; then
282 #endif], [extern int errno; static int x; x = errno;],
283 [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
287 AC_MSG_CHECKING(for locale)
288 AC_TRY_LINK([#include <locale.h>
289 #include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
290 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
291 AC_MSG_CHECKING(for ctype functions)
295 #endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
296 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
298 # Checks for external variable ospeed in the termcap library.
300 AC_MSG_CHECKING(termcap for ospeed)
302 #include <sys/types.h>
308 #endif], [ospeed = 0;],
309 [AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
310 if test $have_ospeed = no; then
311 AC_TRY_LINK(, [extern short ospeed; ospeed = 0;],
312 [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
316 # Compile in secure mode?
318 [ --with-secure Compile in secure mode],
319 AC_DEFINE(SECURE_COMPILE, 1), AC_DEFINE(SECURE_COMPILE, 0))
321 # Checks for regular expression functions.
323 have_posix_regex=unknown
324 AC_MSG_CHECKING(for regcomp)
326 # Select a regular expression library.
329 [ --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local} Select a regular expression library [auto]],
330 WANT_REGEX="$withval")
332 if test $have_regex = no; then
333 if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
334 # Some versions of Solaris have a regcomp() function, but it doesn't work!
335 # So we run a test program. If we're cross-compiling, do it the old way.
337 #include <sys/types.h>
339 main() { regex_t r; regmatch_t rm; char *text = "xabcy";
340 if (regcomp(&r, "abc", 0)) exit(1);
341 if (regexec(&r, text, 1, &rm, 0)) exit(1);
343 if (rm.rm_so != 1) exit(1); /* check for correct offset */
345 if (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
348 have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
349 if test $have_posix_regex = yes; then
350 AC_MSG_RESULT(using POSIX regcomp)
351 AC_DEFINE(HAVE_POSIX_REGCOMP)
353 elif test $have_posix_regex = unknown; then
355 #include <sys/types.h>
357 [regex_t *r; regfree(r);],
358 AC_MSG_RESULT(using POSIX regcomp)
359 AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
366 if test $have_regex = no; then
367 if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
368 AC_CHECK_LIB(pcre, pcre_compile,
369 [AC_MSG_RESULT(using pcre); AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes], [])
373 if test $have_regex = no; then
374 if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
375 AC_CHECK_FUNC(regcmp,
376 AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
380 if test $have_regex = no; then
381 if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
383 #include "regexp.h"], [regcomp("");],
384 AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
388 if test $have_regex = no && test -f ${srcdir}/regexp.c; then
389 if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
390 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
394 if test $have_regex = no; then
395 if test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
396 AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
400 if test $have_regex = no; then
401 AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
405 [ --with-editor=PROGRAM use PROGRAM as the default editor [vi]],
406 AC_DEFINE_UNQUOTED(EDIT_PGM, "$withval"), AC_DEFINE(EDIT_PGM, "vi"))
409 /* Unix definition file for less. -*- C -*-
411 * This file has 3 sections:
413 * Settings always true on Unix.
414 * Settings automatically determined by configure.
416 * * * * * * WARNING * * * * * *
417 * If you edit defines.h by hand, do "touch stamp-h" before you run make
418 * so config.status doesn't overwrite your changes.
421 /* User preferences. */
424 * SECURE is 1 if you wish to disable a bunch of features in order to
425 * be safe to run by unprivileged users.
426 * SECURE_COMPILE is set by the --with-secure configure option.
428 #define SECURE SECURE_COMPILE
431 * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
432 * (This is possible only if your system supplies the system() function.)
434 #define SHELL_ESCAPE (!SECURE)
437 * EXAMINE is 1 if you wish to allow examining files by name from within less.
439 #define EXAMINE (!SECURE)
442 * TAB_COMPLETE_FILENAME is 1 if you wish to allow the TAB key
443 * to complete filenames at prompts.
445 #define TAB_COMPLETE_FILENAME (!SECURE)
448 * CMD_HISTORY is 1 if you wish to allow keys to cycle through
449 * previous commands at prompts.
451 #define CMD_HISTORY 1
454 * HILITE_SEARCH is 1 if you wish to have search targets to be
455 * displayed in standout mode.
457 #define HILITE_SEARCH 1
460 * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
461 * (This is possible only if your system supplies the system() function.)
462 * EDIT_PGM is the name of the (default) editor to be invoked.
464 #define EDITOR (!SECURE)
467 * TAGS is 1 if you wish to support tag files.
469 #define TAGS (!SECURE)
472 * USERFILE is 1 if you wish to allow a .less file to specify
473 * user-defined key bindings.
475 #define USERFILE (!SECURE)
478 * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
479 * This will generally work if your system provides the "popen" function
480 * and the "echo" shell command.
482 #define GLOB (!SECURE)
485 * PIPEC is 1 if you wish to have the "|" command
486 * which allows the user to pipe data into a shell command.
488 #define PIPEC (!SECURE)
491 * LOGFILE is 1 if you wish to allow the -l option (to create log files).
493 #define LOGFILE (!SECURE)
496 * GNU_OPTIONS is 1 if you wish to support the GNU-style command
497 * line options --help and --version.
499 #define GNU_OPTIONS 1
502 * ONLY_RETURN is 1 if you want RETURN to be the only input which
503 * will continue past an error message.
504 * Otherwise, any key will continue past an error message.
506 #define ONLY_RETURN 0
509 * LESSKEYFILE is the filename of the default lesskey output file
510 * (in the HOME directory).
511 * LESSKEYFILE_SYS is the filename of the system-wide lesskey output file.
512 * DEF_LESSKEYINFILE is the filename of the default lesskey input
513 * (in the HOME directory).
514 * LESSHISTFILE is the filename of the history file
515 * (in the HOME directory).
517 #define LESSKEYFILE ".less"
518 #define LESSKEYFILE_SYS SYSDIR "/sysless"
519 #define DEF_LESSKEYINFILE ".lesskey"
520 #define LESSHISTFILE ".lesshst"
523 /* Settings always true on Unix. */
526 * Define MSDOS_COMPILER if compiling under Microsoft C.
528 #define MSDOS_COMPILER 0
531 * Pathname separator character.
533 #define PATHNAME_SEP "/"
536 * HAVE_SYS_TYPES_H is 1 if your system has <sys/types.h>.
538 #define HAVE_SYS_TYPES_H 1
541 * Define if you have the <sgstat.h> header file.
546 * HAVE_PERROR is 1 if your system has the perror() call.
547 * (Actually, if it has sys_errlist, sys_nerr and errno.)
549 #define HAVE_PERROR 1
552 * HAVE_TIME is 1 if your system has the time() call.
557 * HAVE_SHELL is 1 if your system supports a SHELL command interpreter.
562 * Default shell metacharacters and meta-escape character.
564 #define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\"
565 #define DEF_METAESCAPE "\\"
568 * HAVE_DUP is 1 if your system has the dup() call.
573 * Sizes of various buffers.
575 #define CMDBUF_SIZE 512 /* Buffer for multichar commands */
576 #define UNGOT_SIZE 100 /* Max chars to unget() */
577 #define LINEBUF_SIZE 1024 /* Max size of line in input file */
578 #define OUTBUF_SIZE 1024 /* Output buffer */
579 #define PROMPT_SIZE 200 /* Max size of prompt string */
580 #define TERMBUF_SIZE 2048 /* Termcap buffer for tgetent */
581 #define TERMSBUF_SIZE 1024 /* Buffer to hold termcap strings */
582 #define TAGLINE_SIZE 512 /* Max size of line in tags file */
583 #define TABSTOP_MAX 32 /* Max number of custom tab stops */
585 /* Settings automatically determined by configure. */
588 AC_CONFIG_FILES([Makefile])