Check for addnwstr if --enable-wide and don't build curses frontend
[nvi.git] / dist / configure.in
blob5805fa5a82127f0298829326284ccaa84d69201f
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)
218         LIBOBJS="wcwidth.o $LIBOBJS"
220 AC_MSG_RESULT($vi_cv_widechar)
222 dnl If the user wants a Gtk IPC front-end for nvi, build it.
223 AC_SUBST(vi_ipc)
224 AC_SUBST(vi_gtk)
225 AC_SUBST(GTKLIBS)
226 AC_SUBST(GTKINCS)
227 AC_MSG_CHECKING(if --enable-gtk option specified)
228 AC_ARG_ENABLE(gtk,
229         [  --enable-gtk            Build a Gtk front-end for vi.],
230         [vi_cv_gtk="yes"], [vi_cv_gtk="no"])
231 AC_MSG_RESULT($vi_cv_gtk)
232 if test "$vi_cv_gtk" = "yes"; then
233         vi_gtk=vi-gtk
234         vi_ipc=vi-ipc
235         AM_PATH_GTK(1.2.0)
236         GTKINCS="$GTK_CFLAGS"
237         GTKLIBS="$GTK_LIBS $LIBS"
238         SAVELIBS="$LIBS"
239         AM_PATH_GDK_PIXBUF(0.4.0, pixbuf=yes, pixbuf=no)
240         if test "$pixbuf" != "no"; then
241                 LIBS="-lutil $GDK_PIXBUF_LIBS $GTKLIBS"
242                 AC_CHECK_LIB(nvizvt, zvt_get_ptys,
243                         [vi_cv_zvt="yes"], [vi_cv_zvt="no"])
244                 if test "$vi_cv_zvt" = "yes"; then
245                         GTKLIBS="-lnvizvt $LIBS"
246                         AC_DEFINE(HAVE_ZVT)
247                 fi
248                 LIBS="$SAVELIBS"
249         fi
250         AC_PATH_PROG(vi_cv_pango_config, pango-config, no)
251         if test "$vi_cv_pango_config" != "no"; then
252                 PANGOLIBS=`$vi_cv_pango_config --libs pangox`
253                 GTKLIBS="$PANGOLIBS $GTKLIBS"
254                 AC_DEFINE(HAVE_PANGO)
255         fi
256 #       AC_PATH_PROG(vi_cv_gnome_config, gnome-config, no)
257 #       if test "$vi_cv_gnome_config" != "no"; then
258 #               ZVTLIBS=`$vi_cv_gnome_config zvt --libs`
259 #               GTKLIBS="$ZVTLIBS $GTKLIBS"
260 #       fi
263 dnl If the user wants a Motif IPC front-end for nvi, build it.
264 AC_SUBST(vi_motif)
265 AC_SUBST(MOTIFLIBS)
266 AC_MSG_CHECKING(if --enable-motif option specified)
267 AC_ARG_ENABLE(motif,
268         [  --enable-motif          Build a Motif front-end for vi.],
269         [vi_cv_motif="yes"], [vi_cv_motif="no"])
270 AC_MSG_RESULT($vi_cv_motif)
271 if test "$vi_cv_motif" = "yes"; then
272         vi_motif=vi-motif
273         vi_ipc=vi-ipc
275         dnl XXX
276         dnl BSDI's Motif libraries aren't shared.
278         case "$host_os" in
279         bsdi*)  CC=cc;;
280         esac
282         dnl XXX
283         dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
284         dnl -lXext is generally available, the others aren't.
285         dnl
286         dnl XXX
287         dnl Color icons require -lXpm, which may or may not be available,
288         dnl depending on the version of X11.
290         MOTIFLIBS="-lXm -lXt"
291         AC_CHECK_LIB(SM, main,
292             [vi_cv_smlib="yes"], [vi_cv_smlib="no"], "$XLIBS")
293         if test "$vi_cv_smlib" = "yes"; then
294                 MOTIFLIBS="$MOTIFLIBS -lSM"
295         fi
296         AC_CHECK_LIB(ICE, main,
297             [vi_cv_icelib="yes"], [vi_cv_icelib="no"], "$XLIBS")
298         if test "$vi_cv_icelib" = "yes"; then
299                 MOTIFLIBS="$MOTIFLIBS -lICE"
300         fi
301         AC_CHECK_LIB(Xext, main,
302             [vi_cv_xextlib="yes"], [vi_cv_xextlib="no"], "$XLIBS")
303         if test "$vi_cv_xextlib" = "yes"; then
304                 MOTIFLIBS="$MOTIFLIBS -lXext"
305         fi
306         AC_CHECK_LIB(Xpm, main,
307             [vi_cv_xpmlib="yes"], [vi_cv_xpmlib="no"], "$XLIBS")
308         if test "$vi_cv_xpmlib" = "yes"; then
309                 MOTIFLIBS="$MOTIFLIBS -lXpm"
310         fi
311         MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
314 AC_SUBST(IPCOBJS)
315 dnl Check for threads
316 AC_MSG_CHECKING(if --enable-threads option specified)
317 AC_ARG_ENABLE(threads,
318         [  --enable-threads        Turn on thread support.],
319         [vi_cv_threads="yes"], [vi_cv_threads="no"])
320 AC_MSG_RESULT($vi_cv_threads)
321 if test "$vi_cv_threads" = "yes"; then
322         LIBS="$LIBS -pthread"
323         AC_CACHE_VAL(vi_cv_have_pthreads, [dnl
324         AC_TRY_LINK([#include <pthread.h>],
325                 [pthread_self()],
326                 [vi_cv_have_pthreads=yes],
327                 [vi_cv_have_pthreads=no])])
328         if test "$vi_cv_have_pthreads" = "no"; then
329                 AC_MSG_ERROR(No threading library found)
330         fi
331         IPCOBJS="pthread.o $IPCOBJS"
332         AC_DEFINE(HAVE_PTHREAD)
333 else
334         IPCOBJS="nothread.o $IPCOBJS"
337 dnl If the user wants a Perl interpreter in nvi, load it.
338 AC_SUBST(shrpenv)
339 AC_SUBST(perlldflags)
340 AC_SUBST(perllibs)
341 AC_SUBST(vi_cv_perllib)
342 AC_SUBST(LTLIBOBJS)
343 AC_MSG_CHECKING(if --enable-perlinterp option specified)
344 AC_ARG_ENABLE(perlinterp,
345         [  --enable-perlinterp     Include a Perl interpreter in vi.],
346         [vi_cv_perlinterp="yes"], [vi_cv_perlinterp="no"])
347 AC_MSG_RESULT($vi_cv_perlinterp)
348 if test "$vi_cv_perlinterp" = "yes"; then
349         if test "$vi_cv_path_perl" = no; then
350                 AC_MSG_ERROR([No perl5 utility found.])
351         fi
352         $vi_cv_path_perl -e 'require 5.004' || {
353                 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
354         }
355         if test "$vi_cv_threads" = "yes"; then
356                 useithreads=`$vi_cv_path_perl -MConfig -e 'print $Config{useithreads}'`
357                 if test "X$useithreads" != "Xdefine"; then
358                         AC_MSG_ERROR([vi threading only compatible with perl's ithreads.])
359                 fi
360         fi
362         eval `$vi_cv_path_perl -V:shrpenv`
363         vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
364         perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
365                 -e 'ccflags;perl_inc'`
366         if test "X$perlcppflags" != "X"; then
367                 CPPFLAGS="$perlcppflags $CPPFLAGS"
368         fi
369         perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
370                 -e 'ldopts'`
371         perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
372                 -e 'ccdlflags'`
373         LTLIBOBJS="perl.lo perlxsi.lo perlsfio.lo $LTLIBOBJS"
374         AC_DEFINE(HAVE_PERL_INTERP)
377 dnl If the user wants a Tk/Tcl interpreter in nvi, load it.  Make sure that
378 dnl we can find a Tk/Tcl library.
379 AC_MSG_CHECKING(if --enable-tclinterp option specified)
380 AC_ARG_ENABLE(tclinterp,
381         [  --enable-tclinterp      Include a Tk/Tcl interpreter in vi.],
382         [vi_cv_tclinterp="yes"], [vi_cv_tclinterp="no"])
383 AC_MSG_RESULT($vi_cv_tclinterp)
384 if test "$vi_cv_tclinterp" = "yes"; then
385         LIBOBJS="tcl.o $LIBOBJS"
386         LIBS="-ltk -ltcl -lm $XLIBS $LIBS"
387         AC_DEFINE(HAVE_TCL_INTERP)
389         AC_CHECK_LIB(tcl, main,
390                 [vi_cv_tkfatal="no"], [vi_cv_tkfatal="yes"], -ltk -lm)
391         if test "$vi_cv_tkfatal" = "yes"; then
392                 AC_MSG_WARN([No Tk/Tcl library found;])
393                 AC_MSG_ERROR([    see the section ADDING LIBRARIES AND INCLUDE FILES in the README file.])
394         fi
397 dnl Check for the termcap/termlib library.  Compile in nvi's curses routines
398 dnl unless the user specifies otherwise.  These two checks must occur in the
399 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
400 AC_CHECK_LIB(termlib, tgetent,
401         [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
402 if test "$vi_cv_termlib" = no; then
403         AC_CHECK_LIB(termcap, tgetent,
404                 [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
406 if test "$vi_cv_termlib" != no; then
407         LIBS="$vi_cv_termlib $LIBS"
409 AC_SUBST(cobjs)
411 dnl check for curses
412 AC_SUBST(vi_curses)
413 AC_SUBST(CURSLIBS)
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     CURSLIB=slcurses
429 dnl     ],
430 dnl     [
431         SAVELIBS="$LIBS"
432         AC_ARG_WITH(curses,
433                 [  --with-curses=DIR       Path to curses installation. ])
434         if test "x$with_curses" != "x"; then
435                 LDFLAGS="-L$with_curses/lib $LDFLAGS"
436                 CPPFLAGS="-I$with_curses/include $CPPFLAGS"
437         fi;
438         AC_MSG_CHECKING(for ncurses.h)
439         AC_CACHE_VAL(vi_cv_include_ncurses, [dnl
440             AC_CHECK_HEADERS(ncurses.h, 
441                 [vi_cv_include_ncurses=yes], [vi_cv_include_ncurses=no])])
442         AC_MSG_RESULT($vi_cv_include_ncurses)
443         if test "$vi_cv_include_ncurses" = yes; then
444             CURSHEADER=ncurses.h 
445             AC_DEFINE(HAVE_NCURSES_H)
446             AC_MSG_CHECKING(for wide ncurses)
447             AC_TRY_RUN([#include <ncurses.h> 
448                         main(){exit(!(A_CHARTEXT>0xff));}],
449                 [AC_DEFINE(HAVE_NCURSESW)
450                  CURSLIB="ncursesw"
451                  vi_cv_ncursesw=yes],
452                 [CURSLIB="ncurses"
453                 vi_cv_ncursesw=no])
454             AC_MSG_RESULT($vi_cv_ncursesw)
455         else
456             CURSHEADER=curses.h
457             CURSLIB="curses"
458         fi
460         AC_CHECK_LIB($CURSLIB, initscr,
461                 [vi_cv_cursesfatal="no"],
462                 [vi_cv_cursesfatal="yes"])
463         if test "$vi_cv_cursesfatal" = "yes"; then
464                 AC_MSG_ERROR([Need curses.])
465         fi
466         vi_curses=vi
467         if test "$vi_cv_widechar" = "yes"; then
468             AC_CHECK_LIB($CURSLIB, addnwstr,
469                     [AC_DEFINE(HAVE_CURSES_ADDNWSTR)],
470                     [if test "$CURSLIB" != "ncursesw"; then vi_curses=""; fi])
471         fi
472         CURSLIBS="-l$CURSLIB"
473         LIBS="$SAVELIBS"
474 dnl     ])
476 dnl Checks for header files.
477 AC_MSG_CHECKING(for sys/mman.h)
478 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
479 AC_TRY_CPP([#include <sys/mman.h>],
480         [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
481 if test "$vi_cv_include_sys_mman" = yes; then
482         AC_DEFINE(HAVE_SYS_MMAN_H)
484 AC_MSG_RESULT($vi_cv_include_sys_mman)
486 AC_MSG_CHECKING(for sys/select.h)
487 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
488 AC_TRY_CPP([#include <sys/select.h>],
489         [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
490 if test "$vi_cv_include_sys_select" = yes; then
491         AC_DEFINE(HAVE_SYS_SELECT_H)
493 AC_MSG_RESULT($vi_cv_include_sys_select)
495 dnl Checks for typedefs, structures, and compiler characteristics.
496 AC_CHECK_TYPE(ssize_t, int)
497 AC_C_BIGENDIAN
498 AC_C_CONST
499 AC_STRUCT_ST_BLKSIZE
500 AC_TYPE_MODE_T
501 AC_TYPE_OFF_T
502 AC_TYPE_PID_T
503 AC_TYPE_SIZE_T
504 AC_STRUCT_TM
506 dnl Checks for library functions.
507   AC_CHECK_FUNCS(bsearch gethostname memchr memset)
508 AC_REPLACE_FUNCS(bsearch gethostname memchr memset)
509   AC_CHECK_FUNCS(mkstemp mmap strdup strpbrk)
510 AC_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
511   AC_CHECK_FUNCS(vsnprintf)
512 AC_REPLACE_FUNCS(vsnprintf)
514 AC_CHECK_FUNCS(select)
515 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
516 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
517 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
519 AC_FUNC_MMAP
520 AC_FUNC_VFORK
522 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
523 if test "$need_env" = yes; then
524         LIBOBJS="env.o $LIBOBJS"
527 dnl If we need strsep, add it and define it so we get a prototype.
528 if test "$need_strsep" = yes; then
529         LIBOBJS="strsep.o $LIBOBJS"
532 dnl XXX not sure whether this is a good idea
533 LTLIBOBJS="`echo $LIBOBJS | sed 's/\.o/.lo/g'` $LTLIBOBJS"
535 dnl Check for fcntl/flock
536 dnl Use flock preferentially, since it has cleaner semantics and won't
537 dnl hang up the editor.
538 dnl XXX
539 dnl Ultrix has a broken fcntl, but a working flock.
540 dnl IRIX and DGUX have a broken flock, but working fcntl.
541 AC_MSG_CHECKING(for fcntl/flock)
542 AC_CACHE_VAL(vi_cv_lock, [dnl
543         vi_cv_lock=none
544         case "$host_os" in
545         dgux*);;
546         irix*);;
547         *)
548                 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
549                     [vi_cv_lock=flock]);;
550         esac
551         if test "$vi_cv_lock" = none; then
552                 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
553                     [vi_cv_lock=fcntl])
554         fi])
556 if test "$vi_cv_lock" = flock; then
557         AC_DEFINE(HAVE_LOCK_FLOCK)
559 if test "$vi_cv_lock" = fcntl; then
560         AC_DEFINE(HAVE_LOCK_FCNTL)
562 AC_MSG_RESULT($vi_cv_lock)
564 dnl Check for ftruncate/chsize
565 AC_MSG_CHECKING(for ftruncate/chsize)
566 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
567 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
568         [vi_cv_ftruncate=ftruncate],
569 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
570         [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
571 if test "$vi_cv_ftruncate" = ftruncate; then
572         AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
574 if test "$vi_cv_ftruncate" = chsize; then
575         AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
577 if test "$vi_cv_ftruncate" = no; then
578         AC_MSG_ERROR([No file truncation system call.])
580 AC_MSG_RESULT($vi_cv_ftruncate)
582 CSAVELIBS="$LIBS"
583 LIBS="$CURSLIBS $LIBS"
584 dnl Check for the tigetstr/tigetnum functions.
585 AC_MSG_CHECKING(for tigetstr/tigetnum)
586 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
587 AC_TRY_LINK([#include <$CURSHEADER>], [tigetstr(0);],
588         [vi_cv_have_curses_tigetstr=yes],
589         [vi_cv_have_curses_tigetstr=no])])
590 if test "$vi_cv_have_curses_tigetstr" = yes; then
591         AC_DEFINE(HAVE_CURSES_TIGETSTR)
593 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
595 dnl Check for potentially missing curses functions in system or user-specified
596 dnl libraries.  We also have to guess at whether the specified library is a
597 dnl BSD or System V style curses.  Use the newterm function, all System V
598 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
599 if test "$vi_cv_curses" = "bundled curses"; then
600         AC_DEFINE(HAVE_BSD_CURSES)
601         AC_DEFINE(HAVE_CURSES_WADDNSTR)
602         AC_DEFINE(HAVE_CURSES_IDLOK)
603 else
604         dnl Check for the waddnstr function.
605         AC_MSG_CHECKING(for waddnstr)
606         AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
607         AC_TRY_LINK([#include <$CURSHEADER>], [waddnstr(stdscr, 0, 0);],
608                 [vi_cv_have_curses_waddnstr=yes],
609                 [vi_cv_have_curses_waddnstr=no])])
610         if test "$vi_cv_have_curses_waddnstr" = yes; then
611                 AC_DEFINE(HAVE_CURSES_WADDNSTR)
612         fi
613         AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
615         dnl Check for the beep function.
616         AC_MSG_CHECKING(for beep)
617         AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
618         AC_TRY_LINK([#include <$CURSHEADER>], [beep();],
619                 [vi_cv_have_curses_beep=yes],
620                 [vi_cv_have_curses_beep=no])])
621         if test "$vi_cv_have_curses_beep" = yes; then
622                 AC_DEFINE(HAVE_CURSES_BEEP)
623         fi
624         AC_MSG_RESULT($vi_cv_have_curses_beep)
626         dnl Check for the flash function.
627         AC_MSG_CHECKING(for flash)
628         AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
629         AC_TRY_LINK([#include <$CURSHEADER>], [flash();],
630                 [vi_cv_have_curses_flash=yes],
631                 [vi_cv_have_curses_flash=no])])
632         if test "$vi_cv_have_curses_flash" = yes; then
633                 AC_DEFINE(HAVE_CURSES_FLASH)
634         fi
635         AC_MSG_RESULT($vi_cv_have_curses_flash)
637         dnl Check for the idlok function.
638         AC_MSG_CHECKING(for idlok)
639         AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
640         AC_TRY_LINK([#include <$CURSHEADER>], [idlok(0, 0);],
641                 [vi_cv_have_curses_idlok=yes],
642                 [vi_cv_have_curses_idlok=no])])
643         if test "$vi_cv_have_curses_idlok" = yes; then
644                 AC_DEFINE(HAVE_CURSES_IDLOK)
645         fi
646         AC_MSG_RESULT($vi_cv_have_curses_idlok)
648         dnl Check for the keypad function.
649         AC_MSG_CHECKING(for keypad)
650         AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
651         AC_TRY_LINK([#include <$CURSHEADER>], [keypad(0, 0);],
652                 [vi_cv_have_curses_keypad=yes],
653                 [vi_cv_have_curses_keypad=no])])
654         if test "$vi_cv_have_curses_keypad" = yes; then
655                 AC_DEFINE(HAVE_CURSES_KEYPAD)
656         fi
657         AC_MSG_RESULT($vi_cv_have_curses_keypad)
659         dnl Check for the newterm function.
660         AC_MSG_CHECKING(for newterm)
661         AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
662         AC_TRY_LINK([#include <$CURSHEADER>], [newterm(0, 0, 0);],
663                 [vi_cv_have_curses_newterm=yes],
664                 [vi_cv_have_curses_newterm=no])])
665         if test "$vi_cv_have_curses_newterm" = yes; then
666                 AC_DEFINE(HAVE_CURSES_NEWTERM)
667         fi
668         AC_MSG_RESULT($vi_cv_have_curses_newterm)
670         if test "$vi_cv_have_curses_newterm" = no; then
671                 AC_DEFINE(HAVE_BSD_CURSES)
672         fi
675 dnl Check for the setupterm function.  We make this check regardless of
676 dnl using the system library, because it may be part of the underlying
677 dnl termcap/termlib support, and we want to use the local one.
678 AC_MSG_CHECKING(for setupterm)
679 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
680 AC_TRY_LINK([#include <$CURSHEADER>], [setupterm(0, 0, 0);],
681         [vi_cv_have_curses_setupterm=yes],
682         [vi_cv_have_curses_setupterm=no])])
683 if test "$vi_cv_have_curses_setupterm" = yes; then
684         AC_DEFINE(HAVE_CURSES_SETUPTERM)
686 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
687 LIBS="$CSAVELIBS"
689 dnl Some moron decided to drop off an argument from the gettimeofday call,
690 dnl without changing the name.
691 AC_MSG_CHECKING(for broken gettimeofday system call)
692 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
693 AC_TRY_LINK([#include <sys/types.h>
694 #include <sys/time.h>], [gettimeofday(0, 0);],
695         [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
696 if test "$vi_cv_gettimeofday" = broken; then
697         AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
699 AC_MSG_RESULT($vi_cv_gettimeofday)
701 dnl Check for which version of openpty to use, System V or Berkeley.
702 AC_MSG_CHECKING(for System V pty calls)
703 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
704 AC_TRY_LINK(, [grantpt(0);],
705         [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
706 if test "$vi_cv_sys5_pty" = yes; then
707         AC_DEFINE(HAVE_SYS5_PTY)
709 AC_MSG_RESULT($vi_cv_sys5_pty)
711 dnl Check for the revoke system call.
712 AC_MSG_CHECKING(for revoke system call)
713 AC_CACHE_VAL(vi_cv_revoke, [dnl
714 AC_TRY_LINK(, [revoke("a");],
715         [vi_cv_revoke=yes], [vi_cv_revoke=no])])
716 if test "$vi_cv_revoke" = yes; then
717         AC_DEFINE(HAVE_REVOKE)
719 AC_MSG_RESULT($vi_cv_revoke)
721 dnl Some versions of sprintf return a pointer to the first argument instead
722 dnl of a character count.  We assume that the return value of snprintf and
723 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
724 AC_MSG_CHECKING(for int type sprintf return value)
725 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
726 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
727         [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
728 if test "$vi_cv_sprintf_count" = no; then
729         AC_DEFINE(SPRINTF_RET_CHARPNT)
731 AC_MSG_RESULT($vi_cv_sprintf_count)
734 dnl Check for the standard shorthand types.
735 AC_SUBST(u_char_decl)
736 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
737 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
738         [vi_cv_uchar=yes], [vi_cv_uchar=no])])
739 if test "$vi_cv_uchar" = no; then
740         u_char_decl="typedef unsigned char u_char;"
743 AC_SUBST(u_short_decl)
744 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
745 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
746         [vi_cv_ushort=yes], [vi_cv_ushort=no])])
747 if test "$vi_cv_ushort" = no; then
748         u_short_decl="typedef unsigned short u_short;"
751 AC_SUBST(u_int_decl)
752 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
753 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
754         [vi_cv_uint=yes], [vi_cv_uint=no])])
755 if test "$vi_cv_uint" = no; then
756         u_int_decl="typedef unsigned int u_int;"
759 AC_SUBST(u_long_decl)
760 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
761 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
762         [vi_cv_ulong=yes], [vi_cv_ulong=no])])
763 if test "$vi_cv_ulong" = no; then
764         u_long_decl="typedef unsigned long u_long;"
767 dnl DB/Vi use specific integer sizes.
768 AC_SUBST(u_int8_decl)
769 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
770 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
771         [vi_cv_uint8=yes],
772         AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
773             [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
774 if test "$vi_cv_uint8" = no; then
775         AC_MSG_ERROR(No unsigned 8-bit integral type.)
777 if test "$vi_cv_uint8" != yes; then
778         u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
781 AC_SUBST(u_int16_decl)
782 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
783 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
784         [vi_cv_uint16=yes],
785 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
786         [vi_cv_uint16="unsigned short"],
787 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
788         [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
789 if test "$vi_cv_uint16" = no; then
790         AC_MSG_ERROR([No unsigned 16-bit integral type.])
792 if test "$vi_cv_uint16" != yes; then
793         u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
796 AC_SUBST(int16_decl)
797 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
798 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
799         [vi_cv_int16=yes],
800 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
801         [vi_cv_int16="short"],
802 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
803         [vi_cv_int16="int"], [vi_cv_int16=no])))])
804 if test "$vi_cv_int16" = no; then
805         AC_MSG_ERROR([No signed 16-bit integral type.])
807 if test "$vi_cv_int16" != yes; then
808         int16_decl="typedef $vi_cv_int16 int16_t;"
811 AC_SUBST(u_int32_decl)
812 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
813 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
814         [vi_cv_uint32=yes],
815 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
816         [vi_cv_uint32="unsigned int"],
817 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
818         [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
819 if test "$vi_cv_uint32" = no; then
820         AC_MSG_ERROR([No unsigned 32-bit integral type.])
822 if test "$vi_cv_uint32" != yes; then
823         u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
826 AC_SUBST(int32_decl)
827 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
828 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
829         [vi_cv_int32=yes],
830 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
831         [vi_cv_int32="int"],
832 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
833         [vi_cv_int32="long"], [vi_cv_int32=no])))])
834 if test "$vi_cv_int32" = no; then
835         AC_MSG_ERROR([No signed 32-bit integral type.])
837 if test "$vi_cv_int32" != yes; then
838         int32_decl="typedef $vi_cv_int32 int32_t;"
841 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
842 [AC_TRY_COMPILE([#include <stdio.h>
843 int fprintf ();
844 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
846 AC_SUBST(NEED_FPRINTF_PROTO)
847 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
848 [AC_TRY_COMPILE([ #include <stdio.h>
849 typedef int     (*funcPtr)();
850 ],[funcPtr ptr = (funcPtr) fprintf;], 
851 vi_cv_proto_fprintf=no, 
852 [vi_cv_proto_fprintf=yes, AC_DEFINE(NEED_FPRINTF_PROTO)])])
855 dnl Check for DB 3
856 AC_ARG_WITH(db3,
857         [  --with-db3=db3prefix    Path to db3 installation. ])
858 if test "$with_db3" = "no"; then
859         AC_MSG_ERROR([Need DB 3.])
862 saveLDFLAGS="$LDFLAGS"
863 if test "x$with_db3" != "x"; then
864         LDFLAGS="-L$with_db3/lib $LDFLAGS"
865         CFLAGS="-I$with_db3/include $CFLAGS"
868 AC_CHECK_LIB(db, db_create,
869         [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
870 if test "$vi_cv_dbfatal" = "yes"; then
871         AC_MSG_ERROR([Need DB 3.])
874 LDFLAGS="$saveLDFLAGS"
876 AC_SUBST(dl_src)
877 AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
878 AC_ARG_ENABLE(dynamic-loading,
879         [  --enable-dynamic-loading Load DB 3 dynamically.],
880         [vi_cv_dl="yes"], [vi_cv_dl="no"])
881 AC_MSG_RESULT($vi_cv_dl)
882 if test "$vi_cv_dl" = yes; then
883         AC_CHECK_LIB(dl, dlopen,
884                 [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
885         if test "$vi_cv_dlfatal" = "yes"; then
886                 AC_MSG_ERROR([Need dl to support dynamic loading.])
887         fi
888         OLDPATH="$PATH"
890         PATH="$with_db3/lib:/usr/lib:/lib"
891         AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
892         if test "$vi_cv_path_db3" = no; then
893                 AC_MSG_ERROR([Path of libdb-3.so not found.])
894         fi
895         PATH="$OLDPATH"
897         AC_DEFINE(USE_DYNAMIC_LOADING)
898         LTLIBOBJS="dldb.lo $LTLIBOBJS"
899         dl_src=../common/dldb.c
900         LIBS="-ldl $LIBS"
901 else
902         LIBS="-ldb $LIBS"
903         LDFLAGS="-L$with_db3/lib $LDFLAGS"
907 dnl We compile in nvi's RE routines unless the user specifies otherwise.
908 AC_MSG_CHECKING(if --disable-re option specified)
909 AC_ARG_ENABLE(re,
910         [  --disable-re            DON'T use the nvi-provided RE routines.],
911         [vi_cv_re_lib="other RE"], [vi_cv_re_lib="bundled RE"])
912 AC_MSG_RESULT($vi_cv_re_lib)
913 case "$vi_cv_re_lib" in
914 "bundled RE")
915         CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
916         LTLIBOBJS="\$(REOBJS) $LTLIBOBJS";;
917 "other RE")
918         ;;
919 esac
921 AC_OUTPUT(Makefile port.h:port.h.in
922     pathnames.h:pathnames.h.in recover:recover.in)