1 dnl @(#)configure.in 8.148 (Berkeley) 8/3/97
2 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT(../common/main.c)
5 AM_INIT_AUTOMAKE(vi, 1.80)
6 AM_CONFIG_HEADER(config.h)
15 dnl If the user wants a debugging environment, set OPTFLAG now, some
16 dnl compilers won't mix optimizing and debug flags.)
17 AC_MSG_CHECKING(if --enable-debug option specified)
19 [ --enable-debug Build a debugging version.],
20 [vi_cv_debug="yes"], [vi_cv_debug="no"])
21 AC_MSG_RESULT($vi_cv_debug)
22 if test "$vi_cv_debug" = yes; then
24 OPTFLAG=${OPTFLAG-"-g"}
25 no_op_OPTFLAG=${no_op_OPTFLAG-"-g"}
28 dnl This is where we handle stuff that autoconf can't handle.
30 dnl Don't override anything if it's already set from the environment.
32 dnl Compiler, preprocessor and load flags.
33 dnl AUX: -ZP disables _BSD_SOURCE et al, but enables POSIX at link time.
34 dnl LynxOS: We check for gcc 2.x or better, the gcc 1 that was shipped with
35 dnl LynxOS historically wasn't good enough.
38 aix3.2.5) OPTFLAG=${OPTFLAG-"-O"};;
39 aix4.1*) CFLAGS=${CFLAGS-"-qstrict"}
40 OPTFLAG=${OPTFLAG-"-O3"};;
41 aux*) CPPFLAGS=${CPPFLAGS-"-ZP -D_BSD_SOURCE -D_SYSV_SOURCE -D_AUX_SOURCE"}
42 LDFLAGS=${LDFLAGS-"-ZP"}
43 OPTFLAG=${OPTFLAG-"-O"};;
44 bsd4.4) OPTFLAG=${OPTFLAG-"-O2"};;
45 bsdi*) CC=${CC-"shlicc"}
46 OPTFLAG=${OPTFLAG-"-O2"};;
47 irix6*) OPTFLAG=${OPTFLAG-"-O2"};;
48 irix*) OPTFLAG=${OPTFLAG-"-O2"};;
50 AC_MSG_CHECKING([for GNU C (gcc) version 2.x])
51 ac_cv_gcc_vers=`${CC-cc} -v 2>&1 | \
52 grep "gcc version " | sed 's/.*version //'`
53 ac_cv_gcc_major=`echo "$ac_cv_gcc_vers" | sed 's/\..*//'`
54 if test "$ac_cv_gcc_major" = "2" ; then
58 AC_MSG_WARN([Nvi requires gcc 2.x to build on LynxOS.])
59 AC_MSG_ERROR([See build/README.LynxOS for more information.])
61 nextstep3) CPPFLAGS=${CPPFLAGS-"-w -pipe -posix"}
62 LDFLAGS=${LDFLAGS-"-posix"}
63 OPTFLAG=${OPTFLAG-"-O2"};;
64 osf*) CFLAGS=${CFLAGS-"-Olimit 1000"};;
65 solaris*) no_op_OPTFLAG=${no_op_OPTFLAG-""};;
66 sunos*) no_op_OPTFLAG=${no_op_OPTFLAG-""};;
69 dnl The default OPTFLAG is -O
71 OPTFLAG=${OPTFLAG-"-O"}
73 dnl The default compiler is cc (NOT gcc), the default CFLAGS is empty,
74 dnl NOT whatever AC_PROG_CC sets.
80 dnl The SunOS/Solaris compiler can't optimize vi/v_txt.c; the symptom is
81 dnl that the command 35i==<esc> turns into an infinite loop.
82 AC_SUBST(no_op_OPTFLAG)
83 no_op_OPTFLAG=${no_op_OPTFLAG-"$OPTFLAG"}
87 bsdi2.1) LIBS=${LIBS-"-lipc"};;
88 dgux*) LIBS=${LIBS-"-ldgc"};;
89 irix6*) LIBS=${LIBS-"-lbsd"};;
90 irix*) LIBS=${LIBS-"-lc_s -lbsd"};;
91 isc*) LIBS=${LIBS-"-lcposix -linet"};;
92 netbsd1*) LIBS=${LIBS-"-lcrypt"};;
93 ptx*) LIBS=${LIBS-"-lseq -linet -lsocket"};;
94 sco3.2*) LIBS=${LIBS-"-lsocket"};;
95 sinix*) LIBS=${LIBS-"-lelf -lc"};;
96 solaris*) LIBS=${LIBS-"-lsocket -lnsl -ldl"}
98 wgs*) LIBS=${LIBS-"-lnsl"};;
101 dnl A/UX has a broken getopt(3), strpbrk(3).
103 aux*) LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
106 dnl Ultrix has a broken POSIX.1 VDISABLE value.
108 ultrix*) AC_DEFINE(HAVE_BROKEN_VDISABLE);;
111 dnl If the user wants a tracing version, add the TRACE compile flag.
112 AC_MSG_CHECKING(if --enable-trace option specified)
114 [ --enable-trace Build a tracing version.],
115 [vi_cv_trace="yes"], [vi_cv_trace="no"])
116 if test "$vi_cv_trace" = yes; then
117 CPPFLAGS="-DTRACE $CPPFLAGS"
119 AC_MSG_RESULT($vi_cv_trace)
121 dnl The user may have additional CPP information.
122 CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"
124 dnl The user may have additional load line information.
125 LDFLAGS="$ADDLDFLAGS $LDFLAGS"
127 dnl The user may have additional library information.
128 LIBS="$ADDLIBS $LIBS"
130 dnl Checks for programs.
131 PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib"
133 dnl Check for the shell path.
134 AC_PATH_PROG(vi_cv_path_shell, sh, no)
135 if test "$vi_cv_path_shell" = no; then
136 AC_MSG_ERROR([No shell utility found.])
139 dnl Check for the sendmail path.
140 AC_PATH_PROG(vi_cv_path_sendmail, sendmail, no)
141 if test "$vi_cv_path_sendmail" = no; then
142 AC_MSG_WARN([No sendmail utility found;])
143 AC_MSG_WARN([ users will not be told of saved files.])
146 dnl Check for the perl5/perl path.
147 AC_SUBST(vi_cv_path_perl)
148 AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)
150 dnl Check for the "preserve" path.
151 dnl Historically, nvi has used /var/tmp/vi.recover. The Linux filesystem
152 dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
153 dnl beneath it so that we don't have name collisions with other editors.
154 dnl Other systems have /var/preserve as well, so we test first for an already
155 dnl existing name, and then use the first one that's writeable.
156 AC_SUBST(vi_cv_path_preserve)
157 AC_MSG_CHECKING(for preserve directory)
158 AC_CACHE_VAL(vi_cv_path_preserve, [dnl
159 dirlist="/var/preserve /var/tmp /usr/tmp"
160 vi_cv_path_preserve=no
161 for i in $dirlist; do
162 if test -d $i/vi.recover; then
163 vi_cv_path_preserve=$i/vi.recover
167 if test "$vi_cv_path_preserve" = no; then
168 for i in $dirlist; do
169 if test -d $i -a -w $i; then
170 vi_cv_path_preserve=$i/vi.recover
176 if test "$vi_cv_path_preserve" = no; then
177 AC_MSG_ERROR([No writeable preserve directory found.])
179 AC_MSG_RESULT($vi_cv_path_preserve)
181 dnl Check for programs used for installation
183 AC_PATH_PROG(vi_cv_path_ar, ar, missing_ar)
184 AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
185 AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
186 AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
187 AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
188 AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
189 AC_PATH_PROG(vi_cv_path_ranlib, ranlib, missing_ranlib)
190 AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
192 dnl Checks for libraries.
193 dnl Find the X libraries and includes.
196 if test "$no_x" != yes; then
197 if test "X$x_libraries" != "X"; then
198 if test "X$RLIBS" = "Xyes"; then
199 XLIBS="-R$x_libraries -L$x_libraries $XLIBS"
201 XLIBS="-L$x_libraries $XLIBS"
205 if test "X$x_includes" != "X"; then
206 XINCS="-I$x_includes"
210 dnl Check if the user wants widechar support.
211 AC_MSG_CHECKING(if --enable-widechar option specified)
212 AC_ARG_ENABLE(widechar,
213 [ --enable-widechar Build a wide char aware vi.],
214 [vi_cv_widechar="yes"], [vi_cv_widechar="no"])
215 if test "$vi_cv_widechar" = "yes"; then
216 AC_DEFINE(USE_WIDECHAR)
219 dnl If the user wants a Gtk IPC front-end for nvi, build it.
224 AC_MSG_CHECKING(if --enable-gtk option specified)
226 [ --enable-gtk Build a Gtk front-end for vi.],
227 [vi_cv_gtk="yes"], [vi_cv_gtk="no"])
228 AC_MSG_RESULT($vi_cv_gtk)
229 if test "$vi_cv_gtk" = "yes"; then
233 GTKINCS="$GTK_CFLAGS"
234 GTKLIBS="$GTK_LIBS $LIBS"
236 AM_PATH_GDK_PIXBUF(0.4.0, , AC_MSG_ERROR([You must have gdk-pixbuf installed.]))
237 LIBS="-lutil $GDK_PIXBUF_LIBS $GTKLIBS"
238 AC_CHECK_LIB(nvizvt, zvt_get_ptys,
239 [vi_cv_zvt="yes"], [vi_cv_zvt="no"])
240 if test "$vi_cv_zvt" = "yes"; then
241 GTKLIBS="-lnvizvt $LIBS"
245 # AC_PATH_PROG(vi_cv_gnome_config, gnome-config, no)
246 # if test "$vi_cv_gnome_config" != "no"; then
247 # ZVTLIBS=`$vi_cv_gnome_config zvt --libs`
248 # GTKLIBS="$ZVTLIBS $GTKLIBS"
252 dnl If the user wants a Motif IPC front-end for nvi, build it.
255 AC_MSG_CHECKING(if --enable-motif option specified)
257 [ --enable-motif Build a Motif front-end for vi.],
258 [vi_cv_motif="yes"], [vi_cv_motif="no"])
259 AC_MSG_RESULT($vi_cv_motif)
260 if test "$vi_cv_motif" = "yes"; then
265 dnl BSDI's Motif libraries aren't shared.
272 dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
273 dnl -lXext is generally available, the others aren't.
276 dnl Color icons require -lXpm, which may or may not be available,
277 dnl depending on the version of X11.
279 MOTIFLIBS="-lXm -lXt"
280 AC_CHECK_LIB(SM, main,
281 [vi_cv_smlib="yes"], [vi_cv_smlib="no"], "$XLIBS")
282 if test "$vi_cv_smlib" = "yes"; then
283 MOTIFLIBS="$MOTIFLIBS -lSM"
285 AC_CHECK_LIB(ICE, main,
286 [vi_cv_icelib="yes"], [vi_cv_icelib="no"], "$XLIBS")
287 if test "$vi_cv_icelib" = "yes"; then
288 MOTIFLIBS="$MOTIFLIBS -lICE"
290 AC_CHECK_LIB(Xext, main,
291 [vi_cv_xextlib="yes"], [vi_cv_xextlib="no"], "$XLIBS")
292 if test "$vi_cv_xextlib" = "yes"; then
293 MOTIFLIBS="$MOTIFLIBS -lXext"
295 AC_CHECK_LIB(Xpm, main,
296 [vi_cv_xpmlib="yes"], [vi_cv_xpmlib="no"], "$XLIBS")
297 if test "$vi_cv_xpmlib" = "yes"; then
298 MOTIFLIBS="$MOTIFLIBS -lXpm"
300 MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
304 dnl Check for threads
305 AC_MSG_CHECKING(if --enable-threads option specified)
306 AC_ARG_ENABLE(threads,
307 [ --enable-threads Turn on thread support.],
308 [vi_cv_threads="yes"], [vi_cv_threads="no"])
309 AC_MSG_RESULT($vi_cv_threads)
310 if test "$vi_cv_threads" = "yes"; then
311 LIBS="$LIBS -pthread"
312 AC_CACHE_VAL(vi_cv_have_pthreads, [dnl
313 AC_TRY_LINK([#include <pthread.h>],
315 [vi_cv_have_pthreads=yes],
316 [vi_cv_have_pthreads=no])])
317 if test "$vi_cv_have_pthreads" = "no"; then
318 AC_MSG_ERROR(No threading library found)
320 IPCOBJS="pthread.o $IPCOBJS"
321 AC_DEFINE(HAVE_PTHREAD)
323 IPCOBJS="nothread.o $IPCOBJS"
326 dnl If the user wants a Perl interpreter in nvi, load it.
328 AC_SUBST(perlldflags)
330 AC_SUBST(vi_cv_perllib)
332 AC_MSG_CHECKING(if --enable-perlinterp option specified)
333 AC_ARG_ENABLE(perlinterp,
334 [ --enable-perlinterp Include a Perl interpreter in vi.],
335 [vi_cv_perlinterp="yes"], [vi_cv_perlinterp="no"])
336 AC_MSG_RESULT($vi_cv_perlinterp)
337 if test "$vi_cv_perlinterp" = "yes"; then
338 if test "$vi_cv_path_perl" = no; then
339 AC_MSG_ERROR([No perl5 utility found.])
341 $vi_cv_path_perl -e 'require 5.004' || {
342 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
344 if test "$vi_cv_threads" = "yes"; then
345 useithreads=`$vi_cv_path_perl -MConfig -e 'print $Config{useithreads}'`
346 if test "X$useithreads" != "Xdefine"; then
347 AC_MSG_ERROR([vi threading only compatible with perl's ithreads.])
351 eval `$vi_cv_path_perl -V:shrpenv`
352 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
353 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
354 -e 'ccflags;perl_inc'`
355 if test "X$perlcppflags" != "X"; then
356 CPPFLAGS="$perlcppflags $CPPFLAGS"
358 perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
360 perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
362 LTLIBOBJS="perl.lo perlxsi.lo perlsfio.lo $LTLIBOBJS"
363 AC_DEFINE(HAVE_PERL_INTERP)
366 dnl If the user wants a Tk/Tcl interpreter in nvi, load it. Make sure that
367 dnl we can find a Tk/Tcl library.
368 AC_MSG_CHECKING(if --enable-tclinterp option specified)
369 AC_ARG_ENABLE(tclinterp,
370 [ --enable-tclinterp Include a Tk/Tcl interpreter in vi.],
371 [vi_cv_tclinterp="yes"], [vi_cv_tclinterp="no"])
372 AC_MSG_RESULT($vi_cv_tclinterp)
373 if test "$vi_cv_tclinterp" = "yes"; then
374 LIBOBJS="tcl.o $LIBOBJS"
375 LIBS="-ltk -ltcl -lm $XLIBS $LIBS"
376 AC_DEFINE(HAVE_TCL_INTERP)
378 AC_CHECK_LIB(tcl, main,
379 [vi_cv_tkfatal="no"], [vi_cv_tkfatal="yes"], -ltk -lm)
380 if test "$vi_cv_tkfatal" = "yes"; then
381 AC_MSG_WARN([No Tk/Tcl library found;])
382 AC_MSG_ERROR([ see the section ADDING LIBRARIES AND INCLUDE FILES in the README file.])
386 dnl Check for the termcap/termlib library. Compile in nvi's curses routines
387 dnl unless the user specifies otherwise. These two checks must occur in the
388 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
389 AC_CHECK_LIB(termlib, tgetent,
390 [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
391 if test "$vi_cv_termlib" = no; then
392 AC_CHECK_LIB(termcap, tgetent,
393 [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
395 if test "$vi_cv_termlib" != no; then
396 LIBS="$vi_cv_termlib $LIBS"
400 # XXX actually check for curses !
401 LIBS="-lcurses $LIBS"
403 dnl Checks for header files.
404 AC_MSG_CHECKING(for sys/mman.h)
405 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
406 AC_TRY_CPP([#include <sys/mman.h>],
407 [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
408 if test "$vi_cv_include_sys_mman" = yes; then
409 AC_DEFINE(HAVE_SYS_MMAN_H)
411 AC_MSG_RESULT($vi_cv_include_sys_mman)
413 AC_MSG_CHECKING(for sys/select.h)
414 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
415 AC_TRY_CPP([#include <sys/select.h>],
416 [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
417 if test "$vi_cv_include_sys_select" = yes; then
418 AC_DEFINE(HAVE_SYS_SELECT_H)
420 AC_MSG_RESULT($vi_cv_include_sys_select)
422 dnl Checks for typedefs, structures, and compiler characteristics.
423 AC_CHECK_TYPE(ssize_t, int)
433 dnl Checks for library functions.
434 AC_CHECK_FUNCS(bsearch gethostname memchr memset)
435 AC_REPLACE_FUNCS(bsearch gethostname memchr memset)
436 AC_CHECK_FUNCS(mkstemp mmap strdup strpbrk)
437 AC_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
438 AC_CHECK_FUNCS(vsnprintf)
439 AC_REPLACE_FUNCS(vsnprintf)
441 AC_CHECK_FUNCS(select)
442 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
443 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
444 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
449 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
450 if test "$need_env" = yes; then
451 LIBOBJS="env.o $LIBOBJS"
454 dnl If we need strsep, add it and define it so we get a prototype.
455 if test "$need_strsep" = yes; then
456 LIBOBJS="strsep.o $LIBOBJS"
459 dnl XXX not sure whether this is a good idea
460 LTLIBOBJS="`echo $LIBOBJS | sed 's/\.o/.lo/g'` $LTLIBOBJS"
462 dnl Check for fcntl/flock
463 dnl Use flock preferentially, since it has cleaner semantics and won't
464 dnl hang up the editor.
466 dnl Ultrix has a broken fcntl, but a working flock.
467 dnl IRIX and DGUX have a broken flock, but working fcntl.
468 AC_MSG_CHECKING(for fcntl/flock)
469 AC_CACHE_VAL(vi_cv_lock, [dnl
475 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
476 [vi_cv_lock=flock]);;
478 if test "$vi_cv_lock" = none; then
479 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
483 if test "$vi_cv_lock" = flock; then
484 AC_DEFINE(HAVE_LOCK_FLOCK)
486 if test "$vi_cv_lock" = fcntl; then
487 AC_DEFINE(HAVE_LOCK_FCNTL)
489 AC_MSG_RESULT($vi_cv_lock)
491 dnl Check for ftruncate/chsize
492 AC_MSG_CHECKING(for ftruncate/chsize)
493 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
494 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
495 [vi_cv_ftruncate=ftruncate],
496 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
497 [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
498 if test "$vi_cv_ftruncate" = ftruncate; then
499 AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
501 if test "$vi_cv_ftruncate" = chsize; then
502 AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
504 if test "$vi_cv_ftruncate" = no; then
505 AC_MSG_ERROR([No file truncation system call.])
507 AC_MSG_RESULT($vi_cv_ftruncate)
509 dnl Check for the tigetstr/tigetnum functions.
510 AC_MSG_CHECKING(for tigetstr/tigetnum)
511 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
512 AC_TRY_LINK([#include <curses.h>], [tigetstr(0);],
513 [vi_cv_have_curses_tigetstr=yes],
514 [vi_cv_have_curses_tigetstr=no])])
515 if test "$vi_cv_have_curses_tigetstr" = yes; then
516 AC_DEFINE(HAVE_CURSES_TIGETSTR)
518 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
520 dnl Check for potentially missing curses functions in system or user-specified
521 dnl libraries. We also have to guess at whether the specified library is a
522 dnl BSD or System V style curses. Use the newterm function, all System V
523 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
524 if test "$vi_cv_curses" = "bundled curses"; then
525 AC_DEFINE(HAVE_BSD_CURSES)
526 AC_DEFINE(HAVE_CURSES_WADDNSTR)
527 AC_DEFINE(HAVE_CURSES_IDLOK)
529 dnl Check for the waddnstr function.
530 AC_MSG_CHECKING(for waddnstr)
531 AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
532 AC_TRY_LINK([#include <curses.h>], [waddnstr(stdscr, 0, 0);],
533 [vi_cv_have_curses_waddnstr=yes],
534 [vi_cv_have_curses_waddnstr=no])])
535 if test "$vi_cv_have_curses_waddnstr" = yes; then
536 AC_DEFINE(HAVE_CURSES_WADDNSTR)
538 AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
540 dnl Check for the beep function.
541 AC_MSG_CHECKING(for beep)
542 AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
543 AC_TRY_LINK([#include <curses.h>], [beep();],
544 [vi_cv_have_curses_beep=yes],
545 [vi_cv_have_curses_beep=no])])
546 if test "$vi_cv_have_curses_beep" = yes; then
547 AC_DEFINE(HAVE_CURSES_BEEP)
549 AC_MSG_RESULT($vi_cv_have_curses_beep)
551 dnl Check for the flash function.
552 AC_MSG_CHECKING(for flash)
553 AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
554 AC_TRY_LINK([#include <curses.h>], [flash();],
555 [vi_cv_have_curses_flash=yes],
556 [vi_cv_have_curses_flash=no])])
557 if test "$vi_cv_have_curses_flash" = yes; then
558 AC_DEFINE(HAVE_CURSES_FLASH)
560 AC_MSG_RESULT($vi_cv_have_curses_flash)
562 dnl Check for the idlok function.
563 AC_MSG_CHECKING(for idlok)
564 AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
565 AC_TRY_LINK([#include <curses.h>], [idlok(0, 0);],
566 [vi_cv_have_curses_idlok=yes],
567 [vi_cv_have_curses_idlok=no])])
568 if test "$vi_cv_have_curses_idlok" = yes; then
569 AC_DEFINE(HAVE_CURSES_IDLOK)
571 AC_MSG_RESULT($vi_cv_have_curses_idlok)
573 dnl Check for the keypad function.
574 AC_MSG_CHECKING(for keypad)
575 AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
576 AC_TRY_LINK([#include <curses.h>], [keypad(0, 0);],
577 [vi_cv_have_curses_keypad=yes],
578 [vi_cv_have_curses_keypad=no])])
579 if test "$vi_cv_have_curses_keypad" = yes; then
580 AC_DEFINE(HAVE_CURSES_KEYPAD)
582 AC_MSG_RESULT($vi_cv_have_curses_keypad)
584 dnl Check for the newterm function.
585 AC_MSG_CHECKING(for newterm)
586 AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
587 AC_TRY_LINK([#include <curses.h>], [newterm(0, 0, 0);],
588 [vi_cv_have_curses_newterm=yes],
589 [vi_cv_have_curses_newterm=no])])
590 if test "$vi_cv_have_curses_newterm" = yes; then
591 AC_DEFINE(HAVE_CURSES_NEWTERM)
593 AC_MSG_RESULT($vi_cv_have_curses_newterm)
595 if test "$vi_cv_have_curses_newterm" = no; then
596 AC_DEFINE(HAVE_BSD_CURSES)
600 dnl Check for the setupterm function. We make this check regardless of
601 dnl using the system library, because it may be part of the underlying
602 dnl termcap/termlib support, and we want to use the local one.
603 AC_MSG_CHECKING(for setupterm)
604 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
605 AC_TRY_LINK([#include <curses.h>], [setupterm(0, 0, 0);],
606 [vi_cv_have_curses_setupterm=yes],
607 [vi_cv_have_curses_setupterm=no])])
608 if test "$vi_cv_have_curses_setupterm" = yes; then
609 AC_DEFINE(HAVE_CURSES_SETUPTERM)
611 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
613 dnl Some moron decided to drop off an argument from the gettimeofday call,
614 dnl without changing the name.
615 AC_MSG_CHECKING(for broken gettimeofday system call)
616 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
617 AC_TRY_LINK([#include <sys/types.h>
618 #include <sys/time.h>], [gettimeofday(0, 0);],
619 [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
620 if test "$vi_cv_gettimeofday" = broken; then
621 AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
623 AC_MSG_RESULT($vi_cv_gettimeofday)
625 dnl Check for which version of openpty to use, System V or Berkeley.
626 AC_MSG_CHECKING(for System V pty calls)
627 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
628 AC_TRY_LINK(, [grantpt(0);],
629 [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
630 if test "$vi_cv_sys5_pty" = yes; then
631 AC_DEFINE(HAVE_SYS5_PTY)
633 AC_MSG_RESULT($vi_cv_sys5_pty)
635 dnl Check for the revoke system call.
636 AC_MSG_CHECKING(for revoke system call)
637 AC_CACHE_VAL(vi_cv_revoke, [dnl
638 AC_TRY_LINK(, [revoke("a");],
639 [vi_cv_revoke=yes], [vi_cv_revoke=no])])
640 if test "$vi_cv_revoke" = yes; then
641 AC_DEFINE(HAVE_REVOKE)
643 AC_MSG_RESULT($vi_cv_revoke)
645 dnl Some versions of sprintf return a pointer to the first argument instead
646 dnl of a character count. We assume that the return value of snprintf and
647 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
648 AC_MSG_CHECKING(for int type sprintf return value)
649 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
650 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
651 [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
652 if test "$vi_cv_sprintf_count" = no; then
653 AC_DEFINE(SPRINTF_RET_CHARPNT)
655 AC_MSG_RESULT($vi_cv_sprintf_count)
658 dnl Check for the standard shorthand types.
659 AC_SUBST(u_char_decl)
660 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
661 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
662 [vi_cv_uchar=yes], [vi_cv_uchar=no])])
663 if test "$vi_cv_uchar" = no; then
664 u_char_decl="typedef unsigned char u_char;"
667 AC_SUBST(u_short_decl)
668 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
669 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
670 [vi_cv_ushort=yes], [vi_cv_ushort=no])])
671 if test "$vi_cv_ushort" = no; then
672 u_short_decl="typedef unsigned short u_short;"
676 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
677 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
678 [vi_cv_uint=yes], [vi_cv_uint=no])])
679 if test "$vi_cv_uint" = no; then
680 u_int_decl="typedef unsigned int u_int;"
683 AC_SUBST(u_long_decl)
684 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
685 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
686 [vi_cv_ulong=yes], [vi_cv_ulong=no])])
687 if test "$vi_cv_ulong" = no; then
688 u_long_decl="typedef unsigned long u_long;"
691 dnl DB/Vi use specific integer sizes.
692 AC_SUBST(u_int8_decl)
693 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
694 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
696 AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
697 [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
698 if test "$vi_cv_uint8" = no; then
699 AC_MSG_ERROR(No unsigned 8-bit integral type.)
701 if test "$vi_cv_uint8" != yes; then
702 u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
705 AC_SUBST(u_int16_decl)
706 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
707 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
709 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
710 [vi_cv_uint16="unsigned short"],
711 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
712 [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
713 if test "$vi_cv_uint16" = no; then
714 AC_MSG_ERROR([No unsigned 16-bit integral type.])
716 if test "$vi_cv_uint16" != yes; then
717 u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
721 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
722 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
724 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
725 [vi_cv_int16="short"],
726 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
727 [vi_cv_int16="int"], [vi_cv_int16=no])))])
728 if test "$vi_cv_int16" = no; then
729 AC_MSG_ERROR([No signed 16-bit integral type.])
731 if test "$vi_cv_int16" != yes; then
732 int16_decl="typedef $vi_cv_int16 int16_t;"
735 AC_SUBST(u_int32_decl)
736 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
737 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
739 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
740 [vi_cv_uint32="unsigned int"],
741 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
742 [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
743 if test "$vi_cv_uint32" = no; then
744 AC_MSG_ERROR([No unsigned 32-bit integral type.])
746 if test "$vi_cv_uint32" != yes; then
747 u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
751 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
752 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
754 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
756 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
757 [vi_cv_int32="long"], [vi_cv_int32=no])))])
758 if test "$vi_cv_int32" = no; then
759 AC_MSG_ERROR([No signed 32-bit integral type.])
761 if test "$vi_cv_int32" != yes; then
762 int32_decl="typedef $vi_cv_int32 int32_t;"
765 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
766 [AC_TRY_COMPILE([#include <stdio.h>
768 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
770 AC_SUBST(NEED_FPRINTF_PROTO)
771 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
772 [AC_TRY_COMPILE([ #include <stdio.h>
773 typedef int (*funcPtr)();
774 ],[funcPtr ptr = (funcPtr) fprintf;],
775 vi_cv_proto_fprintf=no,
776 [vi_cv_proto_fprintf=yes, AC_DEFINE(NEED_FPRINTF_PROTO)])])
781 [ --with-db3=db3prefix Path to db3 installation. ])
782 if test "$with_db3" = "no"; then
783 AC_MSG_ERROR([Need DB 3.])
786 saveLDFLAGS="$LDFLAGS"
787 if test "x$with_db3" != "x"; then
788 LDFLAGS="-L$with_db3/lib $LDFLAGS"
789 CFLAGS="-I$with_db3/include $CFLAGS"
792 AC_CHECK_LIB(db, db_create,
793 [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
794 if test "$vi_cv_dbfatal" = "yes"; then
795 AC_MSG_ERROR([Need DB 3.])
798 LDFLAGS="$saveLDFLAGS"
801 AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
802 AC_ARG_ENABLE(dynamic-loading,
803 [ --enable-dynamic-loading Load DB 3 dynamically.],
804 [vi_cv_dl="yes"], [vi_cv_dl="no"])
805 AC_MSG_RESULT($vi_cv_dl)
806 if test "$vi_cv_dl" = yes; then
807 AC_CHECK_LIB(dl, dlopen,
808 [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
809 if test "$vi_cv_dlfatal" = "yes"; then
810 AC_MSG_ERROR([Need dl to support dynamic loading.])
814 PATH="$with_db3/lib:/usr/lib:/lib"
815 AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
816 if test "$vi_cv_path_db3" = no; then
817 AC_MSG_ERROR([Path of libdb-3.so not found.])
821 AC_DEFINE(USE_DYNAMIC_LOADING)
822 LTLIBOBJS="dldb.lo $LTLIBOBJS"
823 dl_src=../common/dldb.c
827 LDFLAGS="-L$with_db3/lib $LDFLAGS"
831 dnl We compile in nvi's RE routines unless the user specifies otherwise.
832 AC_MSG_CHECKING(if --disable-re option specified)
834 [ --disable-re DON'T use the nvi-provided RE routines.],
835 [vi_cv_re_lib="other RE"], [vi_cv_re_lib="bundled RE"])
836 AC_MSG_RESULT($vi_cv_re_lib)
837 case "$vi_cv_re_lib" in
839 CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
840 LTLIBOBJS="\$(REOBJS) $LTLIBOBJS";;
845 AC_OUTPUT(Makefile port.h:port.h.in
846 pathnames.h:pathnames.h.in recover:recover.in)