]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/less/configure.in
This commit was generated by cvs2svn to compensate for changes in r102786,
[FreeBSD/FreeBSD.git] / contrib / less / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(forwback.c)
3 AC_CONFIG_HEADER(defines.h)
4
5 dnl Checks for programs.
6 AC_PROG_CC
7 AC_ISC_POSIX
8 AC_PROG_GCC_TRADITIONAL
9 AC_PROG_INSTALL
10
11 dnl Check for compilation model.
12 dnl AC_SYS_LARGEFILE is not supported in all versions of autoconf.
13 dnl Remove the dnl comment on the next line to use large (64 bit) files.
14 dnl AC_SYS_LARGEFILE
15
16 dnl Checks for libraries.
17 AC_CHECK_LIB(xcurses, initscr, [have_xcurses=yes], [have_xcurses=no])
18 AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
19 AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
20 AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
21 AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
22 dnl Regular expressions (regcmp) are in -lgen on Solaris 2,
23 dnl and in -lintl on SCO Unix.
24 AC_CHECK_LIB(gen, regcmp)
25 AC_CHECK_LIB(intl, regcmp)
26 AC_CHECK_LIB(PW, regcmp)
27 dnl Checks for terminal libraries
28
29 AC_MSG_CHECKING(for working terminal libraries)
30 TERMLIBS=
31
32 dnl Check for systems where curses is broken.
33 curses_broken=0
34 if test x`uname -s` = "xHP-UX" >/dev/null 2>&1; then
35 if test x`uname -r` = "xB.11.00" >/dev/null 2>&1; then
36    curses_broken=1
37 fi
38 if test x`uname -r` = "xB.11.11" >/dev/null 2>&1; then
39    curses_broken=1
40 fi
41 fi
42
43 if test $curses_broken = 0; then
44 dnl -- Try xcurses.
45 if test "x$TERMLIBS" = x; then
46   if test $have_xcurses = yes; then
47     TERMLIBS="-lxcurses"
48     SAVE_LIBS=$LIBS
49     LIBS="$LIBS $TERMLIBS"
50     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
51       [termok=yes], [termok=no])
52     LIBS=$SAVE_LIBS
53     if test $termok = no; then TERMLIBS=""; fi
54   fi
55 fi
56
57 dnl -- Try ncurses.
58 if test "x$TERMLIBS" = x; then
59   if test $have_ncurses = yes; then
60     TERMLIBS="-lncurses"
61     SAVE_LIBS=$LIBS
62     LIBS="$LIBS $TERMLIBS"
63     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
64       [termok=yes], [termok=no])
65     LIBS=$SAVE_LIBS
66     if test $termok = no; then TERMLIBS=""; fi
67   fi
68 fi
69
70 dnl -- Try curses.
71 if test "x$TERMLIBS" = x; then
72   if test $have_curses = yes; then
73     TERMLIBS="-lcurses"
74     SAVE_LIBS=$LIBS
75     LIBS="$LIBS $TERMLIBS"
76     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
77       [termok=yes], [termok=no])
78     LIBS=$SAVE_LIBS
79     if test $termok = no; then TERMLIBS=""; fi
80   fi
81 fi
82
83 dnl -- Try curses & termcap.
84 if test "x$TERMLIBS" = x; then
85   if test $have_curses = yes; then
86   if test $have_termcap = yes; then
87     TERMLIBS="-lcurses -ltermcap"
88     SAVE_LIBS=$LIBS
89     LIBS="$LIBS $TERMLIBS"
90     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
91       [termok=yes], [termok=no])
92     LIBS=$SAVE_LIBS
93     if test $termok = no; then TERMLIBS=""; fi
94   fi
95   fi
96 fi
97 fi
98
99 dnl -- Try termcap.
100 if test "x$TERMLIBS" = x; then
101   if test $have_termcap = yes; then
102     TERMLIBS="-ltermcap"
103     SAVE_LIBS=$LIBS
104     LIBS="$LIBS $TERMLIBS"
105     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
106       [termok=yes], [termok=no])
107     LIBS=$SAVE_LIBS
108     if test $termok = no; then TERMLIBS=""; fi
109   fi
110 fi
111
112 dnl -- Try termlib.
113 if test "x$TERMLIBS" = x; then
114   if test $have_termlib = yes; then
115     TERMLIBS="-lcurses -ltermlib"
116     SAVE_LIBS=$LIBS
117     LIBS="$LIBS $TERMLIBS"
118     AC_TRY_LINK(, [tgetent(0,0); tgetflag(0); tgetnum(0); tgetstr(0,0);],
119       [termok=yes], [termok=no])
120     LIBS=$SAVE_LIBS
121     if test $termok = no; then TERMLIBS=""; fi
122   fi
123 fi
124
125 if test "x$TERMLIBS" = x; then
126   AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
127   exit 1
128 fi
129 AC_MSG_RESULT(using $TERMLIBS)
130 LIBS="$LIBS $TERMLIBS"
131
132
133 dnl Checks for header files.
134 AC_CHECK_HEADERS(ctype.h errno.h fcntl.h limits.h stdio.h stdlib.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h)
135
136 dnl Checks for identifiers.
137 AC_TYPE_OFF_T
138 AC_MSG_CHECKING(for void)
139 AC_TRY_COMPILE(, [void *foo = 0;], 
140   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
141 AC_MSG_CHECKING(for const)
142 AC_TRY_COMPILE(, [const int foo = 0;], 
143   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
144 AC_MSG_CHECKING(for time_t)
145 AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
146   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
147
148 dnl Checks for functions and external variables.
149 AC_TYPE_SIGNAL
150 AC_CHECK_FUNCS(fsync memcpy popen _setjmp sigprocmask sigsetmask stat strchr strstr system)
151
152 dnl Some systems have termios.h but not the corresponding functions.
153 AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
154
155 AC_MSG_CHECKING(for fileno)
156 AC_TRY_LINK([
157 #if HAVE_STDIO_H
158 #include <stdio.h>
159 #endif], [static int x; x = fileno(stdin);],
160   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
161
162 AC_MSG_CHECKING(for strerror)
163 AC_TRY_LINK([
164 #if HAVE_STDIO_H
165 #include <stdio.h>
166 #endif
167 #if HAVE_STRING_H
168 #include <string.h>
169 #endif
170 #if HAVE_ERRNO_H
171 #include <errno.h>
172 #endif], [static char *x; x = strerror(0);],
173   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
174
175 AC_MSG_CHECKING(for sys_errlist)
176 AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], 
177   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
178
179 AC_MSG_CHECKING(for sigset_t)
180 AC_TRY_LINK([
181 #include <signal.h>
182 ], [sigset_t s; s = 0;],
183   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGSET_T)], [AC_MSG_RESULT(no)])
184
185 AC_MSG_CHECKING(for sigemptyset)
186 AC_TRY_LINK([
187 #include <signal.h>
188 ], [sigset_t s; sigemptyset(&s);],
189   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SIGEMPTYSET)], [AC_MSG_RESULT(no)])
190
191 have_errno=no
192 AC_MSG_CHECKING(for errno)
193 AC_TRY_LINK([
194 #if HAVE_ERRNO_H
195 #include <errno.h>
196 #endif], [static int x; x = errno;], 
197   [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
198 if test $have_errno = no; then
199 AC_TRY_LINK([
200 #if HAVE_ERRNO_H
201 #include <errno.h>
202 #endif], [extern int errno; static int x; x = errno;], 
203   [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
204   [AC_MSG_RESULT(no)])
205 fi
206
207 AC_MSG_CHECKING(for locale)
208 AC_TRY_LINK([#include <locale.h>
209 #include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
210   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
211 AC_MSG_CHECKING(for ctype functions)
212 AC_TRY_LINK([
213 #if HAVE_CTYPE_H
214 #include <ctype.h>
215 #endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
216   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
217
218 dnl Checks for external variable ospeed in the termcap library.
219 have_ospeed=no
220 AC_MSG_CHECKING(termcap for ospeed)
221 AC_TRY_LINK([
222 #include <sys/types.h>
223 #if HAVE_TERMIOS_H
224 #include <termios.h>
225 #endif
226 #if HAVE_TERMCAP_H
227 #include <termcap.h>
228 #endif], [ospeed = 0;],
229 [AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
230 if test $have_ospeed = no; then
231 AC_TRY_LINK(, [extern short ospeed; ospeed = 0;], 
232   [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
233   [AC_MSG_RESULT(no)])
234 fi
235
236 dnl Checks for regular expression functions.
237 have_regex=no
238 have_posix_regex=unknown
239 AC_MSG_CHECKING(for regcomp)
240
241 WANT_REGEX=auto
242 AC_ARG_WITH(regex,
243   [  --with-regex={auto,pcre,posix,regcmp,re_comp,regcomp,regcomp-local}  Select a regular expression library  [auto]],
244   WANT_REGEX="$withval")
245
246 if test $have_regex = no; then
247 if test $WANT_REGEX = auto -o $WANT_REGEX = posix; then
248 dnl Some versions of Solaris have a regcomp() function, but it doesn't work!
249 dnl So we run a test program.  If we're cross-compiling, do it the old way.
250 AC_TRY_RUN([
251 #include <sys/types.h>
252 #include <regex.h>
253 main() { regex_t r; regmatch_t rm; char *text = "xabcy";
254 if (regcomp(&r, "abc", 0)) exit(1);
255 if (regexec(&r, text, 1, &rm, 0)) exit(1);
256 #ifndef __WATCOMC__
257 if (rm.rm_so != 1) exit(1); /* check for correct offset */
258 #else
259 if (rm.rm_sp != text + 1) exit(1); /* check for correct offset */
260 #endif
261 exit(0); }],
262   have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
263 if test $have_posix_regex = yes; then
264   AC_MSG_RESULT(using POSIX regcomp)
265   AC_DEFINE(HAVE_POSIX_REGCOMP)
266   have_regex=yes
267 elif test $have_posix_regex = unknown; then
268   AC_TRY_LINK([
269 #include <sys/types.h>
270 #include <regex.h>],
271   [regex_t *r; regfree(r);],
272   AC_MSG_RESULT(using POSIX regcomp)
273   AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
274 else
275   AC_MSG_RESULT(no)
276 fi
277 fi
278 fi
279
280 if test $have_regex = no; then
281 if test $WANT_REGEX = auto -o $WANT_REGEX = pcre; then
282 AC_CHECK_LIB(pcre, pcre_compile, 
283 [AC_MSG_RESULT(using pcre); AC_DEFINE(HAVE_PCRE) LIBS="$LIBS -lpcre" have_regex=yes], [])
284 fi
285 fi
286
287 if test $have_regex = no; then
288 if test $WANT_REGEX = auto -o $WANT_REGEX = regcmp; then
289 AC_CHECK_FUNC(regcmp, 
290 AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
291 fi
292 fi
293
294 if test $have_regex = no; then
295 if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp; then
296 AC_TRY_LINK([
297 #include "regexp.h"], [regcomp("");],
298 AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
299 fi
300 fi
301
302 if test $have_regex = no && test -f ${srcdir}/regexp.c; then
303 if test $WANT_REGEX = auto -o $WANT_REGEX = regcomp-local; then
304 AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) AC_DEFINE(HAVE_REGEXEC2) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes
305 fi
306 fi
307
308 if test $have_regex = no; then
309 if test $WANT_REGEX = auto -o $WANT_REGEX = re_comp; then
310 AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
311 fi
312 fi
313
314 if test $have_regex = no; then
315 AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
316 fi
317
318 AC_ARG_WITH(editor,
319   [  --with-editor=PROGRAM   use PROGRAM as the default editor [vi]],
320   AC_DEFINE_UNQUOTED(EDIT_PGM, "$withval"))
321
322 AC_OUTPUT(Makefile)