More use of -R option.
[nvi.git] / dist / configure.in
blob9b17798831fcebd1e6e9b04a57e0cb816fa0a39c
1 dnl     @(#)configure.in        8.148 (Berkeley) 8/3/97
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.2)
6 AM_CONFIG_HEADER(config.h)
8 dnl Configure setup.
9 AC_PROG_INSTALL()
10 AC_CANONICAL_HOST
11 dnl part of AM_INIT_AUTOMAKE ?
12 dnl AC_ARG_PROGRAM()
14 AC_PROG_LIBTOOL
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)
19 AC_ARG_ENABLE(debug,
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
24         AC_DEFINE(DEBUG)
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.
30 dnl XXX
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.
37 AC_SUBST(CPPFLAGS)
38 case "$host_os" in
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"};;
50 lynxos*)   AC_PROG_CC()
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
56                 AC_MSG_RESULT(yes)
57            else
58                 AC_MSG_RESULT(no)
59                 AC_MSG_WARN([Nvi requires gcc 2.x to build on LynxOS.])
60                 AC_MSG_ERROR([See build/README.LynxOS for more information.])
61            fi;;
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-""};;
68 esac
70 dnl The default OPTFLAG is -O
71 AC_SUBST(OPTFLAG)
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.
76 AC_SUBST(CC)
77 CC=${CC-cc}
78 CFLAGS=${CFLAGS-""}
79 AC_PROG_CC
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"}
86 dnl Libraries.
87 case "$host_os" in
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            RLIBS=yes;;
99 wgs*)      LIBS=${LIBS-"-lnsl"};;
100 esac
102 dnl A/UX has a broken getopt(3), strpbrk(3).
103 case "$host_os" in
104 aux*)      LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
105 esac
107 dnl Ultrix has a broken POSIX.1 VDISABLE value.
108 case "$host_os" in
109 ultrix*)   AC_DEFINE(HAVE_BROKEN_VDISABLE);;
110 esac
112 if test "X$RLIBS" = "Xyes"; then
113         LRscript='s/^\(.*\)/-R\1 -L\1 /'
114 else
115         LRscript='s/^\(.*\)/-L\1 /'
118 dnl If the user wants a tracing version, add the TRACE compile flag.
119 AC_MSG_CHECKING(if --enable-trace option specified)
120 AC_ARG_ENABLE(trace,
121         [  --enable-trace          Build a tracing version.],
122         [vi_cv_trace="yes"], [vi_cv_trace="no"])
123 if test "$vi_cv_trace" = yes; then
124         CPPFLAGS="-DTRACE $CPPFLAGS"
126 AC_MSG_RESULT($vi_cv_trace)
128 dnl The user may have additional CPP information.
129 CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"
131 dnl The user may have additional load line information.
132 LDFLAGS="$ADDLDFLAGS $LDFLAGS"
134 dnl The user may have additional library information.
135 LIBS="$ADDLIBS $LIBS"
137 dnl Checks for programs.
138 PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib"
140 dnl Check for the shell path.
141 AC_PATH_PROG(vi_cv_path_shell, sh, no)
142 if test "$vi_cv_path_shell" = no; then
143         AC_MSG_ERROR([No shell utility found.])
146 dnl Check for the sendmail path.
147 AC_PATH_PROG(vi_cv_path_sendmail, sendmail, no)
148 if test "$vi_cv_path_sendmail" = no; then
149         AC_MSG_WARN([No sendmail utility found;])
150         AC_MSG_WARN([    users will not be told of saved files.])
153 dnl Check for the perl5/perl path.
154 AC_SUBST(vi_cv_path_perl)
155 AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)
157 dnl Check for the "preserve" path.
158 dnl Historically, nvi has used /var/tmp/vi.recover.  The Linux filesystem
159 dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
160 dnl beneath it so that we don't have name collisions with other editors.
161 dnl Other systems have /var/preserve as well, so we test first for an already
162 dnl existing name, and then use the first one that's writeable.
163 AC_SUBST(vi_cv_path_preserve)
164 AC_MSG_CHECKING(for preserve directory)
165 AC_CACHE_VAL(vi_cv_path_preserve, [dnl
166         dirlist="/var/preserve /var/tmp /usr/tmp"
167         vi_cv_path_preserve=no
168         for i in $dirlist; do
169                 if test -d $i/vi.recover; then
170                         vi_cv_path_preserve=$i/vi.recover
171                         break;
172                 fi
173         done
174         if test "$vi_cv_path_preserve" = no; then
175                 for i in $dirlist; do
176                         if test -d $i -a -w $i; then
177                                 vi_cv_path_preserve=$i/vi.recover
178                                 break;
179                         fi
180                 done
182         fi])
183 if test "$vi_cv_path_preserve" = no; then
184         AC_MSG_ERROR([No writeable preserve directory found.])
186 AC_MSG_RESULT($vi_cv_path_preserve)
188 dnl Check for programs used for installation
189 AC_PROG_AWK
190 AC_PATH_PROG(vi_cv_path_ar, ar, missing_ar)
191 AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
192 AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
193 AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
194 AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
195 AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
196 AC_PATH_PROG(vi_cv_path_ranlib, ranlib, missing_ranlib)
197 AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
199 dnl Checks for libraries.
200 dnl Find the X libraries and includes.
201 AC_PATH_X
202 AC_SUBST(XINCS)
203 if test "$no_x" != yes; then
204         if test "X$x_libraries" != "X"; then
205                 XLIBS="`echo $x_libraries | sed "$LRscript"` $XLIBS"
206         fi
207         XLIBS="$XLIBS -lX11"
208         if test "X$x_includes" != "X"; then
209                 XINCS="-I$x_includes"
210         fi
213 dnl Check if the user wants widechar support.
214 AC_MSG_CHECKING(if --enable-widechar option specified)
215 AC_ARG_ENABLE(widechar,
216         [  --enable-widechar       Build a wide char aware vi.],
217         [vi_cv_widechar="yes"], [vi_cv_widechar="no"])
218 if test "$vi_cv_widechar" = "yes"; then
219         AC_DEFINE(USE_WIDECHAR)
221 AC_MSG_RESULT($vi_cv_widechar)
223 dnl If the user wants a Gtk IPC front-end for nvi, build it.
224 AC_SUBST(vi_programs)
225 AC_SUBST(vi_ipc)
226 AC_SUBST(GTKLIBS)
227 AC_SUBST(GTKINCS)
228 AC_MSG_CHECKING(if --enable-gtk option specified)
229 AC_ARG_ENABLE(gtk,
230         [  --enable-gtk            Build a Gtk front-end for vi.],
231         [vi_cv_gtk="yes"], [vi_cv_gtk="no"])
232 AC_MSG_RESULT($vi_cv_gtk)
233 if test "$vi_cv_gtk" = "yes"; then
234         #
235         # Find pkg-config
236         #
237         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
238         if test x$PKG_CONFIG = xno ; then
239             if test "$vi_cv_widechar" = "yes"; then
240                 AC_MSG_ERROR(
241 [*** pkg-config not found. See http://pkgconfig.sourceforge.net])
242             fi
244         else
245             if ! $PKG_CONFIG --atleast-pkgconfig-version 0.5 ; then
246                 if test "$vi_cv_widechar" = "yes"; then
247                     AC_MSG_ERROR(
248 [*** pkg-config too old; version 0.5 or better required.])
249                 fi
250                 PKG_CONFIG=no
251             fi
253         fi
254         if test x$PKG_CONFIG = xno ; then
255             PKG_CONFIG=/bin/false
256         fi
258         vi_programs="$vi_programs vi-gtk"
259         vi_ipc=vi-ipc
260         AC_MSG_CHECKING(for gtk+)
261         if $PKG_CONFIG gtk+-2.0 ; then
262               GTKINCS=`$PKG_CONFIG --cflags gtk+-2.0`
263               GTKLIBS=`$PKG_CONFIG --libs gtk+-2.0`
265               AC_MSG_RESULT(ok)
266               AC_DEFINE(HAVE_PANGO)
267         else
268             if test "$vi_cv_widechar" = "yes"; then
269                 AC_MSG_ERROR([
270 *** gtk+-2.0 is required. The latest version of gtk
271 *** is always available from ftp://ftp.gtk.org/.
272                 ])
273             else
274                 AM_PATH_GTK(1.2.0)
275                 GTKINCS="$GTK_CFLAGS"
276                 GTKLIBS="$GTK_LIBS $LIBS"
277             fi
278         fi
280         SAVELIBS="$LIBS"
281         LIBS="-lutil $GTKLIBS"
282         AC_CHECK_LIB(nvizvt, zvt_get_ptys,
283                 [vi_cv_zvt="yes"], [vi_cv_zvt="no"])
284         if test "$vi_cv_zvt" = "yes"; then
285                 GTKLIBS="-lnvizvt $LIBS"
286                 AC_DEFINE(HAVE_ZVT)
287         fi
288         LIBS="$SAVELIBS"
289 #       AC_PATH_PROG(vi_cv_gnome_config, gnome-config, no)
290 #       if test "$vi_cv_gnome_config" != "no"; then
291 #               ZVTLIBS=`$vi_cv_gnome_config zvt --libs`
292 #               GTKLIBS="$ZVTLIBS $GTKLIBS"
293 #       fi
296 dnl If the user wants a Motif IPC front-end for nvi, build it.
297 AC_SUBST(MOTIFLIBS)
298 AC_MSG_CHECKING(if --enable-motif option specified)
299 AC_ARG_ENABLE(motif,
300         [  --enable-motif          Build a Motif front-end for vi.],
301         [vi_cv_motif="yes"], [vi_cv_motif="no"])
302 AC_MSG_RESULT($vi_cv_motif)
303 if test "$vi_cv_motif" = "yes"; then
304         vi_programs="$vi_programs vi-motif"
305         vi_ipc=vi-ipc
307         dnl XXX
308         dnl BSDI's Motif libraries aren't shared.
310         case "$host_os" in
311         bsdi*)  CC=cc;;
312         esac
314         dnl XXX
315         dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
316         dnl -lXext is generally available, the others aren't.
317         dnl
318         dnl XXX
319         dnl Color icons require -lXpm, which may or may not be available,
320         dnl depending on the version of X11.
322         MOTIFLIBS="-lXm -lXt"
323         AC_CHECK_LIB(SM, main,
324             [vi_cv_smlib="yes"], [vi_cv_smlib="no"], "$XLIBS")
325         if test "$vi_cv_smlib" = "yes"; then
326                 MOTIFLIBS="$MOTIFLIBS -lSM"
327         fi
328         AC_CHECK_LIB(ICE, main,
329             [vi_cv_icelib="yes"], [vi_cv_icelib="no"], "$XLIBS")
330         if test "$vi_cv_icelib" = "yes"; then
331                 MOTIFLIBS="$MOTIFLIBS -lICE"
332         fi
333         AC_CHECK_LIB(Xext, main,
334             [vi_cv_xextlib="yes"], [vi_cv_xextlib="no"], "$XLIBS")
335         if test "$vi_cv_xextlib" = "yes"; then
336                 MOTIFLIBS="$MOTIFLIBS -lXext"
337         fi
338         AC_CHECK_LIB(Xpm, main,
339             [vi_cv_xpmlib="yes"], [vi_cv_xpmlib="no"], "$XLIBS")
340         if test "$vi_cv_xpmlib" = "yes"; then
341                 MOTIFLIBS="$MOTIFLIBS -lXpm"
342         fi
343         MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
346 AC_SUBST(IPCOBJS)
347 dnl Check for threads
348 AC_MSG_CHECKING(if --enable-threads option specified)
349 AC_ARG_ENABLE(threads,
350         [  --enable-threads        Turn on thread support.],
351         [vi_cv_threads="yes"], [vi_cv_threads="no"])
352 AC_MSG_RESULT($vi_cv_threads)
353 if test "$vi_cv_threads" = "yes"; then
354         LIBS="$LIBS -lpthread"
355         AC_CACHE_VAL(vi_cv_have_pthreads, [dnl
356         AC_TRY_LINK([#include <pthread.h>],
357                 [pthread_self()],
358                 [vi_cv_have_pthreads=yes],
359                 [vi_cv_have_pthreads=no])])
360         if test "$vi_cv_have_pthreads" = "no"; then
361                 AC_MSG_ERROR(No threading library found)
362         fi
363         IPCOBJS="pthread.o $IPCOBJS"
364         AC_DEFINE(HAVE_PTHREAD)
365 else
366         IPCOBJS="nothread.o $IPCOBJS"
369 dnl If the user wants a Perl interpreter in nvi, load it.
370 AC_SUBST(shrpenv)
371 AC_SUBST(perlldflags)
372 AC_SUBST(perllibs)
373 AC_SUBST(vi_cv_perllib)
374 AC_SUBST(LTLIBOBJS)
375 AC_MSG_CHECKING(if --enable-perlinterp option specified)
376 AC_ARG_ENABLE(perlinterp,
377         [  --enable-perlinterp     Include a Perl interpreter in vi.],
378         [vi_cv_perlinterp="yes"], [vi_cv_perlinterp="no"])
379 AC_MSG_RESULT($vi_cv_perlinterp)
380 if test "$vi_cv_perlinterp" = "yes"; then
381         if test "$vi_cv_path_perl" = no; then
382                 AC_MSG_ERROR([No perl5 utility found.])
383         fi
384         $vi_cv_path_perl -e 'require 5.004' || {
385                 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
386         }
387         if test "$vi_cv_threads" = "yes"; then
388                 useithreads=`$vi_cv_path_perl -MConfig -e 'print $Config{useithreads}'`
389                 if test "X$useithreads" != "Xdefine"; then
390                         AC_MSG_ERROR([vi threading only compatible with perl's ithreads.])
391                 fi
392         fi
394         eval `$vi_cv_path_perl -V:shrpenv`
395         vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
396         perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
397                 -e 'ccflags;perl_inc'`
398         if test "X$perlcppflags" != "X"; then
399                 CPPFLAGS="$perlcppflags $CPPFLAGS"
400         fi
401         perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
402                 -e 'ldopts'`
403         perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
404                 -e 'ccdlflags'`
405         LTLIBOBJS="perl.lo perlxsi.lo perlsfio.lo $LTLIBOBJS"
406         AC_DEFINE(HAVE_PERL_INTERP)
409 dnl If the user wants a Tk/Tcl interpreter in nvi, load it.  Make sure that
410 dnl we can find a Tk/Tcl library.
411 AC_MSG_CHECKING(if --enable-tclinterp option specified)
412 AC_ARG_ENABLE(tclinterp,
413         [  --enable-tclinterp      Include a Tk/Tcl interpreter in vi.],
414         [vi_cv_tclinterp="yes"], [vi_cv_tclinterp="no"])
415 AC_MSG_RESULT($vi_cv_tclinterp)
416 if test "$vi_cv_tclinterp" = "yes"; then
417         LIBOBJS="tcl.o $LIBOBJS"
418         LIBS="-ltk -ltcl -lm $XLIBS $LIBS"
419         AC_DEFINE(HAVE_TCL_INTERP)
421         AC_CHECK_LIB(tcl, main,
422                 [vi_cv_tkfatal="no"], [vi_cv_tkfatal="yes"], -ltk -lm)
423         if test "$vi_cv_tkfatal" = "yes"; then
424                 AC_MSG_WARN([No Tk/Tcl library found;])
425                 AC_MSG_ERROR([    see the section ADDING LIBRARIES AND INCLUDE FILES in the README file.])
426         fi
429 dnl check for curses
430 AC_SUBST(CURSLIBS)
431 AC_SUBST(CURSCPPFLAGS)
432 AC_SUBST(CURSLDFLAGS)
433 AC_SUBST(HAVE_NCURSESW)
435 dnl AC_ARG_WITH(slang,
436 dnl     [  --with-slang[=DIR]     Use S-Lang instead of curses. ],
437 dnl     [
438 dnl     if test "$withval" != yes; then
439 dnl             LDFLAGS="-L${withval}/lib $LDFLAGS"
440 dnl             CPPFLAGS="-I${withval}/include $CPPFLAGS"
441 dnl     fi
442 dnl     AC_DEFINE(USE_SLANG_CURSES)
443 dnl         AC_CHECK_LIB(slang, SLtt_get_terminfo,
444 dnl                 [CURSLIBS="$CURSLIBS -lslang -lm"],
445 dnl                 [AC_MSG_ERROR(unable to compile.  check config.log)], -lm)
446 dnl 
447 dnl     vi_cv_curses=slcurses
448 dnl     ],
449 dnl     [
450         SAVELIBS="$LIBS"
451         SAVELDFLAGS="$LDFLAGS"
452         SAVECPPFLAGS="$CPPFLAGS"
453         AC_ARG_WITH(curses,
454                 [  --with-curses=DIR       Path to curses installation. ])
455         if test "x$with_curses" != "x"; then
456                 CURSLDFLAGS="`echo $with_curses/lib | sed "$LRscript"` $CURSLDFLAGS"
457                 CURSCPPFLAGS="-I$with_curses/include $CURSCPPFLAGS"
458         fi;
459         LDFLAGS="$CURSLDFLAGS $LDFLAGS"
460         CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
462         if test "$vi_cv_widechar" = "yes"; then
463             for vi_cv_curses in ncurses ncursesw curses; do
464                 AC_CHECK_LIB($vi_cv_curses, waddnwstr,[break])
465                 vi_cv_curses=unknown
466             done
467         else 
468             for vi_cv_curses in ncurses ncursesw curses; do
469                 AC_CHECK_LIB($vi_cv_curses, initscr, [break])
470                 vi_cv_curses=unknown
471             done
472         fi
474         if test "$vi_cv_curses" != "unknown"; then
475             CURSHEADER=curses.h
476             if test "$vi_cv_curses" = "ncurses"; then
477                 AC_CHECK_HEADERS(ncurses.h, [CURSHEADER=ncurses.h])
478             fi
479             if test "$vi_cv_curses" = "ncursesw"; then
480                 AC_CHECK_HEADERS(ncursesw/ncurses.h, 
481                         [CURSHEADER=ncursesw/ncurses.h])
482             fi
483             vi_programs="vi $vi_programs"
484             CURSLIBS="-l$vi_cv_curses"
485         else
486             AC_MSG_WARN([*** No suitable curses library found.])
487             if test "$vi_programs"X = X; then
488                 AC_MSG_ERROR([No executable to build.])
489             fi
490         fi
492 dnl Check for the termcap/termlib library.  These two checks must occur in the
493 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
494 dnl On Solaris curses==termlib, but different versions of curses
495 dnl can be used. Avoid loading termlib is curses has tgetent.
496 AC_CHECK_LIB($vi_cv_curses, tgetent,
497         [vi_cv_curses_tgetent=yes], [vi_cv_curses_tgetent=no])
498 if test "$vi_cv_curses_tgetent" = no; then
499         AC_CHECK_LIB(termlib, tgetent,
500                 [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
501         if test "$vi_cv_termlib" = no; then
502                 AC_CHECK_LIB(termcap, tgetent,
503                         [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
504         fi
506 if test "$vi_cv_termlib" != no; then
507         CURSLIBS="$CURSLIBS $vi_cv_termlib"
510         LIBS="$SAVELIBS"
511         LDFLAGS="$SAVELDFLAGS"
512         CPPFLAGS="$SAVECPPFLAGS"
513 dnl     ])
515 dnl Checks for header files.
516 AC_MSG_CHECKING(for sys/mman.h)
517 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
518 AC_TRY_CPP([#include <sys/mman.h>],
519         [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
520 if test "$vi_cv_include_sys_mman" = yes; then
521         AC_DEFINE(HAVE_SYS_MMAN_H)
523 AC_MSG_RESULT($vi_cv_include_sys_mman)
525 AC_MSG_CHECKING(for sys/select.h)
526 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
527 AC_TRY_CPP([#include <sys/select.h>],
528         [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
529 if test "$vi_cv_include_sys_select" = yes; then
530         AC_DEFINE(HAVE_SYS_SELECT_H)
532 AC_MSG_RESULT($vi_cv_include_sys_select)
534 dnl Checks for typedefs, structures, and compiler characteristics.
535 AC_CHECK_TYPE(ssize_t, int)
536 AC_C_BIGENDIAN
537 AC_C_CONST
538 AC_STRUCT_ST_BLKSIZE
539 AC_TYPE_MODE_T
540 AC_TYPE_OFF_T
541 AC_TYPE_PID_T
542 AC_TYPE_SIZE_T
543 AC_STRUCT_TM
545 dnl Checks for library functions.
546   AC_CHECK_FUNCS(bsearch gethostname memchr memset)
547 AC_REPLACE_FUNCS(bsearch gethostname memchr memset)
548   AC_CHECK_FUNCS(mkstemp mmap strdup strpbrk)
549 AC_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
550   AC_CHECK_FUNCS(vsnprintf)
551 AC_REPLACE_FUNCS(vsnprintf)
553 AC_CHECK_FUNCS(select)
554 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
555 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
556 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
558 AC_FUNC_MMAP
559 AC_FUNC_VFORK
561 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
562 if test "$need_env" = yes; then
563         LIBOBJS="env.o $LIBOBJS"
566 dnl If we need strsep, add it and define it so we get a prototype.
567 if test "$need_strsep" = yes; then
568         LIBOBJS="strsep.o $LIBOBJS"
571 dnl XXX not sure whether this is a good idea
572 LTLIBOBJS="`echo $LIBOBJS | sed 's/\.o/.lo/g'` $LTLIBOBJS"
574 dnl Check for fcntl/flock
575 dnl Use flock preferentially, since it has cleaner semantics and won't
576 dnl hang up the editor.
577 dnl XXX
578 dnl Ultrix has a broken fcntl, but a working flock.
579 dnl IRIX and DGUX have a broken flock, but working fcntl.
580 AC_MSG_CHECKING(for fcntl/flock)
581 AC_CACHE_VAL(vi_cv_lock, [dnl
582         vi_cv_lock=none
583         case "$host_os" in
584         dgux*);;
585         irix*);;
586         *)
587                 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
588                     [vi_cv_lock=flock]);;
589         esac
590         if test "$vi_cv_lock" = none; then
591                 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
592                     [vi_cv_lock=fcntl])
593         fi])
595 if test "$vi_cv_lock" = flock; then
596         AC_DEFINE(HAVE_LOCK_FLOCK)
598 if test "$vi_cv_lock" = fcntl; then
599         AC_DEFINE(HAVE_LOCK_FCNTL)
601 AC_MSG_RESULT($vi_cv_lock)
603 dnl Check for ftruncate/chsize
604 AC_MSG_CHECKING(for ftruncate/chsize)
605 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
606 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
607         [vi_cv_ftruncate=ftruncate],
608 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
609         [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
610 if test "$vi_cv_ftruncate" = ftruncate; then
611         AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
613 if test "$vi_cv_ftruncate" = chsize; then
614         AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
616 if test "$vi_cv_ftruncate" = no; then
617         AC_MSG_ERROR([No file truncation system call.])
619 AC_MSG_RESULT($vi_cv_ftruncate)
621 CSAVELIBS="$LIBS"
622 CSAVELDFLAGS="$LDFLAGS"
623 CSAVECPPFLAGS="$CPPFLAGS"
624 LIBS="$CURSLIBS $LIBS"
625 LDFLAGS="$CURSLDFLAGS $LDFLAGS"
626 CPPFLAGS="$CURSCPPFLAGS $CPPFLAGS"
627 dnl Check for the tigetstr/tigetnum functions.
628 AC_MSG_CHECKING(for tigetstr/tigetnum)
629 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
630 AC_TRY_LINK([#include <$CURSHEADER>], [tigetstr(0);],
631         [vi_cv_have_curses_tigetstr=yes],
632         [vi_cv_have_curses_tigetstr=no])])
633 if test "$vi_cv_have_curses_tigetstr" = yes; then
634         AC_DEFINE(HAVE_CURSES_TIGETSTR)
636 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
638 dnl Check for potentially missing curses functions in system or user-specified
639 dnl libraries.  We also have to guess at whether the specified library is a
640 dnl BSD or System V style curses.  Use the newterm function, all System V
641 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
642 if test "$vi_cv_curses" = "bundled curses"; then
643         AC_DEFINE(HAVE_BSD_CURSES)
644         AC_DEFINE(HAVE_CURSES_WADDNSTR)
645         AC_DEFINE(HAVE_CURSES_IDLOK)
646 else
647         dnl Check for the waddnstr function.
648         AC_MSG_CHECKING(for waddnstr)
649         AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
650         AC_TRY_LINK([#include <$CURSHEADER>], [waddnstr(stdscr, 0, 0);],
651                 [vi_cv_have_curses_waddnstr=yes],
652                 [vi_cv_have_curses_waddnstr=no])])
653         if test "$vi_cv_have_curses_waddnstr" = yes; then
654                 AC_DEFINE(HAVE_CURSES_WADDNSTR)
655         fi
656         AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
658         dnl Check for the beep function.
659         AC_MSG_CHECKING(for beep)
660         AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
661         AC_TRY_LINK([#include <$CURSHEADER>], [beep();],
662                 [vi_cv_have_curses_beep=yes],
663                 [vi_cv_have_curses_beep=no])])
664         if test "$vi_cv_have_curses_beep" = yes; then
665                 AC_DEFINE(HAVE_CURSES_BEEP)
666         fi
667         AC_MSG_RESULT($vi_cv_have_curses_beep)
669         dnl Check for the flash function.
670         AC_MSG_CHECKING(for flash)
671         AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
672         AC_TRY_LINK([#include <$CURSHEADER>], [flash();],
673                 [vi_cv_have_curses_flash=yes],
674                 [vi_cv_have_curses_flash=no])])
675         if test "$vi_cv_have_curses_flash" = yes; then
676                 AC_DEFINE(HAVE_CURSES_FLASH)
677         fi
678         AC_MSG_RESULT($vi_cv_have_curses_flash)
680         dnl Check for the idlok function.
681         AC_MSG_CHECKING(for idlok)
682         AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
683         AC_TRY_LINK([#include <$CURSHEADER>], [idlok(0, 0);],
684                 [vi_cv_have_curses_idlok=yes],
685                 [vi_cv_have_curses_idlok=no])])
686         if test "$vi_cv_have_curses_idlok" = yes; then
687                 AC_DEFINE(HAVE_CURSES_IDLOK)
688         fi
689         AC_MSG_RESULT($vi_cv_have_curses_idlok)
691         dnl Check for the keypad function.
692         AC_MSG_CHECKING(for keypad)
693         AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
694         AC_TRY_LINK([#include <$CURSHEADER>], [keypad(0, 0);],
695                 [vi_cv_have_curses_keypad=yes],
696                 [vi_cv_have_curses_keypad=no])])
697         if test "$vi_cv_have_curses_keypad" = yes; then
698                 AC_DEFINE(HAVE_CURSES_KEYPAD)
699         fi
700         AC_MSG_RESULT($vi_cv_have_curses_keypad)
702         dnl Check for the newterm function.
703         AC_MSG_CHECKING(for newterm)
704         AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
705         AC_TRY_LINK([#include <$CURSHEADER>], [newterm(0, 0, 0);],
706                 [vi_cv_have_curses_newterm=yes],
707                 [vi_cv_have_curses_newterm=no])])
708         if test "$vi_cv_have_curses_newterm" = yes; then
709                 AC_DEFINE(HAVE_CURSES_NEWTERM)
710         fi
711         AC_MSG_RESULT($vi_cv_have_curses_newterm)
713         if test "$vi_cv_have_curses_newterm" = no; then
714                 AC_DEFINE(HAVE_BSD_CURSES)
715         fi
718 dnl Check for the setupterm function.  We make this check regardless of
719 dnl using the system library, because it may be part of the underlying
720 dnl termcap/termlib support, and we want to use the local one.
721 AC_MSG_CHECKING(for setupterm)
722 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
723 AC_TRY_LINK([#include <$CURSHEADER>], [setupterm(0, 0, 0);],
724         [vi_cv_have_curses_setupterm=yes],
725         [vi_cv_have_curses_setupterm=no])])
726 if test "$vi_cv_have_curses_setupterm" = yes; then
727         AC_DEFINE(HAVE_CURSES_SETUPTERM)
729 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
730 LIBS="$CSAVELIBS"
731 LDFLAGS="$CSAVELDFLAGS"
732 CPPFLAGS="$CSAVECPPFLAGS"
734 dnl Some moron decided to drop off an argument from the gettimeofday call,
735 dnl without changing the name.
736 AC_MSG_CHECKING(for broken gettimeofday system call)
737 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
738 AC_TRY_LINK([#include <sys/types.h>
739 #include <sys/time.h>], [gettimeofday(0, 0);],
740         [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
741 if test "$vi_cv_gettimeofday" = broken; then
742         AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
744 AC_MSG_RESULT($vi_cv_gettimeofday)
746 dnl Check for which version of openpty to use, System V or Berkeley.
747 AC_MSG_CHECKING(for System V pty calls)
748 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
749 AC_TRY_LINK(, [grantpt(0);],
750         [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
751 if test "$vi_cv_sys5_pty" = yes; then
752         AC_DEFINE(HAVE_SYS5_PTY)
754 AC_MSG_RESULT($vi_cv_sys5_pty)
756 dnl Check for the revoke system call.
757 AC_MSG_CHECKING(for revoke system call)
758 AC_CACHE_VAL(vi_cv_revoke, [dnl
759 AC_TRY_LINK(, [revoke("a");],
760         [vi_cv_revoke=yes], [vi_cv_revoke=no])])
761 if test "$vi_cv_revoke" = yes; then
762         AC_DEFINE(HAVE_REVOKE)
764 AC_MSG_RESULT($vi_cv_revoke)
766 dnl Some versions of sprintf return a pointer to the first argument instead
767 dnl of a character count.  We assume that the return value of snprintf and
768 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
769 AC_MSG_CHECKING(for int type sprintf return value)
770 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
771 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
772         [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
773 if test "$vi_cv_sprintf_count" = no; then
774         AC_DEFINE(SPRINTF_RET_CHARPNT)
776 AC_MSG_RESULT($vi_cv_sprintf_count)
779 dnl Check for the standard shorthand types.
780 AC_SUBST(u_char_decl)
781 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
782 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
783         [vi_cv_uchar=yes], [vi_cv_uchar=no])])
784 if test "$vi_cv_uchar" = no; then
785         u_char_decl="typedef unsigned char u_char;"
788 AC_SUBST(u_short_decl)
789 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
790 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
791         [vi_cv_ushort=yes], [vi_cv_ushort=no])])
792 if test "$vi_cv_ushort" = no; then
793         u_short_decl="typedef unsigned short u_short;"
796 AC_SUBST(u_int_decl)
797 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
798 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
799         [vi_cv_uint=yes], [vi_cv_uint=no])])
800 if test "$vi_cv_uint" = no; then
801         u_int_decl="typedef unsigned int u_int;"
804 AC_SUBST(u_long_decl)
805 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
806 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
807         [vi_cv_ulong=yes], [vi_cv_ulong=no])])
808 if test "$vi_cv_ulong" = no; then
809         u_long_decl="typedef unsigned long u_long;"
812 dnl DB/Vi use specific integer sizes.
813 AC_SUBST(u_int8_decl)
814 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
815 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
816         [vi_cv_uint8=yes],
817         AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
818             [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
819 if test "$vi_cv_uint8" = no; then
820         AC_MSG_ERROR(No unsigned 8-bit integral type.)
822 if test "$vi_cv_uint8" != yes; then
823         u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
826 AC_SUBST(u_int16_decl)
827 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
828 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
829         [vi_cv_uint16=yes],
830 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
831         [vi_cv_uint16="unsigned short"],
832 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
833         [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
834 if test "$vi_cv_uint16" = no; then
835         AC_MSG_ERROR([No unsigned 16-bit integral type.])
837 if test "$vi_cv_uint16" != yes; then
838         u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
841 AC_SUBST(int16_decl)
842 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
843 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
844         [vi_cv_int16=yes],
845 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
846         [vi_cv_int16="short"],
847 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
848         [vi_cv_int16="int"], [vi_cv_int16=no])))])
849 if test "$vi_cv_int16" = no; then
850         AC_MSG_ERROR([No signed 16-bit integral type.])
852 if test "$vi_cv_int16" != yes; then
853         int16_decl="typedef $vi_cv_int16 int16_t;"
856 AC_SUBST(u_int32_decl)
857 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
858 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
859         [vi_cv_uint32=yes],
860 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
861         [vi_cv_uint32="unsigned int"],
862 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
863         [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
864 if test "$vi_cv_uint32" = no; then
865         AC_MSG_ERROR([No unsigned 32-bit integral type.])
867 if test "$vi_cv_uint32" != yes; then
868         u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
871 AC_SUBST(int32_decl)
872 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
873 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
874         [vi_cv_int32=yes],
875 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
876         [vi_cv_int32="int"],
877 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
878         [vi_cv_int32="long"], [vi_cv_int32=no])))])
879 if test "$vi_cv_int32" = no; then
880         AC_MSG_ERROR([No signed 32-bit integral type.])
882 if test "$vi_cv_int32" != yes; then
883         int32_decl="typedef $vi_cv_int32 int32_t;"
886 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
887 [AC_TRY_COMPILE([#include <stdio.h>
888 int fprintf ();
889 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
891 AC_SUBST(NEED_FPRINTF_PROTO)
892 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
893 [AC_TRY_COMPILE([ #include <stdio.h>
894 typedef int     (*funcPtr)();
895 ],[funcPtr ptr = (funcPtr) fprintf;], 
896 vi_cv_proto_fprintf=no, 
897 [vi_cv_proto_fprintf=yes, AC_DEFINE(NEED_FPRINTF_PROTO)])])
900 dnl Check for DB 3
901 AC_ARG_WITH(db3,
902         [  --with-db3=db3prefix    Path to db3 installation. ])
903 if test "$with_db3" = "no"; then
904         AC_MSG_ERROR([Need DB 3.])
907 saveLDFLAGS="$LDFLAGS"
908 if test "x$with_db3" != "x"; then
909         LDFLAGS="-L$with_db3/lib $LDFLAGS"
910         CFLAGS="-I$with_db3/include $CFLAGS"
913 AC_CHECK_LIB(db, db_create,
914         [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
915 if test "$vi_cv_dbfatal" = "yes"; then
916         AC_MSG_ERROR([Need DB 3.])
919 LDFLAGS="$saveLDFLAGS"
921 AC_SUBST(dl_src)
922 AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
923 AC_ARG_ENABLE(dynamic-loading,
924         [  --enable-dynamic-loading Load DB 3 dynamically.],
925         [vi_cv_dl="yes"], [vi_cv_dl="no"])
926 AC_MSG_RESULT($vi_cv_dl)
927 if test "$vi_cv_dl" = yes; then
928         AC_CHECK_LIB(dl, dlopen,
929                 [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
930         if test "$vi_cv_dlfatal" = "yes"; then
931                 AC_MSG_ERROR([Need dl to support dynamic loading.])
932         fi
933         OLDPATH="$PATH"
935         PATH="$with_db3/lib:/usr/lib:/lib"
936         AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
937         if test "$vi_cv_path_db3" = no; then
938                 AC_MSG_ERROR([Path of libdb-3.so not found.])
939         fi
940         PATH="$OLDPATH"
942         AC_DEFINE(USE_DYNAMIC_LOADING)
943         LTLIBOBJS="dldb.lo $LTLIBOBJS"
944         dl_src=../common/dldb.c
945         LIBS="-ldl $LIBS"
946 else
947         LIBS="-ldb $LIBS"
948         LDFLAGS="`echo $with_db3/lib | sed "$LRscript"` $LDFLAGS"
952 dnl We compile in nvi's RE routines unless the user specifies otherwise.
953 AC_MSG_CHECKING(if --disable-re option specified)
954 AC_ARG_ENABLE(re,
955         [  --disable-re            DON'T use the nvi-provided RE routines.],
956         [vi_cv_re_lib="other RE"], [vi_cv_re_lib="bundled RE"])
957 AC_MSG_RESULT($vi_cv_re_lib)
958 case "$vi_cv_re_lib" in
959 "bundled RE")
960         CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
961         LTLIBOBJS="\$(REOBJS) $LTLIBOBJS";;
962 "other RE")
963         ;;
964 esac
966 AC_OUTPUT(Makefile port.h:port.h.in
967     pathnames.h:pathnames.h.in recover:recover.in)