nvi 1.81.6
[nvi.git] / dist / configure.in
blob8b262e79e6cc9c34e03a265f8a3ff99ccaaaafa6
1 dnl     $Id: configure.in,v 8.192 2003/02/17 20:09:07 skimo Exp $
2 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT(../common/main.c)
5 AC_CONFIG_AUX_DIR(.)
6 AM_INIT_AUTOMAKE(vi, 1.81.6)
7 AM_CONFIG_HEADER(config.h)
9 dnl Configure setup.
10 AC_PROG_INSTALL()
11 AC_CANONICAL_HOST
12 dnl part of AM_INIT_AUTOMAKE ?
13 dnl AC_ARG_PROGRAM()
15 AC_PROG_LIBTOOL
17 dnl If the user wants a debugging environment, set OPTFLAG now, some
18 dnl compilers won't mix optimizing and debug flags.)
19 AC_MSG_CHECKING(if --enable-debug option specified)
20 AC_ARG_ENABLE(debug,
21         [  --enable-debug          Build a debugging version.],
22         [vi_cv_debug=$enableval], [vi_cv_debug="no"])
23 AC_MSG_RESULT($vi_cv_debug)
24 if test "$vi_cv_debug" = yes; then
25         AC_DEFINE(DEBUG)
26         OPTFLAG=${OPTFLAG-"-g"}
27         no_op_OPTFLAG=${no_op_OPTFLAG-"-g"}
30 dnl This is where we handle stuff that autoconf can't handle.
31 dnl XXX
32 dnl Don't override anything if it's already set from the environment.
34 dnl Compiler, preprocessor and load flags.
35 dnl AUX:        -ZP disables _BSD_SOURCE et al, but enables POSIX at link time.
36 dnl LynxOS:     We check for gcc 2.x or better, the gcc 1 that was shipped with
37 dnl             LynxOS historically wasn't good enough.
38 AC_SUBST(CPPFLAGS)
39 case "$host_os" in
40 aix3.2.5)  OPTFLAG=${OPTFLAG-"-O"};;
41 aix4.1*)   CFLAGS=${CFLAGS-"-qstrict"}
42            OPTFLAG=${OPTFLAG-"-O3"};;
43 aux*)      CPPFLAGS=${CPPFLAGS-"-ZP -D_BSD_SOURCE -D_SYSV_SOURCE -D_AUX_SOURCE"}
44            LDFLAGS=${LDFLAGS-"-ZP"}
45            OPTFLAG=${OPTFLAG-"-O"};;
46 bsd4.4)    OPTFLAG=${OPTFLAG-"-O2"};;
47 bsdi*)     CC=${CC-"shlicc"}
48            OPTFLAG=${OPTFLAG-"-O2"};;
49 irix6*)    OPTFLAG=${OPTFLAG-"-O2"};;
50 irix*)     OPTFLAG=${OPTFLAG-"-O2"};;
51 lynxos*)   AC_PROG_CC()
52            AC_MSG_CHECKING([for GNU C (gcc) version 2.x])
53            ac_cv_gcc_vers=`${CC-cc} -v 2>&1 | \
54                 grep "gcc version " | sed 's/.*version //'`
55            ac_cv_gcc_major=`echo "$ac_cv_gcc_vers" | sed 's/\..*//'`
56            if test "$ac_cv_gcc_major" = "2" ; then
57                 AC_MSG_RESULT(yes)
58            else
59                 AC_MSG_RESULT(no)
60                 AC_MSG_WARN([Nvi requires gcc 2.x to build on LynxOS.])
61                 AC_MSG_ERROR([See build/README.LynxOS for more information.])
62            fi;;
63 nextstep3) CPPFLAGS=${CPPFLAGS-"-w -pipe -posix"}
64            LDFLAGS=${LDFLAGS-"-posix"}
65            OPTFLAG=${OPTFLAG-"-O2"};;
66 osf*)      CFLAGS=${CFLAGS-"-Olimit 1000"};;
67 solaris*)  no_op_OPTFLAG=${no_op_OPTFLAG-""};;
68 sunos*)    no_op_OPTFLAG=${no_op_OPTFLAG-""};;
69 esac
71 dnl The default OPTFLAG is -O
72 AC_SUBST(OPTFLAG)
73 OPTFLAG=${OPTFLAG-"-O"}
75 dnl The default compiler is cc (NOT gcc), the default CFLAGS is empty,
76 dnl NOT whatever AC_PROG_CC sets.
77 AC_SUBST(CC)
78 CC=${CC-cc}
79 CFLAGS=${CFLAGS-""}
80 AC_PROG_CC
82 if test "$GCC" = yes; then
83         AC_DEFINE(HAVE_GCC)
86 dnl The SunOS/Solaris compiler can't optimize vi/v_txt.c; the symptom is
87 dnl that the command 35i==<esc> turns into an infinite loop.
88 AC_SUBST(no_op_OPTFLAG)
89 no_op_OPTFLAG=${no_op_OPTFLAG-"$OPTFLAG"}
91 dnl Libraries.
92 case "$host_os" in
93 bsdi2.1)   LIBS=${LIBS-"-lipc"};;
94 dgux*)     LIBS=${LIBS-"-ldgc"};;
95 irix6*)    LIBS=${LIBS-"-lbsd"};;
96 irix*)     LIBS=${LIBS-"-lc_s -lbsd"};;
97 isc*)      LIBS=${LIBS-"-lcposix -linet"};;
98 netbsd1*)  LIBS=${LIBS-"-lcrypt"};;
99 ptx*)      LIBS=${LIBS-"-lseq -linet -lsocket"};;
100 sco3.2*)   LIBS=${LIBS-"-lsocket"};;
101 sinix*)    LIBS=${LIBS-"-lelf -lc"};;
102 solaris*)  LIBS=${LIBS-"-lsocket -lnsl -ldl"};;
103 wgs*)      LIBS=${LIBS-"-lnsl"};;
104 esac
106 dnl A/UX has a broken getopt(3), strpbrk(3).
107 case "$host_os" in
108 aux*)      LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
109 esac
111 dnl Ultrix has a broken POSIX.1 VDISABLE value.
112 case "$host_os" in
113 ultrix*)   AC_DEFINE(HAVE_BROKEN_VDISABLE);;
114 esac
116 AC_MSG_CHECKING(whether recording of pathnames of libraries is enabled)
117 AC_ARG_ENABLE(runpath,
118         [  --disable-runpath       Don't record path of libraries in binary.],
119         [vi_cv_runpath="$enableval"], [vi_cv_runpath="yes"])
120 AC_MSG_RESULT($vi_cv_runpath)
122 if test "X$vi_cv_runpath" = "Xyes"; then
123         LRscript='s/^\(.*\)/-R\1 -L\1 /'
124 else
125         LRscript='s/^\(.*\)/-L\1 /'
128 dnl If the user wants a tracing version, add the TRACE compile flag.
129 AC_MSG_CHECKING(if --enable-trace option specified)
130 AC_ARG_ENABLE(trace,
131         [  --enable-trace          Build a tracing version.],
132         [vi_cv_trace="yes"], [vi_cv_trace="no"])
133 if test "$vi_cv_trace" = yes; then
134         CPPFLAGS="-DTRACE $CPPFLAGS"
136 AC_MSG_RESULT($vi_cv_trace)
138 dnl The user may have additional CPP information.
139 CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"
141 dnl The user may have additional load line information.
142 LDFLAGS="$ADDLDFLAGS $LDFLAGS"
144 dnl The user may have additional library information.
145 LIBS="$ADDLIBS $LIBS"
147 dnl Checks for programs.
148 PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib"
150 dnl Check for the shell path.
151 AC_PATH_PROG(vi_cv_path_shell, sh, no)
152 if test "$vi_cv_path_shell" = no; then
153         AC_MSG_ERROR([No shell utility found.])
156 dnl Check for the sendmail path.
157 AC_PATH_PROG(vi_cv_path_sendmail, sendmail, no)
158 if test "$vi_cv_path_sendmail" = no; then
159         AC_MSG_WARN([No sendmail utility found;])
160         AC_MSG_WARN([    users will not be told of saved files.])
163 dnl Check for the perl5/perl path.
164 AC_SUBST(vi_cv_path_perl)
165 AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)
167 dnl Check for the "preserve" path.
168 dnl Historically, nvi has used /var/tmp/vi.recover.  The Linux filesystem
169 dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
170 dnl beneath it so that we don't have name collisions with other editors.
171 dnl Other systems have /var/preserve as well, so we test first for an already
172 dnl existing name, and then use the first one that's writeable.
173 AC_SUBST(vi_cv_path_preserve)
174 AC_MSG_CHECKING(for preserve directory)
175 AC_CACHE_VAL(vi_cv_path_preserve, [dnl
176         dirlist="/var/preserve /var/tmp /usr/tmp"
177         vi_cv_path_preserve=no
178         for i in $dirlist; do
179                 if test -d $i/vi.recover; then
180                         vi_cv_path_preserve=$i/vi.recover
181                         break;
182                 fi
183         done
184         if test "$vi_cv_path_preserve" = no; then
185                 for i in $dirlist; do
186                         if test -d $i -a -w $i; then
187                                 vi_cv_path_preserve=$i/vi.recover
188                                 break;
189                         fi
190                 done
192         fi])
193 if test "$vi_cv_path_preserve" = no; then
194         AC_MSG_ERROR([No writeable preserve directory found.])
196 AC_MSG_RESULT($vi_cv_path_preserve)
197 AC_PATH_PROG(vi_cv_path_fuser, fuser, no)
198 AC_PATH_PROG(vi_cv_path_lsof, lsof, no)
199 AC_SUBST(INUSE)
200 INUSE=""
201 if test "$vi_cv_path_lsof" != no; then
202         INUSE='test `lsof -t $i`'
204 if test "$vi_cv_path_fuser" != no; then
205         INUSE='fuser -s $i'
208 dnl Check for programs used for installation
209 AC_PROG_AWK
210 AC_PATH_PROG(vi_cv_path_ar, ar, missing_ar)
211 AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
212 AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
213 AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
214 AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
215 AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
216 AC_PATH_PROG(vi_cv_path_ranlib, ranlib, missing_ranlib)
217 AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
219 dnl Checks for libraries.
220 dnl Find the X libraries and includes.
221 AC_PATH_X
222 AC_SUBST(XINCS)
223 if test "$no_x" != yes; then
224         if test "X$x_libraries" != "X"; then
225                 XLIBS="`echo $x_libraries | sed "$LRscript"` $XLIBS"
226         fi
227         XLIBS="$XLIBS -lX11"
228         if test "X$x_includes" != "X"; then
229                 XINCS="-I$x_includes"
230         fi
233 AC_DEFUN([VI_CV_REPLACE_FUNCS],
234 [AC_FOREACH([AC_Func], [$1], [])dnl
235 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
238 dnl Check if the user wants widechar support.
239 AC_MSG_CHECKING(if --enable-widechar option specified)
240 AC_ARG_ENABLE(widechar,
241         [  --enable-widechar       Build a wide char aware vi.],
242         [vi_cv_widechar=$enableval], [vi_cv_widechar="no"])
243 if test "$vi_cv_widechar" = "yes"; then
244         AC_DEFINE(USE_WIDECHAR)
246 AC_MSG_RESULT($vi_cv_widechar)
248 dnl Check whether we can use iconv
249 AC_CHECK_HEADER(langinfo.h, [
250         AC_CHECK_HEADER(iconv.h, [
251                 AC_DEFINE(USE_ICONV)
252                 VI_CV_REPLACE_FUNCS(iswblank)
253         ])
256 dnl If the user wants a Gtk IPC front-end for nvi, build it.
257 AC_SUBST(vi_programs)
258 AC_SUBST(vi_ipc)
259 AC_SUBST(GTKLIBS)
260 AC_SUBST(GTKINCS)
261 AC_MSG_CHECKING(if --enable-gtk option specified)
262 AC_ARG_ENABLE(gtk,
263         [  --enable-gtk            Build a Gtk front-end for vi.],
264         [vi_cv_gtk=$enableval], [vi_cv_gtk="no"])
265 AC_MSG_RESULT($vi_cv_gtk)
266 if test "$vi_cv_gtk" = "yes"; then
267         #
268         # Find pkg-config
269         #
270         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
271         if test x$PKG_CONFIG = xno ; then
272             if test "$vi_cv_widechar" = "yes"; then
273                 AC_MSG_ERROR(
274 [*** pkg-config not found. See http://pkgconfig.sourceforge.net])
275             fi
277         else
278             if ! $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then
279                 if test "$vi_cv_widechar" = "yes"; then
280                     AC_MSG_ERROR(
281 [*** pkg-config too old; version 0.5 or better required.])
282                 fi
283                 PKG_CONFIG=no
284             fi
286         fi
287         if test x$PKG_CONFIG = xno ; then
288             PKG_CONFIG=/bin/false
289         fi
291         vi_programs="$vi_programs vi-gtk"
292         vi_ipc=vi-ipc
293         AC_MSG_CHECKING(for gtk+)
294         if $PKG_CONFIG gtk+-2.0 ; then
295               GTKINCS=`$PKG_CONFIG --cflags gtk+-2.0`
296               GTKLIBS=`$PKG_CONFIG --libs gtk+-2.0`
298               AC_MSG_RESULT(ok)
299               AC_DEFINE(HAVE_PANGO)
300         else
301             if test "$vi_cv_widechar" = "yes"; then
302                 AC_MSG_ERROR([
303 *** gtk+-2.0 is required. The latest version of gtk
304 *** is always available from ftp://ftp.gtk.org/.
305                 ])
306             else
307                 AM_PATH_GTK(1.2.0)
308                 GTKINCS="$GTK_CFLAGS"
309                 GTKLIBS="$GTK_LIBS $LIBS"
310             fi
311         fi
313         SAVELIBS="$LIBS"
314         LIBS="-lutil $GTKLIBS"
315         AC_CHECK_LIB(nvizvt, zvt_get_ptys,
316                 [vi_cv_zvt="yes"], [vi_cv_zvt="no"])
317         if test "$vi_cv_zvt" = "yes"; then
318                 GTKLIBS="-lnvizvt $LIBS"
319                 AC_DEFINE(HAVE_ZVT)
320         fi
321         LIBS="$SAVELIBS"
322 #       AC_PATH_PROG(vi_cv_gnome_config, gnome-config, no)
323 #       if test "$vi_cv_gnome_config" != "no"; then
324 #               ZVTLIBS=`$vi_cv_gnome_config zvt --libs`
325 #               GTKLIBS="$ZVTLIBS $GTKLIBS"
326 #       fi
329 dnl If the user wants a Motif IPC front-end for nvi, build it.
330 AC_SUBST(MOTIFLIBS)
331 AC_MSG_CHECKING(if --enable-motif option specified)
332 AC_ARG_ENABLE(motif,
333         [  --enable-motif          Build a Motif front-end for vi.],
334         [vi_cv_motif=$enableval], [vi_cv_motif="no"])
335 AC_MSG_RESULT($vi_cv_motif)
336 if test "$vi_cv_motif" = "yes"; then
337         vi_programs="$vi_programs vi-motif"
338         vi_ipc=vi-ipc
340         dnl XXX
341         dnl BSDI's Motif libraries aren't shared.
343         case "$host_os" in
344         bsdi*)  CC=cc;;
345         esac
347         dnl XXX
348         dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
349         dnl -lXext is generally available, the others aren't.
350         dnl
351         dnl XXX
352         dnl Color icons require -lXpm, which may or may not be available,
353         dnl depending on the version of X11.
355         MOTIFLIBS="-lXm -lXt"
356         AC_CHECK_LIB(SM, main,
357             [vi_cv_smlib="yes"], [vi_cv_smlib="no"], "$XLIBS")
358         if test "$vi_cv_smlib" = "yes"; then
359                 MOTIFLIBS="$MOTIFLIBS -lSM"
360         fi
361         AC_CHECK_LIB(ICE, main,
362             [vi_cv_icelib="yes"], [vi_cv_icelib="no"], "$XLIBS")
363         if test "$vi_cv_icelib" = "yes"; then
364                 MOTIFLIBS="$MOTIFLIBS -lICE"
365         fi
366         AC_CHECK_LIB(Xext, main,
367             [vi_cv_xextlib="yes"], [vi_cv_xextlib="no"], "$XLIBS")
368         if test "$vi_cv_xextlib" = "yes"; then
369                 MOTIFLIBS="$MOTIFLIBS -lXext"
370         fi
371         AC_CHECK_LIB(Xpm, main,
372             [vi_cv_xpmlib="yes"], [vi_cv_xpmlib="no"], "$XLIBS")
373         if test "$vi_cv_xpmlib" = "yes"; then
374                 MOTIFLIBS="$MOTIFLIBS -lXpm"
375         fi
376         MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
379 AC_SUBST(IPCOBJS)
380 dnl Check for threads
381 AC_MSG_CHECKING(if --enable-threads option specified)
382 AC_ARG_ENABLE(threads,
383         [  --enable-threads        Turn on thread support.],
384         [vi_cv_threads=$enableval], [vi_cv_threads="no"])
385 AC_MSG_RESULT($vi_cv_threads)
386 if test "$vi_cv_threads" = "yes"; then
387         LIBS="$LIBS -lpthread"
388         AC_CACHE_VAL(vi_cv_have_pthreads, [dnl
389         AC_TRY_LINK([#include <pthread.h>],
390                 [pthread_self()],
391                 [vi_cv_have_pthreads=yes],
392                 [vi_cv_have_pthreads=no])])
393         if test "$vi_cv_have_pthreads" = "no"; then
394                 AC_MSG_ERROR(No threading library found)
395         fi
396         IPCOBJS="pthread.o $IPCOBJS"
397         AC_DEFINE(HAVE_PTHREAD)
398 else
399         IPCOBJS="nothread.o $IPCOBJS"
402 dnl If the user wants a Perl interpreter in nvi, load it.
403 AC_SUBST(shrpenv)
404 AC_SUBST(perlldflags)
405 AC_SUBST(perllibs)
406 AC_SUBST(vi_cv_perllib)
407 AC_MSG_CHECKING(if --enable-perlinterp option specified)
408 AC_ARG_ENABLE(perlinterp,
409         [  --enable-perlinterp     Include a Perl interpreter in vi.],
410         [vi_cv_perlinterp=$enableval], [vi_cv_perlinterp="no"])
411 AC_MSG_RESULT($vi_cv_perlinterp)
412 if test "$vi_cv_perlinterp" = "yes"; then
413         if test "$vi_cv_path_perl" = no; then
414                 AC_MSG_ERROR([No perl5 utility found.])
415         fi
416         $vi_cv_path_perl -e 'require 5.004' || {
417                 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
418         }
419         if test "$vi_cv_threads" = "yes"; then
420                 useithreads=`$vi_cv_path_perl -MConfig -e 'print $Config{useithreads}'`
421                 if test "X$useithreads" != "Xdefine"; then
422                         AC_MSG_ERROR([vi threading only compatible with perl's ithreads.])
423                 fi
424         fi
426         eval `$vi_cv_path_perl -V:shrpenv`
427         vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
428         perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
429                 -e 'ccflags;perl_inc'`
430         if test "X$perlcppflags" != "X"; then
431                 CPPFLAGS="$perlcppflags $CPPFLAGS"
432         fi
433         perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
434                 -e 'ldopts'`
435         perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
436                 -e 'ccdlflags'`
437         LIBOBJS="perl.o perlxsi.o perlsfio.o $LIBOBJS"
438         AC_DEFINE(HAVE_PERL_INTERP)
439         AC_CACHE_CHECK([whether we need to use perl's setenv], 
440                 vi_cv_perl_setenv, [
441                 AC_TRY_RUN([
442 #include <EXTERN.h>
443 #include <perl.h>
444 #include <XSUB.h>
445 int main(){
446 #if defined(USE_ENVIRON_ARRAY) && !defined(PERL_USE_SAFE_PUTENV)
447 exit(0);
448 #else
449 exit(1);
450 #endif
452                 ], [vi_cv_perl_setenv=yes], [vi_cv_perl_setenv=no])])
453         if test "$vi_cv_perl_setenv" = yes; then
454                 AC_DEFINE(USE_PERL_SETENV)
455         fi
458 dnl If the user wants a Tk/Tcl interpreter in nvi, load it.  Make sure that
459 dnl we can find a Tk/Tcl library.
460 AC_MSG_CHECKING(if --enable-tclinterp option specified)
461 AC_ARG_ENABLE(tclinterp,
462         [  --enable-tclinterp      Include a Tk/Tcl interpreter in vi.],
463         [vi_cv_tclinterp=$enableval], [vi_cv_tclinterp="no"])
464 AC_MSG_RESULT($vi_cv_tclinterp)
465 if test "$vi_cv_tclinterp" = "yes"; then
466         AC_MSG_CHECKING([for tclConfig.sh])
467         AC_CACHE_VAL(vi_cv_tclconfig, [
468                 vi_cv_tclconfig=`$srcdir/findconfig`])
469         AC_MSG_RESULT($vi_cv_tclconfig)
470         if test "x$vi_cv_tclconfig" = x; then
471                 AC_MSG_ERROR([No Tcl library found;])
472         fi
473         . $vi_cv_tclconfig
474         LIBOBJS="tcl.o $LIBOBJS"
475         LIBS="$TCL_LIB_SPEC $TCL_LIBS $LIBS"
476         AC_DEFINE(HAVE_TCL_INTERP)
479 dnl check for curses
480 AC_SUBST(CURSLIBS)
481 AC_SUBST(CURSCPPFLAGS)
482 AC_SUBST(CURSLDFLAGS)
483 AC_SUBST(HAVE_NCURSESW)
485 dnl AC_ARG_WITH(slang,
486 dnl     [  --with-slang[=DIR]     Use S-Lang instead of curses. ],
487 dnl     [
488 dnl     if test "$withval" != yes; then
489 dnl             LDFLAGS="-L${withval}/lib $LDFLAGS"
490 dnl             CPPFLAGS="-I${withval}/include $CPPFLAGS"
491 dnl     fi
492 dnl     AC_DEFINE(USE_SLANG_CURSES)
493 dnl         AC_CHECK_LIB(slang, SLtt_get_terminfo,
494 dnl                 [CURSLIBS="$CURSLIBS -lslang -lm"],
495 dnl                 [AC_MSG_ERROR(unable to compile.  check config.log)], -lm)
496 dnl 
497 dnl     vi_cv_curses=slcurses
498 dnl     ],
499 dnl     [
500         SAVELIBS="$LIBS"
501         SAVELDFLAGS="$LDFLAGS"
502         SAVECPPFLAGS="$CPPFLAGS"
503         AC_ARG_WITH(curses,
504                 [  --with-curses=DIR       Path to curses installation. ])
505         if test "x$with_curses" != "x"; then
506                 CURSLDFLAGS="`echo $with_curses/lib | sed "$LRscript"` $CURSLDFLAGS"
507                 CURSCPPFLAGS="-I$with_curses/include $CURSCPPFLAGS"
508         fi;
509         LDFLAGS="$CURSLDFLAGS $LDFLAGS"
510         CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
512         if test "$vi_cv_widechar" = "yes"; then
513             for vi_cv_curses in ncurses ncursesw curses; do
514                 AC_CHECK_LIB($vi_cv_curses, waddnwstr,[break])
515                 vi_cv_curses=unknown
516             done
517         else 
518             for vi_cv_curses in ncurses ncursesw curses; do
519                 AC_CHECK_LIB($vi_cv_curses, initscr, [break])
520                 vi_cv_curses=unknown
521             done
522         fi
524         if test "$vi_cv_curses" != "unknown"; then
525             CURSHEADER=curses.h
526             if test "$vi_cv_curses" = "ncurses"; then
527                 AC_CHECK_HEADERS(ncurses.h, [CURSHEADER=ncurses.h])
528             fi
529             if test "$vi_cv_curses" = "ncursesw"; then
530                 AC_CHECK_HEADERS(ncursesw/ncurses.h, 
531                         [CURSHEADER=ncursesw/ncurses.h])
532             fi
533             vi_programs="vi $vi_programs"
534             CURSLIBS="-l$vi_cv_curses"
535         else
536             AC_MSG_WARN([*** No suitable curses library found.])
537             if test "$vi_programs"X = X; then
538                 AC_MSG_ERROR([No executable to build.])
539             fi
540         fi
542 dnl Check for the termcap/termlib library.  These two checks must occur in the
543 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
544 dnl On Solaris curses==termlib, but different versions of curses
545 dnl can be used. Avoid loading termlib is curses has tgetent.
546 AC_CHECK_LIB($vi_cv_curses, tgetent,
547         [vi_cv_curses_tgetent=yes], [vi_cv_curses_tgetent=no])
548 if test "$vi_cv_curses_tgetent" = no; then
549         AC_CHECK_LIB(termlib, tgetent,
550                 [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
551         if test "$vi_cv_termlib" = no; then
552                 AC_CHECK_LIB(termcap, tgetent,
553                         [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
554         fi
556 if test "$vi_cv_termlib" != no; then
557         CURSLIBS="$CURSLIBS $vi_cv_termlib"
560         LIBS="$SAVELIBS"
561         LDFLAGS="$SAVELDFLAGS"
562         CPPFLAGS="$SAVECPPFLAGS"
563 dnl     ])
565 dnl Checks for header files.
566 AC_MSG_CHECKING(for sys/mman.h)
567 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
568 AC_TRY_CPP([#include <sys/mman.h>],
569         [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
570 if test "$vi_cv_include_sys_mman" = yes; then
571         AC_DEFINE(HAVE_SYS_MMAN_H)
573 AC_MSG_RESULT($vi_cv_include_sys_mman)
575 AC_MSG_CHECKING(for sys/select.h)
576 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
577 AC_TRY_CPP([#include <sys/select.h>],
578         [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
579 if test "$vi_cv_include_sys_select" = yes; then
580         AC_DEFINE(HAVE_SYS_SELECT_H)
582 AC_MSG_RESULT($vi_cv_include_sys_select)
584 dnl Checks for typedefs, structures, and compiler characteristics.
585 AC_CHECK_TYPE(ssize_t, int)
586 AC_C_BIGENDIAN
587 AC_C_CONST
588 AC_STRUCT_ST_BLKSIZE
589 AC_TYPE_MODE_T
590 AC_TYPE_OFF_T
591 AC_TYPE_PID_T
592 AC_TYPE_SIZE_T
593 AC_STRUCT_TM
595 dnl Checks for library functions.
596 VI_CV_REPLACE_FUNCS(bsearch gethostname memchr memset)
597 VI_CV_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
598 VI_CV_REPLACE_FUNCS(snprintf vsnprintf)
600 AC_CHECK_FUNCS(select)
601 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
602 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
603 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
605 AC_FUNC_MMAP
606 AC_FUNC_VFORK
608 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
609 if test "$need_env" = yes; then
610         LIBOBJS="env.o $LIBOBJS"
613 dnl If we need strsep, add it and define it so we get a prototype.
614 if test "$need_strsep" = yes; then
615         LIBOBJS="strsep.o $LIBOBJS"
618 dnl Check for fcntl/flock
619 dnl Use flock preferentially, since it has cleaner semantics and won't
620 dnl hang up the editor.
621 dnl XXX
622 dnl Ultrix has a broken fcntl, but a working flock.
623 dnl IRIX and DGUX have a broken flock, but working fcntl.
624 AC_MSG_CHECKING(for fcntl/flock)
625 AC_CACHE_VAL(vi_cv_lock, [dnl
626         vi_cv_lock=none
627         case "$host_os" in
628         dgux*);;
629         irix*);;
630         *)
631                 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
632                     [vi_cv_lock=flock]);;
633         esac
634         if test "$vi_cv_lock" = none; then
635                 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
636                     [vi_cv_lock=fcntl])
637         fi])
639 if test "$vi_cv_lock" = flock; then
640         AC_DEFINE(HAVE_LOCK_FLOCK)
642 if test "$vi_cv_lock" = fcntl; then
643         AC_DEFINE(HAVE_LOCK_FCNTL)
645 AC_MSG_RESULT($vi_cv_lock)
647 dnl Check for ftruncate/chsize
648 AC_MSG_CHECKING(for ftruncate/chsize)
649 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
650 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
651         [vi_cv_ftruncate=ftruncate],
652 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
653         [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
654 if test "$vi_cv_ftruncate" = ftruncate; then
655         AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
657 if test "$vi_cv_ftruncate" = chsize; then
658         AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
660 if test "$vi_cv_ftruncate" = no; then
661         AC_MSG_ERROR([No file truncation system call.])
663 AC_MSG_RESULT($vi_cv_ftruncate)
665 CSAVELIBS="$LIBS"
666 CSAVELDFLAGS="$LDFLAGS"
667 CSAVECPPFLAGS="$CPPFLAGS"
668 LIBS="$CURSLIBS $LIBS"
669 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
670 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
671 dnl Check for the tigetstr/tigetnum functions.
672 AC_MSG_CHECKING(for tigetstr/tigetnum)
673 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
674 AC_TRY_LINK([#include <$CURSHEADER>], [tigetstr(0);],
675         [vi_cv_have_curses_tigetstr=yes],
676         [vi_cv_have_curses_tigetstr=no])])
677 if test "$vi_cv_have_curses_tigetstr" = yes; then
678         AC_DEFINE(HAVE_CURSES_TIGETSTR)
680 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
682 dnl Check for potentially missing curses functions in system or user-specified
683 dnl libraries.  We also have to guess at whether the specified library is a
684 dnl BSD or System V style curses.  Use the newterm function, all System V
685 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
686 if test "$vi_cv_curses" = "bundled curses"; then
687         AC_DEFINE(HAVE_BSD_CURSES)
688         AC_DEFINE(HAVE_CURSES_WADDNSTR)
689         AC_DEFINE(HAVE_CURSES_IDLOK)
690 else
691         dnl Check for the waddnstr function.
692         AC_MSG_CHECKING(for waddnstr)
693         AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
694         AC_TRY_LINK([#include <$CURSHEADER>], [waddnstr(stdscr, 0, 0);],
695                 [vi_cv_have_curses_waddnstr=yes],
696                 [vi_cv_have_curses_waddnstr=no])])
697         if test "$vi_cv_have_curses_waddnstr" = yes; then
698                 AC_DEFINE(HAVE_CURSES_WADDNSTR)
699         fi
700         AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
702         dnl Check for the beep function.
703         AC_MSG_CHECKING(for beep)
704         AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
705         AC_TRY_LINK([#include <$CURSHEADER>], [beep();],
706                 [vi_cv_have_curses_beep=yes],
707                 [vi_cv_have_curses_beep=no])])
708         if test "$vi_cv_have_curses_beep" = yes; then
709                 AC_DEFINE(HAVE_CURSES_BEEP)
710         fi
711         AC_MSG_RESULT($vi_cv_have_curses_beep)
713         dnl Check for the flash function.
714         AC_MSG_CHECKING(for flash)
715         AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
716         AC_TRY_LINK([#include <$CURSHEADER>], [flash();],
717                 [vi_cv_have_curses_flash=yes],
718                 [vi_cv_have_curses_flash=no])])
719         if test "$vi_cv_have_curses_flash" = yes; then
720                 AC_DEFINE(HAVE_CURSES_FLASH)
721         fi
722         AC_MSG_RESULT($vi_cv_have_curses_flash)
724         dnl Check for the idlok function.
725         AC_MSG_CHECKING(for idlok)
726         AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
727         AC_TRY_LINK([#include <$CURSHEADER>], [idlok(0, 0);],
728                 [vi_cv_have_curses_idlok=yes],
729                 [vi_cv_have_curses_idlok=no])])
730         if test "$vi_cv_have_curses_idlok" = yes; then
731                 AC_DEFINE(HAVE_CURSES_IDLOK)
732         fi
733         AC_MSG_RESULT($vi_cv_have_curses_idlok)
735         dnl Check for the keypad function.
736         AC_MSG_CHECKING(for keypad)
737         AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
738         AC_TRY_LINK([#include <$CURSHEADER>], [keypad(0, 0);],
739                 [vi_cv_have_curses_keypad=yes],
740                 [vi_cv_have_curses_keypad=no])])
741         if test "$vi_cv_have_curses_keypad" = yes; then
742                 AC_DEFINE(HAVE_CURSES_KEYPAD)
743         fi
744         AC_MSG_RESULT($vi_cv_have_curses_keypad)
746         dnl Check for the newterm function.
747         AC_MSG_CHECKING(for newterm)
748         AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
749         AC_TRY_LINK([#include <$CURSHEADER>], [newterm(0, 0, 0);],
750                 [vi_cv_have_curses_newterm=yes],
751                 [vi_cv_have_curses_newterm=no])])
752         if test "$vi_cv_have_curses_newterm" = yes; then
753                 AC_DEFINE(HAVE_CURSES_NEWTERM)
754         fi
755         AC_MSG_RESULT($vi_cv_have_curses_newterm)
757         if test "$vi_cv_have_curses_newterm" = no; then
758                 AC_DEFINE(HAVE_BSD_CURSES)
759         fi
762 dnl Check for the setupterm function.  We make this check regardless of
763 dnl using the system library, because it may be part of the underlying
764 dnl termcap/termlib support, and we want to use the local one.
765 AC_MSG_CHECKING(for setupterm)
766 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
767 AC_TRY_LINK([#include <$CURSHEADER>], [setupterm(0, 0, 0);],
768         [vi_cv_have_curses_setupterm=yes],
769         [vi_cv_have_curses_setupterm=no])])
770 if test "$vi_cv_have_curses_setupterm" = yes; then
771         AC_DEFINE(HAVE_CURSES_SETUPTERM)
773 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
774 LIBS="$CSAVELIBS"
775 LDFLAGS="$CSAVELDFLAGS"
776 CPPFLAGS="$CSAVECPPFLAGS"
778 dnl Some moron decided to drop off an argument from the gettimeofday call,
779 dnl without changing the name.
780 AC_MSG_CHECKING(for broken gettimeofday system call)
781 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
782 AC_TRY_LINK([#include <sys/types.h>
783 #include <sys/time.h>], [gettimeofday(0, 0);],
784         [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
785 if test "$vi_cv_gettimeofday" = broken; then
786         AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
788 AC_MSG_RESULT($vi_cv_gettimeofday)
790 dnl Check for which version of openpty to use, System V or Berkeley.
791 AC_MSG_CHECKING(for System V pty calls)
792 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
793 AC_TRY_LINK(, [grantpt(0);],
794         [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
795 if test "$vi_cv_sys5_pty" = yes; then
796         AC_DEFINE(HAVE_SYS5_PTY)
798 AC_MSG_RESULT($vi_cv_sys5_pty)
800 dnl Check for the revoke system call.
801 AC_MSG_CHECKING(for revoke system call)
802 AC_CACHE_VAL(vi_cv_revoke, [dnl
803 AC_TRY_LINK(, [revoke("a");],
804         [vi_cv_revoke=yes], [vi_cv_revoke=no])])
805 if test "$vi_cv_revoke" = yes; then
806         AC_DEFINE(HAVE_REVOKE)
808 AC_MSG_RESULT($vi_cv_revoke)
810 dnl Some versions of sprintf return a pointer to the first argument instead
811 dnl of a character count.  We assume that the return value of snprintf and
812 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
813 AC_MSG_CHECKING(for int type sprintf return value)
814 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
815 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
816         [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
817 if test "$vi_cv_sprintf_count" = no; then
818         AC_DEFINE(SPRINTF_RET_CHARPNT)
820 AC_MSG_RESULT($vi_cv_sprintf_count)
823 dnl Check for the standard shorthand types.
824 AC_SUBST(u_char_decl)
825 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
826 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
827         [vi_cv_uchar=yes], [vi_cv_uchar=no])])
828 if test "$vi_cv_uchar" = no; then
829         u_char_decl="typedef unsigned char u_char;"
832 AC_SUBST(u_short_decl)
833 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
834 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
835         [vi_cv_ushort=yes], [vi_cv_ushort=no])])
836 if test "$vi_cv_ushort" = no; then
837         u_short_decl="typedef unsigned short u_short;"
840 AC_SUBST(u_int_decl)
841 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
842 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
843         [vi_cv_uint=yes], [vi_cv_uint=no])])
844 if test "$vi_cv_uint" = no; then
845         u_int_decl="typedef unsigned int u_int;"
848 AC_SUBST(u_long_decl)
849 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
850 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
851         [vi_cv_ulong=yes], [vi_cv_ulong=no])])
852 if test "$vi_cv_ulong" = no; then
853         u_long_decl="typedef unsigned long u_long;"
856 dnl DB/Vi use specific integer sizes.
857 AC_SUBST(u_int8_decl)
858 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
859 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
860         [vi_cv_uint8=yes],
861         AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
862             [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
863 if test "$vi_cv_uint8" = no; then
864         AC_MSG_ERROR(No unsigned 8-bit integral type.)
866 if test "$vi_cv_uint8" != yes; then
867         u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
870 AC_SUBST(u_int16_decl)
871 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
872 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
873         [vi_cv_uint16=yes],
874 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
875         [vi_cv_uint16="unsigned short"],
876 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
877         [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
878 if test "$vi_cv_uint16" = no; then
879         AC_MSG_ERROR([No unsigned 16-bit integral type.])
881 if test "$vi_cv_uint16" != yes; then
882         u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
885 AC_SUBST(int16_decl)
886 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
887 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
888         [vi_cv_int16=yes],
889 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
890         [vi_cv_int16="short"],
891 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
892         [vi_cv_int16="int"], [vi_cv_int16=no])))])
893 if test "$vi_cv_int16" = no; then
894         AC_MSG_ERROR([No signed 16-bit integral type.])
896 if test "$vi_cv_int16" != yes; then
897         int16_decl="typedef $vi_cv_int16 int16_t;"
900 AC_SUBST(u_int32_decl)
901 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
902 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
903         [vi_cv_uint32=yes],
904 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
905         [vi_cv_uint32="unsigned int"],
906 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
907         [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
908 if test "$vi_cv_uint32" = no; then
909         AC_MSG_ERROR([No unsigned 32-bit integral type.])
911 if test "$vi_cv_uint32" != yes; then
912         u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
915 AC_SUBST(int32_decl)
916 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
917 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
918         [vi_cv_int32=yes],
919 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
920         [vi_cv_int32="int"],
921 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
922         [vi_cv_int32="long"], [vi_cv_int32=no])))])
923 if test "$vi_cv_int32" = no; then
924         AC_MSG_ERROR([No signed 32-bit integral type.])
926 if test "$vi_cv_int32" != yes; then
927         int32_decl="typedef $vi_cv_int32 int32_t;"
930 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
931 [AC_TRY_COMPILE([#include <stdio.h>
932 int fprintf ();
933 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
935 AC_SUBST(NEED_FPRINTF_PROTO)
936 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
937 [AC_TRY_COMPILE([ #include <stdio.h>
938 typedef int     (*funcPtr)();
939 ],[funcPtr ptr = (funcPtr) fprintf;], 
940 vi_cv_proto_fprintf=no, 
941 [vi_cv_proto_fprintf=yes])])
942 if test "$vi_cv_proto_fprintf" = yes; then
943         AC_DEFINE(NEED_FPRINTF_PROTO)
946 AC_ARG_WITH(db_type,
947         [  --with-db=bundled|system Which db to use. ])
948 case "$with_db_type" in
949 "db1")
950         AC_MSG_WARN([Use of db1 is not officially supported.])
951         AC_DEFINE(USE_DB1)
952         ;;
953 "system")
954         ;;
956         with_db_type="bundled"
957         ;;
958 esac
960 dnl Check for DB 3
961 AC_ARG_WITH(db_prefix,
962         [  --with-db-prefix=PFX    Path to db installation. ])
964 SAVELDFLAGS="$LDFLAGS"
965 if test "x$with_db_prefix" != "x"; then
966         LDFLAGS="-L$with_db_prefix/lib $LDFLAGS"
967         CPPFLAGS="-I$with_db_prefix/include $CPPFLAGS"
969 if test "$with_db_type" != db1; then
970         SAVELIBS="$LIBS"
972         LIBS="$LIBS -ldb"
973         AC_TRY_LINK([#include <db.h>],
974                 [db_create(NULL,NULL,0)],
975                 [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
976         if test "$vi_cv_dbfatal" = "yes"; then
977                 AC_MSG_ERROR([Need DB 3.])
978         fi
980         LIBS="$SAVELIBS"
982 LDFLAGS="$SAVELDFLAGS"
984 AC_SUBST(dl_src)
985 AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
986 AC_ARG_ENABLE(dynamic-loading,
987         [  --enable-dynamic-loading Load DB 3 dynamically.],
988         [vi_cv_dl=$enableval], [vi_cv_dl="no"])
989 AC_MSG_RESULT($vi_cv_dl)
990 if test "$vi_cv_dl" = yes; then
991         AC_CHECK_LIB(dl, dlopen,
992                 [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
993         if test "$vi_cv_dlfatal" = "yes"; then
994                 AC_MSG_ERROR([Need dl to support dynamic loading.])
995         fi
996         OLDPATH="$PATH"
998         PATH="$with_db_prefix/lib:/usr/lib:/lib"
999         AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
1000         if test "$vi_cv_path_db3" = no; then
1001                 AC_MSG_ERROR([Path of libdb-3.so not found.])
1002         fi
1003         PATH="$OLDPATH"
1005         AC_DEFINE(USE_DYNAMIC_LOADING)
1006         LIBOBJS="dldb.o $LIBOBJS"
1007         dl_src=../common/dldb.c
1008         LIBS="-ldl $LIBS"
1009 else
1010         LIBS="-ldb $LIBS"
1011         if test "X$with_db_prefix" != "X"; then
1012                 LDFLAGS="`echo $with_db_prefix/lib | sed "$LRscript"` $LDFLAGS"
1013         fi
1016 AC_ARG_WITH(db_build,
1017         [  --with-db-build=prefix  Path to db build. ])
1018 if test "x$with_db_build" != "x"; then
1019         vi_cv_dbsrc=`$AWK '/^srcdir/ {gsub("srcdir[[ \t]]*=","");print $1}' \
1020                      $with_db_build/Makefile`
1021         case $with_db_build in
1022         *[[\\/]]);;
1023         *)
1024             with_db_build="$with_db_build/";;
1025         esac
1026         case $vi_cv_dbsrc in
1027         [[\\/]]*);;
1028         *)
1029             vi_cv_dbsrc="$with_db_build$vi_cv_dbsrc";;
1030         esac
1033 vi_cv_db4="no"
1034 AC_ARG_ENABLE(log4,
1035         [  --enable-db4-logging    Enable experimental/broken db4 logging.],
1036         [
1037         AC_MSG_CHECKING(for DB 4)
1038         AC_EGREP_CPP([^4],
1039                 [#include <db.h>
1040         DB_VERSION_MAJOR],
1041                 [vi_cv_db4="yes"], [vi_cv_db4="no"])
1042         AC_MSG_RESULT($vi_cv_db4)
1043         ])
1044 if test "$vi_cv_db4" = "yes"; then
1045         CPPFLAGS="-I$vi_cv_dbsrc/include $CPPFLAGS"
1046         CPPFLAGS="-I$vi_cv_dbsrc/include_auto $CPPFLAGS"
1047         CPPFLAGS="-I$with_db_build $CPPFLAGS"
1048         AC_DEFINE(USE_DB4_LOGGING)
1049         LIBOBJS="log4.o vi_auto.o vi_rec.o $LIBOBJS"
1050 else
1051         LIBOBJS="log.o $LIBOBJS"
1054 dnl We compile in nvi's RE routines unless the user specifies otherwise.
1055 AC_MSG_CHECKING(if --disable-re option specified)
1056 AC_ARG_ENABLE(re,
1057         [  --disable-re            DON'T use the nvi-provided RE routines.],
1058         [if test "$enable_re" = "yes"; then
1059                 vi_cv_re_lib="bundled RE"
1060         else
1061                 vi_cv_re_lib="other RE"
1062         fi],[vi_cv_re_lib="bundled RE"])
1063 AC_MSG_RESULT($vi_cv_re_lib)
1064 case "$vi_cv_re_lib" in
1065 "bundled RE")
1066         CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
1067         LIBOBJS="regcomp.o regerror.o regexec.o regfree.o $LIBOBJS";;
1068 "other RE")
1069         ;;
1070 esac
1072 AC_OUTPUT(Makefile port.h:port.h.in
1073     pathnames.h:pathnames.h.in recover:recover.in)