1 dnl $Id: configure.in,v 8.184 2001/10/11 19:22:30 skimo Exp $
2 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT(../common/main.c)
5 AM_INIT_AUTOMAKE(vi, 1.81.5)
6 AM_CONFIG_HEADER(config.h)
11 dnl part of AM_INIT_AUTOMAKE ?
16 dnl If the user wants a debugging environment, set OPTFLAG now, some
17 dnl compilers won't mix optimizing and debug flags.)
18 AC_MSG_CHECKING(if --enable-debug option specified)
20 [ --enable-debug Build a debugging version.],
21 [vi_cv_debug="yes"], [vi_cv_debug="no"])
22 AC_MSG_RESULT($vi_cv_debug)
23 if test "$vi_cv_debug" = yes; then
25 OPTFLAG=${OPTFLAG-"-g"}
26 no_op_OPTFLAG=${no_op_OPTFLAG-"-g"}
29 dnl This is where we handle stuff that autoconf can't handle.
31 dnl Don't override anything if it's already set from the environment.
33 dnl Compiler, preprocessor and load flags.
34 dnl AUX: -ZP disables _BSD_SOURCE et al, but enables POSIX at link time.
35 dnl LynxOS: We check for gcc 2.x or better, the gcc 1 that was shipped with
36 dnl LynxOS historically wasn't good enough.
39 aix3.2.5) OPTFLAG=${OPTFLAG-"-O"};;
40 aix4.1*) CFLAGS=${CFLAGS-"-qstrict"}
41 OPTFLAG=${OPTFLAG-"-O3"};;
42 aux*) CPPFLAGS=${CPPFLAGS-"-ZP -D_BSD_SOURCE -D_SYSV_SOURCE -D_AUX_SOURCE"}
43 LDFLAGS=${LDFLAGS-"-ZP"}
44 OPTFLAG=${OPTFLAG-"-O"};;
45 bsd4.4) OPTFLAG=${OPTFLAG-"-O2"};;
46 bsdi*) CC=${CC-"shlicc"}
47 OPTFLAG=${OPTFLAG-"-O2"};;
48 irix6*) OPTFLAG=${OPTFLAG-"-O2"};;
49 irix*) OPTFLAG=${OPTFLAG-"-O2"};;
51 AC_MSG_CHECKING([for GNU C (gcc) version 2.x])
52 ac_cv_gcc_vers=`${CC-cc} -v 2>&1 | \
53 grep "gcc version " | sed 's/.*version //'`
54 ac_cv_gcc_major=`echo "$ac_cv_gcc_vers" | sed 's/\..*//'`
55 if test "$ac_cv_gcc_major" = "2" ; then
59 AC_MSG_WARN([Nvi requires gcc 2.x to build on LynxOS.])
60 AC_MSG_ERROR([See build/README.LynxOS for more information.])
62 nextstep3) CPPFLAGS=${CPPFLAGS-"-w -pipe -posix"}
63 LDFLAGS=${LDFLAGS-"-posix"}
64 OPTFLAG=${OPTFLAG-"-O2"};;
65 osf*) CFLAGS=${CFLAGS-"-Olimit 1000"};;
66 solaris*) no_op_OPTFLAG=${no_op_OPTFLAG-""};;
67 sunos*) no_op_OPTFLAG=${no_op_OPTFLAG-""};;
70 dnl The default OPTFLAG is -O
72 OPTFLAG=${OPTFLAG-"-O"}
74 dnl The default compiler is cc (NOT gcc), the default CFLAGS is empty,
75 dnl NOT whatever AC_PROG_CC sets.
81 dnl The SunOS/Solaris compiler can't optimize vi/v_txt.c; the symptom is
82 dnl that the command 35i==<esc> turns into an infinite loop.
83 AC_SUBST(no_op_OPTFLAG)
84 no_op_OPTFLAG=${no_op_OPTFLAG-"$OPTFLAG"}
88 bsdi2.1) LIBS=${LIBS-"-lipc"};;
89 dgux*) LIBS=${LIBS-"-ldgc"};;
90 irix6*) LIBS=${LIBS-"-lbsd"};;
91 irix*) LIBS=${LIBS-"-lc_s -lbsd"};;
92 isc*) LIBS=${LIBS-"-lcposix -linet"};;
93 netbsd1*) LIBS=${LIBS-"-lcrypt"};;
94 ptx*) LIBS=${LIBS-"-lseq -linet -lsocket"};;
95 sco3.2*) LIBS=${LIBS-"-lsocket"};;
96 sinix*) LIBS=${LIBS-"-lelf -lc"};;
97 solaris*) LIBS=${LIBS-"-lsocket -lnsl -ldl"};;
98 wgs*) LIBS=${LIBS-"-lnsl"};;
101 dnl A/UX has a broken getopt(3), strpbrk(3).
103 aux*) LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
106 dnl Ultrix has a broken POSIX.1 VDISABLE value.
108 ultrix*) AC_DEFINE(HAVE_BROKEN_VDISABLE);;
111 AC_MSG_CHECKING(whether recording of pathnames of libraries is enabled)
112 AC_ARG_ENABLE(runpath,
113 [ --disable-runpath Don't record path of libraries in binary.],
114 [vi_cv_runpath="$enableval"], [vi_cv_runpath="yes"])
115 AC_MSG_RESULT($vi_cv_runpath)
117 if test "X$vi_cv_runpath" = "Xyes"; then
118 LRscript='s/^\(.*\)/-R\1 -L\1 /'
120 LRscript='s/^\(.*\)/-L\1 /'
123 dnl If the user wants a tracing version, add the TRACE compile flag.
124 AC_MSG_CHECKING(if --enable-trace option specified)
126 [ --enable-trace Build a tracing version.],
127 [vi_cv_trace="yes"], [vi_cv_trace="no"])
128 if test "$vi_cv_trace" = yes; then
129 CPPFLAGS="-DTRACE $CPPFLAGS"
131 AC_MSG_RESULT($vi_cv_trace)
133 dnl The user may have additional CPP information.
134 CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"
136 dnl The user may have additional load line information.
137 LDFLAGS="$ADDLDFLAGS $LDFLAGS"
139 dnl The user may have additional library information.
140 LIBS="$ADDLIBS $LIBS"
142 dnl Checks for programs.
143 PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib"
145 dnl Check for the shell path.
146 AC_PATH_PROG(vi_cv_path_shell, sh, no)
147 if test "$vi_cv_path_shell" = no; then
148 AC_MSG_ERROR([No shell utility found.])
151 dnl Check for the sendmail path.
152 AC_PATH_PROG(vi_cv_path_sendmail, sendmail, no)
153 if test "$vi_cv_path_sendmail" = no; then
154 AC_MSG_WARN([No sendmail utility found;])
155 AC_MSG_WARN([ users will not be told of saved files.])
158 dnl Check for the perl5/perl path.
159 AC_SUBST(vi_cv_path_perl)
160 AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)
162 dnl Check for the "preserve" path.
163 dnl Historically, nvi has used /var/tmp/vi.recover. The Linux filesystem
164 dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
165 dnl beneath it so that we don't have name collisions with other editors.
166 dnl Other systems have /var/preserve as well, so we test first for an already
167 dnl existing name, and then use the first one that's writeable.
168 AC_SUBST(vi_cv_path_preserve)
169 AC_MSG_CHECKING(for preserve directory)
170 AC_CACHE_VAL(vi_cv_path_preserve, [dnl
171 dirlist="/var/preserve /var/tmp /usr/tmp"
172 vi_cv_path_preserve=no
173 for i in $dirlist; do
174 if test -d $i/vi.recover; then
175 vi_cv_path_preserve=$i/vi.recover
179 if test "$vi_cv_path_preserve" = no; then
180 for i in $dirlist; do
181 if test -d $i -a -w $i; then
182 vi_cv_path_preserve=$i/vi.recover
188 if test "$vi_cv_path_preserve" = no; then
189 AC_MSG_ERROR([No writeable preserve directory found.])
191 AC_MSG_RESULT($vi_cv_path_preserve)
192 AC_PATH_PROG(vi_cv_path_fuser, fuser, no)
193 AC_PATH_PROG(vi_cv_path_lsof, lsof, no)
196 if test "$vi_cv_path_lsof" != no; then
197 INUSE='test `lsof -t $i`'
199 if test "$vi_cv_path_fuser" != no; then
203 dnl Check for programs used for installation
205 AC_PATH_PROG(vi_cv_path_ar, ar, missing_ar)
206 AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
207 AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
208 AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
209 AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
210 AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
211 AC_PATH_PROG(vi_cv_path_ranlib, ranlib, missing_ranlib)
212 AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
214 dnl Checks for libraries.
215 dnl Find the X libraries and includes.
218 if test "$no_x" != yes; then
219 if test "X$x_libraries" != "X"; then
220 XLIBS="`echo $x_libraries | sed "$LRscript"` $XLIBS"
223 if test "X$x_includes" != "X"; then
224 XINCS="-I$x_includes"
228 dnl Check if the user wants widechar support.
229 AC_MSG_CHECKING(if --enable-widechar option specified)
230 AC_ARG_ENABLE(widechar,
231 [ --enable-widechar Build a wide char aware vi.],
232 [vi_cv_widechar="yes"], [vi_cv_widechar="no"])
233 if test "$vi_cv_widechar" = "yes"; then
234 AC_DEFINE(USE_WIDECHAR)
236 AC_MSG_RESULT($vi_cv_widechar)
238 dnl Check whether we can use iconv
239 AC_CHECK_HEADER(langinfo.h, [
240 AC_CHECK_HEADER(iconv.h, [
242 AC_REPLACE_FUNCS(iswchar)
246 dnl If the user wants a Gtk IPC front-end for nvi, build it.
247 AC_SUBST(vi_programs)
251 AC_MSG_CHECKING(if --enable-gtk option specified)
253 [ --enable-gtk Build a Gtk front-end for vi.],
254 [vi_cv_gtk="yes"], [vi_cv_gtk="no"])
255 AC_MSG_RESULT($vi_cv_gtk)
256 if test "$vi_cv_gtk" = "yes"; then
260 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
261 if test x$PKG_CONFIG = xno ; then
262 if test "$vi_cv_widechar" = "yes"; then
264 [*** pkg-config not found. See http://pkgconfig.sourceforge.net])
268 if ! $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then
269 if test "$vi_cv_widechar" = "yes"; then
271 [*** pkg-config too old; version 0.5 or better required.])
277 if test x$PKG_CONFIG = xno ; then
278 PKG_CONFIG=/bin/false
281 vi_programs="$vi_programs vi-gtk"
283 AC_MSG_CHECKING(for gtk+)
284 if $PKG_CONFIG gtk+-2.0 ; then
285 GTKINCS=`$PKG_CONFIG --cflags gtk+-2.0`
286 GTKLIBS=`$PKG_CONFIG --libs gtk+-2.0`
289 AC_DEFINE(HAVE_PANGO)
291 if test "$vi_cv_widechar" = "yes"; then
293 *** gtk+-2.0 is required. The latest version of gtk
294 *** is always available from ftp://ftp.gtk.org/.
298 GTKINCS="$GTK_CFLAGS"
299 GTKLIBS="$GTK_LIBS $LIBS"
304 LIBS="-lutil $GTKLIBS"
305 AC_CHECK_LIB(nvizvt, zvt_get_ptys,
306 [vi_cv_zvt="yes"], [vi_cv_zvt="no"])
307 if test "$vi_cv_zvt" = "yes"; then
308 GTKLIBS="-lnvizvt $LIBS"
312 # AC_PATH_PROG(vi_cv_gnome_config, gnome-config, no)
313 # if test "$vi_cv_gnome_config" != "no"; then
314 # ZVTLIBS=`$vi_cv_gnome_config zvt --libs`
315 # GTKLIBS="$ZVTLIBS $GTKLIBS"
319 dnl If the user wants a Motif IPC front-end for nvi, build it.
321 AC_MSG_CHECKING(if --enable-motif option specified)
323 [ --enable-motif Build a Motif front-end for vi.],
324 [vi_cv_motif="yes"], [vi_cv_motif="no"])
325 AC_MSG_RESULT($vi_cv_motif)
326 if test "$vi_cv_motif" = "yes"; then
327 vi_programs="$vi_programs vi-motif"
331 dnl BSDI's Motif libraries aren't shared.
338 dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
339 dnl -lXext is generally available, the others aren't.
342 dnl Color icons require -lXpm, which may or may not be available,
343 dnl depending on the version of X11.
345 MOTIFLIBS="-lXm -lXt"
346 AC_CHECK_LIB(SM, main,
347 [vi_cv_smlib="yes"], [vi_cv_smlib="no"], "$XLIBS")
348 if test "$vi_cv_smlib" = "yes"; then
349 MOTIFLIBS="$MOTIFLIBS -lSM"
351 AC_CHECK_LIB(ICE, main,
352 [vi_cv_icelib="yes"], [vi_cv_icelib="no"], "$XLIBS")
353 if test "$vi_cv_icelib" = "yes"; then
354 MOTIFLIBS="$MOTIFLIBS -lICE"
356 AC_CHECK_LIB(Xext, main,
357 [vi_cv_xextlib="yes"], [vi_cv_xextlib="no"], "$XLIBS")
358 if test "$vi_cv_xextlib" = "yes"; then
359 MOTIFLIBS="$MOTIFLIBS -lXext"
361 AC_CHECK_LIB(Xpm, main,
362 [vi_cv_xpmlib="yes"], [vi_cv_xpmlib="no"], "$XLIBS")
363 if test "$vi_cv_xpmlib" = "yes"; then
364 MOTIFLIBS="$MOTIFLIBS -lXpm"
366 MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
370 dnl Check for threads
371 AC_MSG_CHECKING(if --enable-threads option specified)
372 AC_ARG_ENABLE(threads,
373 [ --enable-threads Turn on thread support.],
374 [vi_cv_threads="yes"], [vi_cv_threads="no"])
375 AC_MSG_RESULT($vi_cv_threads)
376 if test "$vi_cv_threads" = "yes"; then
377 LIBS="$LIBS -lpthread"
378 AC_CACHE_VAL(vi_cv_have_pthreads, [dnl
379 AC_TRY_LINK([#include <pthread.h>],
381 [vi_cv_have_pthreads=yes],
382 [vi_cv_have_pthreads=no])])
383 if test "$vi_cv_have_pthreads" = "no"; then
384 AC_MSG_ERROR(No threading library found)
386 IPCOBJS="pthread.o $IPCOBJS"
387 AC_DEFINE(HAVE_PTHREAD)
389 IPCOBJS="nothread.o $IPCOBJS"
392 dnl If the user wants a Perl interpreter in nvi, load it.
394 AC_SUBST(perlldflags)
396 AC_SUBST(vi_cv_perllib)
398 AC_MSG_CHECKING(if --enable-perlinterp option specified)
399 AC_ARG_ENABLE(perlinterp,
400 [ --enable-perlinterp Include a Perl interpreter in vi.],
401 [vi_cv_perlinterp="yes"], [vi_cv_perlinterp="no"])
402 AC_MSG_RESULT($vi_cv_perlinterp)
403 if test "$vi_cv_perlinterp" = "yes"; then
404 if test "$vi_cv_path_perl" = no; then
405 AC_MSG_ERROR([No perl5 utility found.])
407 $vi_cv_path_perl -e 'require 5.004' || {
408 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
410 if test "$vi_cv_threads" = "yes"; then
411 useithreads=`$vi_cv_path_perl -MConfig -e 'print $Config{useithreads}'`
412 if test "X$useithreads" != "Xdefine"; then
413 AC_MSG_ERROR([vi threading only compatible with perl's ithreads.])
417 eval `$vi_cv_path_perl -V:shrpenv`
418 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
419 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
420 -e 'ccflags;perl_inc'`
421 if test "X$perlcppflags" != "X"; then
422 CPPFLAGS="$perlcppflags $CPPFLAGS"
424 perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
426 perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
428 LTLIBOBJS="perl.lo perlxsi.lo perlsfio.lo $LTLIBOBJS"
429 AC_DEFINE(HAVE_PERL_INTERP)
430 AC_CACHE_CHECK([whether we need to use perl's setenv],
437 #if defined(USE_ENVIRON_ARRAY) && !defined(PERL_USE_SAFE_PUTENV)
443 ], [vi_cv_perl_setenv=yes], [vi_cv_perl_setenv=no])])
444 if test "$vi_cv_perl_setenv" = yes; then
445 AC_DEFINE(USE_PERL_SETENV)
449 dnl If the user wants a Tk/Tcl interpreter in nvi, load it. Make sure that
450 dnl we can find a Tk/Tcl library.
451 AC_MSG_CHECKING(if --enable-tclinterp option specified)
452 AC_ARG_ENABLE(tclinterp,
453 [ --enable-tclinterp Include a Tk/Tcl interpreter in vi.],
454 [vi_cv_tclinterp="yes"], [vi_cv_tclinterp="no"])
455 AC_MSG_RESULT($vi_cv_tclinterp)
456 if test "$vi_cv_tclinterp" = "yes"; then
457 AC_MSG_CHECKING([for tclConfig.sh])
458 AC_CACHE_VAL(vi_cv_tclconfig, [
459 vi_cv_tclconfig=`$srcdir/findconfig`])
460 AC_MSG_RESULT($vi_cv_tclconfig)
461 if test "x$vi_cv_tclconfig" = x; then
462 AC_MSG_ERROR([No Tcl library found;])
465 LTLIBOBJS="tcl.lo $LTLIBOBJS"
466 LIBS="$TCL_LIB_SPEC $TCL_LIBS $LIBS"
467 AC_DEFINE(HAVE_TCL_INTERP)
472 AC_SUBST(CURSCPPFLAGS)
473 AC_SUBST(CURSLDFLAGS)
474 AC_SUBST(HAVE_NCURSESW)
476 dnl AC_ARG_WITH(slang,
477 dnl [ --with-slang[=DIR] Use S-Lang instead of curses. ],
479 dnl if test "$withval" != yes; then
480 dnl LDFLAGS="-L${withval}/lib $LDFLAGS"
481 dnl CPPFLAGS="-I${withval}/include $CPPFLAGS"
483 dnl AC_DEFINE(USE_SLANG_CURSES)
484 dnl AC_CHECK_LIB(slang, SLtt_get_terminfo,
485 dnl [CURSLIBS="$CURSLIBS -lslang -lm"],
486 dnl [AC_MSG_ERROR(unable to compile. check config.log)], -lm)
488 dnl vi_cv_curses=slcurses
492 SAVELDFLAGS="$LDFLAGS"
493 SAVECPPFLAGS="$CPPFLAGS"
495 [ --with-curses=DIR Path to curses installation. ])
496 if test "x$with_curses" != "x"; then
497 CURSLDFLAGS="`echo $with_curses/lib | sed "$LRscript"` $CURSLDFLAGS"
498 CURSCPPFLAGS="-I$with_curses/include $CURSCPPFLAGS"
500 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
501 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
503 if test "$vi_cv_widechar" = "yes"; then
504 for vi_cv_curses in ncurses ncursesw curses; do
505 AC_CHECK_LIB($vi_cv_curses, waddnwstr,[break])
509 for vi_cv_curses in ncurses ncursesw curses; do
510 AC_CHECK_LIB($vi_cv_curses, initscr, [break])
515 if test "$vi_cv_curses" != "unknown"; then
517 if test "$vi_cv_curses" = "ncurses"; then
518 AC_CHECK_HEADERS(ncurses.h, [CURSHEADER=ncurses.h])
520 if test "$vi_cv_curses" = "ncursesw"; then
521 AC_CHECK_HEADERS(ncursesw/ncurses.h,
522 [CURSHEADER=ncursesw/ncurses.h])
524 vi_programs="vi $vi_programs"
525 CURSLIBS="-l$vi_cv_curses"
527 AC_MSG_WARN([*** No suitable curses library found.])
528 if test "$vi_programs"X = X; then
529 AC_MSG_ERROR([No executable to build.])
533 dnl Check for the termcap/termlib library. These two checks must occur in the
534 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
535 dnl On Solaris curses==termlib, but different versions of curses
536 dnl can be used. Avoid loading termlib is curses has tgetent.
537 AC_CHECK_LIB($vi_cv_curses, tgetent,
538 [vi_cv_curses_tgetent=yes], [vi_cv_curses_tgetent=no])
539 if test "$vi_cv_curses_tgetent" = no; then
540 AC_CHECK_LIB(termlib, tgetent,
541 [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
542 if test "$vi_cv_termlib" = no; then
543 AC_CHECK_LIB(termcap, tgetent,
544 [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
547 if test "$vi_cv_termlib" != no; then
548 CURSLIBS="$CURSLIBS $vi_cv_termlib"
552 LDFLAGS="$SAVELDFLAGS"
553 CPPFLAGS="$SAVECPPFLAGS"
556 dnl Checks for header files.
557 AC_MSG_CHECKING(for sys/mman.h)
558 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
559 AC_TRY_CPP([#include <sys/mman.h>],
560 [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
561 if test "$vi_cv_include_sys_mman" = yes; then
562 AC_DEFINE(HAVE_SYS_MMAN_H)
564 AC_MSG_RESULT($vi_cv_include_sys_mman)
566 AC_MSG_CHECKING(for sys/select.h)
567 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
568 AC_TRY_CPP([#include <sys/select.h>],
569 [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
570 if test "$vi_cv_include_sys_select" = yes; then
571 AC_DEFINE(HAVE_SYS_SELECT_H)
573 AC_MSG_RESULT($vi_cv_include_sys_select)
575 dnl Checks for typedefs, structures, and compiler characteristics.
576 AC_CHECK_TYPE(ssize_t, int)
586 dnl Checks for library functions.
587 AC_CHECK_FUNCS(bsearch gethostname memchr memset)
588 AC_REPLACE_FUNCS(bsearch gethostname memchr memset)
589 AC_CHECK_FUNCS(mkstemp mmap strdup strpbrk)
590 AC_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
591 AC_CHECK_FUNCS(snprintf vsnprintf)
592 AC_REPLACE_FUNCS(snprintf vsnprintf)
594 AC_CHECK_FUNCS(select)
595 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
596 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
597 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
602 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
603 if test "$need_env" = yes; then
604 LIBOBJS="env.o $LIBOBJS"
607 dnl If we need strsep, add it and define it so we get a prototype.
608 if test "$need_strsep" = yes; then
609 LIBOBJS="strsep.o $LIBOBJS"
612 dnl XXX not sure whether this is a good idea
613 LTLIBOBJS="`echo $LIBOBJS | sed 's/\.o/.lo/g'` $LTLIBOBJS"
615 dnl Check for fcntl/flock
616 dnl Use flock preferentially, since it has cleaner semantics and won't
617 dnl hang up the editor.
619 dnl Ultrix has a broken fcntl, but a working flock.
620 dnl IRIX and DGUX have a broken flock, but working fcntl.
621 AC_MSG_CHECKING(for fcntl/flock)
622 AC_CACHE_VAL(vi_cv_lock, [dnl
628 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
629 [vi_cv_lock=flock]);;
631 if test "$vi_cv_lock" = none; then
632 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
636 if test "$vi_cv_lock" = flock; then
637 AC_DEFINE(HAVE_LOCK_FLOCK)
639 if test "$vi_cv_lock" = fcntl; then
640 AC_DEFINE(HAVE_LOCK_FCNTL)
642 AC_MSG_RESULT($vi_cv_lock)
644 dnl Check for ftruncate/chsize
645 AC_MSG_CHECKING(for ftruncate/chsize)
646 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
647 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
648 [vi_cv_ftruncate=ftruncate],
649 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
650 [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
651 if test "$vi_cv_ftruncate" = ftruncate; then
652 AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
654 if test "$vi_cv_ftruncate" = chsize; then
655 AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
657 if test "$vi_cv_ftruncate" = no; then
658 AC_MSG_ERROR([No file truncation system call.])
660 AC_MSG_RESULT($vi_cv_ftruncate)
663 CSAVELDFLAGS="$LDFLAGS"
664 CSAVECPPFLAGS="$CPPFLAGS"
665 LIBS="$CURSLIBS $LIBS"
666 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
667 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
668 dnl Check for the tigetstr/tigetnum functions.
669 AC_MSG_CHECKING(for tigetstr/tigetnum)
670 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
671 AC_TRY_LINK([#include <$CURSHEADER>], [tigetstr(0);],
672 [vi_cv_have_curses_tigetstr=yes],
673 [vi_cv_have_curses_tigetstr=no])])
674 if test "$vi_cv_have_curses_tigetstr" = yes; then
675 AC_DEFINE(HAVE_CURSES_TIGETSTR)
677 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
679 dnl Check for potentially missing curses functions in system or user-specified
680 dnl libraries. We also have to guess at whether the specified library is a
681 dnl BSD or System V style curses. Use the newterm function, all System V
682 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
683 if test "$vi_cv_curses" = "bundled curses"; then
684 AC_DEFINE(HAVE_BSD_CURSES)
685 AC_DEFINE(HAVE_CURSES_WADDNSTR)
686 AC_DEFINE(HAVE_CURSES_IDLOK)
688 dnl Check for the waddnstr function.
689 AC_MSG_CHECKING(for waddnstr)
690 AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
691 AC_TRY_LINK([#include <$CURSHEADER>], [waddnstr(stdscr, 0, 0);],
692 [vi_cv_have_curses_waddnstr=yes],
693 [vi_cv_have_curses_waddnstr=no])])
694 if test "$vi_cv_have_curses_waddnstr" = yes; then
695 AC_DEFINE(HAVE_CURSES_WADDNSTR)
697 AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
699 dnl Check for the beep function.
700 AC_MSG_CHECKING(for beep)
701 AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
702 AC_TRY_LINK([#include <$CURSHEADER>], [beep();],
703 [vi_cv_have_curses_beep=yes],
704 [vi_cv_have_curses_beep=no])])
705 if test "$vi_cv_have_curses_beep" = yes; then
706 AC_DEFINE(HAVE_CURSES_BEEP)
708 AC_MSG_RESULT($vi_cv_have_curses_beep)
710 dnl Check for the flash function.
711 AC_MSG_CHECKING(for flash)
712 AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
713 AC_TRY_LINK([#include <$CURSHEADER>], [flash();],
714 [vi_cv_have_curses_flash=yes],
715 [vi_cv_have_curses_flash=no])])
716 if test "$vi_cv_have_curses_flash" = yes; then
717 AC_DEFINE(HAVE_CURSES_FLASH)
719 AC_MSG_RESULT($vi_cv_have_curses_flash)
721 dnl Check for the idlok function.
722 AC_MSG_CHECKING(for idlok)
723 AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
724 AC_TRY_LINK([#include <$CURSHEADER>], [idlok(0, 0);],
725 [vi_cv_have_curses_idlok=yes],
726 [vi_cv_have_curses_idlok=no])])
727 if test "$vi_cv_have_curses_idlok" = yes; then
728 AC_DEFINE(HAVE_CURSES_IDLOK)
730 AC_MSG_RESULT($vi_cv_have_curses_idlok)
732 dnl Check for the keypad function.
733 AC_MSG_CHECKING(for keypad)
734 AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
735 AC_TRY_LINK([#include <$CURSHEADER>], [keypad(0, 0);],
736 [vi_cv_have_curses_keypad=yes],
737 [vi_cv_have_curses_keypad=no])])
738 if test "$vi_cv_have_curses_keypad" = yes; then
739 AC_DEFINE(HAVE_CURSES_KEYPAD)
741 AC_MSG_RESULT($vi_cv_have_curses_keypad)
743 dnl Check for the newterm function.
744 AC_MSG_CHECKING(for newterm)
745 AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
746 AC_TRY_LINK([#include <$CURSHEADER>], [newterm(0, 0, 0);],
747 [vi_cv_have_curses_newterm=yes],
748 [vi_cv_have_curses_newterm=no])])
749 if test "$vi_cv_have_curses_newterm" = yes; then
750 AC_DEFINE(HAVE_CURSES_NEWTERM)
752 AC_MSG_RESULT($vi_cv_have_curses_newterm)
754 if test "$vi_cv_have_curses_newterm" = no; then
755 AC_DEFINE(HAVE_BSD_CURSES)
759 dnl Check for the setupterm function. We make this check regardless of
760 dnl using the system library, because it may be part of the underlying
761 dnl termcap/termlib support, and we want to use the local one.
762 AC_MSG_CHECKING(for setupterm)
763 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
764 AC_TRY_LINK([#include <$CURSHEADER>], [setupterm(0, 0, 0);],
765 [vi_cv_have_curses_setupterm=yes],
766 [vi_cv_have_curses_setupterm=no])])
767 if test "$vi_cv_have_curses_setupterm" = yes; then
768 AC_DEFINE(HAVE_CURSES_SETUPTERM)
770 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
772 LDFLAGS="$CSAVELDFLAGS"
773 CPPFLAGS="$CSAVECPPFLAGS"
775 dnl Some moron decided to drop off an argument from the gettimeofday call,
776 dnl without changing the name.
777 AC_MSG_CHECKING(for broken gettimeofday system call)
778 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
779 AC_TRY_LINK([#include <sys/types.h>
780 #include <sys/time.h>], [gettimeofday(0, 0);],
781 [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
782 if test "$vi_cv_gettimeofday" = broken; then
783 AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
785 AC_MSG_RESULT($vi_cv_gettimeofday)
787 dnl Check for which version of openpty to use, System V or Berkeley.
788 AC_MSG_CHECKING(for System V pty calls)
789 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
790 AC_TRY_LINK(, [grantpt(0);],
791 [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
792 if test "$vi_cv_sys5_pty" = yes; then
793 AC_DEFINE(HAVE_SYS5_PTY)
795 AC_MSG_RESULT($vi_cv_sys5_pty)
797 dnl Check for the revoke system call.
798 AC_MSG_CHECKING(for revoke system call)
799 AC_CACHE_VAL(vi_cv_revoke, [dnl
800 AC_TRY_LINK(, [revoke("a");],
801 [vi_cv_revoke=yes], [vi_cv_revoke=no])])
802 if test "$vi_cv_revoke" = yes; then
803 AC_DEFINE(HAVE_REVOKE)
805 AC_MSG_RESULT($vi_cv_revoke)
807 dnl Some versions of sprintf return a pointer to the first argument instead
808 dnl of a character count. We assume that the return value of snprintf and
809 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
810 AC_MSG_CHECKING(for int type sprintf return value)
811 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
812 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
813 [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
814 if test "$vi_cv_sprintf_count" = no; then
815 AC_DEFINE(SPRINTF_RET_CHARPNT)
817 AC_MSG_RESULT($vi_cv_sprintf_count)
820 dnl Check for the standard shorthand types.
821 AC_SUBST(u_char_decl)
822 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
823 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
824 [vi_cv_uchar=yes], [vi_cv_uchar=no])])
825 if test "$vi_cv_uchar" = no; then
826 u_char_decl="typedef unsigned char u_char;"
829 AC_SUBST(u_short_decl)
830 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
831 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
832 [vi_cv_ushort=yes], [vi_cv_ushort=no])])
833 if test "$vi_cv_ushort" = no; then
834 u_short_decl="typedef unsigned short u_short;"
838 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
839 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
840 [vi_cv_uint=yes], [vi_cv_uint=no])])
841 if test "$vi_cv_uint" = no; then
842 u_int_decl="typedef unsigned int u_int;"
845 AC_SUBST(u_long_decl)
846 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
847 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
848 [vi_cv_ulong=yes], [vi_cv_ulong=no])])
849 if test "$vi_cv_ulong" = no; then
850 u_long_decl="typedef unsigned long u_long;"
853 dnl DB/Vi use specific integer sizes.
854 AC_SUBST(u_int8_decl)
855 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
856 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
858 AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
859 [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
860 if test "$vi_cv_uint8" = no; then
861 AC_MSG_ERROR(No unsigned 8-bit integral type.)
863 if test "$vi_cv_uint8" != yes; then
864 u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
867 AC_SUBST(u_int16_decl)
868 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
869 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
871 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
872 [vi_cv_uint16="unsigned short"],
873 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
874 [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
875 if test "$vi_cv_uint16" = no; then
876 AC_MSG_ERROR([No unsigned 16-bit integral type.])
878 if test "$vi_cv_uint16" != yes; then
879 u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
883 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
884 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
886 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
887 [vi_cv_int16="short"],
888 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
889 [vi_cv_int16="int"], [vi_cv_int16=no])))])
890 if test "$vi_cv_int16" = no; then
891 AC_MSG_ERROR([No signed 16-bit integral type.])
893 if test "$vi_cv_int16" != yes; then
894 int16_decl="typedef $vi_cv_int16 int16_t;"
897 AC_SUBST(u_int32_decl)
898 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
899 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
901 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
902 [vi_cv_uint32="unsigned int"],
903 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
904 [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
905 if test "$vi_cv_uint32" = no; then
906 AC_MSG_ERROR([No unsigned 32-bit integral type.])
908 if test "$vi_cv_uint32" != yes; then
909 u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
913 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
914 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
916 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
918 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
919 [vi_cv_int32="long"], [vi_cv_int32=no])))])
920 if test "$vi_cv_int32" = no; then
921 AC_MSG_ERROR([No signed 32-bit integral type.])
923 if test "$vi_cv_int32" != yes; then
924 int32_decl="typedef $vi_cv_int32 int32_t;"
927 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
928 [AC_TRY_COMPILE([#include <stdio.h>
930 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
932 AC_SUBST(NEED_FPRINTF_PROTO)
933 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
934 [AC_TRY_COMPILE([ #include <stdio.h>
935 typedef int (*funcPtr)();
936 ],[funcPtr ptr = (funcPtr) fprintf;],
937 vi_cv_proto_fprintf=no,
938 [vi_cv_proto_fprintf=yes])])
939 if test "$vi_cv_proto_fprintf" = yes; then
940 AC_DEFINE(NEED_FPRINTF_PROTO)
946 [ --with-db3=db3prefix Path to db3 installation. ])
947 if test "$with_db3" = "no"; then
948 AC_MSG_ERROR([Need DB 3.])
951 saveLDFLAGS="$LDFLAGS"
952 if test "x$with_db3" != "x"; then
953 LDFLAGS="-L$with_db3/lib $LDFLAGS"
954 CFLAGS="-I$with_db3/include $CFLAGS"
957 AC_CHECK_LIB(db, db_create,
958 [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
959 if test "$vi_cv_dbfatal" = "yes"; then
960 AC_MSG_ERROR([Need DB 3.])
963 LDFLAGS="$saveLDFLAGS"
966 AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
967 AC_ARG_ENABLE(dynamic-loading,
968 [ --enable-dynamic-loading Load DB 3 dynamically.],
969 [vi_cv_dl="yes"], [vi_cv_dl="no"])
970 AC_MSG_RESULT($vi_cv_dl)
971 if test "$vi_cv_dl" = yes; then
972 AC_CHECK_LIB(dl, dlopen,
973 [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
974 if test "$vi_cv_dlfatal" = "yes"; then
975 AC_MSG_ERROR([Need dl to support dynamic loading.])
979 PATH="$with_db3/lib:/usr/lib:/lib"
980 AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
981 if test "$vi_cv_path_db3" = no; then
982 AC_MSG_ERROR([Path of libdb-3.so not found.])
986 AC_DEFINE(USE_DYNAMIC_LOADING)
987 LTLIBOBJS="dldb.lo $LTLIBOBJS"
988 dl_src=../common/dldb.c
992 if test "X$with_db3" != "X"; then
993 LDFLAGS="`echo $with_db3/lib | sed "$LRscript"` $LDFLAGS"
998 dnl We compile in nvi's RE routines unless the user specifies otherwise.
999 AC_MSG_CHECKING(if --disable-re option specified)
1001 [ --disable-re DON'T use the nvi-provided RE routines.],
1002 [vi_cv_re_lib="other RE"], [vi_cv_re_lib="bundled RE"])
1003 AC_MSG_RESULT($vi_cv_re_lib)
1004 case "$vi_cv_re_lib" in
1006 CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
1007 LTLIBOBJS="\$(REOBJS) $LTLIBOBJS";;
1012 AC_OUTPUT(Makefile port.h:port.h.in
1013 pathnames.h:pathnames.h.in recover:recover.in)