Detect curses via pkg-config
[nvi.git] / dist / configure.ac
blob7b056ea90858892017b36f78015d7b4fe2b67585
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 pkg-config
211 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
212 if test x$PKG_CONFIG = xno ; then
213     PKG_CONFIG=/bin/false
216 dnl Check for programs used for installation
217 AC_PROG_AWK
218 AC_PATH_PROG(vi_cv_path_ar, ar, missing_ar)
219 AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
220 AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
221 AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
222 AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
223 AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
224 AC_PATH_PROG(vi_cv_path_ranlib, ranlib, missing_ranlib)
225 AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
227 dnl Checks for libraries.
228 dnl Find the X libraries and includes.
229 AC_PATH_X
230 AC_SUBST(XINCS)
231 if test "$no_x" != yes; then
232         if test "X$x_libraries" != "X"; then
233                 XLIBS="`echo $x_libraries | sed "$LRscript"` $XLIBS"
234         fi
235         XLIBS="$XLIBS -lX11"
236         if test "X$x_includes" != "X"; then
237                 XINCS="-I$x_includes"
238         fi
241 AC_DEFUN([VI_CV_REPLACE_FUNCS],
242 [AC_FOREACH([AC_Func], [$1], [])dnl
243 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
246 dnl Check if the user wants widechar support.
247 AC_MSG_CHECKING(if --enable-widechar option specified)
248 AC_ARG_ENABLE(widechar,
249         [  --enable-widechar       Build a wide char aware vi.],
250         [vi_cv_widechar=$enableval], [vi_cv_widechar="no"])
251 if test "$vi_cv_widechar" = "yes"; then
252         AC_DEFINE(USE_WIDECHAR, 1, [Define when using wide characters.])
254 AC_MSG_RESULT($vi_cv_widechar)
256 dnl Check whether we can use iconv
257 AC_CHECK_HEADER(langinfo.h, [
258         AC_CHECK_HEADER(iconv.h, [
259                 AC_DEFINE(USE_ICONV, 1, [Define when iconv can be used.])
260                 VI_CV_REPLACE_FUNCS(iswblank)
261         ])
264 dnl If the user wants a Gtk IPC front-end for nvi, build it.
265 AC_SUBST(vi_programs)
266 AC_SUBST(vi_ipc)
267 AC_SUBST(GTKLIBS)
268 AC_SUBST(GTKINCS)
269 AC_MSG_CHECKING(if --enable-gtk option specified)
270 AC_ARG_ENABLE(gtk,
271         [  --enable-gtk            Build a Gtk front-end for vi.],
272         [vi_cv_gtk=$enableval], [vi_cv_gtk="no"])
273 AC_MSG_RESULT($vi_cv_gtk)
274 if test "$vi_cv_gtk" = "yes"; then
275         if $PKG_CONFIG ; then
276             if test "$vi_cv_widechar" = "yes"; then
277                 AC_MSG_ERROR(
278 [*** pkg-config not found. See http://pkgconfig.sourceforge.net])
279             fi
281         else
282             if ! $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then
283                 if test "$vi_cv_widechar" = "yes"; then
284                     AC_MSG_ERROR(
285 [*** pkg-config too old; version 0.5 or better required.])
286                 fi
287                 PKG_CONFIG=/bin/false
288             fi
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, 1, [Define is appropriate pango is available.])
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, 1, [Define is appropriate zvt is available.])
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, 1, [Define if using 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, 1,
439                         [Define if you want to compile in the Perl interpreter.])
440         AC_CACHE_CHECK([whether we need to use perl's setenv],
441                 vi_cv_perl_setenv, [
442                 AC_TRY_RUN([
443 #include <EXTERN.h>
444 #include <perl.h>
445 #include <XSUB.h>
446 int main(){
447 #if defined(USE_ENVIRON_ARRAY) && !defined(PERL_USE_SAFE_PUTENV)
448 exit(0);
449 #else
450 exit(1);
451 #endif
453                 ], [vi_cv_perl_setenv=yes], [vi_cv_perl_setenv=no])])
454         if test "$vi_cv_perl_setenv" = yes; then
455                 AC_DEFINE(USE_PERL_SETENV, 1,
456                                 [Define when perl's setenv should be used.])
457         fi
460 dnl If the user wants a Tk/Tcl interpreter in nvi, load it.  Make sure that
461 dnl we can find a Tk/Tcl library.
462 AC_MSG_CHECKING(if --enable-tclinterp option specified)
463 AC_ARG_ENABLE(tclinterp,
464         [  --enable-tclinterp      Include a Tk/Tcl interpreter in vi.],
465         [vi_cv_tclinterp=$enableval], [vi_cv_tclinterp="no"])
466 AC_MSG_RESULT($vi_cv_tclinterp)
467 if test "$vi_cv_tclinterp" = "yes"; then
468         AC_MSG_CHECKING([for tclConfig.sh])
469         AC_CACHE_VAL(vi_cv_tclconfig, [
470                 vi_cv_tclconfig=`$srcdir/findconfig`])
471         AC_MSG_RESULT($vi_cv_tclconfig)
472         if test "x$vi_cv_tclconfig" = x; then
473                 AC_MSG_ERROR([No Tcl library found;])
474         fi
475         . $vi_cv_tclconfig
476         LIBOBJS="tcl.o $LIBOBJS"
477         LIBS="$TCL_LIB_SPEC $TCL_LIBS $LIBS"
478         AC_DEFINE(HAVE_TCL_INTERP, 1,
479                         [Define if you want to compile in the Tcl interpreter.])
482 dnl check for curses
483 AC_SUBST(CURSLIBS)
484 AC_SUBST(CURSCPPFLAGS)
485 AC_SUBST(CURSLDFLAGS)
486 AC_SUBST(HAVE_NCURSESW)
488 dnl AC_ARG_WITH(slang,
489 dnl     [  --with-slang[=DIR]     Use S-Lang instead of curses. ],
490 dnl     [
491 dnl     if test "$withval" != yes; then
492 dnl             LDFLAGS="-L${withval}/lib $LDFLAGS"
493 dnl             CPPFLAGS="-I${withval}/include $CPPFLAGS"
494 dnl     fi
495 dnl     AC_DEFINE(USE_SLANG_CURSES)
496 dnl         AC_CHECK_LIB(slang, SLtt_get_terminfo,
497 dnl                 [CURSLIBS="$CURSLIBS -lslang -lm"],
498 dnl                 [AC_MSG_ERROR(unable to compile.  check config.log)], -lm)
500 dnl     vi_cv_curses=slcurses
501 dnl     ],
502 dnl     [
503         SAVELIBS="$LIBS"
504         SAVELDFLAGS="$LDFLAGS"
505         SAVECPPFLAGS="$CPPFLAGS"
506         AC_ARG_WITH(curses,
507                 [  --with-curses=DIR       Path to curses installation. ])
508         if test "x$with_curses" != "x"; then
509                 CURSLDFLAGS="`echo $with_curses/lib | sed "$LRscript"` $CURSLDFLAGS"
510                 CURSCPPFLAGS="-I$with_curses/include $CURSCPPFLAGS"
511         else
512             if test "$vi_cv_widechar" = "yes"; then
513                 CURSCPPFLAGS=$($PKG_CONFIG --cflags ncursesw)
514                 CURLSLIBS=$($PKG_CONFIG --libs ncursesw)
515             else
516                 CURSCPPFLAGS=$($PKG_CONFIG --cflags ncurses)
517                 CURLSLIBS=$($PKG_CONFIG --libs ncurses)
518             fi
519             if test $? != 0; then
520                 vi_cv_curses=unknown
521             else
522                 vi_programs="vi $vi_programs"
523             fi
524         fi
525         LDFLAGS="$CURSLDFLAGS $LDFLAGS"
526         CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
528         if test "$vi_cv_curses" != "unknown"; then
529             if test "$vi_cv_widechar" = "yes"; then
530                 for vi_cv_curses in ncurses ncursesw curses; do
531                     AC_CHECK_LIB($vi_cv_curses, waddnwstr,[break])
532                     vi_cv_curses=unknown
533                 done
534             else
535                 for vi_cv_curses in ncurses ncursesw curses; do
536                     AC_CHECK_LIB($vi_cv_curses, initscr, [break])
537                     vi_cv_curses=unknown
538                 done
539             fi
541             if test "$vi_cv_curses" != "unknown"; then
542                 CURSHEADER=curses.h
543                 if test "$vi_cv_curses" = "ncurses"; then
544                     AC_CHECK_HEADERS(ncurses.h, [CURSHEADER=ncurses.h])
545                 fi
546                 if test "$vi_cv_curses" = "ncursesw"; then
547                     AC_CHECK_HEADERS(ncursesw/ncurses.h,
548                         [CURSHEADER=ncursesw/ncurses.h])
549                 fi
550                 vi_programs="vi $vi_programs"
551                 CURSLIBS="-l$vi_cv_curses"
552             else
553                 AC_MSG_WARN([*** No suitable curses library found.])
554                 if test "$vi_programs"X = X; then
555                     AC_MSG_ERROR([No executable to build.])
556                 fi
557             fi
558         fi
560 dnl Check for the termcap/termlib library.  These two checks must occur in the
561 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
562 dnl On Solaris curses==termlib, but different versions of curses
563 dnl can be used. Avoid loading termlib is curses has tgetent.
564 AC_CHECK_LIB($vi_cv_curses, tgetent,
565         [vi_cv_curses_tgetent=yes], [vi_cv_curses_tgetent=no])
566 if test "$vi_cv_curses_tgetent" = no; then
567         AC_CHECK_LIB(termlib, tgetent,
568                 [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
569         if test "$vi_cv_termlib" = no; then
570                 AC_CHECK_LIB(termcap, tgetent,
571                         [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
572         fi
574 if test "$vi_cv_termlib" != no; then
575         CURSLIBS="$CURSLIBS $vi_cv_termlib"
578         LIBS="$SAVELIBS"
579         LDFLAGS="$SAVELDFLAGS"
580         CPPFLAGS="$SAVECPPFLAGS"
581 dnl     ])
583 dnl Checks for header files.
584 AC_MSG_CHECKING(for sys/mman.h)
585 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
586 AC_TRY_CPP([#include <sys/mman.h>],
587         [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
588 if test "$vi_cv_include_sys_mman" = yes; then
589         AC_DEFINE(HAVE_SYS_MMAN_H, 1, [Define if you have <sys/mman.h>])
591 AC_MSG_RESULT($vi_cv_include_sys_mman)
593 AC_MSG_CHECKING(for sys/select.h)
594 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
595 AC_TRY_CPP([#include <sys/select.h>],
596         [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
597 if test "$vi_cv_include_sys_select" = yes; then
598         AC_DEFINE(HAVE_SYS_SELECT_H, 1, [Define if you have <sys/select.h])
600 AC_MSG_RESULT($vi_cv_include_sys_select)
602 dnl Checks for typedefs, structures, and compiler characteristics.
603 AC_CHECK_TYPE(ssize_t, int)
604 AC_C_BIGENDIAN
605 AC_C_CONST
606 AC_STRUCT_ST_BLKSIZE
607 AC_TYPE_MODE_T
608 AC_TYPE_OFF_T
609 AC_TYPE_PID_T
610 AC_TYPE_SIZE_T
611 AC_STRUCT_TM
613 AC_CHECK_HEADER(sys/cdefs.h, [],
614         [AC_CONFIG_FILES([sys/cdefs.h:../db.1.85/PORT/include/cdefs.h])])
616 dnl Checks for library functions.
617 VI_CV_REPLACE_FUNCS(bsearch gethostname memchr memset)
618 VI_CV_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
619 VI_CV_REPLACE_FUNCS(snprintf vsnprintf)
621 AC_CHECK_FUNCS(select)
622 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
623 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
624 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
626 AC_FUNC_MMAP
627 AC_FUNC_VFORK
629 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
630 if test "$need_env" = yes; then
631         LIBOBJS="env.o $LIBOBJS"
634 dnl If we need strsep, add it and define it so we get a prototype.
635 if test "$need_strsep" = yes; then
636         LIBOBJS="strsep.o $LIBOBJS"
639 dnl Check for fcntl/flock
640 dnl Use flock preferentially, since it has cleaner semantics and won't
641 dnl hang up the editor.
642 dnl XXX
643 dnl Ultrix has a broken fcntl, but a working flock.
644 dnl IRIX and DGUX have a broken flock, but working fcntl.
645 AC_MSG_CHECKING(for fcntl/flock)
646 AC_CACHE_VAL(vi_cv_lock, [dnl
647         vi_cv_lock=none
648         case "$host_os" in
649         dgux*);;
650         irix*);;
651         *)
652                 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
653                     [vi_cv_lock=flock]);;
654         esac
655         if test "$vi_cv_lock" = none; then
656                 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
657                     [vi_cv_lock=fcntl])
658         fi])
660 if test "$vi_cv_lock" = flock; then
661         AC_DEFINE(HAVE_LOCK_FLOCK, 1,
662                         [Define if you have flock(2) style locking.])
664 if test "$vi_cv_lock" = fcntl; then
665         AC_DEFINE(HAVE_LOCK_FCNTL, 1,
666                         [Define if you have fcntl(2) style locking.])
668 AC_MSG_RESULT($vi_cv_lock)
670 dnl Check for ftruncate/chsize
671 AC_MSG_CHECKING(for ftruncate/chsize)
672 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
673 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
674         [vi_cv_ftruncate=ftruncate],
675 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
676         [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
677 if test "$vi_cv_ftruncate" = ftruncate; then
678         AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE, 1,
679                         [Define if you have the ftruncate(2) system call.])
681 if test "$vi_cv_ftruncate" = chsize; then
682         AC_DEFINE(HAVE_FTRUNCATE_CHSIZE, 1,
683                         [Define if you have the chsize(2) system call.])
685 if test "$vi_cv_ftruncate" = no; then
686         AC_MSG_ERROR([No file truncation system call.])
688 AC_MSG_RESULT($vi_cv_ftruncate)
690 CSAVELIBS="$LIBS"
691 CSAVELDFLAGS="$LDFLAGS"
692 CSAVECPPFLAGS="$CPPFLAGS"
693 LIBS="$CURSLIBS $LIBS"
694 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
695 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
696 dnl Check for the tigetstr/tigetnum functions.
697 AC_MSG_CHECKING(for tigetstr/tigetnum)
698 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
699 AC_TRY_LINK([#include <$CURSHEADER>], [tigetstr(0);],
700         [vi_cv_have_curses_tigetstr=yes],
701         [vi_cv_have_curses_tigetstr=no])])
702 if test "$vi_cv_have_curses_tigetstr" = yes; then
703         AC_DEFINE(HAVE_CURSES_TIGETSTR, 1,
704                 [Define if you have the curses(3) tigetstr/tigetnum functions.])
706 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
708 dnl Check for potentially missing curses functions in system or user-specified
709 dnl libraries.  We also have to guess at whether the specified library is a
710 dnl BSD or System V style curses.  Use the newterm function, all System V
711 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
712 if test "$vi_cv_curses" = "bundled curses"; then
713         AC_DEFINE(HAVE_BSD_CURSES, 1,
714                         [Define if you have a BSD version of curses.])
715         AC_DEFINE(HAVE_CURSES_WADDNSTR, 1,
716                         [Define if you have the curses(3) waddnstr function.])
717         AC_DEFINE(HAVE_CURSES_IDLOK, 1,
718                         [Define if you have the curses(3) idlok function.])
719 else
720         dnl Check for the waddnstr function.
721         AC_MSG_CHECKING(for waddnstr)
722         AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
723         AC_TRY_LINK([#include <$CURSHEADER>], [waddnstr(stdscr, 0, 0);],
724                 [vi_cv_have_curses_waddnstr=yes],
725                 [vi_cv_have_curses_waddnstr=no])])
726         if test "$vi_cv_have_curses_waddnstr" = yes; then
727                 AC_DEFINE(HAVE_CURSES_WADDNSTR, 1,
728                         [Define if you have the curses(3) waddnstr function.])
729         fi
730         AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
732         dnl Check for the beep function.
733         AC_MSG_CHECKING(for beep)
734         AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
735         AC_TRY_LINK([#include <$CURSHEADER>], [beep();],
736                 [vi_cv_have_curses_beep=yes],
737                 [vi_cv_have_curses_beep=no])])
738         if test "$vi_cv_have_curses_beep" = yes; then
739                 AC_DEFINE(HAVE_CURSES_BEEP, 1,
740                         [Define if you have the curses(3) beep function.])
741         fi
742         AC_MSG_RESULT($vi_cv_have_curses_beep)
744         dnl Check for the flash function.
745         AC_MSG_CHECKING(for flash)
746         AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
747         AC_TRY_LINK([#include <$CURSHEADER>], [flash();],
748                 [vi_cv_have_curses_flash=yes],
749                 [vi_cv_have_curses_flash=no])])
750         if test "$vi_cv_have_curses_flash" = yes; then
751                 AC_DEFINE(HAVE_CURSES_FLASH, 1,
752                         [Define if you have the curses(3) flash function.])
753         fi
754         AC_MSG_RESULT($vi_cv_have_curses_flash)
756         dnl Check for the idlok function.
757         AC_MSG_CHECKING(for idlok)
758         AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
759         AC_TRY_LINK([#include <$CURSHEADER>], [idlok(0, 0);],
760                 [vi_cv_have_curses_idlok=yes],
761                 [vi_cv_have_curses_idlok=no])])
762         if test "$vi_cv_have_curses_idlok" = yes; then
763                 AC_DEFINE(HAVE_CURSES_IDLOK, 1,
764                         [Define if you have the curses(3) idlok function.])
765         fi
766         AC_MSG_RESULT($vi_cv_have_curses_idlok)
768         dnl Check for the keypad function.
769         AC_MSG_CHECKING(for keypad)
770         AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
771         AC_TRY_LINK([#include <$CURSHEADER>], [keypad(0, 0);],
772                 [vi_cv_have_curses_keypad=yes],
773                 [vi_cv_have_curses_keypad=no])])
774         if test "$vi_cv_have_curses_keypad" = yes; then
775                 AC_DEFINE(HAVE_CURSES_KEYPAD, 1,
776                         [Define if you have the curses(3) keypad function.])
777         fi
778         AC_MSG_RESULT($vi_cv_have_curses_keypad)
780         dnl Check for the newterm function.
781         AC_MSG_CHECKING(for newterm)
782         AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
783         AC_TRY_LINK([#include <$CURSHEADER>], [newterm(0, 0, 0);],
784                 [vi_cv_have_curses_newterm=yes],
785                 [vi_cv_have_curses_newterm=no])])
786         if test "$vi_cv_have_curses_newterm" = yes; then
787                 AC_DEFINE(HAVE_CURSES_NEWTERM, 1,
788                         [Define if you have the curses(3) newterm function.])
789         fi
790         AC_MSG_RESULT($vi_cv_have_curses_newterm)
792         if test "$vi_cv_have_curses_newterm" = no; then
793                 AC_DEFINE(HAVE_BSD_CURSES, 1,
794                         [Define if you have a BSD version of curses.])
795         fi
798 dnl Check for the setupterm function.  We make this check regardless of
799 dnl using the system library, because it may be part of the underlying
800 dnl termcap/termlib support, and we want to use the local one.
801 AC_MSG_CHECKING(for setupterm)
802 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
803 AC_TRY_LINK([#include <$CURSHEADER>], [setupterm(0, 0, 0);],
804         [vi_cv_have_curses_setupterm=yes],
805         [vi_cv_have_curses_setupterm=no])])
806 if test "$vi_cv_have_curses_setupterm" = yes; then
807         AC_DEFINE(HAVE_CURSES_SETUPTERM, 1,
808                         [Define if you have the curses(3) setupterm function.])
810 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
811 LIBS="$CSAVELIBS"
812 LDFLAGS="$CSAVELDFLAGS"
813 CPPFLAGS="$CSAVECPPFLAGS"
815 dnl Some moron decided to drop off an argument from the gettimeofday call,
816 dnl without changing the name.
817 AC_MSG_CHECKING(for broken gettimeofday system call)
818 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
819 AC_TRY_LINK([#include <sys/types.h>
820 #include <sys/time.h>], [gettimeofday(0, 0);],
821         [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
822 if test "$vi_cv_gettimeofday" = broken; then
823         AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY, 1,
824                 [Define if you have a System V-style (broken) gettimeofday.])
826 AC_MSG_RESULT($vi_cv_gettimeofday)
828 dnl Check for which version of openpty to use, System V or Berkeley.
829 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
830 AC_CHECK_HEADER(sys/stropts.h,
831         [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
832 if test "$vi_cv_sys5_pty" = yes; then
833         AC_DEFINE(HAVE_SYS5_PTY, 1,
834                 [Define if you have the System V style pty calls.])
836 AC_MSG_CHECKING(for System V pty calls)
837 AC_MSG_RESULT($vi_cv_sys5_pty)
839 dnl Check for the revoke system call.
840 AC_MSG_CHECKING(for revoke system call)
841 AC_CACHE_VAL(vi_cv_revoke, [dnl
842 AC_TRY_LINK(, [revoke("a");],
843         [vi_cv_revoke=yes], [vi_cv_revoke=no])])
844 if test "$vi_cv_revoke" = yes; then
845         AC_DEFINE(HAVE_REVOKE, 1,
846                 [Define if you have the Berkeley style revoke(2) system call.])
848 AC_MSG_RESULT($vi_cv_revoke)
850 dnl Some versions of sprintf return a pointer to the first argument instead
851 dnl of a character count.  We assume that the return value of snprintf and
852 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
853 AC_MSG_CHECKING(for int type sprintf return value)
854 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
855 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
856         [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
857 if test "$vi_cv_sprintf_count" = no; then
858         AC_DEFINE(SPRINTF_RET_CHARPNT, 1,
859                 [Define if your sprintf returns a pointer, not a length.])
861 AC_MSG_RESULT($vi_cv_sprintf_count)
864 dnl Check for the standard shorthand types.
865 AC_SUBST(u_char_decl)
866 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
867 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
868         [vi_cv_uchar=yes], [vi_cv_uchar=no])])
869 if test "$vi_cv_uchar" = no; then
870         u_char_decl="typedef unsigned char u_char;"
873 AC_SUBST(u_short_decl)
874 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
875 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
876         [vi_cv_ushort=yes], [vi_cv_ushort=no])])
877 if test "$vi_cv_ushort" = no; then
878         u_short_decl="typedef unsigned short u_short;"
881 AC_SUBST(u_int_decl)
882 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
883 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
884         [vi_cv_uint=yes], [vi_cv_uint=no])])
885 if test "$vi_cv_uint" = no; then
886         u_int_decl="typedef unsigned int u_int;"
889 AC_SUBST(u_long_decl)
890 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
891 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
892         [vi_cv_ulong=yes], [vi_cv_ulong=no])])
893 if test "$vi_cv_ulong" = no; then
894         u_long_decl="typedef unsigned long u_long;"
897 dnl DB/Vi use specific integer sizes.
898 AC_SUBST(u_int8_decl)
899 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
900 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
901         [vi_cv_uint8=yes],
902         AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
903             [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
904 if test "$vi_cv_uint8" = no; then
905         AC_MSG_ERROR(No unsigned 8-bit integral type.)
907 if test "$vi_cv_uint8" != yes; then
908         u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
911 AC_SUBST(u_int16_decl)
912 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
913 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
914         [vi_cv_uint16=yes],
915 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
916         [vi_cv_uint16="unsigned short"],
917 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
918         [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
919 if test "$vi_cv_uint16" = no; then
920         AC_MSG_ERROR([No unsigned 16-bit integral type.])
922 if test "$vi_cv_uint16" != yes; then
923         u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
926 AC_SUBST(int16_decl)
927 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
928 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
929         [vi_cv_int16=yes],
930 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
931         [vi_cv_int16="short"],
932 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
933         [vi_cv_int16="int"], [vi_cv_int16=no])))])
934 if test "$vi_cv_int16" = no; then
935         AC_MSG_ERROR([No signed 16-bit integral type.])
937 if test "$vi_cv_int16" != yes; then
938         int16_decl="typedef $vi_cv_int16 int16_t;"
941 AC_SUBST(u_int32_decl)
942 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
943 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
944         [vi_cv_uint32=yes],
945 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
946         [vi_cv_uint32="unsigned int"],
947 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
948         [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
949 if test "$vi_cv_uint32" = no; then
950         AC_MSG_ERROR([No unsigned 32-bit integral type.])
952 if test "$vi_cv_uint32" != yes; then
953         u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
956 AC_SUBST(int32_decl)
957 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
958 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
959         [vi_cv_int32=yes],
960 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
961         [vi_cv_int32="int"],
962 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
963         [vi_cv_int32="long"], [vi_cv_int32=no])))])
964 if test "$vi_cv_int32" = no; then
965         AC_MSG_ERROR([No signed 32-bit integral type.])
967 if test "$vi_cv_int32" != yes; then
968         int32_decl="typedef $vi_cv_int32 int32_t;"
971 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
972 [AC_TRY_COMPILE([#include <stdio.h>
973 int fprintf ();
974 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
976 AC_SUBST(NEED_FPRINTF_PROTO)
977 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
978 [AC_TRY_COMPILE([ #include <stdio.h>
979 typedef int     (*funcPtr)();
980 ],[funcPtr ptr = (funcPtr) fprintf;],
981 vi_cv_proto_fprintf=no,
982 [vi_cv_proto_fprintf=yes])])
983 if test "$vi_cv_proto_fprintf" = yes; then
984         AC_DEFINE(NEED_FPRINTF_PROTO, 1,
985                 [Define when fprintf prototype not in an obvious place.])
988 AC_ARG_WITH(db_type,
989         [  --with-db=bundled|system Which db to use. ])
991 dnl Check for DB 3
992 AC_ARG_WITH(db_prefix,
993         [  --with-db-prefix=PFX    Path to db installation. ])
995 AC_SUBST(DB_LDFLAGS)
996 AC_SUBST(DB_CPPFLAGS)
997 if test "x$with_db_prefix" != "x"; then
998         DB_LDFLAGS="-L$with_db_prefix/lib $LDFLAGS"
999         DB_CPPFLAGS="-I$with_db_prefix/include $CPPFLAGS"
1000         with_db_type="system"
1003 AC_MSG_CHECKING(which db to use)
1004 case "$with_db_type" in
1005 "system")
1006         ;;
1008         with_db_type="bundled"
1009         ;;
1010 esac
1011 AC_MSG_RESULT($with_db_type)
1012 AM_CONDITIONAL(BUNDLED_DB, test $with_db_type = bundled)
1014 case "$with_db_type" in
1015 bundled)
1016         AC_DEFINE(USE_BUNDLED_DB, 1, [Define when using bundled db.])
1017         LIBOBJS="log1.o $LIBOBJS"
1018         ;;
1019 system)
1020         SAVELDFLAGS="$LDFLAGS"
1021         SAVELIBS="$LIBS"
1023         if test "x$with_db_prefix" != "x"; then
1024                 LDFLAGS="-L$with_db_prefix/lib $LDFLAGS"
1025                 CPPFLAGS="-I$with_db_prefix/include $CPPFLAGS"
1026                 with_db_type="system"
1027         fi
1029         LIBS="$LIBS -ldb"
1030         AC_TRY_LINK([#include <db.h>],
1031                 [db_create(NULL,NULL,0)],
1032                 [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
1033         if test "$vi_cv_dbfatal" = "yes"; then
1034                 AC_MSG_ERROR([Need DB 3.])
1035         fi
1037         LIBS="$SAVELIBS"
1038         LDFLAGS="$SAVELDFLAGS"
1040         AC_SUBST(dl_src)
1041         AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
1042         AC_ARG_ENABLE(dynamic-loading,
1043                 [  --enable-dynamic-loading Load DB 3 dynamically.],
1044                 [vi_cv_dl=$enableval], [vi_cv_dl="no"])
1045         AC_MSG_RESULT($vi_cv_dl)
1046         if test "$vi_cv_dl" = yes; then
1047                 AC_CHECK_LIB(dl, dlopen,
1048                         [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
1049                 if test "$vi_cv_dlfatal" = "yes"; then
1050                         AC_MSG_ERROR([Need dl to support dynamic loading.])
1051                 fi
1052                 OLDPATH="$PATH"
1054                 PATH="$with_db_prefix/lib:/usr/lib:/lib"
1055                 AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
1056                 if test "$vi_cv_path_db3" = no; then
1057                         AC_MSG_ERROR([Path of libdb-3.so not found.])
1058                 fi
1059                 PATH="$OLDPATH"
1061                 AC_DEFINE(USE_DYNAMIC_LOADING, 1,
1062                                 [Define when dynamically loading DB 3.])
1063                 LIBOBJS="dldb.o $LIBOBJS"
1064                 dl_src=../common/dldb.c
1065                 LIBS="-ldl $LIBS"
1066         else
1067                 LIBS="-ldb $LIBS"
1068                 if test "X$with_db_prefix" != "X"; then
1069                         LDFLAGS="`echo $with_db_prefix/lib | sed "$LRscript"` $LDFLAGS"
1070                 fi
1071         fi
1073         AC_ARG_WITH(db_build,
1074                 [  --with-db-build=prefix  Path to db build. ])
1075         if test "x$with_db_build" != "x"; then
1076                 vi_cv_dbsrc=`$AWK '/^srcdir/ {gsub("srcdir[[ \t]]*=","");print $1}' \
1077                              $with_db_build/Makefile`
1078                 case $with_db_build in
1079                 *[[\\/]]);;
1080                 *)
1081                     with_db_build="$with_db_build/";;
1082                 esac
1083                 case $vi_cv_dbsrc in
1084                 [[\\/]]*);;
1085                 *)
1086                     vi_cv_dbsrc="$with_db_build$vi_cv_dbsrc";;
1087                 esac
1088         fi;
1090         vi_cv_db4="no"
1091         AC_ARG_ENABLE(log4,
1092                 [  --enable-db4-logging    Enable experimental/broken db4 logging.],
1093                 [
1094                 AC_MSG_CHECKING(for DB 4)
1095                 AC_EGREP_CPP([^4],
1096                         [#include <db.h>
1097                 DB_VERSION_MAJOR],
1098                         [vi_cv_db4="yes"], [vi_cv_db4="no"])
1099                 AC_MSG_RESULT($vi_cv_db4)
1100                 ])
1101         if test "$vi_cv_db4" = "yes"; then
1102                 DB_CPPFLAGS="-I$vi_cv_dbsrc/include $DB_CPPFLAGS"
1103                 DB_CPPFLAGS="-I$vi_cv_dbsrc/include_auto $DB_CPPFLAGS"
1104                 DB_CPPFLAGS="-I$with_db_build $DB_CPPFLAGS"
1105                 AC_DEFINE(USE_DB4_LOGGING, 1, [Define when using db4 logging.])
1106                 LIBOBJS="log4.o vi_auto.o vi_rec.o $LIBOBJS"
1107         else
1108                 LIBOBJS="log.o $LIBOBJS"
1109         fi
1110         ;;
1111 esac
1113 dnl We compile in nvi's RE routines unless the user specifies otherwise.
1114 AC_MSG_CHECKING(if --disable-re option specified)
1115 AC_ARG_ENABLE(re,
1116         [  --disable-re            DON'T use the nvi-provided RE routines.],
1117         [if test "$enable_re" = "yes"; then
1118                 vi_cv_re_lib="bundled RE"
1119         else
1120                 vi_cv_re_lib="other RE"
1121         fi],[vi_cv_re_lib="bundled RE"])
1122 AC_MSG_RESULT($vi_cv_re_lib)
1123 case "$vi_cv_re_lib" in
1124 "bundled RE")
1125         CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
1126         LIBOBJS="regcomp.o regerror.o regexec.o regfree.o $LIBOBJS";;
1127 "other RE")
1128         ;;
1129 esac
1131 AC_OUTPUT(Makefile port.h:port.h.in compat.h:port.h.in
1132     pathnames.h:pathnames.h.in recover:recover.in)