use three-argument AC_DEFINE instead of acconfig.h
[nvi.git] / dist / configure.in
blob0732ebbfd066c4b70a910475fc43837cbe84e8b3
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, 1, [Define if you want a debugging version.])
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, 1, [Define if you 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, 1,
114                         [Define if you have a Ultrix-style (broken) vdisable.]);;
115 esac
117 AC_MSG_CHECKING(whether recording of pathnames of libraries is enabled)
118 AC_ARG_ENABLE(runpath,
119         [  --disable-runpath       Don't record path of libraries in binary.],
120         [vi_cv_runpath="$enableval"], [vi_cv_runpath="yes"])
121 AC_MSG_RESULT($vi_cv_runpath)
123 if test "X$vi_cv_runpath" = "Xyes"; then
124         LRscript='s/^\(.*\)/-R\1 -L\1 /'
125 else
126         LRscript='s/^\(.*\)/-L\1 /'
129 dnl If the user wants a tracing version, add the TRACE compile flag.
130 AC_MSG_CHECKING(if --enable-trace option specified)
131 AC_ARG_ENABLE(trace,
132         [  --enable-trace          Build a tracing version.],
133         [vi_cv_trace="yes"], [vi_cv_trace="no"])
134 if test "$vi_cv_trace" = yes; then
135         CPPFLAGS="-DTRACE $CPPFLAGS"
137 AC_MSG_RESULT($vi_cv_trace)
139 dnl The user may have additional CPP information.
140 CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"
142 dnl The user may have additional load line information.
143 LDFLAGS="$ADDLDFLAGS $LDFLAGS"
145 dnl The user may have additional library information.
146 LIBS="$ADDLIBS $LIBS"
148 dnl Checks for programs.
149 PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib"
151 dnl Check for the shell path.
152 AC_PATH_PROG(vi_cv_path_shell, sh, no)
153 if test "$vi_cv_path_shell" = no; then
154         AC_MSG_ERROR([No shell utility found.])
157 dnl Check for the sendmail path.
158 AC_PATH_PROG(vi_cv_path_sendmail, sendmail, no)
159 if test "$vi_cv_path_sendmail" = no; then
160         AC_MSG_WARN([No sendmail utility found;])
161         AC_MSG_WARN([    users will not be told of saved files.])
164 dnl Check for the perl5/perl path.
165 AC_SUBST(vi_cv_path_perl)
166 AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)
168 dnl Check for the "preserve" path.
169 dnl Historically, nvi has used /var/tmp/vi.recover.  The Linux filesystem
170 dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
171 dnl beneath it so that we don't have name collisions with other editors.
172 dnl Other systems have /var/preserve as well, so we test first for an already
173 dnl existing name, and then use the first one that's writeable.
174 AC_SUBST(vi_cv_path_preserve)
175 AC_MSG_CHECKING(for preserve directory)
176 AC_CACHE_VAL(vi_cv_path_preserve, [dnl
177         dirlist="/var/preserve /var/tmp /usr/tmp"
178         vi_cv_path_preserve=no
179         for i in $dirlist; do
180                 if test -d $i/vi.recover; then
181                         vi_cv_path_preserve=$i/vi.recover
182                         break;
183                 fi
184         done
185         if test "$vi_cv_path_preserve" = no; then
186                 for i in $dirlist; do
187                         if test -d $i -a -w $i; then
188                                 vi_cv_path_preserve=$i/vi.recover
189                                 break;
190                         fi
191                 done
193         fi])
194 if test "$vi_cv_path_preserve" = no; then
195         AC_MSG_ERROR([No writeable preserve directory found.])
197 AC_MSG_RESULT($vi_cv_path_preserve)
198 AC_PATH_PROG(vi_cv_path_fuser, fuser, no)
199 AC_PATH_PROG(vi_cv_path_lsof, lsof, no)
200 AC_SUBST(INUSE)
201 INUSE=""
202 if test "$vi_cv_path_lsof" != no; then
203         INUSE='test `lsof -t $i`'
205 if test "$vi_cv_path_fuser" != no; then
206         INUSE='fuser -s $i'
209 dnl Check for programs used for installation
210 AC_PROG_AWK
211 AC_PATH_PROG(vi_cv_path_ar, ar, missing_ar)
212 AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
213 AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
214 AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
215 AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
216 AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
217 AC_PATH_PROG(vi_cv_path_ranlib, ranlib, missing_ranlib)
218 AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
220 dnl Checks for libraries.
221 dnl Find the X libraries and includes.
222 AC_PATH_X
223 AC_SUBST(XINCS)
224 if test "$no_x" != yes; then
225         if test "X$x_libraries" != "X"; then
226                 XLIBS="`echo $x_libraries | sed "$LRscript"` $XLIBS"
227         fi
228         XLIBS="$XLIBS -lX11"
229         if test "X$x_includes" != "X"; then
230                 XINCS="-I$x_includes"
231         fi
234 AC_DEFUN([VI_CV_REPLACE_FUNCS],
235 [AC_FOREACH([AC_Func], [$1], [])dnl
236 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
239 dnl Check if the user wants widechar support.
240 AC_MSG_CHECKING(if --enable-widechar option specified)
241 AC_ARG_ENABLE(widechar,
242         [  --enable-widechar       Build a wide char aware vi.],
243         [vi_cv_widechar=$enableval], [vi_cv_widechar="no"])
244 if test "$vi_cv_widechar" = "yes"; then
245         AC_DEFINE(USE_WIDECHAR, 1, [Define when using wide characters.])
247 AC_MSG_RESULT($vi_cv_widechar)
249 dnl Check whether we can use iconv
250 AC_CHECK_HEADER(langinfo.h, [
251         AC_CHECK_HEADER(iconv.h, [
252                 AC_DEFINE(USE_ICONV, 1, [Define when iconv can be used.])
253                 VI_CV_REPLACE_FUNCS(iswblank)
254         ])
257 dnl If the user wants a Gtk IPC front-end for nvi, build it.
258 AC_SUBST(vi_programs)
259 AC_SUBST(vi_ipc)
260 AC_SUBST(GTKLIBS)
261 AC_SUBST(GTKINCS)
262 AC_MSG_CHECKING(if --enable-gtk option specified)
263 AC_ARG_ENABLE(gtk,
264         [  --enable-gtk            Build a Gtk front-end for vi.],
265         [vi_cv_gtk=$enableval], [vi_cv_gtk="no"])
266 AC_MSG_RESULT($vi_cv_gtk)
267 if test "$vi_cv_gtk" = "yes"; then
268         #
269         # Find pkg-config
270         #
271         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
272         if test x$PKG_CONFIG = xno ; then
273             if test "$vi_cv_widechar" = "yes"; then
274                 AC_MSG_ERROR(
275 [*** pkg-config not found. See http://pkgconfig.sourceforge.net])
276             fi
278         else
279             if ! $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then
280                 if test "$vi_cv_widechar" = "yes"; then
281                     AC_MSG_ERROR(
282 [*** pkg-config too old; version 0.5 or better required.])
283                 fi
284                 PKG_CONFIG=no
285             fi
287         fi
288         if test x$PKG_CONFIG = xno ; then
289             PKG_CONFIG=/bin/false
290         fi
292         vi_programs="$vi_programs vi-gtk"
293         vi_ipc=vi-ipc
294         AC_MSG_CHECKING(for gtk+)
295         if $PKG_CONFIG gtk+-2.0 ; then
296               GTKINCS=`$PKG_CONFIG --cflags gtk+-2.0`
297               GTKLIBS=`$PKG_CONFIG --libs gtk+-2.0`
299               AC_MSG_RESULT(ok)
300               AC_DEFINE(HAVE_PANGO, 1, [Define is appropriate pango is available.])
301         else
302             if test "$vi_cv_widechar" = "yes"; then
303                 AC_MSG_ERROR([
304 *** gtk+-2.0 is required. The latest version of gtk
305 *** is always available from ftp://ftp.gtk.org/.
306                 ])
307             else
308                 AM_PATH_GTK(1.2.0)
309                 GTKINCS="$GTK_CFLAGS"
310                 GTKLIBS="$GTK_LIBS $LIBS"
311             fi
312         fi
314         SAVELIBS="$LIBS"
315         LIBS="-lutil $GTKLIBS"
316         AC_CHECK_LIB(nvizvt, zvt_get_ptys,
317                 [vi_cv_zvt="yes"], [vi_cv_zvt="no"])
318         if test "$vi_cv_zvt" = "yes"; then
319                 GTKLIBS="-lnvizvt $LIBS"
320                 AC_DEFINE(HAVE_ZVT, 1, [Define is appropriate zvt is available.])
321         fi
322         LIBS="$SAVELIBS"
323 #       AC_PATH_PROG(vi_cv_gnome_config, gnome-config, no)
324 #       if test "$vi_cv_gnome_config" != "no"; then
325 #               ZVTLIBS=`$vi_cv_gnome_config zvt --libs`
326 #               GTKLIBS="$ZVTLIBS $GTKLIBS"
327 #       fi
330 dnl If the user wants a Motif IPC front-end for nvi, build it.
331 AC_SUBST(MOTIFLIBS)
332 AC_MSG_CHECKING(if --enable-motif option specified)
333 AC_ARG_ENABLE(motif,
334         [  --enable-motif          Build a Motif front-end for vi.],
335         [vi_cv_motif=$enableval], [vi_cv_motif="no"])
336 AC_MSG_RESULT($vi_cv_motif)
337 if test "$vi_cv_motif" = "yes"; then
338         vi_programs="$vi_programs vi-motif"
339         vi_ipc=vi-ipc
341         dnl XXX
342         dnl BSDI's Motif libraries aren't shared.
344         case "$host_os" in
345         bsdi*)  CC=cc;;
346         esac
348         dnl XXX
349         dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
350         dnl -lXext is generally available, the others aren't.
351         dnl
352         dnl XXX
353         dnl Color icons require -lXpm, which may or may not be available,
354         dnl depending on the version of X11.
356         MOTIFLIBS="-lXm -lXt"
357         AC_CHECK_LIB(SM, main,
358             [vi_cv_smlib="yes"], [vi_cv_smlib="no"], "$XLIBS")
359         if test "$vi_cv_smlib" = "yes"; then
360                 MOTIFLIBS="$MOTIFLIBS -lSM"
361         fi
362         AC_CHECK_LIB(ICE, main,
363             [vi_cv_icelib="yes"], [vi_cv_icelib="no"], "$XLIBS")
364         if test "$vi_cv_icelib" = "yes"; then
365                 MOTIFLIBS="$MOTIFLIBS -lICE"
366         fi
367         AC_CHECK_LIB(Xext, main,
368             [vi_cv_xextlib="yes"], [vi_cv_xextlib="no"], "$XLIBS")
369         if test "$vi_cv_xextlib" = "yes"; then
370                 MOTIFLIBS="$MOTIFLIBS -lXext"
371         fi
372         AC_CHECK_LIB(Xpm, main,
373             [vi_cv_xpmlib="yes"], [vi_cv_xpmlib="no"], "$XLIBS")
374         if test "$vi_cv_xpmlib" = "yes"; then
375                 MOTIFLIBS="$MOTIFLIBS -lXpm"
376         fi
377         MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
380 AC_SUBST(IPCOBJS)
381 dnl Check for threads
382 AC_MSG_CHECKING(if --enable-threads option specified)
383 AC_ARG_ENABLE(threads,
384         [  --enable-threads        Turn on thread support.],
385         [vi_cv_threads=$enableval], [vi_cv_threads="no"])
386 AC_MSG_RESULT($vi_cv_threads)
387 if test "$vi_cv_threads" = "yes"; then
388         LIBS="$LIBS -lpthread"
389         AC_CACHE_VAL(vi_cv_have_pthreads, [dnl
390         AC_TRY_LINK([#include <pthread.h>],
391                 [pthread_self()],
392                 [vi_cv_have_pthreads=yes],
393                 [vi_cv_have_pthreads=no])])
394         if test "$vi_cv_have_pthreads" = "no"; then
395                 AC_MSG_ERROR(No threading library found)
396         fi
397         IPCOBJS="pthread.o $IPCOBJS"
398         AC_DEFINE(HAVE_PTHREAD, 1, [Define if using pthread.])
399 else
400         IPCOBJS="nothread.o $IPCOBJS"
403 dnl If the user wants a Perl interpreter in nvi, load it.
404 AC_SUBST(shrpenv)
405 AC_SUBST(perlldflags)
406 AC_SUBST(perllibs)
407 AC_SUBST(vi_cv_perllib)
408 AC_MSG_CHECKING(if --enable-perlinterp option specified)
409 AC_ARG_ENABLE(perlinterp,
410         [  --enable-perlinterp     Include a Perl interpreter in vi.],
411         [vi_cv_perlinterp=$enableval], [vi_cv_perlinterp="no"])
412 AC_MSG_RESULT($vi_cv_perlinterp)
413 if test "$vi_cv_perlinterp" = "yes"; then
414         if test "$vi_cv_path_perl" = no; then
415                 AC_MSG_ERROR([No perl5 utility found.])
416         fi
417         $vi_cv_path_perl -e 'require 5.004' || {
418                 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
419         }
420         if test "$vi_cv_threads" = "yes"; then
421                 useithreads=`$vi_cv_path_perl -MConfig -e 'print $Config{useithreads}'`
422                 if test "X$useithreads" != "Xdefine"; then
423                         AC_MSG_ERROR([vi threading only compatible with perl's ithreads.])
424                 fi
425         fi
427         eval `$vi_cv_path_perl -V:shrpenv`
428         vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
429         perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
430                 -e 'ccflags;perl_inc'`
431         if test "X$perlcppflags" != "X"; then
432                 CPPFLAGS="$perlcppflags $CPPFLAGS"
433         fi
434         perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
435                 -e 'ldopts'`
436         perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
437                 -e 'ccdlflags'`
438         LIBOBJS="perl.o perlxsi.o perlsfio.o $LIBOBJS"
439         AC_DEFINE(HAVE_PERL_INTERP, 1,
440                         [Define if you want to compile in the Perl interpreter.])
441         AC_CACHE_CHECK([whether we need to use perl's setenv], 
442                 vi_cv_perl_setenv, [
443                 AC_TRY_RUN([
444 #include <EXTERN.h>
445 #include <perl.h>
446 #include <XSUB.h>
447 int main(){
448 #if defined(USE_ENVIRON_ARRAY) && !defined(PERL_USE_SAFE_PUTENV)
449 exit(0);
450 #else
451 exit(1);
452 #endif
454                 ], [vi_cv_perl_setenv=yes], [vi_cv_perl_setenv=no])])
455         if test "$vi_cv_perl_setenv" = yes; then
456                 AC_DEFINE(USE_PERL_SETENV, 1,
457                                 [Define when perl's setenv should be used.])
458         fi
461 dnl If the user wants a Tk/Tcl interpreter in nvi, load it.  Make sure that
462 dnl we can find a Tk/Tcl library.
463 AC_MSG_CHECKING(if --enable-tclinterp option specified)
464 AC_ARG_ENABLE(tclinterp,
465         [  --enable-tclinterp      Include a Tk/Tcl interpreter in vi.],
466         [vi_cv_tclinterp=$enableval], [vi_cv_tclinterp="no"])
467 AC_MSG_RESULT($vi_cv_tclinterp)
468 if test "$vi_cv_tclinterp" = "yes"; then
469         AC_MSG_CHECKING([for tclConfig.sh])
470         AC_CACHE_VAL(vi_cv_tclconfig, [
471                 vi_cv_tclconfig=`$srcdir/findconfig`])
472         AC_MSG_RESULT($vi_cv_tclconfig)
473         if test "x$vi_cv_tclconfig" = x; then
474                 AC_MSG_ERROR([No Tcl library found;])
475         fi
476         . $vi_cv_tclconfig
477         LIBOBJS="tcl.o $LIBOBJS"
478         LIBS="$TCL_LIB_SPEC $TCL_LIBS $LIBS"
479         AC_DEFINE(HAVE_TCL_INTERP, 1,
480                         [Define if you want to compile in the Tcl interpreter.])
483 dnl check for curses
484 AC_SUBST(CURSLIBS)
485 AC_SUBST(CURSCPPFLAGS)
486 AC_SUBST(CURSLDFLAGS)
487 AC_SUBST(HAVE_NCURSESW)
489 dnl AC_ARG_WITH(slang,
490 dnl     [  --with-slang[=DIR]     Use S-Lang instead of curses. ],
491 dnl     [
492 dnl     if test "$withval" != yes; then
493 dnl             LDFLAGS="-L${withval}/lib $LDFLAGS"
494 dnl             CPPFLAGS="-I${withval}/include $CPPFLAGS"
495 dnl     fi
496 dnl     AC_DEFINE(USE_SLANG_CURSES)
497 dnl         AC_CHECK_LIB(slang, SLtt_get_terminfo,
498 dnl                 [CURSLIBS="$CURSLIBS -lslang -lm"],
499 dnl                 [AC_MSG_ERROR(unable to compile.  check config.log)], -lm)
500 dnl 
501 dnl     vi_cv_curses=slcurses
502 dnl     ],
503 dnl     [
504         SAVELIBS="$LIBS"
505         SAVELDFLAGS="$LDFLAGS"
506         SAVECPPFLAGS="$CPPFLAGS"
507         AC_ARG_WITH(curses,
508                 [  --with-curses=DIR       Path to curses installation. ])
509         if test "x$with_curses" != "x"; then
510                 CURSLDFLAGS="`echo $with_curses/lib | sed "$LRscript"` $CURSLDFLAGS"
511                 CURSCPPFLAGS="-I$with_curses/include $CURSCPPFLAGS"
512         fi;
513         LDFLAGS="$CURSLDFLAGS $LDFLAGS"
514         CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
516         if test "$vi_cv_widechar" = "yes"; then
517             for vi_cv_curses in ncurses ncursesw curses; do
518                 AC_CHECK_LIB($vi_cv_curses, waddnwstr,[break])
519                 vi_cv_curses=unknown
520             done
521         else 
522             for vi_cv_curses in ncurses ncursesw curses; do
523                 AC_CHECK_LIB($vi_cv_curses, initscr, [break])
524                 vi_cv_curses=unknown
525             done
526         fi
528         if test "$vi_cv_curses" != "unknown"; then
529             CURSHEADER=curses.h
530             if test "$vi_cv_curses" = "ncurses"; then
531                 AC_CHECK_HEADERS(ncurses.h, [CURSHEADER=ncurses.h])
532             fi
533             if test "$vi_cv_curses" = "ncursesw"; then
534                 AC_CHECK_HEADERS(ncursesw/ncurses.h, 
535                         [CURSHEADER=ncursesw/ncurses.h])
536             fi
537             vi_programs="vi $vi_programs"
538             CURSLIBS="-l$vi_cv_curses"
539         else
540             AC_MSG_WARN([*** No suitable curses library found.])
541             if test "$vi_programs"X = X; then
542                 AC_MSG_ERROR([No executable to build.])
543             fi
544         fi
546 dnl Check for the termcap/termlib library.  These two checks must occur in the
547 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
548 dnl On Solaris curses==termlib, but different versions of curses
549 dnl can be used. Avoid loading termlib is curses has tgetent.
550 AC_CHECK_LIB($vi_cv_curses, tgetent,
551         [vi_cv_curses_tgetent=yes], [vi_cv_curses_tgetent=no])
552 if test "$vi_cv_curses_tgetent" = no; then
553         AC_CHECK_LIB(termlib, tgetent,
554                 [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
555         if test "$vi_cv_termlib" = no; then
556                 AC_CHECK_LIB(termcap, tgetent,
557                         [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
558         fi
560 if test "$vi_cv_termlib" != no; then
561         CURSLIBS="$CURSLIBS $vi_cv_termlib"
564         LIBS="$SAVELIBS"
565         LDFLAGS="$SAVELDFLAGS"
566         CPPFLAGS="$SAVECPPFLAGS"
567 dnl     ])
569 dnl Checks for header files.
570 AC_MSG_CHECKING(for sys/mman.h)
571 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
572 AC_TRY_CPP([#include <sys/mman.h>],
573         [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
574 if test "$vi_cv_include_sys_mman" = yes; then
575         AC_DEFINE(HAVE_SYS_MMAN_H, 1, [Define if you have <sys/mman.h>])
577 AC_MSG_RESULT($vi_cv_include_sys_mman)
579 AC_MSG_CHECKING(for sys/select.h)
580 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
581 AC_TRY_CPP([#include <sys/select.h>],
582         [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
583 if test "$vi_cv_include_sys_select" = yes; then
584         AC_DEFINE(HAVE_SYS_SELECT_H, 1, [Define if you have <sys/select.h])
586 AC_MSG_RESULT($vi_cv_include_sys_select)
588 dnl Checks for typedefs, structures, and compiler characteristics.
589 AC_CHECK_TYPE(ssize_t, int)
590 AC_C_BIGENDIAN
591 AC_C_CONST
592 AC_STRUCT_ST_BLKSIZE
593 AC_TYPE_MODE_T
594 AC_TYPE_OFF_T
595 AC_TYPE_PID_T
596 AC_TYPE_SIZE_T
597 AC_STRUCT_TM
599 AC_CHECK_HEADER(sys/cdefs.h, [],
600         [AC_CONFIG_FILES([sys/cdefs.h:../db.1.85/PORT/include/cdefs.h])])
602 dnl Checks for library functions.
603 VI_CV_REPLACE_FUNCS(bsearch gethostname memchr memset)
604 VI_CV_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
605 VI_CV_REPLACE_FUNCS(snprintf vsnprintf)
607 AC_CHECK_FUNCS(select)
608 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
609 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
610 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
612 AC_FUNC_MMAP
613 AC_FUNC_VFORK
615 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
616 if test "$need_env" = yes; then
617         LIBOBJS="env.o $LIBOBJS"
620 dnl If we need strsep, add it and define it so we get a prototype.
621 if test "$need_strsep" = yes; then
622         LIBOBJS="strsep.o $LIBOBJS"
625 dnl Check for fcntl/flock
626 dnl Use flock preferentially, since it has cleaner semantics and won't
627 dnl hang up the editor.
628 dnl XXX
629 dnl Ultrix has a broken fcntl, but a working flock.
630 dnl IRIX and DGUX have a broken flock, but working fcntl.
631 AC_MSG_CHECKING(for fcntl/flock)
632 AC_CACHE_VAL(vi_cv_lock, [dnl
633         vi_cv_lock=none
634         case "$host_os" in
635         dgux*);;
636         irix*);;
637         *)
638                 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
639                     [vi_cv_lock=flock]);;
640         esac
641         if test "$vi_cv_lock" = none; then
642                 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
643                     [vi_cv_lock=fcntl])
644         fi])
646 if test "$vi_cv_lock" = flock; then
647         AC_DEFINE(HAVE_LOCK_FLOCK, 1,
648                         [Define if you have flock(2) style locking.])
650 if test "$vi_cv_lock" = fcntl; then
651         AC_DEFINE(HAVE_LOCK_FCNTL, 1,
652                         [Define if you have fcntl(2) style locking.])
654 AC_MSG_RESULT($vi_cv_lock)
656 dnl Check for ftruncate/chsize
657 AC_MSG_CHECKING(for ftruncate/chsize)
658 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
659 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
660         [vi_cv_ftruncate=ftruncate],
661 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
662         [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
663 if test "$vi_cv_ftruncate" = ftruncate; then
664         AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE, 1,
665                         [Define if you have the ftruncate(2) system call.])
667 if test "$vi_cv_ftruncate" = chsize; then
668         AC_DEFINE(HAVE_FTRUNCATE_CHSIZE, 1,
669                         [Define if you have the chsize(2) system call.])
671 if test "$vi_cv_ftruncate" = no; then
672         AC_MSG_ERROR([No file truncation system call.])
674 AC_MSG_RESULT($vi_cv_ftruncate)
676 CSAVELIBS="$LIBS"
677 CSAVELDFLAGS="$LDFLAGS"
678 CSAVECPPFLAGS="$CPPFLAGS"
679 LIBS="$CURSLIBS $LIBS"
680 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
681 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
682 dnl Check for the tigetstr/tigetnum functions.
683 AC_MSG_CHECKING(for tigetstr/tigetnum)
684 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
685 AC_TRY_LINK([#include <$CURSHEADER>], [tigetstr(0);],
686         [vi_cv_have_curses_tigetstr=yes],
687         [vi_cv_have_curses_tigetstr=no])])
688 if test "$vi_cv_have_curses_tigetstr" = yes; then
689         AC_DEFINE(HAVE_CURSES_TIGETSTR, 1,
690                 [Define if you have the curses(3) tigetstr/tigetnum functions.])
692 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
694 dnl Check for potentially missing curses functions in system or user-specified
695 dnl libraries.  We also have to guess at whether the specified library is a
696 dnl BSD or System V style curses.  Use the newterm function, all System V
697 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
698 if test "$vi_cv_curses" = "bundled curses"; then
699         AC_DEFINE(HAVE_BSD_CURSES, 1,
700                         [Define if you have a BSD version of curses.])
701         AC_DEFINE(HAVE_CURSES_WADDNSTR, 1,
702                         [Define if you have the curses(3) waddnstr function.])
703         AC_DEFINE(HAVE_CURSES_IDLOK, 1,
704                         [Define if you have the curses(3) idlok function.])
705 else
706         dnl Check for the waddnstr function.
707         AC_MSG_CHECKING(for waddnstr)
708         AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
709         AC_TRY_LINK([#include <$CURSHEADER>], [waddnstr(stdscr, 0, 0);],
710                 [vi_cv_have_curses_waddnstr=yes],
711                 [vi_cv_have_curses_waddnstr=no])])
712         if test "$vi_cv_have_curses_waddnstr" = yes; then
713                 AC_DEFINE(HAVE_CURSES_WADDNSTR, 1,
714                         [Define if you have the curses(3) waddnstr function.])
715         fi
716         AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
718         dnl Check for the beep function.
719         AC_MSG_CHECKING(for beep)
720         AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
721         AC_TRY_LINK([#include <$CURSHEADER>], [beep();],
722                 [vi_cv_have_curses_beep=yes],
723                 [vi_cv_have_curses_beep=no])])
724         if test "$vi_cv_have_curses_beep" = yes; then
725                 AC_DEFINE(HAVE_CURSES_BEEP, 1,
726                         [Define if you have the curses(3) beep function.])
727         fi
728         AC_MSG_RESULT($vi_cv_have_curses_beep)
730         dnl Check for the flash function.
731         AC_MSG_CHECKING(for flash)
732         AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
733         AC_TRY_LINK([#include <$CURSHEADER>], [flash();],
734                 [vi_cv_have_curses_flash=yes],
735                 [vi_cv_have_curses_flash=no])])
736         if test "$vi_cv_have_curses_flash" = yes; then
737                 AC_DEFINE(HAVE_CURSES_FLASH, 1,
738                         [Define if you have the curses(3) flash function.])
739         fi
740         AC_MSG_RESULT($vi_cv_have_curses_flash)
742         dnl Check for the idlok function.
743         AC_MSG_CHECKING(for idlok)
744         AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
745         AC_TRY_LINK([#include <$CURSHEADER>], [idlok(0, 0);],
746                 [vi_cv_have_curses_idlok=yes],
747                 [vi_cv_have_curses_idlok=no])])
748         if test "$vi_cv_have_curses_idlok" = yes; then
749                 AC_DEFINE(HAVE_CURSES_IDLOK, 1,
750                         [Define if you have the curses(3) idlok function.])
751         fi
752         AC_MSG_RESULT($vi_cv_have_curses_idlok)
754         dnl Check for the keypad function.
755         AC_MSG_CHECKING(for keypad)
756         AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
757         AC_TRY_LINK([#include <$CURSHEADER>], [keypad(0, 0);],
758                 [vi_cv_have_curses_keypad=yes],
759                 [vi_cv_have_curses_keypad=no])])
760         if test "$vi_cv_have_curses_keypad" = yes; then
761                 AC_DEFINE(HAVE_CURSES_KEYPAD, 1,
762                         [Define if you have the curses(3) keypad function.])
763         fi
764         AC_MSG_RESULT($vi_cv_have_curses_keypad)
766         dnl Check for the newterm function.
767         AC_MSG_CHECKING(for newterm)
768         AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
769         AC_TRY_LINK([#include <$CURSHEADER>], [newterm(0, 0, 0);],
770                 [vi_cv_have_curses_newterm=yes],
771                 [vi_cv_have_curses_newterm=no])])
772         if test "$vi_cv_have_curses_newterm" = yes; then
773                 AC_DEFINE(HAVE_CURSES_NEWTERM, 1,
774                         [Define if you have the curses(3) newterm function.])
775         fi
776         AC_MSG_RESULT($vi_cv_have_curses_newterm)
778         if test "$vi_cv_have_curses_newterm" = no; then
779                 AC_DEFINE(HAVE_BSD_CURSES, 1,
780                         [Define if you have a BSD version of curses.])
781         fi
784 dnl Check for the setupterm function.  We make this check regardless of
785 dnl using the system library, because it may be part of the underlying
786 dnl termcap/termlib support, and we want to use the local one.
787 AC_MSG_CHECKING(for setupterm)
788 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
789 AC_TRY_LINK([#include <$CURSHEADER>], [setupterm(0, 0, 0);],
790         [vi_cv_have_curses_setupterm=yes],
791         [vi_cv_have_curses_setupterm=no])])
792 if test "$vi_cv_have_curses_setupterm" = yes; then
793         AC_DEFINE(HAVE_CURSES_SETUPTERM, 1,
794                         [Define if you have the curses(3) setupterm function.])
796 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
797 LIBS="$CSAVELIBS"
798 LDFLAGS="$CSAVELDFLAGS"
799 CPPFLAGS="$CSAVECPPFLAGS"
801 dnl Some moron decided to drop off an argument from the gettimeofday call,
802 dnl without changing the name.
803 AC_MSG_CHECKING(for broken gettimeofday system call)
804 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
805 AC_TRY_LINK([#include <sys/types.h>
806 #include <sys/time.h>], [gettimeofday(0, 0);],
807         [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
808 if test "$vi_cv_gettimeofday" = broken; then
809         AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY, 1,
810                 [Define if you have a System V-style (broken) gettimeofday.])
812 AC_MSG_RESULT($vi_cv_gettimeofday)
814 dnl Check for which version of openpty to use, System V or Berkeley.
815 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
816 AC_CHECK_HEADER(sys/stropts.h,
817         [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
818 if test "$vi_cv_sys5_pty" = yes; then
819         AC_DEFINE(HAVE_SYS5_PTY, 1,
820                 [Define if you have the System V style pty calls.])
822 AC_MSG_CHECKING(for System V pty calls)
823 AC_MSG_RESULT($vi_cv_sys5_pty)
825 dnl Check for the revoke system call.
826 AC_MSG_CHECKING(for revoke system call)
827 AC_CACHE_VAL(vi_cv_revoke, [dnl
828 AC_TRY_LINK(, [revoke("a");],
829         [vi_cv_revoke=yes], [vi_cv_revoke=no])])
830 if test "$vi_cv_revoke" = yes; then
831         AC_DEFINE(HAVE_REVOKE, 1,
832                 [Define if you have the Berkeley style revoke(2) system call.])
834 AC_MSG_RESULT($vi_cv_revoke)
836 dnl Some versions of sprintf return a pointer to the first argument instead
837 dnl of a character count.  We assume that the return value of snprintf and
838 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
839 AC_MSG_CHECKING(for int type sprintf return value)
840 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
841 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
842         [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
843 if test "$vi_cv_sprintf_count" = no; then
844         AC_DEFINE(SPRINTF_RET_CHARPNT, 1,
845                 [Define if your sprintf returns a pointer, not a length.])
847 AC_MSG_RESULT($vi_cv_sprintf_count)
850 dnl Check for the standard shorthand types.
851 AC_SUBST(u_char_decl)
852 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
853 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
854         [vi_cv_uchar=yes], [vi_cv_uchar=no])])
855 if test "$vi_cv_uchar" = no; then
856         u_char_decl="typedef unsigned char u_char;"
859 AC_SUBST(u_short_decl)
860 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
861 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
862         [vi_cv_ushort=yes], [vi_cv_ushort=no])])
863 if test "$vi_cv_ushort" = no; then
864         u_short_decl="typedef unsigned short u_short;"
867 AC_SUBST(u_int_decl)
868 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
869 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
870         [vi_cv_uint=yes], [vi_cv_uint=no])])
871 if test "$vi_cv_uint" = no; then
872         u_int_decl="typedef unsigned int u_int;"
875 AC_SUBST(u_long_decl)
876 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
877 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
878         [vi_cv_ulong=yes], [vi_cv_ulong=no])])
879 if test "$vi_cv_ulong" = no; then
880         u_long_decl="typedef unsigned long u_long;"
883 dnl DB/Vi use specific integer sizes.
884 AC_SUBST(u_int8_decl)
885 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
886 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
887         [vi_cv_uint8=yes],
888         AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
889             [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
890 if test "$vi_cv_uint8" = no; then
891         AC_MSG_ERROR(No unsigned 8-bit integral type.)
893 if test "$vi_cv_uint8" != yes; then
894         u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
897 AC_SUBST(u_int16_decl)
898 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
899 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
900         [vi_cv_uint16=yes],
901 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
902         [vi_cv_uint16="unsigned short"],
903 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
904         [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
905 if test "$vi_cv_uint16" = no; then
906         AC_MSG_ERROR([No unsigned 16-bit integral type.])
908 if test "$vi_cv_uint16" != yes; then
909         u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
912 AC_SUBST(int16_decl)
913 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
914 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
915         [vi_cv_int16=yes],
916 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
917         [vi_cv_int16="short"],
918 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
919         [vi_cv_int16="int"], [vi_cv_int16=no])))])
920 if test "$vi_cv_int16" = no; then
921         AC_MSG_ERROR([No signed 16-bit integral type.])
923 if test "$vi_cv_int16" != yes; then
924         int16_decl="typedef $vi_cv_int16 int16_t;"
927 AC_SUBST(u_int32_decl)
928 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
929 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
930         [vi_cv_uint32=yes],
931 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
932         [vi_cv_uint32="unsigned int"],
933 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
934         [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
935 if test "$vi_cv_uint32" = no; then
936         AC_MSG_ERROR([No unsigned 32-bit integral type.])
938 if test "$vi_cv_uint32" != yes; then
939         u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
942 AC_SUBST(int32_decl)
943 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
944 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
945         [vi_cv_int32=yes],
946 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
947         [vi_cv_int32="int"],
948 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
949         [vi_cv_int32="long"], [vi_cv_int32=no])))])
950 if test "$vi_cv_int32" = no; then
951         AC_MSG_ERROR([No signed 32-bit integral type.])
953 if test "$vi_cv_int32" != yes; then
954         int32_decl="typedef $vi_cv_int32 int32_t;"
957 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
958 [AC_TRY_COMPILE([#include <stdio.h>
959 int fprintf ();
960 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
962 AC_SUBST(NEED_FPRINTF_PROTO)
963 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
964 [AC_TRY_COMPILE([ #include <stdio.h>
965 typedef int     (*funcPtr)();
966 ],[funcPtr ptr = (funcPtr) fprintf;], 
967 vi_cv_proto_fprintf=no, 
968 [vi_cv_proto_fprintf=yes])])
969 if test "$vi_cv_proto_fprintf" = yes; then
970         AC_DEFINE(NEED_FPRINTF_PROTO, 1,
971                 [Define when fprintf prototype not in an obvious place.])
974 AC_ARG_WITH(db_type,
975         [  --with-db=bundled|system Which db to use. ])
977 dnl Check for DB 3
978 AC_ARG_WITH(db_prefix,
979         [  --with-db-prefix=PFX    Path to db installation. ])
981 AC_SUBST(DB_LDFLAGS)
982 AC_SUBST(DB_CPPFLAGS)
983 if test "x$with_db_prefix" != "x"; then
984         DB_LDFLAGS="-L$with_db_prefix/lib $LDFLAGS"
985         DB_CPPFLAGS="-I$with_db_prefix/include $CPPFLAGS"
986         with_db_type="system"
989 AC_MSG_CHECKING(which db to use)
990 case "$with_db_type" in
991 "system")
992         ;;
994         with_db_type="bundled"
995         ;;
996 esac
997 AC_MSG_RESULT($with_db_type)
998 AM_CONDITIONAL(BUNDLED_DB, test $with_db_type = bundled)
1000 case "$with_db_type" in
1001 bundled)
1002         AC_DEFINE(USE_BUNDLED_DB, 1, [Define when using bundled db.])
1003         LIBOBJS="log1.o $LIBOBJS"
1004         ;;
1005 system)
1006         SAVELDFLAGS="$LDFLAGS"
1007         SAVELIBS="$LIBS"
1009         if test "x$with_db_prefix" != "x"; then
1010                 LDFLAGS="-L$with_db_prefix/lib $LDFLAGS"
1011                 CPPFLAGS="-I$with_db_prefix/include $CPPFLAGS"
1012                 with_db_type="system"
1013         fi
1015         LIBS="$LIBS -ldb"
1016         AC_TRY_LINK([#include <db.h>],
1017                 [db_create(NULL,NULL,0)],
1018                 [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
1019         if test "$vi_cv_dbfatal" = "yes"; then
1020                 AC_MSG_ERROR([Need DB 3.])
1021         fi
1023         LIBS="$SAVELIBS"
1024         LDFLAGS="$SAVELDFLAGS"
1026         AC_SUBST(dl_src)
1027         AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
1028         AC_ARG_ENABLE(dynamic-loading,
1029                 [  --enable-dynamic-loading Load DB 3 dynamically.],
1030                 [vi_cv_dl=$enableval], [vi_cv_dl="no"])
1031         AC_MSG_RESULT($vi_cv_dl)
1032         if test "$vi_cv_dl" = yes; then
1033                 AC_CHECK_LIB(dl, dlopen,
1034                         [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
1035                 if test "$vi_cv_dlfatal" = "yes"; then
1036                         AC_MSG_ERROR([Need dl to support dynamic loading.])
1037                 fi
1038                 OLDPATH="$PATH"
1040                 PATH="$with_db_prefix/lib:/usr/lib:/lib"
1041                 AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
1042                 if test "$vi_cv_path_db3" = no; then
1043                         AC_MSG_ERROR([Path of libdb-3.so not found.])
1044                 fi
1045                 PATH="$OLDPATH"
1047                 AC_DEFINE(USE_DYNAMIC_LOADING, 1,
1048                                 [Define when dynamically loading DB 3.])
1049                 LIBOBJS="dldb.o $LIBOBJS"
1050                 dl_src=../common/dldb.c
1051                 LIBS="-ldl $LIBS"
1052         else
1053                 LIBS="-ldb $LIBS"
1054                 if test "X$with_db_prefix" != "X"; then
1055                         LDFLAGS="`echo $with_db_prefix/lib | sed "$LRscript"` $LDFLAGS"
1056                 fi
1057         fi
1059         AC_ARG_WITH(db_build,
1060                 [  --with-db-build=prefix  Path to db build. ])
1061         if test "x$with_db_build" != "x"; then
1062                 vi_cv_dbsrc=`$AWK '/^srcdir/ {gsub("srcdir[[ \t]]*=","");print $1}' \
1063                              $with_db_build/Makefile`
1064                 case $with_db_build in
1065                 *[[\\/]]);;
1066                 *)
1067                     with_db_build="$with_db_build/";;
1068                 esac
1069                 case $vi_cv_dbsrc in
1070                 [[\\/]]*);;
1071                 *)
1072                     vi_cv_dbsrc="$with_db_build$vi_cv_dbsrc";;
1073                 esac
1074         fi;
1076         vi_cv_db4="no"
1077         AC_ARG_ENABLE(log4,
1078                 [  --enable-db4-logging    Enable experimental/broken db4 logging.],
1079                 [
1080                 AC_MSG_CHECKING(for DB 4)
1081                 AC_EGREP_CPP([^4],
1082                         [#include <db.h>
1083                 DB_VERSION_MAJOR],
1084                         [vi_cv_db4="yes"], [vi_cv_db4="no"])
1085                 AC_MSG_RESULT($vi_cv_db4)
1086                 ])
1087         if test "$vi_cv_db4" = "yes"; then
1088                 DB_CPPFLAGS="-I$vi_cv_dbsrc/include $DB_CPPFLAGS"
1089                 DB_CPPFLAGS="-I$vi_cv_dbsrc/include_auto $DB_CPPFLAGS"
1090                 DB_CPPFLAGS="-I$with_db_build $DB_CPPFLAGS"
1091                 AC_DEFINE(USE_DB4_LOGGING, 1, [Define when using db4 logging.])
1092                 LIBOBJS="log4.o vi_auto.o vi_rec.o $LIBOBJS"
1093         else
1094                 LIBOBJS="log.o $LIBOBJS"
1095         fi
1096         ;;
1097 esac
1099 dnl We compile in nvi's RE routines unless the user specifies otherwise.
1100 AC_MSG_CHECKING(if --disable-re option specified)
1101 AC_ARG_ENABLE(re,
1102         [  --disable-re            DON'T use the nvi-provided RE routines.],
1103         [if test "$enable_re" = "yes"; then
1104                 vi_cv_re_lib="bundled RE"
1105         else
1106                 vi_cv_re_lib="other RE"
1107         fi],[vi_cv_re_lib="bundled RE"])
1108 AC_MSG_RESULT($vi_cv_re_lib)
1109 case "$vi_cv_re_lib" in
1110 "bundled RE")
1111         CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
1112         LIBOBJS="regcomp.o regerror.o regexec.o regfree.o $LIBOBJS";;
1113 "other RE")
1114         ;;
1115 esac
1117 AC_OUTPUT(Makefile port.h:port.h.in compat.h:port.h.in
1118     pathnames.h:pathnames.h.in recover:recover.in)