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)
217 LIBOBJS="wcwidth.o $LIBOBJS"
219 AC_MSG_RESULT($vi_cv_widechar)
221 dnl If the user wants a Gtk IPC front-end for nvi, build it.
226 AC_MSG_CHECKING(if --enable-gtk option specified)
228 [ --enable-gtk Build a Gtk front-end for vi.],
229 [vi_cv_gtk="yes"], [vi_cv_gtk="no"])
230 AC_MSG_RESULT($vi_cv_gtk)
231 if test "$vi_cv_gtk" = "yes"; then
235 GTKINCS="$GTK_CFLAGS"
236 GTKLIBS="$GTK_LIBS $LIBS"
238 AM_PATH_GDK_PIXBUF(0.4.0, pixbuf=yes, pixbuf=no)
239 if test "$pixbuf" != "no"; then
240 LIBS="-lutil $GDK_PIXBUF_LIBS $GTKLIBS"
241 AC_CHECK_LIB(nvizvt, zvt_get_ptys,
242 [vi_cv_zvt="yes"], [vi_cv_zvt="no"])
243 if test "$vi_cv_zvt" = "yes"; then
244 GTKLIBS="-lnvizvt $LIBS"
249 AC_PATH_PROG(vi_cv_pango_config, pango-config, no)
250 if test "$vi_cv_pango_config" != "no"; then
251 PANGOLIBS=`$vi_cv_pango_config --libs pangox`
252 GTKLIBS="$PANGOLIBS $GTKLIBS"
253 AC_DEFINE(HAVE_PANGO)
255 # AC_PATH_PROG(vi_cv_gnome_config, gnome-config, no)
256 # if test "$vi_cv_gnome_config" != "no"; then
257 # ZVTLIBS=`$vi_cv_gnome_config zvt --libs`
258 # GTKLIBS="$ZVTLIBS $GTKLIBS"
262 dnl If the user wants a Motif IPC front-end for nvi, build it.
265 AC_MSG_CHECKING(if --enable-motif option specified)
267 [ --enable-motif Build a Motif front-end for vi.],
268 [vi_cv_motif="yes"], [vi_cv_motif="no"])
269 AC_MSG_RESULT($vi_cv_motif)
270 if test "$vi_cv_motif" = "yes"; then
275 dnl BSDI's Motif libraries aren't shared.
282 dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
283 dnl -lXext is generally available, the others aren't.
286 dnl Color icons require -lXpm, which may or may not be available,
287 dnl depending on the version of X11.
289 MOTIFLIBS="-lXm -lXt"
290 AC_CHECK_LIB(SM, main,
291 [vi_cv_smlib="yes"], [vi_cv_smlib="no"], "$XLIBS")
292 if test "$vi_cv_smlib" = "yes"; then
293 MOTIFLIBS="$MOTIFLIBS -lSM"
295 AC_CHECK_LIB(ICE, main,
296 [vi_cv_icelib="yes"], [vi_cv_icelib="no"], "$XLIBS")
297 if test "$vi_cv_icelib" = "yes"; then
298 MOTIFLIBS="$MOTIFLIBS -lICE"
300 AC_CHECK_LIB(Xext, main,
301 [vi_cv_xextlib="yes"], [vi_cv_xextlib="no"], "$XLIBS")
302 if test "$vi_cv_xextlib" = "yes"; then
303 MOTIFLIBS="$MOTIFLIBS -lXext"
305 AC_CHECK_LIB(Xpm, main,
306 [vi_cv_xpmlib="yes"], [vi_cv_xpmlib="no"], "$XLIBS")
307 if test "$vi_cv_xpmlib" = "yes"; then
308 MOTIFLIBS="$MOTIFLIBS -lXpm"
310 MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
314 dnl Check for threads
315 AC_MSG_CHECKING(if --enable-threads option specified)
316 AC_ARG_ENABLE(threads,
317 [ --enable-threads Turn on thread support.],
318 [vi_cv_threads="yes"], [vi_cv_threads="no"])
319 AC_MSG_RESULT($vi_cv_threads)
320 if test "$vi_cv_threads" = "yes"; then
321 LIBS="$LIBS -pthread"
322 AC_CACHE_VAL(vi_cv_have_pthreads, [dnl
323 AC_TRY_LINK([#include <pthread.h>],
325 [vi_cv_have_pthreads=yes],
326 [vi_cv_have_pthreads=no])])
327 if test "$vi_cv_have_pthreads" = "no"; then
328 AC_MSG_ERROR(No threading library found)
330 IPCOBJS="pthread.o $IPCOBJS"
331 AC_DEFINE(HAVE_PTHREAD)
333 IPCOBJS="nothread.o $IPCOBJS"
336 dnl If the user wants a Perl interpreter in nvi, load it.
338 AC_SUBST(perlldflags)
340 AC_SUBST(vi_cv_perllib)
342 AC_MSG_CHECKING(if --enable-perlinterp option specified)
343 AC_ARG_ENABLE(perlinterp,
344 [ --enable-perlinterp Include a Perl interpreter in vi.],
345 [vi_cv_perlinterp="yes"], [vi_cv_perlinterp="no"])
346 AC_MSG_RESULT($vi_cv_perlinterp)
347 if test "$vi_cv_perlinterp" = "yes"; then
348 if test "$vi_cv_path_perl" = no; then
349 AC_MSG_ERROR([No perl5 utility found.])
351 $vi_cv_path_perl -e 'require 5.004' || {
352 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
354 if test "$vi_cv_threads" = "yes"; then
355 useithreads=`$vi_cv_path_perl -MConfig -e 'print $Config{useithreads}'`
356 if test "X$useithreads" != "Xdefine"; then
357 AC_MSG_ERROR([vi threading only compatible with perl's ithreads.])
361 eval `$vi_cv_path_perl -V:shrpenv`
362 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
363 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
364 -e 'ccflags;perl_inc'`
365 if test "X$perlcppflags" != "X"; then
366 CPPFLAGS="$perlcppflags $CPPFLAGS"
368 perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
370 perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
372 LTLIBOBJS="perl.lo perlxsi.lo perlsfio.lo $LTLIBOBJS"
373 AC_DEFINE(HAVE_PERL_INTERP)
376 dnl If the user wants a Tk/Tcl interpreter in nvi, load it. Make sure that
377 dnl we can find a Tk/Tcl library.
378 AC_MSG_CHECKING(if --enable-tclinterp option specified)
379 AC_ARG_ENABLE(tclinterp,
380 [ --enable-tclinterp Include a Tk/Tcl interpreter in vi.],
381 [vi_cv_tclinterp="yes"], [vi_cv_tclinterp="no"])
382 AC_MSG_RESULT($vi_cv_tclinterp)
383 if test "$vi_cv_tclinterp" = "yes"; then
384 LIBOBJS="tcl.o $LIBOBJS"
385 LIBS="-ltk -ltcl -lm $XLIBS $LIBS"
386 AC_DEFINE(HAVE_TCL_INTERP)
388 AC_CHECK_LIB(tcl, main,
389 [vi_cv_tkfatal="no"], [vi_cv_tkfatal="yes"], -ltk -lm)
390 if test "$vi_cv_tkfatal" = "yes"; then
391 AC_MSG_WARN([No Tk/Tcl library found;])
392 AC_MSG_ERROR([ see the section ADDING LIBRARIES AND INCLUDE FILES in the README file.])
396 dnl Check for the termcap/termlib library. Compile in nvi's curses routines
397 dnl unless the user specifies otherwise. These two checks must occur in the
398 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
399 AC_CHECK_LIB(termlib, tgetent,
400 [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
401 if test "$vi_cv_termlib" = no; then
402 AC_CHECK_LIB(termcap, tgetent,
403 [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
405 if test "$vi_cv_termlib" != no; then
406 LIBS="$vi_cv_termlib $LIBS"
413 dnl AC_ARG_WITH(slang,
414 dnl [ --with-slang[=DIR] Use S-Lang instead of curses. ],
416 dnl if test "$withval" != yes; then
417 dnl LDFLAGS="-L${withval}/lib $LDFLAGS"
418 dnl CPPFLAGS="-I${withval}/include $CPPFLAGS"
420 dnl AC_DEFINE(USE_SLANG_CURSES)
421 dnl AC_CHECK_LIB(slang, SLtt_get_terminfo,
422 dnl [CURSLIBS="$CURSLIBS -lslang -lm"],
423 dnl [AC_MSG_ERROR(unable to compile. check config.log)], -lm)
430 [ --with-curses=DIR Path to curses installation. ])
431 if test "x$with_curses" != "x"; then
432 LDFLAGS="-L$with_curses/lib $LDFLAGS"
433 CPPFLAGS="-I$with_curses/include $CPPFLAGS"
434 if test -f "$with_curses/include/ncurses.h"; then
435 AC_CHECK_HEADERS(ncurses.h)
441 AC_CHECK_LIB($CURSLIB, initscr,
442 [vi_cv_cursesfatal="no"], [vi_cv_cursesfatal="yes"])
443 if test "$vi_cv_cursesfatal" = "yes"; then
444 AC_MSG_ERROR([Need curses.])
446 CURSLIBS="-l$CURSLIB"
449 dnl Checks for header files.
450 AC_MSG_CHECKING(for sys/mman.h)
451 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
452 AC_TRY_CPP([#include <sys/mman.h>],
453 [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
454 if test "$vi_cv_include_sys_mman" = yes; then
455 AC_DEFINE(HAVE_SYS_MMAN_H)
457 AC_MSG_RESULT($vi_cv_include_sys_mman)
459 AC_MSG_CHECKING(for sys/select.h)
460 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
461 AC_TRY_CPP([#include <sys/select.h>],
462 [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
463 if test "$vi_cv_include_sys_select" = yes; then
464 AC_DEFINE(HAVE_SYS_SELECT_H)
466 AC_MSG_RESULT($vi_cv_include_sys_select)
468 dnl Checks for typedefs, structures, and compiler characteristics.
469 AC_CHECK_TYPE(ssize_t, int)
479 dnl Checks for library functions.
480 AC_CHECK_FUNCS(bsearch gethostname memchr memset)
481 AC_REPLACE_FUNCS(bsearch gethostname memchr memset)
482 AC_CHECK_FUNCS(mkstemp mmap strdup strpbrk)
483 AC_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
484 AC_CHECK_FUNCS(vsnprintf)
485 AC_REPLACE_FUNCS(vsnprintf)
487 AC_CHECK_FUNCS(select)
488 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
489 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
490 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
495 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
496 if test "$need_env" = yes; then
497 LIBOBJS="env.o $LIBOBJS"
500 dnl If we need strsep, add it and define it so we get a prototype.
501 if test "$need_strsep" = yes; then
502 LIBOBJS="strsep.o $LIBOBJS"
505 dnl XXX not sure whether this is a good idea
506 LTLIBOBJS="`echo $LIBOBJS | sed 's/\.o/.lo/g'` $LTLIBOBJS"
508 dnl Check for fcntl/flock
509 dnl Use flock preferentially, since it has cleaner semantics and won't
510 dnl hang up the editor.
512 dnl Ultrix has a broken fcntl, but a working flock.
513 dnl IRIX and DGUX have a broken flock, but working fcntl.
514 AC_MSG_CHECKING(for fcntl/flock)
515 AC_CACHE_VAL(vi_cv_lock, [dnl
521 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
522 [vi_cv_lock=flock]);;
524 if test "$vi_cv_lock" = none; then
525 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
529 if test "$vi_cv_lock" = flock; then
530 AC_DEFINE(HAVE_LOCK_FLOCK)
532 if test "$vi_cv_lock" = fcntl; then
533 AC_DEFINE(HAVE_LOCK_FCNTL)
535 AC_MSG_RESULT($vi_cv_lock)
537 dnl Check for ftruncate/chsize
538 AC_MSG_CHECKING(for ftruncate/chsize)
539 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
540 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
541 [vi_cv_ftruncate=ftruncate],
542 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
543 [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
544 if test "$vi_cv_ftruncate" = ftruncate; then
545 AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
547 if test "$vi_cv_ftruncate" = chsize; then
548 AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
550 if test "$vi_cv_ftruncate" = no; then
551 AC_MSG_ERROR([No file truncation system call.])
553 AC_MSG_RESULT($vi_cv_ftruncate)
555 dnl Check for the tigetstr/tigetnum functions.
556 AC_MSG_CHECKING(for tigetstr/tigetnum)
557 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
558 AC_TRY_LINK([#include <$CURSLIB.h>], [tigetstr(0);],
559 [vi_cv_have_curses_tigetstr=yes],
560 [vi_cv_have_curses_tigetstr=no])])
561 if test "$vi_cv_have_curses_tigetstr" = yes; then
562 AC_DEFINE(HAVE_CURSES_TIGETSTR)
564 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
566 dnl Check for potentially missing curses functions in system or user-specified
567 dnl libraries. We also have to guess at whether the specified library is a
568 dnl BSD or System V style curses. Use the newterm function, all System V
569 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
570 if test "$vi_cv_curses" = "bundled curses"; then
571 AC_DEFINE(HAVE_BSD_CURSES)
572 AC_DEFINE(HAVE_CURSES_WADDNSTR)
573 AC_DEFINE(HAVE_CURSES_IDLOK)
575 dnl Check for the waddnstr function.
576 AC_MSG_CHECKING(for waddnstr)
577 AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
578 AC_TRY_LINK([#include <$CURSLIB.h>], [waddnstr(stdscr, 0, 0);],
579 [vi_cv_have_curses_waddnstr=yes],
580 [vi_cv_have_curses_waddnstr=no])])
581 if test "$vi_cv_have_curses_waddnstr" = yes; then
582 AC_DEFINE(HAVE_CURSES_WADDNSTR)
584 AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
586 dnl Check for the beep function.
587 AC_MSG_CHECKING(for beep)
588 AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
589 AC_TRY_LINK([#include <$CURSLIB.h>], [beep();],
590 [vi_cv_have_curses_beep=yes],
591 [vi_cv_have_curses_beep=no])])
592 if test "$vi_cv_have_curses_beep" = yes; then
593 AC_DEFINE(HAVE_CURSES_BEEP)
595 AC_MSG_RESULT($vi_cv_have_curses_beep)
597 dnl Check for the flash function.
598 AC_MSG_CHECKING(for flash)
599 AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
600 AC_TRY_LINK([#include <$CURSLIB.h>], [flash();],
601 [vi_cv_have_curses_flash=yes],
602 [vi_cv_have_curses_flash=no])])
603 if test "$vi_cv_have_curses_flash" = yes; then
604 AC_DEFINE(HAVE_CURSES_FLASH)
606 AC_MSG_RESULT($vi_cv_have_curses_flash)
608 dnl Check for the idlok function.
609 AC_MSG_CHECKING(for idlok)
610 AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
611 AC_TRY_LINK([#include <$CURSLIB.h>], [idlok(0, 0);],
612 [vi_cv_have_curses_idlok=yes],
613 [vi_cv_have_curses_idlok=no])])
614 if test "$vi_cv_have_curses_idlok" = yes; then
615 AC_DEFINE(HAVE_CURSES_IDLOK)
617 AC_MSG_RESULT($vi_cv_have_curses_idlok)
619 dnl Check for the keypad function.
620 AC_MSG_CHECKING(for keypad)
621 AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
622 AC_TRY_LINK([#include <$CURSLIB.h>], [keypad(0, 0);],
623 [vi_cv_have_curses_keypad=yes],
624 [vi_cv_have_curses_keypad=no])])
625 if test "$vi_cv_have_curses_keypad" = yes; then
626 AC_DEFINE(HAVE_CURSES_KEYPAD)
628 AC_MSG_RESULT($vi_cv_have_curses_keypad)
630 dnl Check for the newterm function.
631 AC_MSG_CHECKING(for newterm)
632 AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
633 AC_TRY_LINK([#include <$CURSLIB.h>], [newterm(0, 0, 0);],
634 [vi_cv_have_curses_newterm=yes],
635 [vi_cv_have_curses_newterm=no])])
636 if test "$vi_cv_have_curses_newterm" = yes; then
637 AC_DEFINE(HAVE_CURSES_NEWTERM)
639 AC_MSG_RESULT($vi_cv_have_curses_newterm)
641 if test "$vi_cv_have_curses_newterm" = no; then
642 AC_DEFINE(HAVE_BSD_CURSES)
646 dnl Check for the setupterm function. We make this check regardless of
647 dnl using the system library, because it may be part of the underlying
648 dnl termcap/termlib support, and we want to use the local one.
649 AC_MSG_CHECKING(for setupterm)
650 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
651 AC_TRY_LINK([#include <$CURSLIB.h>], [setupterm(0, 0, 0);],
652 [vi_cv_have_curses_setupterm=yes],
653 [vi_cv_have_curses_setupterm=no])])
654 if test "$vi_cv_have_curses_setupterm" = yes; then
655 AC_DEFINE(HAVE_CURSES_SETUPTERM)
657 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
659 dnl Some moron decided to drop off an argument from the gettimeofday call,
660 dnl without changing the name.
661 AC_MSG_CHECKING(for broken gettimeofday system call)
662 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
663 AC_TRY_LINK([#include <sys/types.h>
664 #include <sys/time.h>], [gettimeofday(0, 0);],
665 [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
666 if test "$vi_cv_gettimeofday" = broken; then
667 AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
669 AC_MSG_RESULT($vi_cv_gettimeofday)
671 dnl Check for which version of openpty to use, System V or Berkeley.
672 AC_MSG_CHECKING(for System V pty calls)
673 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
674 AC_TRY_LINK(, [grantpt(0);],
675 [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
676 if test "$vi_cv_sys5_pty" = yes; then
677 AC_DEFINE(HAVE_SYS5_PTY)
679 AC_MSG_RESULT($vi_cv_sys5_pty)
681 dnl Check for the revoke system call.
682 AC_MSG_CHECKING(for revoke system call)
683 AC_CACHE_VAL(vi_cv_revoke, [dnl
684 AC_TRY_LINK(, [revoke("a");],
685 [vi_cv_revoke=yes], [vi_cv_revoke=no])])
686 if test "$vi_cv_revoke" = yes; then
687 AC_DEFINE(HAVE_REVOKE)
689 AC_MSG_RESULT($vi_cv_revoke)
691 dnl Some versions of sprintf return a pointer to the first argument instead
692 dnl of a character count. We assume that the return value of snprintf and
693 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
694 AC_MSG_CHECKING(for int type sprintf return value)
695 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
696 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
697 [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
698 if test "$vi_cv_sprintf_count" = no; then
699 AC_DEFINE(SPRINTF_RET_CHARPNT)
701 AC_MSG_RESULT($vi_cv_sprintf_count)
704 dnl Check for the standard shorthand types.
705 AC_SUBST(u_char_decl)
706 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
707 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
708 [vi_cv_uchar=yes], [vi_cv_uchar=no])])
709 if test "$vi_cv_uchar" = no; then
710 u_char_decl="typedef unsigned char u_char;"
713 AC_SUBST(u_short_decl)
714 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
715 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
716 [vi_cv_ushort=yes], [vi_cv_ushort=no])])
717 if test "$vi_cv_ushort" = no; then
718 u_short_decl="typedef unsigned short u_short;"
722 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
723 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
724 [vi_cv_uint=yes], [vi_cv_uint=no])])
725 if test "$vi_cv_uint" = no; then
726 u_int_decl="typedef unsigned int u_int;"
729 AC_SUBST(u_long_decl)
730 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
731 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
732 [vi_cv_ulong=yes], [vi_cv_ulong=no])])
733 if test "$vi_cv_ulong" = no; then
734 u_long_decl="typedef unsigned long u_long;"
737 dnl DB/Vi use specific integer sizes.
738 AC_SUBST(u_int8_decl)
739 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
740 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
742 AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
743 [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
744 if test "$vi_cv_uint8" = no; then
745 AC_MSG_ERROR(No unsigned 8-bit integral type.)
747 if test "$vi_cv_uint8" != yes; then
748 u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
751 AC_SUBST(u_int16_decl)
752 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
753 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
755 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
756 [vi_cv_uint16="unsigned short"],
757 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
758 [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
759 if test "$vi_cv_uint16" = no; then
760 AC_MSG_ERROR([No unsigned 16-bit integral type.])
762 if test "$vi_cv_uint16" != yes; then
763 u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
767 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
768 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
770 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
771 [vi_cv_int16="short"],
772 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
773 [vi_cv_int16="int"], [vi_cv_int16=no])))])
774 if test "$vi_cv_int16" = no; then
775 AC_MSG_ERROR([No signed 16-bit integral type.])
777 if test "$vi_cv_int16" != yes; then
778 int16_decl="typedef $vi_cv_int16 int16_t;"
781 AC_SUBST(u_int32_decl)
782 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
783 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
785 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
786 [vi_cv_uint32="unsigned int"],
787 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
788 [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
789 if test "$vi_cv_uint32" = no; then
790 AC_MSG_ERROR([No unsigned 32-bit integral type.])
792 if test "$vi_cv_uint32" != yes; then
793 u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
797 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
798 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
800 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
802 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
803 [vi_cv_int32="long"], [vi_cv_int32=no])))])
804 if test "$vi_cv_int32" = no; then
805 AC_MSG_ERROR([No signed 32-bit integral type.])
807 if test "$vi_cv_int32" != yes; then
808 int32_decl="typedef $vi_cv_int32 int32_t;"
811 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
812 [AC_TRY_COMPILE([#include <stdio.h>
814 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
816 AC_SUBST(NEED_FPRINTF_PROTO)
817 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
818 [AC_TRY_COMPILE([ #include <stdio.h>
819 typedef int (*funcPtr)();
820 ],[funcPtr ptr = (funcPtr) fprintf;],
821 vi_cv_proto_fprintf=no,
822 [vi_cv_proto_fprintf=yes, AC_DEFINE(NEED_FPRINTF_PROTO)])])
827 [ --with-db3=db3prefix Path to db3 installation. ])
828 if test "$with_db3" = "no"; then
829 AC_MSG_ERROR([Need DB 3.])
832 saveLDFLAGS="$LDFLAGS"
833 if test "x$with_db3" != "x"; then
834 LDFLAGS="-L$with_db3/lib $LDFLAGS"
835 CFLAGS="-I$with_db3/include $CFLAGS"
838 AC_CHECK_LIB(db, db_create,
839 [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
840 if test "$vi_cv_dbfatal" = "yes"; then
841 AC_MSG_ERROR([Need DB 3.])
844 LDFLAGS="$saveLDFLAGS"
847 AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
848 AC_ARG_ENABLE(dynamic-loading,
849 [ --enable-dynamic-loading Load DB 3 dynamically.],
850 [vi_cv_dl="yes"], [vi_cv_dl="no"])
851 AC_MSG_RESULT($vi_cv_dl)
852 if test "$vi_cv_dl" = yes; then
853 AC_CHECK_LIB(dl, dlopen,
854 [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
855 if test "$vi_cv_dlfatal" = "yes"; then
856 AC_MSG_ERROR([Need dl to support dynamic loading.])
860 PATH="$with_db3/lib:/usr/lib:/lib"
861 AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
862 if test "$vi_cv_path_db3" = no; then
863 AC_MSG_ERROR([Path of libdb-3.so not found.])
867 AC_DEFINE(USE_DYNAMIC_LOADING)
868 LTLIBOBJS="dldb.lo $LTLIBOBJS"
869 dl_src=../common/dldb.c
873 LDFLAGS="-L$with_db3/lib $LDFLAGS"
877 dnl We compile in nvi's RE routines unless the user specifies otherwise.
878 AC_MSG_CHECKING(if --disable-re option specified)
880 [ --disable-re DON'T use the nvi-provided RE routines.],
881 [vi_cv_re_lib="other RE"], [vi_cv_re_lib="bundled RE"])
882 AC_MSG_RESULT($vi_cv_re_lib)
883 case "$vi_cv_re_lib" in
885 CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
886 LTLIBOBJS="\$(REOBJS) $LTLIBOBJS";;
891 AC_OUTPUT(Makefile port.h:port.h.in
892 pathnames.h:pathnames.h.in recover:recover.in)