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