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)
6 AM_INIT_AUTOMAKE(vi, 1.81.6)
7 AM_CONFIG_HEADER(config.h)
12 dnl part of AM_INIT_AUTOMAKE ?
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)
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
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.
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.
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"};;
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
60 AC_MSG_WARN([Nvi requires gcc 2.x to build on LynxOS.])
61 AC_MSG_ERROR([See build/README.LynxOS for more information.])
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-""};;
71 dnl The default OPTFLAG is -O
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.
82 if test "$GCC" = yes; then
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"}
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"};;
106 dnl A/UX has a broken getopt(3), strpbrk(3).
108 aux*) LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
111 dnl Ultrix has a broken POSIX.1 VDISABLE value.
113 ultrix*) AC_DEFINE(HAVE_BROKEN_VDISABLE);;
116 AC_MSG_CHECKING(whether recording of pathnames of libraries is enabled)
117 AC_ARG_ENABLE(runpath,
118 [ --disable-runpath Don't record path of libraries in binary.],
119 [vi_cv_runpath="$enableval"], [vi_cv_runpath="yes"])
120 AC_MSG_RESULT($vi_cv_runpath)
122 if test "X$vi_cv_runpath" = "Xyes"; then
123 LRscript='s/^\(.*\)/-R\1 -L\1 /'
125 LRscript='s/^\(.*\)/-L\1 /'
128 dnl If the user wants a tracing version, add the TRACE compile flag.
129 AC_MSG_CHECKING(if --enable-trace option specified)
131 [ --enable-trace Build a tracing version.],
132 [vi_cv_trace="yes"], [vi_cv_trace="no"])
133 if test "$vi_cv_trace" = yes; then
134 CPPFLAGS="-DTRACE $CPPFLAGS"
136 AC_MSG_RESULT($vi_cv_trace)
138 dnl The user may have additional CPP information.
139 CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"
141 dnl The user may have additional load line information.
142 LDFLAGS="$ADDLDFLAGS $LDFLAGS"
144 dnl The user may have additional library information.
145 LIBS="$ADDLIBS $LIBS"
147 dnl Checks for programs.
148 PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib"
150 dnl Check for the shell path.
151 AC_PATH_PROG(vi_cv_path_shell, sh, no)
152 if test "$vi_cv_path_shell" = no; then
153 AC_MSG_ERROR([No shell utility found.])
156 dnl Check for the sendmail path.
157 AC_PATH_PROG(vi_cv_path_sendmail, sendmail, no)
158 if test "$vi_cv_path_sendmail" = no; then
159 AC_MSG_WARN([No sendmail utility found;])
160 AC_MSG_WARN([ users will not be told of saved files.])
163 dnl Check for the perl5/perl path.
164 AC_SUBST(vi_cv_path_perl)
165 AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)
167 dnl Check for the "preserve" path.
168 dnl Historically, nvi has used /var/tmp/vi.recover. The Linux filesystem
169 dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
170 dnl beneath it so that we don't have name collisions with other editors.
171 dnl Other systems have /var/preserve as well, so we test first for an already
172 dnl existing name, and then use the first one that's writeable.
173 AC_SUBST(vi_cv_path_preserve)
174 AC_MSG_CHECKING(for preserve directory)
175 AC_CACHE_VAL(vi_cv_path_preserve, [dnl
176 dirlist="/var/preserve /var/tmp /usr/tmp"
177 vi_cv_path_preserve=no
178 for i in $dirlist; do
179 if test -d $i/vi.recover; then
180 vi_cv_path_preserve=$i/vi.recover
184 if test "$vi_cv_path_preserve" = no; then
185 for i in $dirlist; do
186 if test -d $i -a -w $i; then
187 vi_cv_path_preserve=$i/vi.recover
193 if test "$vi_cv_path_preserve" = no; then
194 AC_MSG_ERROR([No writeable preserve directory found.])
196 AC_MSG_RESULT($vi_cv_path_preserve)
197 AC_PATH_PROG(vi_cv_path_fuser, fuser, no)
198 AC_PATH_PROG(vi_cv_path_lsof, lsof, no)
201 if test "$vi_cv_path_lsof" != no; then
202 INUSE='test `lsof -t $i`'
204 if test "$vi_cv_path_fuser" != no; then
208 dnl Check for programs used for installation
210 AC_PATH_PROG(vi_cv_path_ar, ar, missing_ar)
211 AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
212 AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
213 AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
214 AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
215 AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
216 AC_PATH_PROG(vi_cv_path_ranlib, ranlib, missing_ranlib)
217 AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
219 dnl Checks for libraries.
220 dnl Find the X libraries and includes.
223 if test "$no_x" != yes; then
224 if test "X$x_libraries" != "X"; then
225 XLIBS="`echo $x_libraries | sed "$LRscript"` $XLIBS"
228 if test "X$x_includes" != "X"; then
229 XINCS="-I$x_includes"
233 AC_DEFUN([VI_CV_REPLACE_FUNCS],
234 [AC_FOREACH([AC_Func], [$1], [])dnl
235 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
238 dnl Check if the user wants widechar support.
239 AC_MSG_CHECKING(if --enable-widechar option specified)
240 AC_ARG_ENABLE(widechar,
241 [ --enable-widechar Build a wide char aware vi.],
242 [vi_cv_widechar=$enableval], [vi_cv_widechar="no"])
243 if test "$vi_cv_widechar" = "yes"; then
244 AC_DEFINE(USE_WIDECHAR)
246 AC_MSG_RESULT($vi_cv_widechar)
248 dnl Check whether we can use iconv
249 AC_CHECK_HEADER(langinfo.h, [
250 AC_CHECK_HEADER(iconv.h, [
252 VI_CV_REPLACE_FUNCS(iswblank)
256 dnl If the user wants a Gtk IPC front-end for nvi, build it.
257 AC_SUBST(vi_programs)
261 AC_MSG_CHECKING(if --enable-gtk option specified)
263 [ --enable-gtk Build a Gtk front-end for vi.],
264 [vi_cv_gtk=$enableval], [vi_cv_gtk="no"])
265 AC_MSG_RESULT($vi_cv_gtk)
266 if test "$vi_cv_gtk" = "yes"; then
270 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
271 if test x$PKG_CONFIG = xno ; then
272 if test "$vi_cv_widechar" = "yes"; then
274 [*** pkg-config not found. See http://pkgconfig.sourceforge.net])
278 if ! $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then
279 if test "$vi_cv_widechar" = "yes"; then
281 [*** pkg-config too old; version 0.5 or better required.])
287 if test x$PKG_CONFIG = xno ; then
288 PKG_CONFIG=/bin/false
291 vi_programs="$vi_programs vi-gtk"
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`
299 AC_DEFINE(HAVE_PANGO)
301 if test "$vi_cv_widechar" = "yes"; then
303 *** gtk+-2.0 is required. The latest version of gtk
304 *** is always available from ftp://ftp.gtk.org/.
308 GTKINCS="$GTK_CFLAGS"
309 GTKLIBS="$GTK_LIBS $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"
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"
329 dnl If the user wants a Motif IPC front-end for nvi, build it.
331 AC_MSG_CHECKING(if --enable-motif option specified)
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"
341 dnl BSDI's Motif libraries aren't shared.
348 dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
349 dnl -lXext is generally available, the others aren't.
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"
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"
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"
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"
376 MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
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>],
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)
396 IPCOBJS="pthread.o $IPCOBJS"
397 AC_DEFINE(HAVE_PTHREAD)
399 IPCOBJS="nothread.o $IPCOBJS"
402 dnl If the user wants a Perl interpreter in nvi, load it.
404 AC_SUBST(perlldflags)
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.])
416 $vi_cv_path_perl -e 'require 5.004' || {
417 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
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.])
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"
433 perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
435 perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
437 LIBOBJS="perl.o perlxsi.o perlsfio.o $LIBOBJS"
438 AC_DEFINE(HAVE_PERL_INTERP)
439 AC_CACHE_CHECK([whether we need to use perl's setenv],
446 #if defined(USE_ENVIRON_ARRAY) && !defined(PERL_USE_SAFE_PUTENV)
452 ], [vi_cv_perl_setenv=yes], [vi_cv_perl_setenv=no])])
453 if test "$vi_cv_perl_setenv" = yes; then
454 AC_DEFINE(USE_PERL_SETENV)
458 dnl If the user wants a Tk/Tcl interpreter in nvi, load it. Make sure that
459 dnl we can find a Tk/Tcl library.
460 AC_MSG_CHECKING(if --enable-tclinterp option specified)
461 AC_ARG_ENABLE(tclinterp,
462 [ --enable-tclinterp Include a Tk/Tcl interpreter in vi.],
463 [vi_cv_tclinterp=$enableval], [vi_cv_tclinterp="no"])
464 AC_MSG_RESULT($vi_cv_tclinterp)
465 if test "$vi_cv_tclinterp" = "yes"; then
466 AC_MSG_CHECKING([for tclConfig.sh])
467 AC_CACHE_VAL(vi_cv_tclconfig, [
468 vi_cv_tclconfig=`$srcdir/findconfig`])
469 AC_MSG_RESULT($vi_cv_tclconfig)
470 if test "x$vi_cv_tclconfig" = x; then
471 AC_MSG_ERROR([No Tcl library found;])
474 LIBOBJS="tcl.o $LIBOBJS"
475 LIBS="$TCL_LIB_SPEC $TCL_LIBS $LIBS"
476 AC_DEFINE(HAVE_TCL_INTERP)
481 AC_SUBST(CURSCPPFLAGS)
482 AC_SUBST(CURSLDFLAGS)
483 AC_SUBST(HAVE_NCURSESW)
485 dnl AC_ARG_WITH(slang,
486 dnl [ --with-slang[=DIR] Use S-Lang instead of curses. ],
488 dnl if test "$withval" != yes; then
489 dnl LDFLAGS="-L${withval}/lib $LDFLAGS"
490 dnl CPPFLAGS="-I${withval}/include $CPPFLAGS"
492 dnl AC_DEFINE(USE_SLANG_CURSES)
493 dnl AC_CHECK_LIB(slang, SLtt_get_terminfo,
494 dnl [CURSLIBS="$CURSLIBS -lslang -lm"],
495 dnl [AC_MSG_ERROR(unable to compile. check config.log)], -lm)
497 dnl vi_cv_curses=slcurses
501 SAVELDFLAGS="$LDFLAGS"
502 SAVECPPFLAGS="$CPPFLAGS"
504 [ --with-curses=DIR Path to curses installation. ])
505 if test "x$with_curses" != "x"; then
506 CURSLDFLAGS="`echo $with_curses/lib | sed "$LRscript"` $CURSLDFLAGS"
507 CURSCPPFLAGS="-I$with_curses/include $CURSCPPFLAGS"
509 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
510 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
512 if test "$vi_cv_widechar" = "yes"; then
513 for vi_cv_curses in ncurses ncursesw curses; do
514 AC_CHECK_LIB($vi_cv_curses, waddnwstr,[break])
518 for vi_cv_curses in ncurses ncursesw curses; do
519 AC_CHECK_LIB($vi_cv_curses, initscr, [break])
524 if test "$vi_cv_curses" != "unknown"; then
526 if test "$vi_cv_curses" = "ncurses"; then
527 AC_CHECK_HEADERS(ncurses.h, [CURSHEADER=ncurses.h])
529 if test "$vi_cv_curses" = "ncursesw"; then
530 AC_CHECK_HEADERS(ncursesw/ncurses.h,
531 [CURSHEADER=ncursesw/ncurses.h])
533 vi_programs="vi $vi_programs"
534 CURSLIBS="-l$vi_cv_curses"
536 AC_MSG_WARN([*** No suitable curses library found.])
537 if test "$vi_programs"X = X; then
538 AC_MSG_ERROR([No executable to build.])
542 dnl Check for the termcap/termlib library. These two checks must occur in the
543 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
544 dnl On Solaris curses==termlib, but different versions of curses
545 dnl can be used. Avoid loading termlib is curses has tgetent.
546 AC_CHECK_LIB($vi_cv_curses, tgetent,
547 [vi_cv_curses_tgetent=yes], [vi_cv_curses_tgetent=no])
548 if test "$vi_cv_curses_tgetent" = no; then
549 AC_CHECK_LIB(termlib, tgetent,
550 [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
551 if test "$vi_cv_termlib" = no; then
552 AC_CHECK_LIB(termcap, tgetent,
553 [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
556 if test "$vi_cv_termlib" != no; then
557 CURSLIBS="$CURSLIBS $vi_cv_termlib"
561 LDFLAGS="$SAVELDFLAGS"
562 CPPFLAGS="$SAVECPPFLAGS"
565 dnl Checks for header files.
566 AC_MSG_CHECKING(for sys/mman.h)
567 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
568 AC_TRY_CPP([#include <sys/mman.h>],
569 [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
570 if test "$vi_cv_include_sys_mman" = yes; then
571 AC_DEFINE(HAVE_SYS_MMAN_H)
573 AC_MSG_RESULT($vi_cv_include_sys_mman)
575 AC_MSG_CHECKING(for sys/select.h)
576 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
577 AC_TRY_CPP([#include <sys/select.h>],
578 [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
579 if test "$vi_cv_include_sys_select" = yes; then
580 AC_DEFINE(HAVE_SYS_SELECT_H)
582 AC_MSG_RESULT($vi_cv_include_sys_select)
584 dnl Checks for typedefs, structures, and compiler characteristics.
585 AC_CHECK_TYPE(ssize_t, int)
595 AC_CHECK_HEADER(sys/cdefs.h, [],
596 [AC_CONFIG_FILES([sys/cdefs.h:../db.1.85/PORT/include/cdefs.h])])
598 dnl Checks for library functions.
599 VI_CV_REPLACE_FUNCS(bsearch gethostname memchr memset)
600 VI_CV_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
601 VI_CV_REPLACE_FUNCS(snprintf vsnprintf)
603 AC_CHECK_FUNCS(select)
604 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
605 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
606 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
611 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
612 if test "$need_env" = yes; then
613 LIBOBJS="env.o $LIBOBJS"
616 dnl If we need strsep, add it and define it so we get a prototype.
617 if test "$need_strsep" = yes; then
618 LIBOBJS="strsep.o $LIBOBJS"
621 dnl Check for fcntl/flock
622 dnl Use flock preferentially, since it has cleaner semantics and won't
623 dnl hang up the editor.
625 dnl Ultrix has a broken fcntl, but a working flock.
626 dnl IRIX and DGUX have a broken flock, but working fcntl.
627 AC_MSG_CHECKING(for fcntl/flock)
628 AC_CACHE_VAL(vi_cv_lock, [dnl
634 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
635 [vi_cv_lock=flock]);;
637 if test "$vi_cv_lock" = none; then
638 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
642 if test "$vi_cv_lock" = flock; then
643 AC_DEFINE(HAVE_LOCK_FLOCK)
645 if test "$vi_cv_lock" = fcntl; then
646 AC_DEFINE(HAVE_LOCK_FCNTL)
648 AC_MSG_RESULT($vi_cv_lock)
650 dnl Check for ftruncate/chsize
651 AC_MSG_CHECKING(for ftruncate/chsize)
652 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
653 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
654 [vi_cv_ftruncate=ftruncate],
655 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
656 [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
657 if test "$vi_cv_ftruncate" = ftruncate; then
658 AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
660 if test "$vi_cv_ftruncate" = chsize; then
661 AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
663 if test "$vi_cv_ftruncate" = no; then
664 AC_MSG_ERROR([No file truncation system call.])
666 AC_MSG_RESULT($vi_cv_ftruncate)
669 CSAVELDFLAGS="$LDFLAGS"
670 CSAVECPPFLAGS="$CPPFLAGS"
671 LIBS="$CURSLIBS $LIBS"
672 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
673 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
674 dnl Check for the tigetstr/tigetnum functions.
675 AC_MSG_CHECKING(for tigetstr/tigetnum)
676 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
677 AC_TRY_LINK([#include <$CURSHEADER>], [tigetstr(0);],
678 [vi_cv_have_curses_tigetstr=yes],
679 [vi_cv_have_curses_tigetstr=no])])
680 if test "$vi_cv_have_curses_tigetstr" = yes; then
681 AC_DEFINE(HAVE_CURSES_TIGETSTR)
683 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
685 dnl Check for potentially missing curses functions in system or user-specified
686 dnl libraries. We also have to guess at whether the specified library is a
687 dnl BSD or System V style curses. Use the newterm function, all System V
688 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
689 if test "$vi_cv_curses" = "bundled curses"; then
690 AC_DEFINE(HAVE_BSD_CURSES)
691 AC_DEFINE(HAVE_CURSES_WADDNSTR)
692 AC_DEFINE(HAVE_CURSES_IDLOK)
694 dnl Check for the waddnstr function.
695 AC_MSG_CHECKING(for waddnstr)
696 AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
697 AC_TRY_LINK([#include <$CURSHEADER>], [waddnstr(stdscr, 0, 0);],
698 [vi_cv_have_curses_waddnstr=yes],
699 [vi_cv_have_curses_waddnstr=no])])
700 if test "$vi_cv_have_curses_waddnstr" = yes; then
701 AC_DEFINE(HAVE_CURSES_WADDNSTR)
703 AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
705 dnl Check for the beep function.
706 AC_MSG_CHECKING(for beep)
707 AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
708 AC_TRY_LINK([#include <$CURSHEADER>], [beep();],
709 [vi_cv_have_curses_beep=yes],
710 [vi_cv_have_curses_beep=no])])
711 if test "$vi_cv_have_curses_beep" = yes; then
712 AC_DEFINE(HAVE_CURSES_BEEP)
714 AC_MSG_RESULT($vi_cv_have_curses_beep)
716 dnl Check for the flash function.
717 AC_MSG_CHECKING(for flash)
718 AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
719 AC_TRY_LINK([#include <$CURSHEADER>], [flash();],
720 [vi_cv_have_curses_flash=yes],
721 [vi_cv_have_curses_flash=no])])
722 if test "$vi_cv_have_curses_flash" = yes; then
723 AC_DEFINE(HAVE_CURSES_FLASH)
725 AC_MSG_RESULT($vi_cv_have_curses_flash)
727 dnl Check for the idlok function.
728 AC_MSG_CHECKING(for idlok)
729 AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
730 AC_TRY_LINK([#include <$CURSHEADER>], [idlok(0, 0);],
731 [vi_cv_have_curses_idlok=yes],
732 [vi_cv_have_curses_idlok=no])])
733 if test "$vi_cv_have_curses_idlok" = yes; then
734 AC_DEFINE(HAVE_CURSES_IDLOK)
736 AC_MSG_RESULT($vi_cv_have_curses_idlok)
738 dnl Check for the keypad function.
739 AC_MSG_CHECKING(for keypad)
740 AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
741 AC_TRY_LINK([#include <$CURSHEADER>], [keypad(0, 0);],
742 [vi_cv_have_curses_keypad=yes],
743 [vi_cv_have_curses_keypad=no])])
744 if test "$vi_cv_have_curses_keypad" = yes; then
745 AC_DEFINE(HAVE_CURSES_KEYPAD)
747 AC_MSG_RESULT($vi_cv_have_curses_keypad)
749 dnl Check for the newterm function.
750 AC_MSG_CHECKING(for newterm)
751 AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
752 AC_TRY_LINK([#include <$CURSHEADER>], [newterm(0, 0, 0);],
753 [vi_cv_have_curses_newterm=yes],
754 [vi_cv_have_curses_newterm=no])])
755 if test "$vi_cv_have_curses_newterm" = yes; then
756 AC_DEFINE(HAVE_CURSES_NEWTERM)
758 AC_MSG_RESULT($vi_cv_have_curses_newterm)
760 if test "$vi_cv_have_curses_newterm" = no; then
761 AC_DEFINE(HAVE_BSD_CURSES)
765 dnl Check for the setupterm function. We make this check regardless of
766 dnl using the system library, because it may be part of the underlying
767 dnl termcap/termlib support, and we want to use the local one.
768 AC_MSG_CHECKING(for setupterm)
769 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
770 AC_TRY_LINK([#include <$CURSHEADER>], [setupterm(0, 0, 0);],
771 [vi_cv_have_curses_setupterm=yes],
772 [vi_cv_have_curses_setupterm=no])])
773 if test "$vi_cv_have_curses_setupterm" = yes; then
774 AC_DEFINE(HAVE_CURSES_SETUPTERM)
776 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
778 LDFLAGS="$CSAVELDFLAGS"
779 CPPFLAGS="$CSAVECPPFLAGS"
781 dnl Some moron decided to drop off an argument from the gettimeofday call,
782 dnl without changing the name.
783 AC_MSG_CHECKING(for broken gettimeofday system call)
784 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
785 AC_TRY_LINK([#include <sys/types.h>
786 #include <sys/time.h>], [gettimeofday(0, 0);],
787 [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
788 if test "$vi_cv_gettimeofday" = broken; then
789 AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
791 AC_MSG_RESULT($vi_cv_gettimeofday)
793 dnl Check for which version of openpty to use, System V or Berkeley.
794 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
795 AC_CHECK_HEADER(sys/stropts.h,
796 [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
797 if test "$vi_cv_sys5_pty" = yes; then
798 AC_DEFINE(HAVE_SYS5_PTY)
800 AC_MSG_CHECKING(for System V pty calls)
801 AC_MSG_RESULT($vi_cv_sys5_pty)
803 dnl Check for the revoke system call.
804 AC_MSG_CHECKING(for revoke system call)
805 AC_CACHE_VAL(vi_cv_revoke, [dnl
806 AC_TRY_LINK(, [revoke("a");],
807 [vi_cv_revoke=yes], [vi_cv_revoke=no])])
808 if test "$vi_cv_revoke" = yes; then
809 AC_DEFINE(HAVE_REVOKE)
811 AC_MSG_RESULT($vi_cv_revoke)
813 dnl Some versions of sprintf return a pointer to the first argument instead
814 dnl of a character count. We assume that the return value of snprintf and
815 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
816 AC_MSG_CHECKING(for int type sprintf return value)
817 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
818 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
819 [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
820 if test "$vi_cv_sprintf_count" = no; then
821 AC_DEFINE(SPRINTF_RET_CHARPNT)
823 AC_MSG_RESULT($vi_cv_sprintf_count)
826 dnl Check for the standard shorthand types.
827 AC_SUBST(u_char_decl)
828 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
829 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
830 [vi_cv_uchar=yes], [vi_cv_uchar=no])])
831 if test "$vi_cv_uchar" = no; then
832 u_char_decl="typedef unsigned char u_char;"
835 AC_SUBST(u_short_decl)
836 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
837 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
838 [vi_cv_ushort=yes], [vi_cv_ushort=no])])
839 if test "$vi_cv_ushort" = no; then
840 u_short_decl="typedef unsigned short u_short;"
844 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
845 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
846 [vi_cv_uint=yes], [vi_cv_uint=no])])
847 if test "$vi_cv_uint" = no; then
848 u_int_decl="typedef unsigned int u_int;"
851 AC_SUBST(u_long_decl)
852 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
853 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
854 [vi_cv_ulong=yes], [vi_cv_ulong=no])])
855 if test "$vi_cv_ulong" = no; then
856 u_long_decl="typedef unsigned long u_long;"
859 dnl DB/Vi use specific integer sizes.
860 AC_SUBST(u_int8_decl)
861 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
862 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
864 AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
865 [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
866 if test "$vi_cv_uint8" = no; then
867 AC_MSG_ERROR(No unsigned 8-bit integral type.)
869 if test "$vi_cv_uint8" != yes; then
870 u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
873 AC_SUBST(u_int16_decl)
874 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
875 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
877 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
878 [vi_cv_uint16="unsigned short"],
879 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
880 [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
881 if test "$vi_cv_uint16" = no; then
882 AC_MSG_ERROR([No unsigned 16-bit integral type.])
884 if test "$vi_cv_uint16" != yes; then
885 u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
889 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
890 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
892 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
893 [vi_cv_int16="short"],
894 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
895 [vi_cv_int16="int"], [vi_cv_int16=no])))])
896 if test "$vi_cv_int16" = no; then
897 AC_MSG_ERROR([No signed 16-bit integral type.])
899 if test "$vi_cv_int16" != yes; then
900 int16_decl="typedef $vi_cv_int16 int16_t;"
903 AC_SUBST(u_int32_decl)
904 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
905 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
907 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
908 [vi_cv_uint32="unsigned int"],
909 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
910 [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
911 if test "$vi_cv_uint32" = no; then
912 AC_MSG_ERROR([No unsigned 32-bit integral type.])
914 if test "$vi_cv_uint32" != yes; then
915 u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
919 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
920 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
922 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
924 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
925 [vi_cv_int32="long"], [vi_cv_int32=no])))])
926 if test "$vi_cv_int32" = no; then
927 AC_MSG_ERROR([No signed 32-bit integral type.])
929 if test "$vi_cv_int32" != yes; then
930 int32_decl="typedef $vi_cv_int32 int32_t;"
933 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
934 [AC_TRY_COMPILE([#include <stdio.h>
936 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
938 AC_SUBST(NEED_FPRINTF_PROTO)
939 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
940 [AC_TRY_COMPILE([ #include <stdio.h>
941 typedef int (*funcPtr)();
942 ],[funcPtr ptr = (funcPtr) fprintf;],
943 vi_cv_proto_fprintf=no,
944 [vi_cv_proto_fprintf=yes])])
945 if test "$vi_cv_proto_fprintf" = yes; then
946 AC_DEFINE(NEED_FPRINTF_PROTO)
950 [ --with-db=bundled|system Which db to use. ])
953 AC_ARG_WITH(db_prefix,
954 [ --with-db-prefix=PFX Path to db installation. ])
957 AC_SUBST(DB_CPPFLAGS)
958 if test "x$with_db_prefix" != "x"; then
959 DB_LDFLAGS="-L$with_db_prefix/lib $LDFLAGS"
960 DB_CPPFLAGS="-I$with_db_prefix/include $CPPFLAGS"
961 with_db_type="system"
964 AC_MSG_CHECKING(which db to use)
965 case "$with_db_type" in
969 with_db_type="bundled"
972 AC_MSG_RESULT($with_db_type)
973 AM_CONDITIONAL(BUNDLED_DB, test $with_db_type = bundled)
975 case "$with_db_type" in
977 AC_DEFINE(USE_BUNDLED_DB)
978 LIBOBJS="log1.o $LIBOBJS"
981 SAVELDFLAGS="$LDFLAGS"
984 if test "x$with_db_prefix" != "x"; then
985 LDFLAGS="-L$with_db_prefix/lib $LDFLAGS"
986 CPPFLAGS="-I$with_db_prefix/include $CPPFLAGS"
987 with_db_type="system"
991 AC_TRY_LINK([#include <db.h>],
992 [db_create(NULL,NULL,0)],
993 [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
994 if test "$vi_cv_dbfatal" = "yes"; then
995 AC_MSG_ERROR([Need DB 3.])
999 LDFLAGS="$SAVELDFLAGS"
1002 AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
1003 AC_ARG_ENABLE(dynamic-loading,
1004 [ --enable-dynamic-loading Load DB 3 dynamically.],
1005 [vi_cv_dl=$enableval], [vi_cv_dl="no"])
1006 AC_MSG_RESULT($vi_cv_dl)
1007 if test "$vi_cv_dl" = yes; then
1008 AC_CHECK_LIB(dl, dlopen,
1009 [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
1010 if test "$vi_cv_dlfatal" = "yes"; then
1011 AC_MSG_ERROR([Need dl to support dynamic loading.])
1015 PATH="$with_db_prefix/lib:/usr/lib:/lib"
1016 AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
1017 if test "$vi_cv_path_db3" = no; then
1018 AC_MSG_ERROR([Path of libdb-3.so not found.])
1022 AC_DEFINE(USE_DYNAMIC_LOADING)
1023 LIBOBJS="dldb.o $LIBOBJS"
1024 dl_src=../common/dldb.c
1028 if test "X$with_db_prefix" != "X"; then
1029 LDFLAGS="`echo $with_db_prefix/lib | sed "$LRscript"` $LDFLAGS"
1033 AC_ARG_WITH(db_build,
1034 [ --with-db-build=prefix Path to db build. ])
1035 if test "x$with_db_build" != "x"; then
1036 vi_cv_dbsrc=`$AWK '/^srcdir/ {gsub("srcdir[[ \t]]*=","");print $1}' \
1037 $with_db_build/Makefile`
1038 case $with_db_build in
1041 with_db_build="$with_db_build/";;
1043 case $vi_cv_dbsrc in
1046 vi_cv_dbsrc="$with_db_build$vi_cv_dbsrc";;
1052 [ --enable-db4-logging Enable experimental/broken db4 logging.],
1054 AC_MSG_CHECKING(for DB 4)
1058 [vi_cv_db4="yes"], [vi_cv_db4="no"])
1059 AC_MSG_RESULT($vi_cv_db4)
1061 if test "$vi_cv_db4" = "yes"; then
1062 DB_CPPFLAGS="-I$vi_cv_dbsrc/include $DB_CPPFLAGS"
1063 DB_CPPFLAGS="-I$vi_cv_dbsrc/include_auto $DB_CPPFLAGS"
1064 DB_CPPFLAGS="-I$with_db_build $DB_CPPFLAGS"
1065 AC_DEFINE(USE_DB4_LOGGING)
1066 LIBOBJS="log4.o vi_auto.o vi_rec.o $LIBOBJS"
1068 LIBOBJS="log.o $LIBOBJS"
1073 dnl We compile in nvi's RE routines unless the user specifies otherwise.
1074 AC_MSG_CHECKING(if --disable-re option specified)
1076 [ --disable-re DON'T use the nvi-provided RE routines.],
1077 [if test "$enable_re" = "yes"; then
1078 vi_cv_re_lib="bundled RE"
1080 vi_cv_re_lib="other RE"
1081 fi],[vi_cv_re_lib="bundled RE"])
1082 AC_MSG_RESULT($vi_cv_re_lib)
1083 case "$vi_cv_re_lib" in
1085 CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
1086 LIBOBJS="regcomp.o regerror.o regexec.o regfree.o $LIBOBJS";;
1091 AC_OUTPUT(Makefile port.h:port.h.in compat.h:port.h.in
1092 pathnames.h:pathnames.h.in recover:recover.in)