Display single column Unicode characters in one column.
[nvi.git] / dist / configure.in
blob4f87a7d01be32f9ba30436f3b3459cbcdee9dcfc
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.80)
6 AM_CONFIG_HEADER(config.h)
8 dnl Configure setup.
9 AC_PROG_INSTALL()
10 AC_CANONICAL_HOST
11 AC_ARG_PROGRAM()
13 AC_PROG_LIBTOOL
15 dnl If the user wants a debugging environment, set OPTFLAG now, some
16 dnl compilers won't mix optimizing and debug flags.)
17 AC_MSG_CHECKING(if --enable-debug option specified)
18 AC_ARG_ENABLE(debug,
19         [  --enable-debug          Build a debugging version.],
20         [vi_cv_debug="yes"], [vi_cv_debug="no"])
21 AC_MSG_RESULT($vi_cv_debug)
22 if test "$vi_cv_debug" = yes; then
23         AC_DEFINE(DEBUG)
24         OPTFLAG=${OPTFLAG-"-g"}
25         no_op_OPTFLAG=${no_op_OPTFLAG-"-g"}
28 dnl This is where we handle stuff that autoconf can't handle.
29 dnl XXX
30 dnl Don't override anything if it's already set from the environment.
32 dnl Compiler, preprocessor and load flags.
33 dnl AUX:        -ZP disables _BSD_SOURCE et al, but enables POSIX at link time.
34 dnl LynxOS:     We check for gcc 2.x or better, the gcc 1 that was shipped with
35 dnl             LynxOS historically wasn't good enough.
36 AC_SUBST(CPPFLAGS)
37 case "$host_os" in
38 aix3.2.5)  OPTFLAG=${OPTFLAG-"-O"};;
39 aix4.1*)   CFLAGS=${CFLAGS-"-qstrict"}
40            OPTFLAG=${OPTFLAG-"-O3"};;
41 aux*)      CPPFLAGS=${CPPFLAGS-"-ZP -D_BSD_SOURCE -D_SYSV_SOURCE -D_AUX_SOURCE"}
42            LDFLAGS=${LDFLAGS-"-ZP"}
43            OPTFLAG=${OPTFLAG-"-O"};;
44 bsd4.4)    OPTFLAG=${OPTFLAG-"-O2"};;
45 bsdi*)     CC=${CC-"shlicc"}
46            OPTFLAG=${OPTFLAG-"-O2"};;
47 irix6*)    OPTFLAG=${OPTFLAG-"-O2"};;
48 irix*)     OPTFLAG=${OPTFLAG-"-O2"};;
49 lynxos*)   AC_PROG_CC()
50            AC_MSG_CHECKING([for GNU C (gcc) version 2.x])
51            ac_cv_gcc_vers=`${CC-cc} -v 2>&1 | \
52                 grep "gcc version " | sed 's/.*version //'`
53            ac_cv_gcc_major=`echo "$ac_cv_gcc_vers" | sed 's/\..*//'`
54            if test "$ac_cv_gcc_major" = "2" ; then
55                 AC_MSG_RESULT(yes)
56            else
57                 AC_MSG_RESULT(no)
58                 AC_MSG_WARN([Nvi requires gcc 2.x to build on LynxOS.])
59                 AC_MSG_ERROR([See build/README.LynxOS for more information.])
60            fi;;
61 nextstep3) CPPFLAGS=${CPPFLAGS-"-w -pipe -posix"}
62            LDFLAGS=${LDFLAGS-"-posix"}
63            OPTFLAG=${OPTFLAG-"-O2"};;
64 osf*)      CFLAGS=${CFLAGS-"-Olimit 1000"};;
65 solaris*)  no_op_OPTFLAG=${no_op_OPTFLAG-""};;
66 sunos*)    no_op_OPTFLAG=${no_op_OPTFLAG-""};;
67 esac
69 dnl The default OPTFLAG is -O
70 AC_SUBST(OPTFLAG)
71 OPTFLAG=${OPTFLAG-"-O"}
73 dnl The default compiler is cc (NOT gcc), the default CFLAGS is empty,
74 dnl NOT whatever AC_PROG_CC sets.
75 AC_SUBST(CC)
76 CC=${CC-cc}
77 CFLAGS=${CFLAGS-""}
78 AC_PROG_CC
80 dnl The SunOS/Solaris compiler can't optimize vi/v_txt.c; the symptom is
81 dnl that the command 35i==<esc> turns into an infinite loop.
82 AC_SUBST(no_op_OPTFLAG)
83 no_op_OPTFLAG=${no_op_OPTFLAG-"$OPTFLAG"}
85 dnl Libraries.
86 case "$host_os" in
87 bsdi2.1)   LIBS=${LIBS-"-lipc"};;
88 dgux*)     LIBS=${LIBS-"-ldgc"};;
89 irix6*)    LIBS=${LIBS-"-lbsd"};;
90 irix*)     LIBS=${LIBS-"-lc_s -lbsd"};;
91 isc*)      LIBS=${LIBS-"-lcposix -linet"};;
92 netbsd1*)  LIBS=${LIBS-"-lcrypt"};;
93 ptx*)      LIBS=${LIBS-"-lseq -linet -lsocket"};;
94 sco3.2*)   LIBS=${LIBS-"-lsocket"};;
95 sinix*)    LIBS=${LIBS-"-lelf -lc"};;
96 solaris*)  LIBS=${LIBS-"-lsocket -lnsl -ldl"}
97            RLIBS=yes;;
98 wgs*)      LIBS=${LIBS-"-lnsl"};;
99 esac
101 dnl A/UX has a broken getopt(3), strpbrk(3).
102 case "$host_os" in
103 aux*)      LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
104 esac
106 dnl Ultrix has a broken POSIX.1 VDISABLE value.
107 case "$host_os" in
108 ultrix*)   AC_DEFINE(HAVE_BROKEN_VDISABLE);;
109 esac
111 dnl If the user wants a tracing version, add the TRACE compile flag.
112 AC_MSG_CHECKING(if --enable-trace option specified)
113 AC_ARG_ENABLE(trace,
114         [  --enable-trace          Build a tracing version.],
115         [vi_cv_trace="yes"], [vi_cv_trace="no"])
116 if test "$vi_cv_trace" = yes; then
117         CPPFLAGS="-DTRACE $CPPFLAGS"
119 AC_MSG_RESULT($vi_cv_trace)
121 dnl The user may have additional CPP information.
122 CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"
124 dnl The user may have additional load line information.
125 LDFLAGS="$ADDLDFLAGS $LDFLAGS"
127 dnl The user may have additional library information.
128 LIBS="$ADDLIBS $LIBS"
130 dnl Checks for programs.
131 PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib"
133 dnl Check for the shell path.
134 AC_PATH_PROG(vi_cv_path_shell, sh, no)
135 if test "$vi_cv_path_shell" = no; then
136         AC_MSG_ERROR([No shell utility found.])
139 dnl Check for the sendmail path.
140 AC_PATH_PROG(vi_cv_path_sendmail, sendmail, no)
141 if test "$vi_cv_path_sendmail" = no; then
142         AC_MSG_WARN([No sendmail utility found;])
143         AC_MSG_WARN([    users will not be told of saved files.])
146 dnl Check for the perl5/perl path.
147 AC_SUBST(vi_cv_path_perl)
148 AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)
150 dnl Check for the "preserve" path.
151 dnl Historically, nvi has used /var/tmp/vi.recover.  The Linux filesystem
152 dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
153 dnl beneath it so that we don't have name collisions with other editors.
154 dnl Other systems have /var/preserve as well, so we test first for an already
155 dnl existing name, and then use the first one that's writeable.
156 AC_SUBST(vi_cv_path_preserve)
157 AC_MSG_CHECKING(for preserve directory)
158 AC_CACHE_VAL(vi_cv_path_preserve, [dnl
159         dirlist="/var/preserve /var/tmp /usr/tmp"
160         vi_cv_path_preserve=no
161         for i in $dirlist; do
162                 if test -d $i/vi.recover; then
163                         vi_cv_path_preserve=$i/vi.recover
164                         break;
165                 fi
166         done
167         if test "$vi_cv_path_preserve" = no; then
168                 for i in $dirlist; do
169                         if test -d $i -a -w $i; then
170                                 vi_cv_path_preserve=$i/vi.recover
171                                 break;
172                         fi
173                 done
175         fi])
176 if test "$vi_cv_path_preserve" = no; then
177         AC_MSG_ERROR([No writeable preserve directory found.])
179 AC_MSG_RESULT($vi_cv_path_preserve)
181 dnl Check for programs used for installation
182 AC_PROG_AWK
183 AC_PATH_PROG(vi_cv_path_ar, ar, missing_ar)
184 AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
185 AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
186 AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
187 AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
188 AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
189 AC_PATH_PROG(vi_cv_path_ranlib, ranlib, missing_ranlib)
190 AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)
192 dnl Checks for libraries.
193 dnl Find the X libraries and includes.
194 AC_PATH_X
195 AC_SUBST(XINCS)
196 if test "$no_x" != yes; then
197         if test "X$x_libraries" != "X"; then
198                 if test "X$RLIBS" = "Xyes"; then
199                         XLIBS="-R$x_libraries -L$x_libraries $XLIBS"
200                 else
201                         XLIBS="-L$x_libraries $XLIBS"
202                 fi
203         fi
204         XLIBS="$XLIBS -lX11"
205         if test "X$x_includes" != "X"; then
206                 XINCS="-I$x_includes"
207         fi
210 dnl Check if the user wants widechar support.
211 AC_MSG_CHECKING(if --enable-widechar option specified)
212 AC_ARG_ENABLE(widechar,
213         [  --enable-widechar     Build a wide char aware vi.],
214         [vi_cv_widechar="yes"], [vi_cv_widechar="no"])
215 if test "$vi_cv_widechar" = "yes"; then
216         AC_DEFINE(USE_WIDECHAR)
217         LIBOBJS="wcwidth.o $LIBOBJS"
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         vi_gtk=vi-gtk
233         vi_ipc=vi-ipc
234         AM_PATH_GTK(1.2.0)
235         GTKINCS="$GTK_CFLAGS"
236         GTKLIBS="$GTK_LIBS $LIBS"
237         SAVELIBS="$LIBS"
238         AM_PATH_GDK_PIXBUF(0.4.0, pixbuf=yes, pixbuf=no)
239         if test "$pixbuf" != "no"; then
240                 LIBS="-lutil $GDK_PIXBUF_LIBS $GTKLIBS"
241                 AC_CHECK_LIB(nvizvt, zvt_get_ptys,
242                         [vi_cv_zvt="yes"], [vi_cv_zvt="no"])
243                 if test "$vi_cv_zvt" = "yes"; then
244                         GTKLIBS="-lnvizvt $LIBS"
245                         AC_DEFINE(HAVE_ZVT)
246                 fi
247                 LIBS="$SAVELIBS"
248         fi
249         AC_PATH_PROG(vi_cv_pango_config, pango-config, no)
250         if test "$vi_cv_pango_config" != "no"; then
251                 PANGOLIBS=`$vi_cv_pango_config --libs pangox`
252                 GTKLIBS="$PANGOLIBS $GTKLIBS"
253                 AC_DEFINE(HAVE_PANGO)
254         fi
255 #       AC_PATH_PROG(vi_cv_gnome_config, gnome-config, no)
256 #       if test "$vi_cv_gnome_config" != "no"; then
257 #               ZVTLIBS=`$vi_cv_gnome_config zvt --libs`
258 #               GTKLIBS="$ZVTLIBS $GTKLIBS"
259 #       fi
262 dnl If the user wants a Motif IPC front-end for nvi, build it.
263 AC_SUBST(vi_motif)
264 AC_SUBST(MOTIFLIBS)
265 AC_MSG_CHECKING(if --enable-motif option specified)
266 AC_ARG_ENABLE(motif,
267         [  --enable-motif          Build a Motif front-end for vi.],
268         [vi_cv_motif="yes"], [vi_cv_motif="no"])
269 AC_MSG_RESULT($vi_cv_motif)
270 if test "$vi_cv_motif" = "yes"; then
271         vi_motif=vi-motif
272         vi_ipc=vi-ipc
274         dnl XXX
275         dnl BSDI's Motif libraries aren't shared.
277         case "$host_os" in
278         bsdi*)  CC=cc;;
279         esac
281         dnl XXX
282         dnl The Xinside Motif distribution requires -lSM, -lICE and -lXext.
283         dnl -lXext is generally available, the others aren't.
284         dnl
285         dnl XXX
286         dnl Color icons require -lXpm, which may or may not be available,
287         dnl depending on the version of X11.
289         MOTIFLIBS="-lXm -lXt"
290         AC_CHECK_LIB(SM, main,
291             [vi_cv_smlib="yes"], [vi_cv_smlib="no"], "$XLIBS")
292         if test "$vi_cv_smlib" = "yes"; then
293                 MOTIFLIBS="$MOTIFLIBS -lSM"
294         fi
295         AC_CHECK_LIB(ICE, main,
296             [vi_cv_icelib="yes"], [vi_cv_icelib="no"], "$XLIBS")
297         if test "$vi_cv_icelib" = "yes"; then
298                 MOTIFLIBS="$MOTIFLIBS -lICE"
299         fi
300         AC_CHECK_LIB(Xext, main,
301             [vi_cv_xextlib="yes"], [vi_cv_xextlib="no"], "$XLIBS")
302         if test "$vi_cv_xextlib" = "yes"; then
303                 MOTIFLIBS="$MOTIFLIBS -lXext"
304         fi
305         AC_CHECK_LIB(Xpm, main,
306             [vi_cv_xpmlib="yes"], [vi_cv_xpmlib="no"], "$XLIBS")
307         if test "$vi_cv_xpmlib" = "yes"; then
308                 MOTIFLIBS="$MOTIFLIBS -lXpm"
309         fi
310         MOTIFLIBS="$MOTIFLIBS $XLIBS -lm $LIBS"
313 AC_SUBST(IPCOBJS)
314 dnl Check for threads
315 AC_MSG_CHECKING(if --enable-threads option specified)
316 AC_ARG_ENABLE(threads,
317         [  --enable-threads     Turn on thread support.],
318         [vi_cv_threads="yes"], [vi_cv_threads="no"])
319 AC_MSG_RESULT($vi_cv_threads)
320 if test "$vi_cv_threads" = "yes"; then
321         LIBS="$LIBS -pthread"
322         AC_CACHE_VAL(vi_cv_have_pthreads, [dnl
323         AC_TRY_LINK([#include <pthread.h>],
324                 [pthread_self()],
325                 [vi_cv_have_pthreads=yes],
326                 [vi_cv_have_pthreads=no])])
327         if test "$vi_cv_have_pthreads" = "no"; then
328                 AC_MSG_ERROR(No threading library found)
329         fi
330         IPCOBJS="pthread.o $IPCOBJS"
331         AC_DEFINE(HAVE_PTHREAD)
332 else
333         IPCOBJS="nothread.o $IPCOBJS"
336 dnl If the user wants a Perl interpreter in nvi, load it.
337 AC_SUBST(shrpenv)
338 AC_SUBST(perlldflags)
339 AC_SUBST(perllibs)
340 AC_SUBST(vi_cv_perllib)
341 AC_SUBST(LTLIBOBJS)
342 AC_MSG_CHECKING(if --enable-perlinterp option specified)
343 AC_ARG_ENABLE(perlinterp,
344         [  --enable-perlinterp     Include a Perl interpreter in vi.],
345         [vi_cv_perlinterp="yes"], [vi_cv_perlinterp="no"])
346 AC_MSG_RESULT($vi_cv_perlinterp)
347 if test "$vi_cv_perlinterp" = "yes"; then
348         if test "$vi_cv_path_perl" = no; then
349                 AC_MSG_ERROR([No perl5 utility found.])
350         fi
351         $vi_cv_path_perl -e 'require 5.004' || {
352                 AC_MSG_ERROR([perl5 must be version 5.004 or later.])
353         }
354         if test "$vi_cv_threads" = "yes"; then
355                 useithreads=`$vi_cv_path_perl -MConfig -e 'print $Config{useithreads}'`
356                 if test "X$useithreads" != "Xdefine"; then
357                         AC_MSG_ERROR([vi threading only compatible with perl's ithreads.])
358                 fi
359         fi
361         eval `$vi_cv_path_perl -V:shrpenv`
362         vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
363         perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
364                 -e 'ccflags;perl_inc'`
365         if test "X$perlcppflags" != "X"; then
366                 CPPFLAGS="$perlcppflags $CPPFLAGS"
367         fi
368         perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
369                 -e 'ldopts'`
370         perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
371                 -e 'ccdlflags'`
372         LTLIBOBJS="perl.lo perlxsi.lo perlsfio.lo $LTLIBOBJS"
373         AC_DEFINE(HAVE_PERL_INTERP)
376 dnl If the user wants a Tk/Tcl interpreter in nvi, load it.  Make sure that
377 dnl we can find a Tk/Tcl library.
378 AC_MSG_CHECKING(if --enable-tclinterp option specified)
379 AC_ARG_ENABLE(tclinterp,
380         [  --enable-tclinterp      Include a Tk/Tcl interpreter in vi.],
381         [vi_cv_tclinterp="yes"], [vi_cv_tclinterp="no"])
382 AC_MSG_RESULT($vi_cv_tclinterp)
383 if test "$vi_cv_tclinterp" = "yes"; then
384         LIBOBJS="tcl.o $LIBOBJS"
385         LIBS="-ltk -ltcl -lm $XLIBS $LIBS"
386         AC_DEFINE(HAVE_TCL_INTERP)
388         AC_CHECK_LIB(tcl, main,
389                 [vi_cv_tkfatal="no"], [vi_cv_tkfatal="yes"], -ltk -lm)
390         if test "$vi_cv_tkfatal" = "yes"; then
391                 AC_MSG_WARN([No Tk/Tcl library found;])
392                 AC_MSG_ERROR([    see the section ADDING LIBRARIES AND INCLUDE FILES in the README file.])
393         fi
396 dnl Check for the termcap/termlib library.  Compile in nvi's curses routines
397 dnl unless the user specifies otherwise.  These two checks must occur in the
398 dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
399 AC_CHECK_LIB(termlib, tgetent,
400         [vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
401 if test "$vi_cv_termlib" = no; then
402         AC_CHECK_LIB(termcap, tgetent,
403                 [vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
405 if test "$vi_cv_termlib" != no; then
406         LIBS="$vi_cv_termlib $LIBS"
408 AC_SUBST(cobjs)
410 # XXX actually check for curses !
411 CURSLIB=curses
412 AC_ARG_WITH(curses,
413         [  --with-curses=DIR       Path to curses installation. ])
414 if test "x$with_curses" != "x"; then
415         LDFLAGS="-L$with_curses/lib $LDFLAGS"
416         CFLAGS="-I$with_curses/include $CFLAGS"
417         if test -f "$with_curses/include/ncurses.h"; then
418                 AC_CHECK_HEADERS(ncurses.h)
419                 CURSLIB=ncurses
420         fi
424 AC_CHECK_LIB($CURSLIB, initscr,
425         [vi_cv_cursesfatal="no"], [vi_cv_cursesfatal="yes"])
426 if test "$vi_cv_cursesfatal" = "yes"; then
427         AC_MSG_ERROR([Need curses.])
430 LIBS="-l$CURSLIB $LIBS"
432 dnl Checks for header files.
433 AC_MSG_CHECKING(for sys/mman.h)
434 AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
435 AC_TRY_CPP([#include <sys/mman.h>],
436         [vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
437 if test "$vi_cv_include_sys_mman" = yes; then
438         AC_DEFINE(HAVE_SYS_MMAN_H)
440 AC_MSG_RESULT($vi_cv_include_sys_mman)
442 AC_MSG_CHECKING(for sys/select.h)
443 AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
444 AC_TRY_CPP([#include <sys/select.h>],
445         [vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
446 if test "$vi_cv_include_sys_select" = yes; then
447         AC_DEFINE(HAVE_SYS_SELECT_H)
449 AC_MSG_RESULT($vi_cv_include_sys_select)
451 dnl Checks for typedefs, structures, and compiler characteristics.
452 AC_CHECK_TYPE(ssize_t, int)
453 AC_C_BIGENDIAN
454 AC_C_CONST
455 AC_STRUCT_ST_BLKSIZE
456 AC_TYPE_MODE_T
457 AC_TYPE_OFF_T
458 AC_TYPE_PID_T
459 AC_TYPE_SIZE_T
460 AC_STRUCT_TM
462 dnl Checks for library functions.
463   AC_CHECK_FUNCS(bsearch gethostname memchr memset)
464 AC_REPLACE_FUNCS(bsearch gethostname memchr memset)
465   AC_CHECK_FUNCS(mkstemp mmap strdup strpbrk)
466 AC_REPLACE_FUNCS(mkstemp mmap strdup strpbrk)
467   AC_CHECK_FUNCS(vsnprintf)
468 AC_REPLACE_FUNCS(vsnprintf)
470 AC_CHECK_FUNCS(select)
471 AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
472 AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
473 AC_CHECK_FUNCS(unsetenv,, [need_env=yes])
475 AC_FUNC_MMAP
476 AC_FUNC_VFORK
478 dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
479 if test "$need_env" = yes; then
480         LIBOBJS="env.o $LIBOBJS"
483 dnl If we need strsep, add it and define it so we get a prototype.
484 if test "$need_strsep" = yes; then
485         LIBOBJS="strsep.o $LIBOBJS"
488 dnl XXX not sure whether this is a good idea
489 LTLIBOBJS="`echo $LIBOBJS | sed 's/\.o/.lo/g'` $LTLIBOBJS"
491 dnl Check for fcntl/flock
492 dnl Use flock preferentially, since it has cleaner semantics and won't
493 dnl hang up the editor.
494 dnl XXX
495 dnl Ultrix has a broken fcntl, but a working flock.
496 dnl IRIX and DGUX have a broken flock, but working fcntl.
497 AC_MSG_CHECKING(for fcntl/flock)
498 AC_CACHE_VAL(vi_cv_lock, [dnl
499         vi_cv_lock=none
500         case "$host_os" in
501         dgux*);;
502         irix*);;
503         *)
504                 AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
505                     [vi_cv_lock=flock]);;
506         esac
507         if test "$vi_cv_lock" = none; then
508                 AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
509                     [vi_cv_lock=fcntl])
510         fi])
512 if test "$vi_cv_lock" = flock; then
513         AC_DEFINE(HAVE_LOCK_FLOCK)
515 if test "$vi_cv_lock" = fcntl; then
516         AC_DEFINE(HAVE_LOCK_FCNTL)
518 AC_MSG_RESULT($vi_cv_lock)
520 dnl Check for ftruncate/chsize
521 AC_MSG_CHECKING(for ftruncate/chsize)
522 AC_CACHE_VAL(vi_cv_ftruncate, [dnl
523 AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
524         [vi_cv_ftruncate=ftruncate],
525 AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
526         [vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
527 if test "$vi_cv_ftruncate" = ftruncate; then
528         AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
530 if test "$vi_cv_ftruncate" = chsize; then
531         AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
533 if test "$vi_cv_ftruncate" = no; then
534         AC_MSG_ERROR([No file truncation system call.])
536 AC_MSG_RESULT($vi_cv_ftruncate)
538 dnl Check for the tigetstr/tigetnum functions.
539 AC_MSG_CHECKING(for tigetstr/tigetnum)
540 AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
541 AC_TRY_LINK([#include <$CURSLIB.h>], [tigetstr(0);],
542         [vi_cv_have_curses_tigetstr=yes],
543         [vi_cv_have_curses_tigetstr=no])])
544 if test "$vi_cv_have_curses_tigetstr" = yes; then
545         AC_DEFINE(HAVE_CURSES_TIGETSTR)
547 AC_MSG_RESULT($vi_cv_have_curses_tigetstr)
549 dnl Check for potentially missing curses functions in system or user-specified
550 dnl libraries.  We also have to guess at whether the specified library is a
551 dnl BSD or System V style curses.  Use the newterm function, all System V
552 dnl curses implementations have it, none, as far as I know, of the BSD ones do.
553 if test "$vi_cv_curses" = "bundled curses"; then
554         AC_DEFINE(HAVE_BSD_CURSES)
555         AC_DEFINE(HAVE_CURSES_WADDNSTR)
556         AC_DEFINE(HAVE_CURSES_IDLOK)
557 else
558         dnl Check for the waddnstr function.
559         AC_MSG_CHECKING(for waddnstr)
560         AC_CACHE_VAL(vi_cv_have_curses_waddnstr, [dnl
561         AC_TRY_LINK([#include <$CURSLIB.h>], [waddnstr(stdscr, 0, 0);],
562                 [vi_cv_have_curses_waddnstr=yes],
563                 [vi_cv_have_curses_waddnstr=no])])
564         if test "$vi_cv_have_curses_waddnstr" = yes; then
565                 AC_DEFINE(HAVE_CURSES_WADDNSTR)
566         fi
567         AC_MSG_RESULT($vi_cv_have_curses_waddnstr)
569         dnl Check for the beep function.
570         AC_MSG_CHECKING(for beep)
571         AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
572         AC_TRY_LINK([#include <$CURSLIB.h>], [beep();],
573                 [vi_cv_have_curses_beep=yes],
574                 [vi_cv_have_curses_beep=no])])
575         if test "$vi_cv_have_curses_beep" = yes; then
576                 AC_DEFINE(HAVE_CURSES_BEEP)
577         fi
578         AC_MSG_RESULT($vi_cv_have_curses_beep)
580         dnl Check for the flash function.
581         AC_MSG_CHECKING(for flash)
582         AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
583         AC_TRY_LINK([#include <$CURSLIB.h>], [flash();],
584                 [vi_cv_have_curses_flash=yes],
585                 [vi_cv_have_curses_flash=no])])
586         if test "$vi_cv_have_curses_flash" = yes; then
587                 AC_DEFINE(HAVE_CURSES_FLASH)
588         fi
589         AC_MSG_RESULT($vi_cv_have_curses_flash)
591         dnl Check for the idlok function.
592         AC_MSG_CHECKING(for idlok)
593         AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
594         AC_TRY_LINK([#include <$CURSLIB.h>], [idlok(0, 0);],
595                 [vi_cv_have_curses_idlok=yes],
596                 [vi_cv_have_curses_idlok=no])])
597         if test "$vi_cv_have_curses_idlok" = yes; then
598                 AC_DEFINE(HAVE_CURSES_IDLOK)
599         fi
600         AC_MSG_RESULT($vi_cv_have_curses_idlok)
602         dnl Check for the keypad function.
603         AC_MSG_CHECKING(for keypad)
604         AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
605         AC_TRY_LINK([#include <$CURSLIB.h>], [keypad(0, 0);],
606                 [vi_cv_have_curses_keypad=yes],
607                 [vi_cv_have_curses_keypad=no])])
608         if test "$vi_cv_have_curses_keypad" = yes; then
609                 AC_DEFINE(HAVE_CURSES_KEYPAD)
610         fi
611         AC_MSG_RESULT($vi_cv_have_curses_keypad)
613         dnl Check for the newterm function.
614         AC_MSG_CHECKING(for newterm)
615         AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
616         AC_TRY_LINK([#include <$CURSLIB.h>], [newterm(0, 0, 0);],
617                 [vi_cv_have_curses_newterm=yes],
618                 [vi_cv_have_curses_newterm=no])])
619         if test "$vi_cv_have_curses_newterm" = yes; then
620                 AC_DEFINE(HAVE_CURSES_NEWTERM)
621         fi
622         AC_MSG_RESULT($vi_cv_have_curses_newterm)
624         if test "$vi_cv_have_curses_newterm" = no; then
625                 AC_DEFINE(HAVE_BSD_CURSES)
626         fi
629 dnl Check for the setupterm function.  We make this check regardless of
630 dnl using the system library, because it may be part of the underlying
631 dnl termcap/termlib support, and we want to use the local one.
632 AC_MSG_CHECKING(for setupterm)
633 AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
634 AC_TRY_LINK([#include <$CURSLIB.h>], [setupterm(0, 0, 0);],
635         [vi_cv_have_curses_setupterm=yes],
636         [vi_cv_have_curses_setupterm=no])])
637 if test "$vi_cv_have_curses_setupterm" = yes; then
638         AC_DEFINE(HAVE_CURSES_SETUPTERM)
640 AC_MSG_RESULT($vi_cv_have_curses_setupterm)
642 dnl Some moron decided to drop off an argument from the gettimeofday call,
643 dnl without changing the name.
644 AC_MSG_CHECKING(for broken gettimeofday system call)
645 AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
646 AC_TRY_LINK([#include <sys/types.h>
647 #include <sys/time.h>], [gettimeofday(0, 0);],
648         [vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
649 if test "$vi_cv_gettimeofday" = broken; then
650         AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
652 AC_MSG_RESULT($vi_cv_gettimeofday)
654 dnl Check for which version of openpty to use, System V or Berkeley.
655 AC_MSG_CHECKING(for System V pty calls)
656 AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
657 AC_TRY_LINK(, [grantpt(0);],
658         [vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
659 if test "$vi_cv_sys5_pty" = yes; then
660         AC_DEFINE(HAVE_SYS5_PTY)
662 AC_MSG_RESULT($vi_cv_sys5_pty)
664 dnl Check for the revoke system call.
665 AC_MSG_CHECKING(for revoke system call)
666 AC_CACHE_VAL(vi_cv_revoke, [dnl
667 AC_TRY_LINK(, [revoke("a");],
668         [vi_cv_revoke=yes], [vi_cv_revoke=no])])
669 if test "$vi_cv_revoke" = yes; then
670         AC_DEFINE(HAVE_REVOKE)
672 AC_MSG_RESULT($vi_cv_revoke)
674 dnl Some versions of sprintf return a pointer to the first argument instead
675 dnl of a character count.  We assume that the return value of snprintf and
676 dnl vsprintf etc. will be the same as sprintf, and check the easy one.
677 AC_MSG_CHECKING(for int type sprintf return value)
678 AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
679 AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
680         [vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
681 if test "$vi_cv_sprintf_count" = no; then
682         AC_DEFINE(SPRINTF_RET_CHARPNT)
684 AC_MSG_RESULT($vi_cv_sprintf_count)
687 dnl Check for the standard shorthand types.
688 AC_SUBST(u_char_decl)
689 AC_CACHE_CHECK([for u_char], vi_cv_uchar, [dnl
690 AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
691         [vi_cv_uchar=yes], [vi_cv_uchar=no])])
692 if test "$vi_cv_uchar" = no; then
693         u_char_decl="typedef unsigned char u_char;"
696 AC_SUBST(u_short_decl)
697 AC_CACHE_CHECK([for u_short], vi_cv_ushort, [dnl
698 AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
699         [vi_cv_ushort=yes], [vi_cv_ushort=no])])
700 if test "$vi_cv_ushort" = no; then
701         u_short_decl="typedef unsigned short u_short;"
704 AC_SUBST(u_int_decl)
705 AC_CACHE_CHECK([for u_int], vi_cv_uint, [dnl
706 AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
707         [vi_cv_uint=yes], [vi_cv_uint=no])])
708 if test "$vi_cv_uint" = no; then
709         u_int_decl="typedef unsigned int u_int;"
712 AC_SUBST(u_long_decl)
713 AC_CACHE_CHECK([for u_long], vi_cv_ulong, [dnl
714 AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
715         [vi_cv_ulong=yes], [vi_cv_ulong=no])])
716 if test "$vi_cv_ulong" = no; then
717         u_long_decl="typedef unsigned long u_long;"
720 dnl DB/Vi use specific integer sizes.
721 AC_SUBST(u_int8_decl)
722 AC_CACHE_CHECK([for u_int8_t], vi_cv_uint8, [dnl
723 AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
724         [vi_cv_uint8=yes],
725         AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
726             [vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
727 if test "$vi_cv_uint8" = no; then
728         AC_MSG_ERROR(No unsigned 8-bit integral type.)
730 if test "$vi_cv_uint8" != yes; then
731         u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
734 AC_SUBST(u_int16_decl)
735 AC_CACHE_CHECK([for u_int16_t], vi_cv_uint16, [dnl
736 AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
737         [vi_cv_uint16=yes],
738 AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
739         [vi_cv_uint16="unsigned short"],
740 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
741         [vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
742 if test "$vi_cv_uint16" = no; then
743         AC_MSG_ERROR([No unsigned 16-bit integral type.])
745 if test "$vi_cv_uint16" != yes; then
746         u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
749 AC_SUBST(int16_decl)
750 AC_CACHE_CHECK([for int16_t], vi_cv_int16, [dnl
751 AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
752         [vi_cv_int16=yes],
753 AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
754         [vi_cv_int16="short"],
755 AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
756         [vi_cv_int16="int"], [vi_cv_int16=no])))])
757 if test "$vi_cv_int16" = no; then
758         AC_MSG_ERROR([No signed 16-bit integral type.])
760 if test "$vi_cv_int16" != yes; then
761         int16_decl="typedef $vi_cv_int16 int16_t;"
764 AC_SUBST(u_int32_decl)
765 AC_CACHE_CHECK([for u_int32_t], vi_cv_uint32, [dnl
766 AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
767         [vi_cv_uint32=yes],
768 AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
769         [vi_cv_uint32="unsigned int"],
770 AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
771         [vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
772 if test "$vi_cv_uint32" = no; then
773         AC_MSG_ERROR([No unsigned 32-bit integral type.])
775 if test "$vi_cv_uint32" != yes; then
776         u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
779 AC_SUBST(int32_decl)
780 AC_CACHE_CHECK([for int32_t], vi_cv_int32, [dnl
781 AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
782         [vi_cv_int32=yes],
783 AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
784         [vi_cv_int32="int"],
785 AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
786         [vi_cv_int32="long"], [vi_cv_int32=no])))])
787 if test "$vi_cv_int32" = no; then
788         AC_MSG_ERROR([No signed 32-bit integral type.])
790 if test "$vi_cv_int32" != yes; then
791         int32_decl="typedef $vi_cv_int32 int32_t;"
794 AC_CACHE_CHECK([return type of fprintf], vi_cv_type_fprintf,
795 [AC_TRY_COMPILE([#include <stdio.h>
796 int fprintf ();
797 ],[int i;], vi_cv_type_fprintf=int, vi_cv_type_fprintf=void)])
799 AC_SUBST(NEED_FPRINTF_PROTO)
800 AC_CACHE_CHECK([fprintf prototype needed], vi_cv_proto_fprintf,
801 [AC_TRY_COMPILE([ #include <stdio.h>
802 typedef int     (*funcPtr)();
803 ],[funcPtr ptr = (funcPtr) fprintf;], 
804 vi_cv_proto_fprintf=no, 
805 [vi_cv_proto_fprintf=yes, AC_DEFINE(NEED_FPRINTF_PROTO)])])
808 dnl Check for DB 3
809 AC_ARG_WITH(db3,
810         [  --with-db3=db3prefix    Path to db3 installation. ])
811 if test "$with_db3" = "no"; then
812         AC_MSG_ERROR([Need DB 3.])
815 saveLDFLAGS="$LDFLAGS"
816 if test "x$with_db3" != "x"; then
817         LDFLAGS="-L$with_db3/lib $LDFLAGS"
818         CFLAGS="-I$with_db3/include $CFLAGS"
821 AC_CHECK_LIB(db, db_create,
822         [vi_cv_dbfatal="no"], [vi_cv_dbfatal="yes"])
823 if test "$vi_cv_dbfatal" = "yes"; then
824         AC_MSG_ERROR([Need DB 3.])
827 LDFLAGS="$saveLDFLAGS"
829 AC_SUBST(dl_src)
830 AC_MSG_CHECKING(if --enable-dynamic-loading option specified)
831 AC_ARG_ENABLE(dynamic-loading,
832         [  --enable-dynamic-loading Load DB 3 dynamically.],
833         [vi_cv_dl="yes"], [vi_cv_dl="no"])
834 AC_MSG_RESULT($vi_cv_dl)
835 if test "$vi_cv_dl" = yes; then
836         AC_CHECK_LIB(dl, dlopen,
837                 [vi_cv_dlfatal="no"], [vi_cv_dlfatal="yes"])
838         if test "$vi_cv_dlfatal" = "yes"; then
839                 AC_MSG_ERROR([Need dl to support dynamic loading.])
840         fi
841         OLDPATH="$PATH"
843         PATH="$with_db3/lib:/usr/lib:/lib"
844         AC_PATH_PROG(vi_cv_path_db3, libdb-3.so, no)
845         if test "$vi_cv_path_db3" = no; then
846                 AC_MSG_ERROR([Path of libdb-3.so not found.])
847         fi
848         PATH="$OLDPATH"
850         AC_DEFINE(USE_DYNAMIC_LOADING)
851         LTLIBOBJS="dldb.lo $LTLIBOBJS"
852         dl_src=../common/dldb.c
853         LIBS="-ldl $LIBS"
854 else
855         LIBS="-ldb $LIBS"
856         LDFLAGS="-L$with_db3/lib $LDFLAGS"
860 dnl We compile in nvi's RE routines unless the user specifies otherwise.
861 AC_MSG_CHECKING(if --disable-re option specified)
862 AC_ARG_ENABLE(re,
863         [  --disable-re            DON'T use the nvi-provided RE routines.],
864         [vi_cv_re_lib="other RE"], [vi_cv_re_lib="bundled RE"])
865 AC_MSG_RESULT($vi_cv_re_lib)
866 case "$vi_cv_re_lib" in
867 "bundled RE")
868         CPPFLAGS="-I\$(visrcdir)/regex $CPPFLAGS"
869         LTLIBOBJS="\$(REOBJS) $LTLIBOBJS";;
870 "other RE")
871         ;;
872 esac
874 AC_OUTPUT(Makefile port.h:port.h.in
875     pathnames.h:pathnames.h.in recover:recover.in)