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)
7 AM_INIT_AUTOMAKE([foreign])
8 AC_CONFIG_HEADER(config.h)
13 dnl part of AM_INIT_AUTOMAKE ?
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)
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.
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.
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"};;
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
61 AC_MSG_WARN([Nvi requires gcc 2.x to build on LynxOS.])
62 AC_MSG_ERROR([See build/README.LynxOS for more information.])
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-""};;
72 dnl The default OPTFLAG is -O
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.
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"}
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"};;
107 dnl A/UX has a broken getopt(3), strpbrk(3).
109 aux*) LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
112 dnl Ultrix has a broken POSIX.1 VDISABLE value.
114 ultrix*) AC_DEFINE(HAVE_BROKEN_VDISABLE, 1,
115 [Define if you have a Ultrix-style (broken) vdisable.]);;
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 /'
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)
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
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
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)
203 if test "$vi_cv_path_lsof" != no; then
204 INUSE='test `lsof -t $i`'
206 if test "$vi_cv_path_fuser" != no; then
210 dnl Check for programs used for installation
212 AC_PATH_PROG(vi_cv_path_ar, ar, missing_ar)
213 AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
214 AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
215 AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
216 AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
217 AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
218 AC_PATH_PROG(vi_cv_path_ranlib, ranlib, missing_ranlib)
219 AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
221 dnl Checks for libraries.
222 dnl Find the X libraries and includes.
225 if test "$no_x" != yes; then
226 if test "X$x_libraries" != "X"; then
227 XLIBS="`echo $x_libraries | sed "$LRscript"` $XLIBS"
230 if test "X$x_includes" != "X"; then
231 XINCS="-I$x_includes"
235 AC_DEFUN([VI_CV_REPLACE_FUNCS],
236 [AC_FOREACH([AC_Func], [$1], [])dnl
237 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
240 dnl Check if the user wants widechar support.
241 AC_MSG_CHECKING(if --enable-widechar option specified)
242 AC_ARG_ENABLE(widechar,
243 [ --enable-widechar Build a wide char aware vi.],
244 [vi_cv_widechar=$enableval], [vi_cv_widechar="no"])
245 if test "$vi_cv_widechar" = "yes"; then
246 AC_DEFINE(USE_WIDECHAR, 1, [Define when using wide characters.])
248 AC_MSG_RESULT($vi_cv_widechar)
250 dnl Check whether we can use iconv
251 AC_CHECK_HEADER(langinfo.h, [
252 AC_CHECK_HEADER(iconv.h, [
253 AC_DEFINE(USE_ICONV, 1, [Define when iconv can be used.])
254 VI_CV_REPLACE_FUNCS(iswblank)
258 dnl If the user wants a Gtk IPC front-end for nvi, build it.
259 AC_SUBST(vi_programs)
263 AC_MSG_CHECKING(if --enable-gtk option specified)
265 [ --enable-gtk Build a Gtk front-end for vi.],
266 [vi_cv_gtk=$enableval], [vi_cv_gtk="no"])
267 AC_MSG_RESULT($vi_cv_gtk)
268 if test "$vi_cv_gtk" = "yes"; then
272 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
273 if test x$PKG_CONFIG = xno ; then
274 if test "$vi_cv_widechar" = "yes"; then
276 [*** pkg-config not found. See http://pkgconfig.sourceforge.net])
280 if ! $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then
281 if test "$vi_cv_widechar" = "yes"; then
283 [*** pkg-config too old; version 0.5 or better required.])
289 if test x$PKG_CONFIG = xno ; then
290 PKG_CONFIG=/bin/false
293 vi_programs="$vi_programs vi-gtk"
295 AC_MSG_CHECKING(for gtk+)
296 if $PKG_CONFIG gtk+-2.0 ; then
297 GTKINCS=`$PKG_CONFIG --cflags gtk+-2.0`
298 GTKLIBS=`$PKG_CONFIG --libs gtk+-2.0`
301 AC_DEFINE(HAVE_PANGO, 1, [Define is appropriate pango is available.])
303 if test "$vi_cv_widechar" = "yes"; then
305 *** gtk+-2.0 is required. The latest version of gtk
306 *** is always available from ftp://ftp.gtk.org/.
310 GTKINCS="$GTK_CFLAGS"
311 GTKLIBS="$GTK_LIBS $LIBS"
316 LIBS="-lutil $GTKLIBS"
317 AC_CHECK_LIB(nvizvt, zvt_get_ptys,
318 [vi_cv_zvt="yes"], [vi_cv_zvt="no"])
319 if test "$vi_cv_zvt" = "yes"; then
320 GTKLIBS="-lnvizvt $LIBS"
321 AC_DEFINE(HAVE_ZVT, 1, [Define is appropriate zvt is available.])
324 # AC_PATH_PROG(vi_cv_gnome_config, gnome-config, no)
325 # if test "$vi_cv_gnome_config" != "no"; then
326 # ZVTLIBS=`$vi_cv_gnome_config zvt --libs`
327 # GTKLIBS="$ZVTLIBS $GTKLIBS"
331 dnl If the user wants a Motif IPC front-end for nvi, build it.
333 AC_MSG_CHECKING(if --enable-motif option specified)
335 [ --enable-motif Build a Motif front-end for vi.],
336 [vi_cv_motif=$enableval], [vi_cv_motif="no"])
337 AC_MSG_RESULT($vi_cv_motif)
338 if test "$vi_cv_motif" = "yes"; then
339 vi_programs="$vi_programs vi-motif"
343 dnl BSDI's Motif libraries aren't shared.
350 dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
351 dnl -lXext is generally available, the others aren't.
354 dnl Color icons require -lXpm, which may or may not be available,
355 dnl depending on the version of X11.
357 MOTIFLIBS="-lXm -lXt"
358 AC_CHECK_LIB(SM, main,
359 [vi_cv_smlib="yes"], [vi_cv_smlib="no"], "$XLIBS")
360 if test "$vi_cv_smlib" = "yes"; then
361 MOTIFLIBS="$MOTIFLIBS -lSM"
363 AC_CHECK_LIB(ICE, main,
364 [vi_cv_icelib="yes"], [vi_cv_icelib="no"], "$XLIBS")
365 if test "$vi_cv_icelib" = "yes"; then
366 MOTIFLIBS="$MOTIFLIBS -lICE"
368 AC_CHECK_LIB(Xext, main,
369 [vi_cv_xextlib="yes"], [vi_cv_xextlib="no"], "$XLIBS")
370 if test "$vi_cv_xextlib" = "yes"; then
371 MOTIFLIBS="$MOTIFLIBS -lXext"
373 AC_CHECK_LIB(Xpm, main,
374 [vi_cv_xpmlib="yes"], [vi_cv_xpmlib="no"], "$XLIBS")
375 if test "$vi_cv_xpmlib" = "yes"; then
376 MOTIFLIBS="$MOTIFLIBS -lXpm"
378 MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
382 dnl Check for threads
383 AC_MSG_CHECKING(if --enable-threads option specified)
384 AC_ARG_ENABLE(threads,
385 [ --enable-threads Turn on thread support.],
386 [vi_cv_threads=$enableval], [vi_cv_threads="no"])
387 AC_MSG_RESULT($vi_cv_threads)
388 if test "$vi_cv_threads" = "yes"; then
389 LIBS="$LIBS -lpthread"
390 AC_CACHE_VAL(vi_cv_have_pthreads, [dnl
391 AC_TRY_LINK([#include <pthread.h>],
393 [vi_cv_have_pthreads=yes],
394 [vi_cv_have_pthreads=no])])
395 if test "$vi_cv_have_pthreads" = "no"; then
396 AC_MSG_ERROR(No threading library found)
398 IPCOBJS="pthread.o $IPCOBJS"
399 AC_DEFINE(HAVE_PTHREAD, 1, [Define if using pthread.])
401 IPCOBJS="nothread.o $IPCOBJS"
404 dnl If the user wants a Perl interpreter in nvi, load it.
406 AC_SUBST(perlldflags)
408 AC_SUBST(vi_cv_perllib)
409 AC_MSG_CHECKING(if --enable-perlinterp option specified)
410 AC_ARG_ENABLE(perlinterp,
411 [ --enable-perlinterp Include a Perl interpreter in vi.],
412 [vi_cv_perlinterp=$enableval], [vi_cv_perlinterp="no"])
413 AC_MSG_RESULT($vi_cv_perlinterp)
414 if test "$vi_cv_perlinterp" = "yes"; then
415 if test "$vi_cv_path_perl" = no; then
416 AC_MSG_ERROR([No perl5 utility found.])
418 $vi_cv_path_perl -e 'require 5.004' || {
419 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
421 if test "$vi_cv_threads" = "yes"; then
422 useithreads=`$vi_cv_path_perl -MConfig -e 'print $Config{useithreads}'`
423 if test "X$useithreads" != "Xdefine"; then
424 AC_MSG_ERROR([vi threading only compatible with perl's ithreads.])
428 eval `$vi_cv_path_perl -V:shrpenv`
429 vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
430 perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
431 -e 'ccflags;perl_inc'`
432 if test "X$perlcppflags" != "X"; then
433 CPPFLAGS="$perlcppflags $CPPFLAGS"
435 perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
437 perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
439 LIBOBJS="perl.o perlxsi.o perlsfio.o $LIBOBJS"
440 AC_DEFINE(HAVE_PERL_INTERP, 1,
441 [Define if you want to compile in the Perl interpreter.])
442 AC_CACHE_CHECK([whether we need to use perl's setenv],
449 #if defined(USE_ENVIRON_ARRAY) && !defined(PERL_USE_SAFE_PUTENV)
455 ], [vi_cv_perl_setenv=yes], [vi_cv_perl_setenv=no])])
456 if test "$vi_cv_perl_setenv" = yes; then
457 AC_DEFINE(USE_PERL_SETENV, 1,
458 [Define when perl's setenv should be used.])
462 dnl If the user wants a Tk/Tcl interpreter in nvi, load it. Make sure that
463 dnl we can find a Tk/Tcl library.
464 AC_MSG_CHECKING(if --enable-tclinterp option specified)
465 AC_ARG_ENABLE(tclinterp,
466 [ --enable-tclinterp Include a Tk/Tcl interpreter in vi.],
467 [vi_cv_tclinterp=$enableval], [vi_cv_tclinterp="no"])
468 AC_MSG_RESULT($vi_cv_tclinterp)
469 if test "$vi_cv_tclinterp" = "yes"; then
470 AC_MSG_CHECKING([for tclConfig.sh])
471 AC_CACHE_VAL(vi_cv_tclconfig, [
472 vi_cv_tclconfig=`$srcdir/findconfig`])
473 AC_MSG_RESULT($vi_cv_tclconfig)
474 if test "x$vi_cv_tclconfig" = x; then
475 AC_MSG_ERROR([No Tcl library found;])
478 LIBOBJS="tcl.o $LIBOBJS"
479 LIBS="$TCL_LIB_SPEC $TCL_LIBS $LIBS"
480 AC_DEFINE(HAVE_TCL_INTERP, 1,
481 [Define if you want to compile in the Tcl interpreter.])
486 AC_SUBST(CURSCPPFLAGS)
487 AC_SUBST(CURSLDFLAGS)
488 AC_SUBST(HAVE_NCURSESW)
490 dnl AC_ARG_WITH(slang,
491 dnl [ --with-slang[=DIR] Use S-Lang instead of curses. ],
493 dnl if test "$withval" != yes; then
494 dnl LDFLAGS="-L${withval}/lib $LDFLAGS"
495 dnl CPPFLAGS="-I${withval}/include $CPPFLAGS"
497 dnl AC_DEFINE(USE_SLANG_CURSES)
498 dnl AC_CHECK_LIB(slang, SLtt_get_terminfo,
499 dnl [CURSLIBS="$CURSLIBS -lslang -lm"],
500 dnl [AC_MSG_ERROR(unable to compile. check config.log)], -lm)
502 dnl vi_cv_curses=slcurses
506 SAVELDFLAGS="$LDFLAGS"
507 SAVECPPFLAGS="$CPPFLAGS"
509 [ --with-curses=DIR Path to curses installation. ])
510 if test "x$with_curses" != "x"; then
511 CURSLDFLAGS="`echo $with_curses/lib | sed "$LRscript"` $CURSLDFLAGS"
512 CURSCPPFLAGS="-I$with_curses/include $CURSCPPFLAGS"
514 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
515 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
517 if test "$vi_cv_widechar" = "yes"; then
518 for vi_cv_curses in ncurses ncursesw curses; do
519 AC_CHECK_LIB($vi_cv_curses, waddnwstr,[break])
523 for vi_cv_curses in ncurses ncursesw curses; do
524 AC_CHECK_LIB($vi_cv_curses, initscr, [break])
529 if test "$vi_cv_curses" != "unknown"; then
531 if test "$vi_cv_curses" = "ncurses"; then
532 AC_CHECK_HEADERS(ncurses.h, [CURSHEADER=ncurses.h])
534 if test "$vi_cv_curses" = "ncursesw"; then
535 AC_CHECK_HEADERS(ncursesw/ncurses.h,
536 [CURSHEADER=ncursesw/ncurses.h])
538 vi_programs="vi $vi_programs"
539 CURSLIBS="-l$vi_cv_curses"
541 AC_MSG_WARN([*** No suitable curses library found.])
542 if test "$vi_programs"X = X; then
543 AC_MSG_ERROR([No executable to build.])
547 dnl Check for the termcap/termlib library. These two checks must occur in the
548 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
549 dnl On Solaris curses==termlib, but different versions of curses
550 dnl can be used. Avoid loading termlib is curses has tgetent.
551 AC_CHECK_LIB($vi_cv_curses, tgetent,
552 [vi_cv_curses_tgetent=yes], [vi_cv_curses_tgetent=no])
553 if test "$vi_cv_curses_tgetent" = no; then
554 AC_CHECK_LIB(termlib, tgetent,
555 [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
556 if test "$vi_cv_termlib" = no; then
557 AC_CHECK_LIB(termcap, tgetent,
558 [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
561 if test "$vi_cv_termlib" != no; then
562 CURSLIBS="$CURSLIBS $vi_cv_termlib"
566 LDFLAGS="$SAVELDFLAGS"
567 CPPFLAGS="$SAVECPPFLAGS"
570 dnl Checks for header files.
571 AC_MSG_CHECKING(for sys/mman.h)
572 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
573 AC_TRY_CPP([#include <sys/mman.h>],
574 [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
575 if test "$vi_cv_include_sys_mman" = yes; then
576 AC_DEFINE(HAVE_SYS_MMAN_H, 1, [Define if you have <sys/mman.h>])
578 AC_MSG_RESULT($vi_cv_include_sys_mman)
580 AC_MSG_CHECKING(for sys/select.h)
581 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
582 AC_TRY_CPP([#include <sys/select.h>],
583 [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
584 if test "$vi_cv_include_sys_select" = yes; then
585 AC_DEFINE(HAVE_SYS_SELECT_H, 1, [Define if you have <sys/select.h])
587 AC_MSG_RESULT($vi_cv_include_sys_select)
589 dnl Checks for typedefs, structures, and compiler characteristics.
590 AC_CHECK_TYPE(ssize_t, int)
600 AC_CHECK_HEADER(sys/cdefs.h, [],
601 [AC_CONFIG_FILES([sys/cdefs.h:../db.1.85/PORT/include/cdefs.h])])
603 dnl Checks for library functions.
604 VI_CV_REPLACE_FUNCS(bsearch gethostname memchr memset)
605 VI_CV_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
606 VI_CV_REPLACE_FUNCS(snprintf vsnprintf)
608 AC_CHECK_FUNCS(select)
609 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
610 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
611 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
616 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
617 if test "$need_env" = yes; then
618 LIBOBJS="env.o $LIBOBJS"
621 dnl If we need strsep, add it and define it so we get a prototype.
622 if test "$need_strsep" = yes; then
623 LIBOBJS="strsep.o $LIBOBJS"
626 dnl Check for fcntl/flock
627 dnl Use flock preferentially, since it has cleaner semantics and won't
628 dnl hang up the editor.
630 dnl Ultrix has a broken fcntl, but a working flock.
631 dnl IRIX and DGUX have a broken flock, but working fcntl.
632 AC_MSG_CHECKING(for fcntl/flock)
633 AC_CACHE_VAL(vi_cv_lock, [dnl
639 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
640 [vi_cv_lock=flock]);;
642 if test "$vi_cv_lock" = none; then
643 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
647 if test "$vi_cv_lock" = flock; then
648 AC_DEFINE(HAVE_LOCK_FLOCK, 1,
649 [Define if you have flock(2) style locking.])
651 if test "$vi_cv_lock" = fcntl; then
652 AC_DEFINE(HAVE_LOCK_FCNTL, 1,
653 [Define if you have fcntl(2) style locking.])
655 AC_MSG_RESULT($vi_cv_lock)
657 dnl Check for ftruncate/chsize
658 AC_MSG_CHECKING(for ftruncate/chsize)
659 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
660 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
661 [vi_cv_ftruncate=ftruncate],
662 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
663 [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
664 if test "$vi_cv_ftruncate" = ftruncate; then
665 AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE, 1,
666 [Define if you have the ftruncate(2) system call.])
668 if test "$vi_cv_ftruncate" = chsize; then
669 AC_DEFINE(HAVE_FTRUNCATE_CHSIZE, 1,
670 [Define if you have the chsize(2) system call.])
672 if test "$vi_cv_ftruncate" = no; then
673 AC_MSG_ERROR([No file truncation system call.])
675 AC_MSG_RESULT($vi_cv_ftruncate)
678 CSAVELDFLAGS="$LDFLAGS"
679 CSAVECPPFLAGS="$CPPFLAGS"
680 LIBS="$CURSLIBS $LIBS"
681 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
682 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
683 dnl Check for the tigetstr/tigetnum functions.
684 AC_MSG_CHECKING(for tigetstr/tigetnum)
685 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
686 AC_TRY_LINK([#include <$CURSHEADER>], [tigetstr(0);],
687 [vi_cv_have_curses_tigetstr=yes],
688 [vi_cv_have_curses_tigetstr=no])])
689 if test "$vi_cv_have_curses_tigetstr" = yes; then
690 AC_DEFINE(HAVE_CURSES_TIGETSTR, 1,
691 [Define if you have the curses(3) tigetstr/tigetnum functions.])
693 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
695 dnl Check for potentially missing curses functions in system or user-specified
696 dnl libraries. We also have to guess at whether the specified library is a
697 dnl BSD or System V style curses. Use the newterm function, all System V
698 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
699 if test "$vi_cv_curses" = "bundled curses"; then
700 AC_DEFINE(HAVE_BSD_CURSES, 1,
701 [Define if you have a BSD version of curses.])
702 AC_DEFINE(HAVE_CURSES_WADDNSTR, 1,
703 [Define if you have the curses(3) waddnstr function.])
704 AC_DEFINE(HAVE_CURSES_IDLOK, 1,
705 [Define if you have the curses(3) idlok function.])
707 dnl Check for the waddnstr function.
708 AC_MSG_CHECKING(for waddnstr)
709 AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
710 AC_TRY_LINK([#include <$CURSHEADER>], [waddnstr(stdscr, 0, 0);],
711 [vi_cv_have_curses_waddnstr=yes],
712 [vi_cv_have_curses_waddnstr=no])])
713 if test "$vi_cv_have_curses_waddnstr" = yes; then
714 AC_DEFINE(HAVE_CURSES_WADDNSTR, 1,
715 [Define if you have the curses(3) waddnstr function.])
717 AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
719 dnl Check for the beep function.
720 AC_MSG_CHECKING(for beep)
721 AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
722 AC_TRY_LINK([#include <$CURSHEADER>], [beep();],
723 [vi_cv_have_curses_beep=yes],
724 [vi_cv_have_curses_beep=no])])
725 if test "$vi_cv_have_curses_beep" = yes; then
726 AC_DEFINE(HAVE_CURSES_BEEP, 1,
727 [Define if you have the curses(3) beep function.])
729 AC_MSG_RESULT($vi_cv_have_curses_beep)
731 dnl Check for the flash function.
732 AC_MSG_CHECKING(for flash)
733 AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
734 AC_TRY_LINK([#include <$CURSHEADER>], [flash();],
735 [vi_cv_have_curses_flash=yes],
736 [vi_cv_have_curses_flash=no])])
737 if test "$vi_cv_have_curses_flash" = yes; then
738 AC_DEFINE(HAVE_CURSES_FLASH, 1,
739 [Define if you have the curses(3) flash function.])
741 AC_MSG_RESULT($vi_cv_have_curses_flash)
743 dnl Check for the idlok function.
744 AC_MSG_CHECKING(for idlok)
745 AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
746 AC_TRY_LINK([#include <$CURSHEADER>], [idlok(0, 0);],
747 [vi_cv_have_curses_idlok=yes],
748 [vi_cv_have_curses_idlok=no])])
749 if test "$vi_cv_have_curses_idlok" = yes; then
750 AC_DEFINE(HAVE_CURSES_IDLOK, 1,
751 [Define if you have the curses(3) idlok function.])
753 AC_MSG_RESULT($vi_cv_have_curses_idlok)
755 dnl Check for the keypad function.
756 AC_MSG_CHECKING(for keypad)
757 AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
758 AC_TRY_LINK([#include <$CURSHEADER>], [keypad(0, 0);],
759 [vi_cv_have_curses_keypad=yes],
760 [vi_cv_have_curses_keypad=no])])
761 if test "$vi_cv_have_curses_keypad" = yes; then
762 AC_DEFINE(HAVE_CURSES_KEYPAD, 1,
763 [Define if you have the curses(3) keypad function.])
765 AC_MSG_RESULT($vi_cv_have_curses_keypad)
767 dnl Check for the newterm function.
768 AC_MSG_CHECKING(for newterm)
769 AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
770 AC_TRY_LINK([#include <$CURSHEADER>], [newterm(0, 0, 0);],
771 [vi_cv_have_curses_newterm=yes],
772 [vi_cv_have_curses_newterm=no])])
773 if test "$vi_cv_have_curses_newterm" = yes; then
774 AC_DEFINE(HAVE_CURSES_NEWTERM, 1,
775 [Define if you have the curses(3) newterm function.])
777 AC_MSG_RESULT($vi_cv_have_curses_newterm)
779 if test "$vi_cv_have_curses_newterm" = no; then
780 AC_DEFINE(HAVE_BSD_CURSES, 1,
781 [Define if you have a BSD version of curses.])
785 dnl Check for the setupterm function. We make this check regardless of
786 dnl using the system library, because it may be part of the underlying
787 dnl termcap/termlib support, and we want to use the local one.
788 AC_MSG_CHECKING(for setupterm)
789 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
790 AC_TRY_LINK([#include <$CURSHEADER>], [setupterm(0, 0, 0);],
791 [vi_cv_have_curses_setupterm=yes],
792 [vi_cv_have_curses_setupterm=no])])
793 if test "$vi_cv_have_curses_setupterm" = yes; then
794 AC_DEFINE(HAVE_CURSES_SETUPTERM, 1,
795 [Define if you have the curses(3) setupterm function.])
797 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
799 LDFLAGS="$CSAVELDFLAGS"
800 CPPFLAGS="$CSAVECPPFLAGS"
802 dnl Some moron decided to drop off an argument from the gettimeofday call,
803 dnl without changing the name.
804 AC_MSG_CHECKING(for broken gettimeofday system call)
805 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
806 AC_TRY_LINK([#include <sys/types.h>
807 #include <sys/time.h>], [gettimeofday(0, 0);],
808 [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
809 if test "$vi_cv_gettimeofday" = broken; then
810 AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY, 1,
811 [Define if you have a System V-style (broken) gettimeofday.])
813 AC_MSG_RESULT($vi_cv_gettimeofday)
815 dnl Check for which version of openpty to use, System V or Berkeley.
816 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
817 AC_CHECK_HEADER(sys/stropts.h,
818 [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
819 if test "$vi_cv_sys5_pty" = yes; then
820 AC_DEFINE(HAVE_SYS5_PTY, 1,
821 [Define if you have the System V style pty calls.])
823 AC_MSG_CHECKING(for System V pty calls)
824 AC_MSG_RESULT($vi_cv_sys5_pty)
826 dnl Check for the revoke system call.
827 AC_MSG_CHECKING(for revoke system call)
828 AC_CACHE_VAL(vi_cv_revoke, [dnl
829 AC_TRY_LINK(, [revoke("a");],
830 [vi_cv_revoke=yes], [vi_cv_revoke=no])])
831 if test "$vi_cv_revoke" = yes; then
832 AC_DEFINE(HAVE_REVOKE, 1,
833 [Define if you have the Berkeley style revoke(2) system call.])
835 AC_MSG_RESULT($vi_cv_revoke)
837 dnl Some versions of sprintf return a pointer to the first argument instead
838 dnl of a character count. We assume that the return value of snprintf and
839 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
840 AC_MSG_CHECKING(for int type sprintf return value)
841 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
842 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
843 [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
844 if test "$vi_cv_sprintf_count" = no; then
845 AC_DEFINE(SPRINTF_RET_CHARPNT, 1,
846 [Define if your sprintf returns a pointer, not a length.])
848 AC_MSG_RESULT($vi_cv_sprintf_count)
851 dnl Check for the standard shorthand types.
852 AC_SUBST(u_char_decl)
853 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
854 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
855 [vi_cv_uchar=yes], [vi_cv_uchar=no])])
856 if test "$vi_cv_uchar" = no; then
857 u_char_decl="typedef unsigned char u_char;"
860 AC_SUBST(u_short_decl)
861 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
862 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
863 [vi_cv_ushort=yes], [vi_cv_ushort=no])])
864 if test "$vi_cv_ushort" = no; then
865 u_short_decl="typedef unsigned short u_short;"
869 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
870 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
871 [vi_cv_uint=yes], [vi_cv_uint=no])])
872 if test "$vi_cv_uint" = no; then
873 u_int_decl="typedef unsigned int u_int;"
876 AC_SUBST(u_long_decl)
877 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
878 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
879 [vi_cv_ulong=yes], [vi_cv_ulong=no])])
880 if test "$vi_cv_ulong" = no; then
881 u_long_decl="typedef unsigned long u_long;"
884 dnl DB/Vi use specific integer sizes.
885 AC_SUBST(u_int8_decl)
886 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
887 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
889 AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
890 [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
891 if test "$vi_cv_uint8" = no; then
892 AC_MSG_ERROR(No unsigned 8-bit integral type.)
894 if test "$vi_cv_uint8" != yes; then
895 u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
898 AC_SUBST(u_int16_decl)
899 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
900 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
902 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
903 [vi_cv_uint16="unsigned short"],
904 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
905 [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
906 if test "$vi_cv_uint16" = no; then
907 AC_MSG_ERROR([No unsigned 16-bit integral type.])
909 if test "$vi_cv_uint16" != yes; then
910 u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
914 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
915 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
917 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
918 [vi_cv_int16="short"],
919 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
920 [vi_cv_int16="int"], [vi_cv_int16=no])))])
921 if test "$vi_cv_int16" = no; then
922 AC_MSG_ERROR([No signed 16-bit integral type.])
924 if test "$vi_cv_int16" != yes; then
925 int16_decl="typedef $vi_cv_int16 int16_t;"
928 AC_SUBST(u_int32_decl)
929 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
930 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
932 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
933 [vi_cv_uint32="unsigned int"],
934 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
935 [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
936 if test "$vi_cv_uint32" = no; then
937 AC_MSG_ERROR([No unsigned 32-bit integral type.])
939 if test "$vi_cv_uint32" != yes; then
940 u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
944 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
945 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
947 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
949 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
950 [vi_cv_int32="long"], [vi_cv_int32=no])))])
951 if test "$vi_cv_int32" = no; then
952 AC_MSG_ERROR([No signed 32-bit integral type.])
954 if test "$vi_cv_int32" != yes; then
955 int32_decl="typedef $vi_cv_int32 int32_t;"
958 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
959 [AC_TRY_COMPILE([#include <stdio.h>
961 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
963 AC_SUBST(NEED_FPRINTF_PROTO)
964 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
965 [AC_TRY_COMPILE([ #include <stdio.h>
966 typedef int (*funcPtr)();
967 ],[funcPtr ptr = (funcPtr) fprintf;],
968 vi_cv_proto_fprintf=no,
969 [vi_cv_proto_fprintf=yes])])
970 if test "$vi_cv_proto_fprintf" = yes; then
971 AC_DEFINE(NEED_FPRINTF_PROTO, 1,
972 [Define when fprintf prototype not in an obvious place.])
976 [ --with-db=bundled|system Which db to use. ])
979 AC_ARG_WITH(db_prefix,
980 [ --with-db-prefix=PFX Path to db installation. ])
983 AC_SUBST(DB_CPPFLAGS)
984 if test "x$with_db_prefix" != "x"; then
985 DB_LDFLAGS="-L$with_db_prefix/lib $LDFLAGS"
986 DB_CPPFLAGS="-I$with_db_prefix/include $CPPFLAGS"
987 with_db_type="system"
990 AC_MSG_CHECKING(which db to use)
991 case "$with_db_type" in
995 with_db_type="bundled"
998 AC_MSG_RESULT($with_db_type)
999 AM_CONDITIONAL(BUNDLED_DB, test $with_db_type = bundled)
1001 case "$with_db_type" in
1003 AC_DEFINE(USE_BUNDLED_DB, 1, [Define when using bundled db.])
1004 LIBOBJS="log1.o $LIBOBJS"
1007 SAVELDFLAGS="$LDFLAGS"
1010 if test "x$with_db_prefix" != "x"; then
1011 LDFLAGS="-L$with_db_prefix/lib $LDFLAGS"
1012 CPPFLAGS="-I$with_db_prefix/include $CPPFLAGS"
1013 with_db_type="system"
1017 AC_TRY_LINK([#include <db.h>],
1018 [db_create(NULL,NULL,0)],
1019 [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
1020 if test "$vi_cv_dbfatal" = "yes"; then
1021 AC_MSG_ERROR([Need DB 3.])
1025 LDFLAGS="$SAVELDFLAGS"
1028 AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
1029 AC_ARG_ENABLE(dynamic-loading,
1030 [ --enable-dynamic-loading Load DB 3 dynamically.],
1031 [vi_cv_dl=$enableval], [vi_cv_dl="no"])
1032 AC_MSG_RESULT($vi_cv_dl)
1033 if test "$vi_cv_dl" = yes; then
1034 AC_CHECK_LIB(dl, dlopen,
1035 [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
1036 if test "$vi_cv_dlfatal" = "yes"; then
1037 AC_MSG_ERROR([Need dl to support dynamic loading.])
1041 PATH="$with_db_prefix/lib:/usr/lib:/lib"
1042 AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
1043 if test "$vi_cv_path_db3" = no; then
1044 AC_MSG_ERROR([Path of libdb-3.so not found.])
1048 AC_DEFINE(USE_DYNAMIC_LOADING, 1,
1049 [Define when dynamically loading DB 3.])
1050 LIBOBJS="dldb.o $LIBOBJS"
1051 dl_src=../common/dldb.c
1055 if test "X$with_db_prefix" != "X"; then
1056 LDFLAGS="`echo $with_db_prefix/lib | sed "$LRscript"` $LDFLAGS"
1060 AC_ARG_WITH(db_build,
1061 [ --with-db-build=prefix Path to db build. ])
1062 if test "x$with_db_build" != "x"; then
1063 vi_cv_dbsrc=`$AWK '/^srcdir/ {gsub("srcdir[[ \t]]*=","");print $1}' \
1064 $with_db_build/Makefile`
1065 case $with_db_build in
1068 with_db_build="$with_db_build/";;
1070 case $vi_cv_dbsrc in
1073 vi_cv_dbsrc="$with_db_build$vi_cv_dbsrc";;
1079 [ --enable-db4-logging Enable experimental/broken db4 logging.],
1081 AC_MSG_CHECKING(for DB 4)
1085 [vi_cv_db4="yes"], [vi_cv_db4="no"])
1086 AC_MSG_RESULT($vi_cv_db4)
1088 if test "$vi_cv_db4" = "yes"; then
1089 DB_CPPFLAGS="-I$vi_cv_dbsrc/include $DB_CPPFLAGS"
1090 DB_CPPFLAGS="-I$vi_cv_dbsrc/include_auto $DB_CPPFLAGS"
1091 DB_CPPFLAGS="-I$with_db_build $DB_CPPFLAGS"
1092 AC_DEFINE(USE_DB4_LOGGING, 1, [Define when using db4 logging.])
1093 LIBOBJS="log4.o vi_auto.o vi_rec.o $LIBOBJS"
1095 LIBOBJS="log.o $LIBOBJS"
1100 dnl We compile in nvi's RE routines unless the user specifies otherwise.
1101 AC_MSG_CHECKING(if --disable-re option specified)
1103 [ --disable-re DON'T use the nvi-provided RE routines.],
1104 [if test "$enable_re" = "yes"; then
1105 vi_cv_re_lib="bundled RE"
1107 vi_cv_re_lib="other RE"
1108 fi],[vi_cv_re_lib="bundled RE"])
1109 AC_MSG_RESULT($vi_cv_re_lib)
1110 case "$vi_cv_re_lib" in
1112 CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
1113 LIBOBJS="regcomp.o regerror.o regexec.o regfree.o $LIBOBJS";;
1118 AC_OUTPUT(Makefile port.h:port.h.in compat.h:port.h.in
1119 pathnames.h:pathnames.h.in recover:recover.in)