aboutsummaryrefslogtreecommitdiff
path: root/contrib/nvi/build/configure.in
blob: cb8e4637d957ae4374779983da99ab5d14d0a49d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
dnl	@(#)configure.in	8.134 (Berkeley) 10/15/96

dnl Process this file with autoconf to produce a configure script.
AC_INIT(../common/main.c)
AC_CONFIG_HEADER(config.h)

dnl Configure setup.
AC_PROG_INSTALL()
AC_CANONICAL_HOST
AC_ARG_PROGRAM()

dnl If the user wants a debugging environment, set OPTFLAG now.  (Some
dnl compilers won't mix optimizing and debug flags.)
AC_MSG_CHECKING(if --enable-debug option specified)
AC_ARG_ENABLE(debug,
	[  --enable-debug          Build a debugging version.],
	[vi_cv_debug="yes"], [vi_cv_debug="no"])
if test "$vi_cv_debug" = yes; then
	AC_DEFINE(DEBUG)
	OPTFLAG=${OPTFLAG-"-g"}
	no_op_OPTFLAG=${no_op_OPTFLAG-"-g"}
fi
AC_MSG_RESULT($vi_cv_debug)

dnl This is where we handle stuff that autoconf can't handle.
dnl XXX
dnl Don't override anything if it's already set from the environment.

dnl Compiler, preprocessor and load flags.
dnl AUX:	-ZP disables _BSD_SOURCE et al, but enables POSIX at link time.
dnl LynxOS:	We check for gcc 2.x or better, the gcc 1 that was shipped with
dnl		LynxOS historically wasn't good enough.
AC_SUBST(CPPFLAGS)
case "$host_os" in
aix3.2.5)  OPTFLAG=${OPTFLAG-"-O"};;
aix4.1*)   CFLAGS=${CFLAGS-"-qstrict"}
	   OPTFLAG=${OPTFLAG-"-O3"};;
aux*)	   CPPFLAGS=${CPPFLAGS-"-ZP -D_BSD_SOURCE -D_SYSV_SOURCE -D_AUX_SOURCE"}
	   LDFLAGS=${LDFLAGS-"-ZP"}
	   OPTFLAG=${OPTFLAG-"-O"};;
bsd4.4)    OPTFLAG=${OPTFLAG-"-O2"};;
bsdi*)	   CC=${CC-"shlicc"}
	   OPTFLAG=${OPTFLAG-"-O2"};;
irix6*)	   OPTFLAG=${OPTFLAG-"-O2"};;
irix*)	   OPTFLAG=${OPTFLAG-"-O2"};;
lynxos*)   AC_PROG_CC()
	   AC_MSG_CHECKING([for GNU C (gcc) version 2.x])
	   ac_cv_gcc_vers=`${CC-cc} -v 2>&1 | \
		grep "gcc version " | sed 's/.*version //'`
	   ac_cv_gcc_major=`echo "$ac_cv_gcc_vers" | sed 's/\..*//'`
	   if test "$ac_cv_gcc_major" = "2" ; then
		AC_MSG_RESULT(yes)
	   else
		AC_MSG_RESULT(no)
		echo "Fatal error: Nvi requires gcc 2.x to build on LynxOS."
		echo "See build/README.LynxOS for more information."
		exit 1
	   fi;;
nextstep3) CPPFLAGS=${CPPFLAGS-"-w -pipe -posix"}
	   LDFLAGS=${LDFLAGS-"-posix"}
	   OPTFLAG=${OPTFLAG-"-O9"};;
osf*)	   CFLAGS=${CFLAGS-"-Olimit 1000"};;
solaris*)  no_op_OPTFLAG=${no_op_OPTFLAG-""};;
sunos*)	   no_op_OPTFLAG=${no_op_OPTFLAG-""};;
esac

dnl The default compiler is cc.
AC_SUBST(CC)
CC=${CC-cc}

dnl The default OPTFLAG is -O
AC_SUBST(OPTFLAG)
OPTFLAG=${OPTFLAG-"-O"}

dnl The SunOS/Solaris compiler can't optimize vi/v_txt.c; the symptom is
dnl that the command 35i==<esc> turns into an infinite loop.
AC_SUBST(no_op_OPTFLAG)
no_op_OPTFLAG=${no_op_OPTFLAG-"$OPTFLAG"}

dnl Libraries.
case "$host_os" in
bsdi2.1)   LIBS=${LIBS-"-lipc"};;
dgux*)	   LIBS=${LIBS-"-ldgc"};;
irix6*)	   LIBS=${LIBS-"-lbsd"};;
irix*)	   LIBS=${LIBS-"-lc_s -lbsd"};;
isc*)	   LIBS=${LIBS-"-lcposix -linet"};;
netbsd1*)  LIBS=${LIBS-"-lcrypt"};;
ptx*)	   LIBS=${LIBS-"-lseq -linet -lsocket"};;
sco3.2*)   LIBS=${LIBS-"-lsocket"};;
sinix*)	   LIBS=${LIBS-"-lelf -lc"};;
solaris*)  LIBS=${LIBS-"-lsocket -lnsl -ldl"}
	   RLIBS=yes;;
wgs*)	   LIBS=${LIBS-"-lnsl"};;
esac

dnl A/UX has a broken getopt(3), strpbrk(3).
case "$host_os" in
aux*)	   LIBOBJS="getopt.o strpbrk.o $LIBOBJS";;
esac

dnl Ultrix has a broken POSIX.1 VDISABLE value.
case "$host_os" in
ultrix*)   AC_DEFINE(HAVE_BROKEN_VDISABLE);;
esac

dnl The user may have additional CPP information.
CPPFLAGS="$ADDCPPFLAGS $CPPFLAGS"

dnl The user may have additional load line information.
LDFLAGS="$ADDLDFLAGS $LDFLAGS"

dnl The user may have additional library information.
LIBS="$ADDLIBS $LIBS"

dnl Check to see if it's going to work.
AM_SANITY_CHECK_CC

dnl Checks for programs.
PATH="$PATH:/usr/bin:/usr/sbin:/sbin:/etc:/usr/etc:/usr/lib:/usr/ucblib:"

dnl Check for the shell path.
AC_PATH_PROG(vi_cv_path_shell, sh, no)
if test "$vi_cv_path_shell" = no; then
	echo "Fatal error: the shell utility not found."
	exit 1
fi

dnl Check for the sendmail path.
AC_PATH_PROG(vi_cv_path_sendmail, sendmail, no)
if test "$vi_cv_path_sendmail" = no; then
	echo "WARNING: The sendmail utility was not found!"
	echo "WARNING: Users will not be told of saved files."
fi

dnl Check for the perl5/perl path.
AC_SUBST(vi_cv_path_perl)
AC_PATH_PROGS(vi_cv_path_perl, perl5 perl, no)

dnl Check for the "preserve" path.
dnl Historically, nvi has used /var/tmp/vi.recover.  The Linux filesystem
dnl standard (FSSTND) uses /var/preserve; we add the vi.recover directory
dnl beneath it so that we don't have name collisions with other editors.
dnl Other systems have /var/preserve as well, so we test first for an already
dnl existing name, and then use the first one that's writeable.
AC_SUBST(vi_cv_path_preserve)
AC_MSG_CHECKING(for preserve directory)
AC_CACHE_VAL(vi_cv_path_preserve, [dnl
	dirlist="/var/preserve /var/tmp /usr/tmp"
	vi_cv_path_preserve=no
	for i in $dirlist; do
		if test -d $i/vi.recover; then
			vi_cv_path_preserve=$i/vi.recover
			break;
		fi
	done
	if test "$vi_cv_path_preserve" = no; then
		for i in $dirlist; do
			if test -d $i -a -w $i; then
				vi_cv_path_preserve=$i/vi.recover
				break;
			fi
		done

	fi])
if test "$vi_cv_path_preserve" = no; then
	echo "Fatal error: no writeable preserve directory found."
	exit 1
fi
AC_MSG_RESULT($vi_cv_path_preserve)

dnl Check for programs used for installation
AC_PATH_PROG(vi_cv_path_chmod, chmod, missing_chmod)
AC_PATH_PROG(vi_cv_path_cp, cp, missing_cp)
AC_PATH_PROG(vi_cv_path_ln, ln, missing_ln)
AC_PATH_PROG(vi_cv_path_mkdir, mkdir, missing_mkdir)
AC_PATH_PROG(vi_cv_path_rm, rm, missing_rm)
AC_PATH_PROG(vi_cv_path_strip, strip, missing_strip)

dnl Checks for libraries.
dnl Find the X libraries and includes.
AC_PATH_X
AC_SUBST(XINCS)
if test "$no_x" != yes; then
	if test "X$x_libraries" != "X"; then
		if test "X$RLIBS" = "Xyes"; then
			XLIBS="-R$x_libraries -L$x_libraries $XLIBS"
		else
			XLIBS="-L$x_libraries $XLIBS"
		fi
	fi
	XLIBS="$XLIBS -lX11"
	if test "X$x_includes" != "X"; then
		XINCS="-I$x_includes"
	fi
fi

dnl If the user wants a Perl interpreter in nvi, load it.
AC_SUBST(shrpenv)
AC_SUBST(vi_cv_perllib)
AC_MSG_CHECKING(if --enable-perlinterp option specified)
AC_ARG_ENABLE(perlinterp,
	[  --enable-perlinterp     Include a Perl interpreter in vi.],
	[vi_cv_perlinterp="yes"], [vi_cv_perlinterp="no"])
AC_MSG_RESULT($vi_cv_perlinterp)
if test "$vi_cv_perlinterp" = "yes"; then
	if test "$vi_cv_path_perl" = no; then
		echo "Fatal error: no perl5 utility found."
		exit 1
	fi
	$vi_cv_path_perl -e 'require 5.002' || {
		echo "Fatal error: perl5 must be version 5.002 or later."
		exit 1
	}
	$vi_cv_path_perl -e 'close(STDERR);require 5.003_01' &&
	    AC_DEFINE(HAVE_PERL_5_003_01)

	eval `$vi_cv_path_perl -V:shrpenv`
	if test "X$shrpenv" = "XUNKNOWN"; then # pre 5.003_04
	    shrpenv=""
	fi
	vi_cv_perllib=`$vi_cv_path_perl -MConfig -e 'print $Config{privlib}'`
	perlcppflags=`$vi_cv_path_perl -Mlib=$srcdir -MExtUtils::Embed \
        	-e 'ccflags;perl_inc'`
	if test "X$perlcppflags" != "X"; then
		CPPFLAGS="$perlcppflags $CPPFLAGS"
	fi
	perllibs=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
        	-e 'ldopts'`
	if test "X$perllibs" != "X"; then
		LIBS="$perllibs $LIBS"
	fi
	perlldflags=`cd $srcdir;$vi_cv_path_perl -MExtUtils::Embed \
        	-e 'ccdlflags'`
	if test "X$perlldflags" != "X"; then
		LDFLAGS="$perlldflags $LDFLAGS"
	fi
	LIBOBJS="perl.o perlsfio.o $LIBOBJS"
	AC_DEFINE(HAVE_PERL_INTERP)
fi

dnl If the user wants a Tk/Tcl front-end for nvi, build it.
AC_SUBST(tknvi)
AC_SUBST(TKLIBS)
AC_MSG_CHECKING(if --enable-tknvi option specified)
AC_ARG_ENABLE(tknvi,
	[  --enable-tknvi          Build a Tk/Tcl front-end for vi.],
	[vi_cv_tknvi="yes"], [vi_cv_tknvi="no"])
AC_MSG_RESULT($vi_cv_tknvi)
if test "$vi_cv_tknvi" = "yes"; then
	tknvi=tknvi
	TKLIBS="-ltk -ltcl -lm $XLIBS $LIBS"
fi

dnl If the user wants a Tk/Tcl interpreter in nvi, load it.
AC_MSG_CHECKING(if --enable-tclinterp option specified)
AC_ARG_ENABLE(tclinterp,
	[  --enable-tclinterp      Include a Tk/Tcl interpreter in vi.],
	[vi_cv_tclinterp="yes"], [vi_cv_tclinterp="no"])
AC_MSG_RESULT($vi_cv_tclinterp)
if test "$vi_cv_tclinterp" = "yes"; then
	LIBOBJS="tcl.o $LIBOBJS"
	LIBS="-ltk -ltcl -lm $XLIBS $LIBS"
	AC_DEFINE(HAVE_TCL_INTERP)
fi

dnl Make sure that we can find a Tk/Tcl library.
if test "$vi_cv_tknvi" = "yes" || test "$vi_cv_tclinterp" = "yes"; then
	AC_CHECK_LIB(tcl, main,
		[vi_cv_tkfatal="no"], [vi_cv_tkfatal="yes"], -ltk -lm)
	if test "$vi_cv_tkfatal" = "yes"; then
		echo "Fatal error: no Tk/Tcl library; see the section"
		echo "ADDING LIBRARIES AND INCLUDE FILES in the README file."
		exit 1
	fi
fi

dnl Both Tcl/Tk and Perl interpreters need the vi api code.
if test "$vi_cv_tclinterp" = yes || test "$vi_cv_perlinterp" = yes; then
	LIBOBJS="api.o $LIBOBJS"
fi

dnl Check for the termcap/termlib library.  Compile in nvi's curses routines
dnl unless the user specifies otherwise.  These two checks must occur in the
dnl current order, and -lcurses must be loaded before -ltermcap/-ltermlib.
AC_CHECK_LIB(termlib, tgetent,
	[vi_cv_termlib=-ltermlib], [vi_cv_termlib=no])
if test "$vi_cv_termlib" = no; then
	AC_CHECK_LIB(termcap, tgetent,
		[vi_cv_termlib=-ltermcap], [vi_cv_termlib=no])
fi
if test "$vi_cv_termlib" != no; then
	LIBS="$vi_cv_termlib $LIBS"
fi
AC_SUBST(cobjs)
AC_MSG_CHECKING(if --disable-curses option specified)
AC_ARG_ENABLE(curses,
	[  --disable-curses        DON'T use the nvi-provided curses routines.],
	[vi_cv_curses="other curses"], [vi_cv_curses="bundled curses"])
AC_MSG_RESULT($vi_cv_curses)
case "$vi_cv_curses" in
"bundled curses")
	CPPFLAGS="-I\$(srcdir)/curses $CPPFLAGS"
	cobjs="\$(COBJS)";;
"other curses")
	LIBS="-lcurses $LIBS";;
esac

dnl Checks for header files.
AC_MSG_CHECKING(for sys/mman.h)
AC_CACHE_VAL(vi_cv_include_sys_mman, [dnl
AC_TRY_CPP([#include <sys/mman.h>],
	[vi_cv_include_sys_mman=yes], [vi_cv_include_sys_mman=no])])
if test "$vi_cv_include_sys_mman" = yes; then
	AC_DEFINE(HAVE_SYS_MMAN_H)
fi
AC_MSG_RESULT($vi_cv_include_sys_mman)

AC_MSG_CHECKING(for sys/select.h)
AC_CACHE_VAL(vi_cv_include_sys_select, [dnl
AC_TRY_CPP([#include <sys/select.h>],
	[vi_cv_include_sys_select=yes], [vi_cv_include_sys_select=no])])
if test "$vi_cv_include_sys_select" = yes; then
	AC_DEFINE(HAVE_SYS_SELECT_H)
fi
AC_MSG_RESULT($vi_cv_include_sys_select)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_TYPE(ssize_t, int)
AC_C_BIGENDIAN
AC_C_CONST
AC_STRUCT_ST_BLKSIZE
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_STRUCT_TM

dnl Checks for library functions.
  AC_CHECK_FUNCS(bsearch gethostname getopt memchr memcpy memmove memset)
AC_REPLACE_FUNCS(bsearch gethostname getopt memchr memcpy memmove memset)
  AC_CHECK_FUNCS(mkstemp mmap snprintf strdup strerror strpbrk strtol)
AC_REPLACE_FUNCS(mkstemp mmap snprintf strdup strerror strpbrk strtol)
  AC_CHECK_FUNCS(strtoul vsnprintf)
AC_REPLACE_FUNCS(strtoul vsnprintf)

AC_CHECK_FUNCS(select)
AC_CHECK_FUNCS(setenv, [need_env=no], [need_env=yes])
AC_CHECK_FUNCS(strsep, [need_strsep=no], [need_strsep=yes])
AC_CHECK_FUNCS(unsetenv,, [need_env=yes])

AC_FUNC_MMAP
AC_FUNC_VFORK

dnl If we needed setenv or unsetenv, add in the clib/env.c replacement file.
if test "$need_env" = yes; then
	LIBOBJS="env.o $LIBOBJS"
fi

dnl If we need strsep, add it and define it so we get a prototype.
if test "$need_strsep" = yes; then
	LIBOBJS="strsep.o $LIBOBJS"
fi

dnl Check for fcntl/flock
dnl Use flock preferentially, since it has cleaner semantics and won't
dnl hang up the editor.
dnl XXX
dnl Ultrix has a broken fcntl, but a working flock.
dnl IRIX and DGUX have a broken flock, but working fcntl.
AC_MSG_CHECKING(for fcntl/flock)
AC_CACHE_VAL(vi_cv_lock, [dnl
	vi_cv_lock=none
	case "$host_os" in
	dgux*);;
	irix*);;
	*)
		AC_TRY_LINK([#include <fcntl.h>], [flock(0, 0);],
		    [vi_cv_lock=flock]);;
	esac
	if test "$vi_cv_lock" = none; then
		AC_TRY_LINK([#include <fcntl.h>], [fcntl(0, F_SETLK, 0);],
		    [vi_cv_lock=fcntl])
	fi])

if test "$vi_cv_lock" = flock; then
	AC_DEFINE(HAVE_LOCK_FLOCK)
fi
if test "$vi_cv_lock" = fcntl; then
	AC_DEFINE(HAVE_LOCK_FCNTL)
fi
AC_MSG_RESULT($vi_cv_lock)

dnl Check for ftruncate/chsize
AC_MSG_CHECKING(for ftruncate/chsize)
AC_CACHE_VAL(vi_cv_ftruncate, [dnl
AC_TRY_LINK([#include <unistd.h>], [ftruncate(0, 0);],
	[vi_cv_ftruncate=ftruncate],
AC_TRY_LINK([#include <unistd.h>], [chsize(0, 0);],
	[vi_cv_ftruncate=chsize], [vi_cv_ftruncate=no]))])
if test "$vi_cv_ftruncate" = ftruncate; then
	AC_DEFINE(HAVE_FTRUNCATE_FTRUNCATE)
fi
if test "$vi_cv_ftruncate" = chsize; then
	AC_DEFINE(HAVE_FTRUNCATE_CHSIZE)
fi
if test "$vi_cv_ftruncate" = no; then
	echo
	echo "Fatal error: no file truncation system call."
	exit 1
fi
AC_MSG_RESULT($vi_cv_ftruncate)

dnl Check for the tigetstr/tigetnum functions.
AC_MSG_CHECKING(for tigetstr/tigetnum)
AC_CACHE_VAL(vi_cv_have_curses_tigetstr, [dnl
AC_TRY_LINK([#include <curses.h>], [tigetstr(0);],
	[vi_cv_have_curses_tigetstr=yes],
	[vi_cv_have_curses_tigetstr=no])])
if test "$vi_cv_have_curses_tigetstr" = yes; then
	AC_DEFINE(HAVE_CURSES_TIGETSTR)
fi
AC_MSG_RESULT($vi_cv_have_curses_tigetstr)

dnl Check for potentially missing curses functions in system or user-specified
dnl libraries.  We also have to guess at whether the specified library is a
dnl BSD or System V style curses.  Use the newterm function, all System V
dnl curses implementations have it, none, as far as I know, of the BSD ones do.
if test "$vi_cv_curses" = "bundled curses"; then
	AC_DEFINE(HAVE_BSD_CURSES)
	AC_DEFINE(HAVE_CURSES_ADDNSTR)
	AC_DEFINE(HAVE_CURSES_IDLOK)
else
	dnl Check for the addnstr function.
	AC_MSG_CHECKING(for addnstr)
	AC_CACHE_VAL(vi_cv_have_curses_addnstr, [dnl
	AC_TRY_LINK([#include <curses.h>], [addnstr(0, 0);],
		[vi_cv_have_curses_addnstr=yes],
		[vi_cv_have_curses_addnstr=no])])
	if test "$vi_cv_have_curses_addnstr" = yes; then
		AC_DEFINE(HAVE_CURSES_ADDNSTR)
	fi
	AC_MSG_RESULT($vi_cv_have_curses_addnstr)

	dnl Check for the beep function.
	AC_MSG_CHECKING(for beep)
	AC_CACHE_VAL(vi_cv_have_curses_beep, [dnl
	AC_TRY_LINK([#include <curses.h>], [beep();],
		[vi_cv_have_curses_beep=yes],
		[vi_cv_have_curses_beep=no])])
	if test "$vi_cv_have_curses_beep" = yes; then
		AC_DEFINE(HAVE_CURSES_BEEP)
	fi
	AC_MSG_RESULT($vi_cv_have_curses_beep)

	dnl Check for the flash function.
	AC_MSG_CHECKING(for flash)
	AC_CACHE_VAL(vi_cv_have_curses_flash, [dnl
	AC_TRY_LINK([#include <curses.h>], [flash();],
		[vi_cv_have_curses_flash=yes],
		[vi_cv_have_curses_flash=no])])
	if test "$vi_cv_have_curses_flash" = yes; then
		AC_DEFINE(HAVE_CURSES_FLASH)
	fi
	AC_MSG_RESULT($vi_cv_have_curses_flash)

	dnl Check for the idlok function.
	AC_MSG_CHECKING(for idlok)
	AC_CACHE_VAL(vi_cv_have_curses_idlok, [dnl
	AC_TRY_LINK([#include <curses.h>], [idlok(0, 0);],
		[vi_cv_have_curses_idlok=yes],
		[vi_cv_have_curses_idlok=no])])
	if test "$vi_cv_have_curses_idlok" = yes; then
		AC_DEFINE(HAVE_CURSES_IDLOK)
	fi
	AC_MSG_RESULT($vi_cv_have_curses_idlok)

	dnl Check for the keypad function.
	AC_MSG_CHECKING(for keypad)
	AC_CACHE_VAL(vi_cv_have_curses_keypad, [dnl
	AC_TRY_LINK([#include <curses.h>], [keypad(0, 0);],
		[vi_cv_have_curses_keypad=yes],
		[vi_cv_have_curses_keypad=no])])
	if test "$vi_cv_have_curses_keypad" = yes; then
		AC_DEFINE(HAVE_CURSES_KEYPAD)
	fi
	AC_MSG_RESULT($vi_cv_have_curses_keypad)

	dnl Check for the newterm function.
	AC_MSG_CHECKING(for newterm)
	AC_CACHE_VAL(vi_cv_have_curses_newterm, [dnl
	AC_TRY_LINK([#include <curses.h>], [newterm(0, 0, 0);],
		[vi_cv_have_curses_newterm=yes],
		[vi_cv_have_curses_newterm=no])])
	if test "$vi_cv_have_curses_newterm" = yes; then
		AC_DEFINE(HAVE_CURSES_NEWTERM)
	fi
	AC_MSG_RESULT($vi_cv_have_curses_newterm)

	if test "$vi_cv_have_curses_newterm" = no; then
		AC_DEFINE(HAVE_BSD_CURSES)
	fi
fi

dnl Check for the setupterm function.  We make this check regardless of
dnl using the system library, because it may be part of the underlying
dnl termcap/termlib support, and we want to use the local one.
AC_MSG_CHECKING(for setupterm)
AC_CACHE_VAL(vi_cv_have_curses_setupterm, [dnl
AC_TRY_LINK([#include <curses.h>], [setupterm(0, 0, 0);],
	[vi_cv_have_curses_setupterm=yes],
	[vi_cv_have_curses_setupterm=no])])
if test "$vi_cv_have_curses_setupterm" = yes; then
	AC_DEFINE(HAVE_CURSES_SETUPTERM)
fi
AC_MSG_RESULT($vi_cv_have_curses_setupterm)

dnl Some moron decided to drop off an argument from the gettimeofday call,
dnl without changing the name.
AC_MSG_CHECKING(for broken gettimeofday system call)
AC_CACHE_VAL(vi_cv_gettimeofday, [dnl
AC_TRY_LINK([#include <sys/types.h>
#include <sys/time.h>], [gettimeofday(0, 0);],
	[vi_cv_gettimeofday=okay], [vi_cv_gettimeofday=broken])])
if test "$vi_cv_gettimeofday" = broken; then
	AC_DEFINE(HAVE_BROKEN_GETTIMEOFDAY)
fi
AC_MSG_RESULT($vi_cv_gettimeofday)

dnl Check for which version of openpty to use, System V or Berkeley.
AC_MSG_CHECKING(for System V pty calls)
AC_CACHE_VAL(vi_cv_sys5_pty, [dnl
AC_TRY_LINK(, [grantpt(0);],
	[vi_cv_sys5_pty=yes], [vi_cv_sys5_pty=no])])
if test "$vi_cv_sys5_pty" = yes; then
	AC_DEFINE(HAVE_SYS5_PTY)
fi
AC_MSG_RESULT($vi_cv_sys5_pty)

dnl Check for the revoke system call.
AC_MSG_CHECKING(for revoke system call)
AC_CACHE_VAL(vi_cv_revoke, [dnl
AC_TRY_LINK(, [revoke("a");],
	[vi_cv_revoke=yes], [vi_cv_revoke=no])])
if test "$vi_cv_revoke" = yes; then
	AC_DEFINE(HAVE_REVOKE)
fi
AC_MSG_RESULT($vi_cv_revoke)

dnl Some versions of sprintf return a pointer to the first argument instead
dnl of a character count.  We assume that the return value of snprintf and
dnl vsprintf etc. will be the same as sprintf, and check the easy one.
AC_MSG_CHECKING(for int type sprintf return value)
AC_CACHE_VAL(vi_cv_sprintf_count, [dnl
AC_TRY_RUN([main(){char buf[20]; exit(sprintf(buf, "XXX") != 3);}],
	[vi_cv_sprintf_count=yes], [vi_cv_sprintf_count=no])])
if test "$vi_cv_sprintf_count" = no; then
	AC_DEFINE(SPRINTF_RET_CHARPNT)
fi
AC_MSG_RESULT($vi_cv_sprintf_count)

dnl We compile in nvi's DB routines unless the user specifies otherwise.
AC_MSG_CHECKING(if --disable-db option specified)
AC_ARG_ENABLE(db,
	[  --disable-db            DON'T use the nvi-provided DB routines.],
	[vi_cv_db_lib="other DB"], [vi_cv_db_lib="bundled DB"])
AC_MSG_RESULT($vi_cv_db_lib)
case "$vi_cv_db_lib" in
"bundled DB")
	CPPFLAGS="-I\$(srcdir)/db/include $CPPFLAGS"
	LIBOBJS="\$(DBOBJS) $LIBOBJS";;
"other DB")
	;;
esac

dnl We compile in nvi's RE routines unless the user specifies otherwise.
AC_MSG_CHECKING(if --disable-re option specified)
AC_ARG_ENABLE(re,
	[  --disable-re            DON'T use the nvi-provided RE routines.],
	[vi_cv_re_lib="other RE"], [vi_cv_re_lib="bundled RE"])
AC_MSG_RESULT($vi_cv_re_lib)
case "$vi_cv_re_lib" in
"bundled RE")
	CPPFLAGS="-I\$(srcdir)/regex $CPPFLAGS"
	LIBOBJS="\$(REOBJS) $LIBOBJS";;
"other RE")
	;;
esac

dnl Check for the standard shorthand types.
AC_SUBST(u_char_decl)
AC_MSG_CHECKING(for u_char)
AC_CACHE_VAL(vi_cv_uchar, [dnl
AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;,
	[vi_cv_uchar=yes], [vi_cv_uchar=no])])
AC_MSG_RESULT($vi_cv_uchar)
if test "$vi_cv_uchar" = no; then
	u_char_decl="typedef unsigned char u_char;"
fi

AC_SUBST(u_short_decl)
AC_MSG_CHECKING(for u_short)
AC_CACHE_VAL(vi_cv_ushort, [dnl
AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;,
	[vi_cv_ushort=yes], [vi_cv_ushort=no])])
AC_MSG_RESULT($vi_cv_ushort)
if test "$vi_cv_ushort" = no; then
	u_short_decl="typedef unsigned short u_short;"
fi

AC_SUBST(u_int_decl)
AC_MSG_CHECKING(for u_int)
AC_CACHE_VAL(vi_cv_uint, [dnl
AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;,
	[vi_cv_uint=yes], [vi_cv_uint=no])])
AC_MSG_RESULT($vi_cv_uint)
if test "$vi_cv_uint" = no; then
	u_int_decl="typedef unsigned int u_int;"
fi

AC_SUBST(u_long_decl)
AC_MSG_CHECKING(for u_long)
AC_CACHE_VAL(vi_cv_ulong, [dnl
AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;,
	[vi_cv_ulong=yes], [vi_cv_ulong=no])])
AC_MSG_RESULT($vi_cv_ulong)
if test "$vi_cv_ulong" = no; then
	u_long_decl="typedef unsigned long u_long;"
fi

dnl DB/Vi use specific integer sizes.
AC_SUBST(u_int8_decl)
AC_MSG_CHECKING(for u_int8_t)
AC_CACHE_VAL(vi_cv_uint8, [dnl
AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;,
	[vi_cv_uint8=yes],
AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}],
	[vi_cv_uint8="unsigned char"], [vi_cv_uint8=no]))])
AC_MSG_RESULT($vi_cv_uint8)
if test "$vi_cv_uint8" = no; then
	echo
	echo "Fatal error: no unsigned, 8-bit integral type."
	exit 1
fi
if test "$vi_cv_uint8" != yes; then
	u_int8_decl="typedef $vi_cv_uint8 u_int8_t;"
fi

AC_SUBST(u_int16_decl)
AC_MSG_CHECKING(for u_int16_t)
AC_CACHE_VAL(vi_cv_uint16, [dnl
AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;,
	[vi_cv_uint16=yes],
AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}],
	[vi_cv_uint16="unsigned short"],
AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}],
	[vi_cv_uint16="unsigned int"], [vi_cv_uint16=no])))])
AC_MSG_RESULT($vi_cv_uint16)
if test "$vi_cv_uint16" = no; then
	echo
	echo "Fatal error: no unsigned, 16-bit integral type."
	exit 1
fi
if test "$vi_cv_uint16" != yes; then
	u_int16_decl="typedef $vi_cv_uint16 u_int16_t;"
fi

AC_SUBST(int16_decl)
AC_MSG_CHECKING(for int16_t)
AC_CACHE_VAL(vi_cv_int16, [dnl
AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;,
	[vi_cv_int16=yes],
AC_TRY_RUN([main(){exit(sizeof(short) != 2);}],
	[vi_cv_int16="short"],
AC_TRY_RUN([main(){exit(sizeof(int) != 2);}],
	[vi_cv_int16="int"], [vi_cv_int16=no])))])
AC_MSG_RESULT($vi_cv_int16)
if test "$vi_cv_int16" = no; then
	echo
	echo "Fatal error: no signed, 16-bit integral type."
	exit 1
fi
if test "$vi_cv_int16" != yes; then
	int16_decl="typedef $vi_cv_int16 int16_t;"
fi

AC_SUBST(u_int32_decl)
AC_MSG_CHECKING(for u_int32_t)
AC_CACHE_VAL(vi_cv_uint32, [dnl
AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;,
	[vi_cv_uint32=yes],
AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}],
	[vi_cv_uint32="unsigned int"],
AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}],
	[vi_cv_uint32="unsigned long"], [vi_cv_uint32=no])))])
AC_MSG_RESULT($vi_cv_uint32)
if test "$vi_cv_uint32" = no; then
	echo
	echo "Fatal error: no unsigned, 32-bit integral type."
	exit 1
fi
if test "$vi_cv_uint32" != yes; then
	u_int32_decl="typedef $vi_cv_uint32 u_int32_t;"
fi

AC_SUBST(int32_decl)
AC_MSG_CHECKING(for int32_t)
AC_CACHE_VAL(vi_cv_int32, [dnl
AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;,
	[vi_cv_int32=yes],
AC_TRY_RUN([main(){exit(sizeof(int) != 4);}],
	[vi_cv_int32="int"],
AC_TRY_RUN([main(){exit(sizeof(long) != 4);}],
	[vi_cv_int32="long"], [vi_cv_int32=no])))])
AC_MSG_RESULT($vi_cv_int32)
if test "$vi_cv_int32" = no; then
	echo
	echo "Fatal error: no signed, 32-bit integral type."
	exit 1
fi
if test "$vi_cv_int32" != yes; then
	int32_decl="typedef $vi_cv_int32 int32_t;"
fi

AC_OUTPUT(Makefile port.h:port.h.in
    pathnames.h:pathnames.h.in recover:recover.in)