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