File: configure.in

package info (click to toggle)
tin 1%3A2.1.1-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 12,028 kB
  • sloc: ansic: 77,612; sh: 3,829; makefile: 1,459; yacc: 1,020; perl: 829
file content (1470 lines) | stat: -rw-r--r-- 35,884 bytes parent folder | download
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
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
dnl Project   : tin - a Usenet reader
dnl Module    : configure.in
dnl Author    : Thomas E. Dickey <dickey@invisible-island.net>
dnl Created   : 1995-08-24
dnl Updated   : 2012-03-05
dnl Notes     :
dnl
dnl Copyright (c) 1995-2012 Thomas E. Dickey <dickey@invisible-island.net>
dnl All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions
dnl are met:
dnl 1. Redistributions of source code must retain the above copyright
dnl    notice, this list of conditions and the following disclaimer.
dnl 2. Redistributions in binary form must reproduce the above copyright
dnl    notice, this list of conditions and the following disclaimer in the
dnl    documentation and/or other materials provided with the distribution.
dnl 3. The name of the author may not be used to endorse or promote
dnl    products derived from this software without specific prior written
dnl    permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
dnl OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
dnl WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
dnl ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
dnl WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.13.20110430)
AC_INIT(include/tin.h)
AC_CONFIG_HEADER(include/autoconf.h:include/autoconf.hin)
AC_PREFIX_DEFAULT(/usr/local)

dnl PACKAGE is required for GNU gettext
PACKAGE=tin
VERSION=2.1.1
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)

EXTRAO_DEP='#'

CF_CHECK_CACHE

CF_PATHSEP
CF_WITH_PATH(install-prefix,
	[  --with-install-prefix   prefixes actual install location],
	DESTDIR,/)
case ".$DESTDIR" in # (vi
./)	DESTDIR=
	;; # (vi
./*/)	;; # (vi
./*)	DESTDIR="$DESTDIR/"
	;;
esac

AC_ARG_PROGRAM

###	Compiler/options that autoconf doesn't get right
case "$host_os" in
	aix*)	#(vi
		if test "$CC" = ""; then
			AC_PATH_PROG(XLC, xlc)
			if test "$ac_cv_path_XLC" != ""; then
				CC="$ac_cv_path_XLC"
			fi
		fi
		;;
	hpux*)	#(vi
		test "$CC" != "cc" && test -z "$CFLAGS" && CFLAGS="-O"
		;;
esac

### Native Language Support
ALL_LINGUAS="da de en_GB et fr ru sv tr zh_TW"

### Checks for programs
save_CFLAGS="$CFLAGS"
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
AC_PROG_MAKE_SET
AC_PROG_INSTALL
CF_PROG_YACC
AC_CHECK_PROGS(LINT, lint alint lclint tdlint splint, :)
AC_AIX
CF_XOPEN_SOURCE
CF_SIGWINCH
AC_ISC_POSIX
CF_ANSI_CC_REQD
CF_PROG_EXT
CF_LIB_PREFIX(LIB_PREFIX)
AC_PROG_LN_S

CF_BUILD_CC([-I$(INCDIR)],[])

dnl These are standard among *NIX systems, but not when cross-compiling
AC_CHECK_TOOL(RANLIB, ranlib, ':')
AC_CHECK_TOOL(LD, ld, ld)
CF_PROG_AR
CF_AR_FLAGS

case "$host_cpu:$host_vendor:$host_os" in
	# check for MacOS X, exclude Darwin on ix86
#	powerpc:apple:darwin*)  #(vi
#		AC_DEFINE(MAC_OS_X)
#		;;
	# check for cygwin environment
	# -DSTATIC is needed for pcre
	*:*:*cygwin*)	#(vi
		PCRE_DEFINES="$PCRE_DEFINES -DSTATIC"
		;;
	# SEIUX doesn't have any useful preprocessor symbol
	mips:sei:seiux*)	#(vi
		AC_DEFINE(SEIUX)
		;;
esac

AC_MSG_CHECKING(if you would like to use heapsort)
CF_ARG_ENABLE(heapsort,
	[  --enable-heapsort       enable heapsort() as alternative to qsort],
	[cf_use_heapsort=yes],
	[cf_use_heapsort=no])
AC_MSG_RESULT($cf_use_heapsort)
if test "x$cf_use_heapsort" = xyes; then
	AC_CHECK_FUNCS(heapsort)
	if test x"$ac_cv_func_heapsort" = xyes; then
		AC_MSG_CHECKING(if its prototype is compatible with qsort)
		AC_TRY_COMPILE([
#include <stdlib.h>
#include <sys/types.h>
extern int my_compare(const void *, const void *);
],[
	char *base = 0;
	heapsort((void *)0, 1, 2, my_compare);
],,[cf_use_heapsort=no]);
		AC_MSG_RESULT($cf_use_heapsort)
	else
		CF_VERBOSE(will use our own heapsort function)
		EXTRAO_DEP=''
		EXTRAOBJS="$EXTRAOBJS \$(OBJDIR)/heapsort.o"
	fi
fi
if test "x$cf_use_heapsort" = xyes; then
	AC_DEFINE(USE_HEAPSORT)
fi

CF_WITH_PROGRAM(ispell,
[  --with-ispell           (default: from system path)])

CF_WITH_PROGRAM(metamail,
[  --with-metamail         (default: from system path)])

CF_WITH_PROGRAM(sum,
[  --with-sum              (default: from system path)])
CF_PROG_SUM_R

CF_PATH_EDITOR
CF_PATH_MAILER
CF_PATH_MAILBOX

## PGP Support
AC_MSG_CHECKING(if you want PGP/GPG-Support)
CF_ARG_DISABLE(pgp-gpg,
	[  --disable-pgp-gpg       disable PGP/GPG Support],
	[USE_PGP_GPG=no],
	[USE_PGP_GPG=yes])
AC_MSG_RESULT($enableval)
if test "$USE_PGP_GPG" = "yes" ; then
	CF_WITH_PROGRAM(pgp,
	[  --with-pgp              (default: from system path)])
	# FIXME: check if pgp is pgp2 or pgp6

	CF_WITH_PROGRAM(pgpk,
	[  --with-pgpk             (default: from system path)])
	# FIXME: remove tailing k

	CF_WITH_PROGRAM(gpg,
	[  --with-gpg              (default: from system path)])
fi

## slrnface
CF_WITH_PROGRAM(slrnface,
[  --with-slrnface         (default: from system path)])
if test -n "$ac_cv_path_PATH_SLRNFACE"; then
	EXTRAO_DEP=""
	EXTRAOBJS="$EXTRAOBJS \$(OBJDIR)/xface.o"
fi

## Default shell
AC_ARG_WITH(shell,
	[  --with-shell=PROG       default $SHELL program (default: sh)],
	[cf_cv_default_shell=$withval],
	[cf_cv_default_shell=])
CF_DEFAULT_SHELL($cf_cv_default_shell)

### check for this early, since it'll override several options
AC_MSG_CHECKING(if NNTP-support will be used)
CF_ARG_DISABLE(nntp,
	[  --disable-nntp          disable reading via NNTP],
	[USE_NNTP=no],
	[USE_NNTP=yes])
AC_MSG_RESULT($enableval)

USE_SPOOLDIR=yes
if test "$USE_NNTP" = "yes" ; then
AC_MSG_CHECKING(whether to be NNTP_ONLY)
CF_ARG_ENABLE(nntp-only,
	[  --enable-nntp-only      enable reading via NNTP only],
	[AC_DEFINE(NNTP_ONLY)
	 USE_SPOOLDIR=no],
	[AC_DEFINE(NNTP_ABLE)])
AC_MSG_RESULT($enableval)
fi

###	use option --enable-debug to compile-in test/development code
AC_MSG_CHECKING(if you want to compile-in debug support)
CF_ARG_ENABLE(debug,
	[  --enable-debug          turn on debug support],
	[ENABLE_DEBUG=''
	CFLAGS="-g $CFLAGS"
	LDFLAGS="-g $LDFLAGS"],
	[ENABLE_DEBUG='#'
	test -z "$save_CFLAGS" && CFLAGS=`echo $CFLAGS|sed -e 's/-g //' -e 's/-g$//'`])
AC_MSG_RESULT($enableval)
AC_SUBST(ENABLE_DEBUG)

###	use option --disable-echo to suppress full display compiling commands
CF_DISABLE_ECHO

### use option --enable-prototypes to turn on optional prototypes
AC_MSG_CHECKING(if you want to compile with fallback prototypes)
CF_ARG_ENABLE(prototypes,
	[  --enable-prototypes     check for optional prototypes],
	[with_decl_check=yes],
	[with_decl_check=no])
AC_MSG_RESULT($enableval)

###	use option --enable-warnings to turn on all gcc warnings
EXTRA_CFLAGS=""
if test -n "$GCC"
then
AC_MSG_CHECKING(if you want to turn on gcc warnings)
CF_ARG_ENABLE(warnings,
	[  --enable-warnings       turn on GCC compiler warnings],
	[with_warnings=yes],
	[with_warnings=no])
AC_MSG_RESULT($with_warnings)
if test "$with_warnings" = "yes"
then
	with_ext_const=yes
	CF_GCC_WARNINGS
fi
fi

## !NNTP_ONLY
if test "$USE_SPOOLDIR" = "yes"; then
	## options for directories
	AC_MSG_CHECKING(for news-library path)
	CF_WITH_PATH(libdir,
		[  --with-libdir=PATH      news-library],
		NEWSLIBDIR,/usr/lib/news)
	AC_MSG_RESULT($NEWSLIBDIR)

	AC_MSG_CHECKING(for news spool-directory path)
	CF_WITH_PATH(spooldir,
		[  --with-spooldir=PATH    news spool-directory],
		SPOOLDIR,/var/spool/news)
	AC_MSG_RESULT($SPOOLDIR)

	AC_MSG_CHECKING(for news overview-directory path)
	CF_WITH_PATH(nov-dir,
		[  --with-nov-dir=PATH     news overview-directory],
		NOVROOTDIR,$SPOOLDIR)
	AC_MSG_RESULT($NOVROOTDIR)

	AC_MSG_CHECKING(for overview filename)
	CF_WITH_VALUE(nov-fname,
		[  --with-nov-fname        specify names of overview files],
		OVERVIEW_FILE,.overview)
	AC_MSG_RESULT($OVERVIEW_FILE)

	INEWSPATH="$NEWSLIBDIR"
else
	NEWSLIBDIR=""
	SPOOLDIR=""
	NOVROOTDIR=""
	INEWSPATH="/usr/lib/news"
fi

## TODO: kick the --with-inews-dir= stuff, the check below should be enough
## (requires some code rework in tin)
AC_MSG_CHECKING(for directory containing \"inews\")
CF_WITH_PATH(inews-dir,
	[  --with-inews-dir=PATH   directory containing "inews"],
	INEWSDIR,$INEWSPATH)
INEWSDIR=`echo $INEWSDIR |sed -e 's,/$,,'`
AC_MSG_RESULT($INEWSDIR)

AC_PATH_PROG(INEWS,
	inews, --internal,
	$INEWSDIR:/news/bin:/usr/lib/news/bin:$INEWSPATH)
if test "$ac_cv_path_INEWS" != ""; then
	if test "$ac_cv_path_INEWS" = "--internal"; then
		CF_DEFINE_STRING(PATH_INEWS, "$INEWS")
	else
		CF_DEFINE_STRING(PATH_INEWS, "$INEWS -h")
	fi
fi

### Look for network libraries first, since some functions (such as gethostname)
### are used in a lot of places.
AC_CACHE_CHECK(if you want socks library,cf_cv_use_libsocks,[
AC_ARG_WITH(socks,
	[  --with-socks[=path]     link with socks library if available],
	[cf_cv_use_libsocks=$withval],
	[cf_cv_use_libsocks=no])
])

AC_CACHE_CHECK(if you want socks5 library,cf_cv_use_libsocks5,[
AC_ARG_WITH(socks5,
	[  --with-socks5[=path]    link with socks5 library if available],
	[cf_cv_use_libsocks5=$withval],
	[cf_cv_use_libsocks5=no])
])

if test "x$cf_cv_use_libsocks" != xno ; then
	CF_SOCKS($cf_cv_use_libsocks)
else
	CF_NETLIBS
	if test "x$cf_cv_use_libsocks5" != xno ; then
	CF_SOCKS5($cf_cv_use_libsocks5)
	fi
fi

### which locking method should be used for mailbox locking
### first look for all available locking methods
CF_LOCKFILE

AC_MSG_CHECKING(which locking method will be used)
### fcntl() is preferred, if the user just disables fcntl()
### without specifying an alternative lockf() is preferred
CF_ARG_DISABLE(fcntl,
	[  --disable-fcntl         disable fcntl() locking],
		requested_lock="lockf",
		requested_lock="fcntl")
CF_ARG_ENABLE(lockf,
	[  --enable-lockf          enable lockf() locking],
		requested_lock="lockf")
CF_ARG_ENABLE(flock,
	[  --enable-flock          enable flock() locking],
		requested_lock="flock")
### now check the users wishes against available locking methods
if test -n "$cf_cv_lockfile"; then
	for lock in $cf_cv_lockfile; do
		if test "$lock" = "$requested_lock"; then
			used_locking=$lock
			break
		fi
	done
### if none of them matched use the one with the highest priority
	if test "x$used_locking" = "x"; then
		used_locking=`echo $cf_cv_lockfile|sed -e 's/^\([[^ ]]\+\).*/\1/g'`
	fi
	AC_MSG_RESULT($used_locking)
	CF_UPPER(used_locking,$used_locking)
	AC_DEFINE_UNQUOTED(USE_$used_locking)
else
	AC_MSG_RESULT(none);
	AC_MSG_WARN([[None of fcntl(), lockf(), flock() available]])
fi

AC_MSG_CHECKING(for screen type)
AC_ARG_WITH(screen,
[  --with-screen=xxx       specify screen type, which must be one of:
                          termcap, terminfo, curses, ncurses, ncursesw, or
                          pdcurses (replaces options --enable-curses and
                          --with-ncurses)],
	[cf_with_screen=$withval],
	[cf_with_screen=none])
AC_MSG_RESULT($cf_with_screen)

use_curses=no
use_ncurses=no

CF_WITH_CURSES_DIR($cf_with_screen)

case $cf_with_screen in #(vi
termcap|terminfo) #(we will determine which it really is
	;;
curses) #(vi
	use_curses=yes
	;;
ncurses) #(vi
	use_curses=yes
	use_ncurses=yes
	;;
ncursesw) #(vi
	use_curses=yes
	use_ncurses=yes
	;;
pdcurses) #(vi
	use_curses=yes
	;;
none)
	AC_MSG_CHECKING(if you want to use ncurses library)
	AC_ARG_WITH(ncurses,
		[  --with-ncurses          link with ncurses if available (deprecated)],
		[use_ncurses=$withval],
		[use_ncurses=no])
	AC_MSG_RESULT($use_ncurses)

	AC_MSG_CHECKING(if you want curses rather than termcap interface)
	CF_ARG_ENABLE(curses,
		[  --enable-curses         use curses interface (deprecated)],
		[cf_with_screen=curses;  use_curses=$withval],
		[cf_with_screen=termcap; use_curses=no])
	AC_MSG_RESULT($enableval)
	;;
esac

if test $use_curses != no ; then
	AC_DEFINE(USE_CURSES)
	case $cf_with_screen in #(vi
	ncurses) #(vi
		CF_NCURSES_CONFIG
		;;
	ncursesw) #(vi
		CF_CHECK_HEADERS(stdlib.h wchar.h wctype.h)
		AM_MULTIBYTE_ABLE
		CF_NCURSES_CONFIG(ncursesw)
		CF_XOPEN_CURSES
		test "$cf_cv_need_xopen_extension" = unknown && AC_ERROR(X/Open curses not found)
		;;
	curses) #(vi
		CF_CURSES_CONFIG
		CF_XOPEN_CURSES
		;;
	esac
fi

## substitute externally-installed PCRE library for our bundled version
AC_MSG_CHECKING(if you want to use installed version of pcre)
AC_ARG_WITH(pcre,
	[  --with-pcre=PATH        use installed pcre versus bundled],
	[PCRE_HOME=$withval],
	[PCRE_HOME=no])
AC_MSG_RESULT($PCRE_HOME)
CF_BUNDLED_PCRE($PCRE_HOME)

PCRE_MAKEFILE=
if test "$PCRE_HOME" = "no" ; then
	LINK_SIZE="-DLINK_SIZE=2"
	AC_SUBST(LINK_SIZE)
	PCRE_MAKEFILE="$PCRE_MAKEFILE pcre/Makefile pcre/RunTest"
fi

## debugging libraries (do this after other libraries)
debug_malloc=none
CF_WITH_DBMALLOC(debug_malloc=DBMALLOC)
CF_WITH_DMALLOC(debug_malloc=DMALLOC)

AC_ARG_WITH(trace,
	[  --with-trace            use debugging/traces for screen output],
	[
	AC_CHECK_FUNC(_tracef,[AC_DEFINE(HAVE__TRACEF)],[
	AC_CHECK_LIB(${cf_with_screen}_g,_tracef,
		[AC_DEFINE(HAVE__TRACEF)
		 LIBS=`echo "$LIBS" | sed -e s/-l${cf_with_screen}// -e s/-lcurses//`
		 LIBS="-l${cf_with_screen}_g $LIBS"
		 use_trace=yes
		 AC_DEFINE(USE_TRACE)
		 EXTRAO_DEP=''
		 EXTRAOBJS="$EXTRAOBJS \$(OBJDIR)/trace.o"],
		 use_trace=no)])],
	[use_trace=no])
#AC_MSG_CHECKING(if you want debugging-trace)
#AC_MSG_RESULT($use_trace)
AC_SUBST(EXTRAOBJS)
AC_SUBST(EXTRAO_DEP)

## options for miscellaneous definitions
AC_MSG_CHECKING(for domain-name)
CF_ARG_WITH(domain-name,
	[  --with-domain-name      sets $DOMAIN_NAME],
	DOMAIN_NAME)
if test "$DOMAIN_NAME" != ""; then
	AC_DEFINE_UNQUOTED(DOMAIN_NAME, "$DOMAIN_NAME")
fi
AC_MSG_RESULT($DOMAIN_NAME)

if test "$USE_NNTP" = "yes" ; then
AC_MSG_CHECKING(for NNTP default-server)
CF_ARG_WITH(nntp-default-server,
	[  --with-nntp-default-server
                          (sets NNTP_DEFAULT_SERVER)
                         ],
	[NNTP_DEFAULT_SERVER], news.$DOMAIN_NAME)

    if test "$NNTP_DEFAULT_SERVER" = "" ; then
	if test "$DOMAIN_NAME" != "" ; then
		test -z "$NNTP_DEFAULT_SERVER" && case "$DOMAIN_NAME" in #(((
	 	/*)
			if test -r "$DOMAIN_NAME" ; then
				NNTP_DEFAULT_SERVER="news.`cat $DOMAIN_NAME`"
			else
				NNTP_DEFAULT_SERVER="news"
			fi
			;;
	 	*)
			NNTP_DEFAULT_SERVER="news.$DOMAIN_NAME"
			;;
	 	esac
	else
		NNTP_DEFAULT_SERVER="news"
	fi
    fi
AC_MSG_RESULT($NNTP_DEFAULT_SERVER)
fi

## These options are interdependent, so we delay defining them til now:
test -n "$NNTP_DEFAULT_SERVER" \
	&& AC_DEFINE_UNQUOTED(NNTP_DEFAULT_SERVER,"$NNTP_DEFAULT_SERVER")
test ".$INEWSDIR" != ".$NEWSLIBDIR" && AC_DEFINE_UNQUOTED(INEWSDIR,"$INEWSDIR")
AC_DEFINE_UNQUOTED(NEWSLIBDIR,"$NEWSLIBDIR")
AC_DEFINE_UNQUOTED(NOVROOTDIR,"$NOVROOTDIR")
AC_DEFINE_UNQUOTED(SPOOLDIR,"$SPOOLDIR")

## optional features
AC_MSG_CHECKING(whether to use MH style mail handling for mailgroups)
CF_ARG_ENABLE(mh-mail-handling,
	[  --enable-mh-mail-handling
                          use MH style mail handling for mailgroups],
	[AC_DEFINE(HAVE_MH_MAIL_HANDLING)])
AC_MSG_RESULT($enableval)

CAN_MAKEFILE=
CANDIR_MAKE=
AC_MSG_CHECKING(whether to use Cancel-Locks)
CF_ARG_ENABLE(cancel-locks,
	[  --enable-cancel-locks   enable creation of Cancel-Locks],
	[CANLIBS='-L../libcanlock -lcanlock'
	CAN_MAKEFILE="libcanlock/Makefile"
	AC_DEFINE(USE_CANLOCK)],
	[CANDIR_MAKE='#'
	CANLIBS=''])
AC_MSG_RESULT($enableval)
AC_SUBST(CANDIR_MAKE)
AC_SUBST(CANLIBS)

## gsasl - used for AUTH SASL PLAIN
AC_CHECK_HEADER(gsasl.h,
	AC_CHECK_LIB(gsasl, gsasl_check_version, gsasl=yes, gsasl=no),
	gsasl=no)
if test "$gsasl" = "yes"; then
	CF_ARG_DISABLE(gsasl,
		[  --disable-gsasl         don't use GNU SASL],
		USE_SASL=no,
		[USE_SASL=yes
		AC_DEFINE(USE_SASL, 1, [Define to 1 if you want GNU SASL.])
		LIBS="$LIBS -lgsasl"])
fi

AC_MSG_CHECKING(whether to enable 8-bit keycodes)
CF_ARG_DISABLE(8bit-keys,
	[  --disable-8bit-keys     disable 8-bit keycode support],,
	[AC_DEFINE(HAVE_KEY_PREFIX)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to enable ANSI-color)
CF_ARG_DISABLE(color,
	[  --disable-color         disable ANSI-color support])
use_color=$enableval
AC_MSG_RESULT($use_color)

AC_MSG_CHECKING(whether to enable posting-etiquette)
CF_ARG_DISABLE(etiquette,
	[  --disable-etiquette     disable printing of posting-etiquette],
	[AC_DEFINE(NO_ETIQUETTE)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to strictly observe RFC2047 and break long lines)
CF_ARG_ENABLE(break-long-lines,
	[  --enable-break-long-lines
                          break long mime-encoded lines],
	[AC_DEFINE(MIME_BREAK_LONG_LINES)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to force MM_CHARSET obeyance when decoding mime)
CF_ARG_DISABLE(mime-strict-charset,
	[  --disable-mime-strict-charset
                          force MM_CHARSET obeyance],,
	[AC_DEFINE(MIME_STRICT_CHARSET)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(for MIME character-set)
CF_WITH_DFTENV(mime-default-charset,
	[  --with-mime-default-charset=CHARSET
                          fallback for $MM_CHARSET],
	MM_CHARSET,US-ASCII)
AC_MSG_RESULT($MM_CHARSET)

AC_MSG_CHECKING(for default ISO/ASCII table)
CF_WITH_DFTENV(iso-to-ascii,
	[  --with-iso-to-ascii     ISO -> ASCII conversion],
	DEFAULT_ISO2ASC,-1)
AC_MSG_RESULT($DEFAULT_ISO2ASC)

AC_MSG_CHECKING(whether to enable locale support)
CF_ARG_DISABLE(locale,
	[  --disable-locale        disable locale support],
	[AC_DEFINE(NO_LOCALE)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to enable posting)
CF_ARG_DISABLE(posting,
	[  --disable-posting       disable posting],
	[AC_DEFINE(NO_POSTING)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to enable shell escape)
CF_ARG_DISABLE(shell-escape,
	[  --disable-shell-escape  disable shell escape],
	[AC_DEFINE(NO_SHELL_ESCAPE)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to have fascist newsadmin)
CF_ARG_ENABLE(fascist-newsadmin,
	[  --enable-fascist-newsadmin
                          have fascist newsadmin],
	[AC_DEFINE(HAVE_FASCIST_NEWSADMIN)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to enable inverse video and highlighting)
CF_ARG_DISABLE(inverse-video,
	[  --disable-inverse-video disable inverse video and highlighting],
	[AC_DEFINE(USE_INVERSE_HACK)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to enable piping support)
CF_ARG_DISABLE(piping,
	[  --disable-piping        disable piping support],
	[AC_DEFINE(DONT_HAVE_PIPING)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to enable printer support)
CF_ARG_DISABLE(printing,
	[  --disable-printing      disable printer support],
	[AC_DEFINE(DISABLE_PRINTING)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to unique tmp-files by appending .pid)
CF_ARG_DISABLE(append-pid,
	[  --disable-append-pid    disable appending .pid to tmp-files],,
	[AC_DEFINE(APPEND_PID)])
AC_MSG_RESULT($enableval)

AC_MSG_CHECKING(whether to fallback to XHDR XREF if XOVER isn't supported)
CF_ARG_DISABLE(xhdr-xref,
	[  --disable-xhdr-xref     disable XHDR XREF fallback],,
	[AC_DEFINE(XHDR_XREF)])
AC_MSG_RESULT($enableval)

### bypass a bug in old versions of leafnode & NNTPcache
AC_MSG_CHECKING(whether to send a GROUP command before a LISTGROUP)
CF_ARG_ENABLE(broken-listgroup-fix,
	[  --enable-broken-listgroup-fix
                          send extra GROUP command before LISTGROUP],
	[AC_DEFINE(BROKEN_LISTGROUP)])
AC_MSG_RESULT($enableval)

### on some old systems the WIFEXITED()/WEXITSTATUS() macros do not work
AC_MSG_CHECKING(whether to ignore system()s return value)
CF_ARG_ENABLE(broken-system-fix,
	[  --enable-broken-system-fix
                          ignore system()s return value],
	[AC_DEFINE(IGNORE_SYSTEM_STATUS)])
AC_MSG_RESULT($enableval)

### checks for the location of the system-wide default setting file
AC_MSG_CHECKING(for directory containing tin.defaults file)
CF_WITH_PATH(defaults-dir,
	[  --with-defaults-dir=PATH
                          directory containing tin.defaults file
                         ],
	TIN_DEFAULTS_DIR,/etc/tin)
AC_MSG_RESULT($TIN_DEFAULTS_DIR)
AC_DEFINE_UNQUOTED(TIN_DEFAULTS_DIR,"$TIN_DEFAULTS_DIR")

### check for ipv6 support
AC_MSG_CHECKING([whether to enable IPv6])
CF_ARG_ENABLE(ipv6,
	[  --enable-ipv6           enable IPv6 (with IPv4) support (default: disabled)],
[AC_DEFINE(ENABLE_IPV6)])
AC_MSG_RESULT($enableval)
if test "$enableval" = "yes"; then
	CF_CHECK_IPV6
fi
AC_REPLACE_FUNCS(getaddrinfo getnameinfo)

### should we use 64 bit article numbers if possible?
AC_MSG_CHECKING([whether to enable long article numbers])
CF_ARG_ENABLE(long-article-numbers,
        [  --enable-long-article-numbers
                          enable long article numbers (default: disabled)],
[AC_DEFINE(ENABLE_LONG_ARTICLE_NUMBERS)])
AC_MSG_RESULT($enableval)

### checks for operator characteristics (should be the last option)
AC_MSG_CHECKING(whether to make a coffee while compiling)
AC_ARG_WITH(coffee,
	[  --with-coffee           coffee support],
	[ case "$withval" in
	yes)
	AC_MSG_RESULT(yes - with milk - please!)
	AC_DEFINE(HAVE_COFFEE)
	;;
	*)
	AC_MSG_RESULT(no)
	;;
	esac],
	AC_MSG_RESULT(no))

### checks for compiler characteristics
CF_MAKEFLAGS
AC_LANG_C
AC_C_CONST
AC_C_INLINE
CF_CPP_EXPANDS
CF_CPP_CONCATS
CF_CHECK_NESTED_PARAMS


###	Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
CF_CHECK_HEADERS(\
	argz.h \
	arpa/inet.h \
	curses.h \
	errno.h \
	fcntl.h \
	getopt.h \
	ioctl.h \
	inttypes.h \
	langinfo.h \
	libc.h \
	locale.h \
	malloc.h \
	net/socket.h \
	netdb.h \
	netinet/in.h \
	netlib.h \
	nl_types.h \
	nomacros.h \
	paths.h	\
	poll.h \
	prototypes.h \
	pwd.h \
	sgtty.h \
	socket.h \
	stdarg.h \
	stdbool.h \
	stddef.h \
	stdint.h \
	stdlib.h \
	string.h \
	strings.h \
	stropts.h \
	sys/bsdtypes.h \
	sys/errno.h \
	sys/file.h \
	sys/ioctl.h \
	sys/param.h \
	sys/poll.h \
	sys/ptem.h \
	sys/pty.h \
	sys/select.h \
	sys/stat.h \
	sys/stream.h \
	sys/socket.h \
	sys/time.h \
	sys/timeb.h \
	sys/times.h \
	sys/types.h \
	sys/utsname.h \
	term.h \
	termio.h \
	time.h \
	unistd.h \
	varargs.h \
	wchar.h \
	wctype.h \
)

###	Checks that depend on existence-checks for headers
CF_SIZECHANGE
CF_SYS_SELECT_TIMEVAL

###	Checks for Datatypes.
AC_CHECK_TYPE(gid_t, int)
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int)
AC_CHECK_TYPE(time_t, long)
AC_EGREP_HEADER(in_addr_t, netinet/in.h, ,[
	AC_EGREP_HEADER(in_addr_t, sys/endian.h, ,[
		AC_CHECK_TYPE(in_addr_t, unsigned long)]
	)]
)
AC_TYPE_UID_T

dnl test to see if quad_t is defined
AC_MSG_CHECKING(for quad_t)
AC_TRY_COMPILE([
#include <sys/types.h>
#if 0
#include <stdlib.h>
#include <stddef.h>
#endif /* 0 */
],[quad_t x; x = 0],
ac_cv_quad_t=yes, ac_cv_quad_t=no)
AC_MSG_RESULT($ac_cv_quad_t)
if test $ac_cv_quad_t = yes; then
	AC_DEFINE(HAVE_QUAD_T)
fi

dnl test to see if long long is defined
AC_MSG_CHECKING(for long long)
AC_TRY_COMPILE([
#include <sys/types.h>
],[long long x; x = 0],
ac_cv_long_long=yes, ac_cv_long_long=no)
AC_MSG_RESULT($ac_cv_long_long)
if test $ac_cv_long_long = yes; then
	AC_DEFINE(HAVE_LONG_LONG)
fi

dnl test to see if int_least64_t is defined
AC_MSG_CHECKING(for int_least64_t)
AC_TRY_COMPILE([
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_HAVE_INTTYPES_H
#include <inttypes.h>
#endif
],[int_least64_t x; x = 0],
ac_cv_int_least64_t=yes, ac_cv_int_least64_t=no)
AC_MSG_RESULT($ac_cv_int_least64_t)
if test $ac_cv_int_least64_t = yes; then
	AC_DEFINE(HAVE_INT_LEAST64_T)

	AC_MSG_CHECKING(for INT64_C)
	AC_TRY_COMPILE([
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_HAVE_INTTYPES_H
#include <inttypes.h>
#endif
],[int_least64_t x; x = INT64_C(0)],
	ac_cv_int64_c=yes, ac_cv_int64_c=no)
	AC_MSG_RESULT($ac_cv_int64_c)
	if test $ac_cv_int64_c = yes; then
		AC_DEFINE(HAVE_INT64_C)
	fi
fi


dnl test to see if nl_item is defined
AC_MSG_CHECKING(for nl_item)
AC_TRY_COMPILE([
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#else
#ifdef HAVE_NL_TYPES_H
#include <nl_types.h>
#endif
#endif
],[nl_item x; x = 0],
ac_cv_nl_item=yes, ac_cv_nl_item=no)
AC_MSG_RESULT($ac_cv_nl_item)
if test $ac_cv_nl_item = yes; then
        AC_DEFINE(HAVE_NL_ITEM)
fi

###	Checks for libraries.
# libuu/uudeview
# only define HAVE_LIBUU and HAVE_UUDEVIEW_H if both are found
AC_CHECK_LIB(uu, UUInitialize,
	[AC_CHECK_HEADER(uudeview.h,
		[AC_DEFINE(HAVE_LIBUU)
		AC_DEFINE(HAVE_UUDEVIEW_H)
		LIBS="$LIBS -luu"]
	)]
)


# ICU - International Components for Unicode
# TODO: do seperate checks for
#  - unorm_normalize()
#  - uidna_IDNToUnicode()
#  - ubidi_open()
cf_try_icuuc="no"
AC_CHECK_HEADER(unicode/unorm.h,[
	AC_CHECK_HEADER(unicode/ustring.h, [
		AC_DEFINE(HAVE_UNICODE_UNORM_H)
		AC_DEFINE(HAVE_UNICODE_USTRING_H)
		AC_MSG_CHECKING(for unorm_normalize in libicuuc)
		cf_save_LIBS="$LIBS"
		cf_try_icuuc="no"
		LIBS="$LIBS -licuuc"
		AC_TRY_LINK([#include <unicode/unorm.h>], [
			int32_t needed, ustr = NULL;
 			UErrorCode status;
			needed = unorm_normalize(ustr, -1, UNORM_DEFAULT, 0, NULL, 0, &status);], [
			AC_DEFINE(HAVE_LIBICUUC)
			cf_try_icuuc="yes"],
			LIBS=$cf_save_LIBS
		)
		AC_MSG_RESULT($cf_try_icuuc)
		AC_CHECK_HEADER(unicode/uidna.h, [
			AC_DEFINE(HAVE_UNICODE_UIDNA_H)
		])
		AC_CHECK_HEADER(unicode/ubidi.h, [
			AC_DEFINE(HAVE_UNICODE_UBIDI_H)
		])
	])
])

# without icuuc try GNU libunistring for normalization
if test $cf_try_icuuc = no ; then
	AC_CHECK_HEADER(unitypes.h,[
		AC_CHECK_HEADER(uninorm.h,[
			AC_DEFINE(HAVE_UNITYPES_H)
			AC_DEFINE(HAVE_UNINORM_H)
			AC_MSG_CHECKING(for u8_normalize in libunistring)
			cf_save_LIBS="$LIBS"
			cf_try_unistring="no"
			LIBS="$LIBS -lunistring"
			AC_TRY_LINK([#include <unitypes.h>
				#include <uninorm.h>], [
				size_t ol = 0;
				u8_normalize(UNINORM_NFC, (uint8_t *) "x", 2, NULL, &ol);], [
				AC_DEFINE(HAVE_LIBUNISTRING)
				cf_try_unistring="yes"],
				LIBS=$cf_save_LIBS
			)
			AC_MSG_RESULT($cf_try_unistring)
		])
	])
fi

# without icuuc try libidn for Internationalized Domain Names / IDN 2003
if test $cf_try_icuuc = no ; then
	AC_CHECK_LIB(idn, stringprep_check_version,
		[AC_CHECK_HEADER(stringprep.h,[
			AC_DEFINE(HAVE_STRINGPREP_H)
			AC_CHECK_HEADER(idna.h, [
				AC_DEFINE(HAVE_IDNA_H)
				AC_CHECK_LIB(idn, idna_to_unicode_lzlz, [
					AC_DEFINE(HAVE_IDNA_TO_UNICODE_LZLZ)
					AC_MSG_CHECKING(for IDNA_USE_STD3_ASCII_RULES)
					AC_EGREP_HEADER(IDNA_USE_STD3_ASCII_RULES, idna.h, [
						AC_DEFINE(HAVE_IDNA_USE_STD3_ASCII_RULES)
						AC_MSG_RESULT(yes)],
						AC_MSG_RESULT(no)
					)
				])
				AC_CHECK_LIB(idn, idna_strerror, [
					AC_DEFINE(HAVE_IDNA_STRERROR)
				])
			])
			AC_DEFINE(HAVE_LIBIDN)
			LIBS="$LIBS -lidn"]
		)]
	)
fi

# libidnkit - Internationalized Domain Names / IDN 2008
AC_CHECK_LIB(idnkit, idn_decodename, [
	AC_CHECK_HEADER(idn/api.h, [
		AC_MSG_CHECKING(for IDN_DECODE_LOOKUP)
		cf_save_LIBS="$LIBS"
		LIBS="$LIBS -lidnkit"
		AC_TRY_LINK([#include <idn/api.h>
			#include <string.h>], [
			idn_result_t rs;
			char in[255], out[255];
			strcpy(in, "xn--brenfe-fta9a2q.de");
			rs = idn_decodename(IDN_DECODE_LOOKUP, &in, &out, 254);
			idn_result_tostring(rs);], [
			AC_DEFINE(HAVE_LIBIDNKIT)
			AC_DEFINE(HAVE_IDN_API_H)
			AC_DEFINE(HAVE_IDN_DECODENAME)
			AC_MSG_RESULT(yes)], [
			LIBS=$cf_save_LIBS
			AC_MSG_RESULT(no)
		])
	])
])


if test $use_curses != no ; then
	cf_cv_termlib=$cf_with_screen
else
	CF_TERMCAP_LIBS
	# terminfo-based termcap interfaces may be prototyped in <curses.h>,
	# which may/may not be compatible with <termcap.h>
	AC_MSG_CHECKING(if we should include termcap.h)
	cf_save_CFLAGS="$CFLAGS"
	CFLAGS="$CFLAGS -I$srcdir/include"
	AC_TRY_COMPILE([
#define HAVE_TERMCAP_H 1
#include <tcurses.h>],[
#ifdef NCURSES_VERSION
make an error
#endif
],
		[cf_result=yes],
		[cf_result=no])
	AC_MSG_RESULT($cf_result)
	CFLAGS="$cf_save_CFLAGS"
	test $cf_result = yes && AC_DEFINE(HAVE_TERMCAP_H)
	CF_TYPE_OUTCHAR
fi

cf_tc_funcs=
cf_tc_externs=
if test ".$cf_cv_termlib" = .terminfo ; then
	AC_DEFINE(USE_TERMINFO)
	cf_tc_funcs="tigetint tigetnum tparam tparm"
	cf_tc_externs="$cf_tc_funcs tgoto tigetstr tputs tigetflag"
elif test ".$cf_cv_termlib" = .termcap ; then
	# BSD 'tputs()' may need 'PC' to be set.
	AC_TRY_LINK([],[extern char PC; PC = 0],
		[AC_DEFINE(HAVE_EXTERN_TCAP_PC)])
	cf_tc_funcs="tgetint tgetnum tparam tparm"
	cf_tc_externs="$cf_tc_funcs tgoto tgetstr tputs tgetent tgetflag"
fi

###	Checks for external-data
CF_ERRNO
CF_STRERROR

###	Checks for library functions.
AC_CHECK_FUNCS(\
	alarm \
	atoi \
	atol \
	atoll \
	atoq \
	bcopy \
	chmod \
	closesocket \
	execlp \
	fcntl \
	fdopen \
	fork \
	ftime \
	ftruncate \
	fsync \
	getcwd \
	gettimeofday \
	getwd \
	inet_aton \
	is_xterm \
	isascii \
	lockf \
	memcmp \
	memcpy \
	memmove \
	memset \
	mkdir \
	mkfifo \
	mktemp \
	mkstemp \
	nl_langinfo \
	poll \
	putenv \
	rewinddir \
	resizeterm \
	select \
	setenv \
	setlocale \
	settz \
	setvbuf \
	sigaction \
	snprintf \
	stpcpy \
	strchr \
	strcasecmp \
	strcasestr \
	strdup \
	strftime \
	strpbrk \
	strrchr \
	strrstr \
	strsep \
	strstr \
	strtol \
	strtoll \
	tmpfile \
	tzset \
	uname \
	unlink \
	use_default_colors \
	usleep \
	vasprintf \
	vsnprintf \
	waitpid \
$cf_tc_funcs )

AC_CHECK_FUNC(flock,
	AC_DEFINE(HAVE_FLOCK),[
	AC_CHECK_LIB(bsd, flock,
		AC_DEFINE(HAVE_FLOCK)
		LIBS="$LIBS -lbsd")])

# clock_gettime() / librt
AC_CHECK_FUNC(clock_gettime,
	AC_DEFINE(HAVE_CLOCK_GETTIME),[
		AC_CHECK_LIB(rt, clock_gettime,
			AC_DEFINE(HAVE_CLOCK_GETTIME)
			LIBS="$LIBS -lrt"
		)
	]
)

AM_MULTIBYTE_ABLE

AC_MSG_CHECKING(if gettimeofday takes two arguments)
AC_TRY_COMPILE([
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif],
[struct timeval *tv;
struct timezone *tz;
gettimeofday(&tv, &tz);],
ac_cv_func_gettimeofday_2args=yes, ac_cv_func_gettimeofday_2args=no)
AC_MSG_RESULT($ac_cv_func_gettimeofday_2args)
if test $ac_cv_func_gettimeofday_2args = yes; then
	AC_DEFINE(GETTIMEOFDAY_2ARGS)
fi

CF_POSIX_JC
CF_FUNC_FORK
CF_FUNC_MEMMOVE

AC_MSG_CHECKING(if select expects int * arguments)
AC_EGREP_HEADER([select\(.*, *int *\*,],time.h,
	AC_DEFINE(HAVE_SELECT_INTP) AC_MSG_RESULT(yes),
	AC_MSG_RESULT(no)
)

AC_FUNC_CLOSEDIR_VOID

# autoconf 2.5x assumes setvbuf is not reversed when cross-compiling
if test "$cross_compiling" != yes ; then
	AC_FUNC_SETVBUF_REVERSED
fi

###	Checks for network library functions.
AC_CHECK_FUNCS(\
	gai_strerror \
	getaddrinfo \
	gethostname \
	gethostbyname \
	getservbyname \
	inet_addr \
	inet_ntoa \
	strncasecmp \
)

CF_TYPE_SIGACTION
CF_TERMIOS
CF_PW_GECOS
CF_TM_GMTOFF

AC_SYS_LONG_FILE_NAMES
CF_FUNC_SYSTEM

# Check if we are trying to use curses+color, but cannot
if test $use_color = yes ; then
	if test $use_curses = no ; then
		AC_DEFINE(HAVE_COLOR)
	elif test $cf_with_screen = pdcurses ; then
		AC_DEFINE(HAVE_COLOR)
	else
	 	CF_NCURSES_BROKEN
		CF_COLOR_CURSES
		if test $cf_cv_color_curses = yes ; then
			AC_DEFINE(HAVE_COLOR)
		else
			AC_MSG_WARN(This curses library does not support color)
		fi
	fi
fi

# GCC and Apollo compilers are quite noisy about signal constants (quiet them).
if test -n "$GCC"; then
	check_sig_const=yes
elif test -f /sys/dm/dm ; then
	check_sig_const=yes
elif test -f /sys/dm/spm ; then
	check_sig_const=yes
else
	check_sig_const=no
fi

if test $check_sig_const = yes ; then
	CF_SIG_CONST
fi

CF_COMPTYPE
CF_COREFILE

### test this last, since it uses a partly-built autoconf.h
# Setup includes for test-program to verify declarations
CHECK_DECL_FLAG="-I$srcdir/include -I$srcdir/pcre"
CHECK_DECL_HDRS='
#define M_UNIX
#define __CPROTO__
#define HAVE_CONFDEFS_H
#include <tin.h>'
TIN_DECL_HDRS="$CHECK_DECL_HDRS"

dnl These return non-int values, and can be troublesome if not declared
CF_CHECK_DECL(\
	errno \
	getenv \
	getlogin \
	getpwnam \
	popen \
	strchr \
	strcasestr \
	strsep \
	tmpfile \
)

dnl Check network stuff separately, to limit the effect of inconsistent headers
CHECK_DECL_HDRS="$TIN_DECL_HDRS
#include <tnntp.h>"
CF_CHECK_DECL(\
	gethostbyname \
	getservbyname \
	inet_aton \
	inet_ntoa \
	socket \
)

if test $use_curses = no ; then
CHECK_DECL_HDRS="$TIN_DECL_HDRS
#include <tcurses.h>"
CF_CHECK_DECL(\
	tgetstr \
	tgoto \
)
fi

if test $with_decl_check = yes; then
CHECK_DECL_HDRS="$TIN_DECL_HDRS"
CF_CHECK_DECL(\
	_flsbuf \
	alarm \
	atoi \
	atol \
	atoll \
	atoq \
	bcopy \
	bzero \
	calloc \
	fchmod \
	fclose \
	fdopen \
	fflush \
	fgetc \
	fileno \
	fprintf \
	fputc \
	fputs \
	fread \
	free \
	fseek \
	fwrite \
	getcwd \
	getopt \
	getwd \
	heapsort \
	ioctl \
	isascii \
	kill \
	malloc \
	memset \
	mkstemp \
	mktemp \
	pclose \
	perror \
	printf \
	putenv \
	qsort \
	realloc \
	rename \
	rewind \
	select \
	setenv \
	snprintf \
	sscanf \
	strcasecmp \
	strftime \
	strncasecmp \
	strtol \
	strtoll \
	system \
	time \
	tolower \
	toupper \
	ungetc \
	usleep \
	vsprintf \
	vsnprintf \
)

if test $use_curses = no ; then
CHECK_DECL_HDRS="$TIN_DECL_HDRS
#include <tcurses.h>"
CF_CHECK_DECL($cf_tc_externs)
fi

CHECK_DECL_HDRS="$TIN_DECL_HDRS
#include <tnntp.h>"
CF_CHECK_DECL(\
	connect \
	gethostname \
)

fi

CF_TIOCGWINSZ

### append special libraries that get in the way of testing
case $debug_malloc in
DBMALLOC)
	AC_DEFINE(USE_DBMALLOC)
	LIBS="$LIBS -ldbmalloc"
	;;
DMALLOC)
	AC_DEFINE(USE_DMALLOC)
	LIBS="$LIBS -ldmalloc"
	;;
esac

### Use gettext
### this also calls AM_LANGINFO_CODESET and AM_ICONV
### so we don't need to do the tests ourselves.
CF_BUNDLED_INTL
LIBS="$LIBS $LIBICONV"

### check for alloca (required for bison and/or intl/*)
case "$YACC" in
bison*)
	use_alloca=yes
	;;
*)
	use_alloca=$USE_INCLUDED_LIBINTL
	;;
esac

if test ".$use_alloca" = .yes ; then
	CF_FUNC_ALLOCA
else
	ALLOCA=""
	AC_SUBST(ALLOCA)
fi

CF_CHECK_HEADERS(iconv.h)
AC_MSG_CHECKING(for iconv_open() //TRANSLIT extension)
AC_TRY_RUN([
#ifdef HAVE_ICONV_H
#	include <iconv.h>
#endif /* HAVE_ICONV_H */
#ifdef HAVE_STDLIB_H
#	include <stdlib.h>
#endif /* HAVE_STDLIB_H */
int main() {
	iconv_t cd;

	if ((cd = iconv_open("US-ASCII//TRANSLIT", "ISO-8859-1")) == (iconv_t) (-1))
		exit(1);
	exit(0);
}],
	AC_DEFINE(HAVE_ICONV_OPEN_TRANSLIT) AC_MSG_RESULT(yes),
	AC_MSG_RESULT(no),
	AC_MSG_RESULT(unknown)
)

# FIXME / TESTME
# locale is broken on cygwin < 1.7.0
# group/other bits don't work on cygwin < 1.7.0
# locking doesn't work on cygwin
# link(2) is detected but doesn't work on cygwin
case "$host_os" in
	*cygwin*)
		case `uname -r | sed 's,(.*,,'` in
			1.7.*)
				AC_DEFINE(NO_LOCKING)
				;;
			*)
				# link does not work
				AC_DEFINE(NO_LOCALE)
				AC_DEFINE(NO_LOCKING)
				AC_DEFINE(FILE_MODE_BROKEN)
				;;
			esac
		;;
	*haiku*)
		# link does not work
		AC_DEFINE(NO_LOCKING)
		;;
	*)
		AC_CHECK_FUNC(link, AC_DEFINE(HAVE_LINK))
esac

if test "$cf_cv_termlib" = pdcurses ; then
	CF_PDCURSES_X11
fi
AC_CHECK_FUNCS(vwprintw)

### sum up warnings
if test "$cf_cv_termlib" = none ; then
	AC_MSG_WARN([no term-lib found, you might run into trouble later.])
fi
if test "$YACC" = "" ; then
	AC_MSG_WARN([no yacc-parser found, you might run into trouble later.])
fi
if test "$RANLIB" = "" ; then
	AC_MSG_WARN([no library archive builder found, you might run into trouble later.])
fi

### Finally, build autoconf.h and the makefiles
CFLAGS="$CFLAGS $EXTRA_CFLAGS"

LINTFLAGS=$LINTFLAGS
AC_SUBST(LINTFLAGS)

CF_DEFINE_STRING(TIN_CC,       "$CC")
CF_DEFINE_STRING(TIN_CFLAGS,   "$CFLAGS")
CF_DEFINE_STRING(TIN_CPP,      "$CPP")
CF_DEFINE_STRING(TIN_CPPFLAGS, "$CPPFLAGS")
CF_DEFINE_STRING(TIN_LD,       "$CC")
CF_DEFINE_STRING(TIN_LDFLAGS,  "$LDFLAGS")
CF_DEFINE_STRING(TIN_LIBS,     "$LIBS")

AC_OUTPUT($PCRE_MAKEFILE
	$SUB_MAKEFILE
	$CAN_MAKEFILE
	src/Makefile)