File: configure.in

package info (click to toggle)
links2 2.21-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 27,680 kB
  • sloc: ansic: 180,334; sh: 2,586; cpp: 1,450; makefile: 82; awk: 49; perl: 34
file content (1543 lines) | stat: -rw-r--r-- 53,453 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
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
# configure.in
# (c) 2002 Mikulas Patocka, Karel 'Clock' Kulhavy, Petr 'Brain' Kulhavy,
#          Martin 'PerM' Pergel
# This file is a part of the Links program, released under GPL.

AC_INIT(main.c)

AM_INIT_AUTOMAKE(links, 2.21)

ACLOCAL="./missing aclocal"
AUTOCONF="./missing autoconf"
AUTOMAKE="./missing automake"
AUTOHEADER="./missing autoheader"

export CC
export CPPFLAGS
export CFLAGS
export LDFLAGS
export LIBS

AM_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX

dnl AC_PROG_AWK
dnl AM_PROG_LEX
dnl AC_PROG_YACC

image_formats="GIF PNG XBM"

static_link=0
if test -n "`echo "$CC" "$LDFLAGS" "$CFLAGS" "$LIBS" | grep 'static\>'`"; then
	static_link=1
fi

if test -n "`uname|grep -i bsd`"; then
	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
	LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi

AC_HEADER_STDC
AC_PROG_GCC_TRADITIONAL

dnl Check for libraries

AC_CACHE_CHECK([for EMX], ac_cv_have_emx,
	AC_TRY_COMPILE(, [#ifndef __EMX__
	kill me!
	#endif ], ac_cv_have_emx=yes, ac_cv_have_emx=no)
)
test "$ac_cv_have_emx" = yes && LDFLAGS="`echo "$LDFLAGS" | sed "s/-Zexe//g" | sed "s/-Zbin-files//g"`"
test "$ac_cv_have_emx" = yes && test "$static_link" = 0 && LDFLAGS="$LDFLAGS -Zcrtdll"

AC_CACHE_CHECK([for OpenWatcom], ac_cv_have_watcom,
	AC_TRY_COMPILE(, [#ifndef __WATCOMC__
	kill me!
	#endif ], ac_cv_have_watcom=yes, ac_cv_have_watcom=no)
)
test "$ac_cv_have_watcom" = yes && ac_cv_lib_dir_opendir=no

AC_CACHE_CHECK([for DJGPP], ac_cv_have_djgpp,
	AC_TRY_COMPILE(, [#ifndef __DJGPP
	kill me!
	#endif ], ac_cv_have_djgpp=yes, ac_cv_have_djgpp=no)
)

if test "$ac_cv_have_djgpp" = yes; then
	static_link=1
	test -n "$DJDIR" && test -d "$DJDIR/net/watt/inc" && CPPFLAGS="-I$DJDIR/net/watt/inc $CPPFLAGS"
	test -n "$DJDIR" && test -d "$DJDIR/net/watt/lib" && LDFLAGS="-L$DJDIR/net/watt/lib $LDFLAGS"
fi

AC_CACHE_CHECK([for ARM64 ILP32], ac_cv_have_arm64_ilp32,
	AC_TRY_COMPILE(, [#if !(defined(__aarch64__) && defined(__ILP32__))
	kill me!
	#endif ], ac_cv_have_arm64_ilp32=yes, ac_cv_have_arm64_ilp32=no)
)
test "$ac_cv_have_arm64_ilp32" = yes && disable_openmp=yes

AC_CACHE_CHECK([for volatile], ac_cv_have_volatile,
	AC_TRY_COMPILE([], [
		volatile int a = 0;
		return a;
	], ac_cv_have_volatile=yes, ac_cv_have_volatile=no)
)
if test "$ac_cv_have_volatile" = yes; then
	AC_DEFINE(HAVE_VOLATILE)
fi

AC_CACHE_CHECK([for restrict], ac_cv_have_restrict,
	AC_TRY_COMPILE([
		static void f(int * restrict a, int * restrict b)
		{
		}
	], [
		int a, b;
		f(&a, &b);
		return 0;
	], ac_cv_have_restrict=yes, ac_cv_have_restrict=no)
)
if test "$ac_cv_have_restrict" = yes; then
	AC_DEFINE(HAVE_RESTRICT)
fi

AC_CACHE_CHECK([for __restrict], ac_cv_have___restrict,
	AC_TRY_COMPILE([
		static void f(int * __restrict a, int * __restrict b)
		{
		}
	], [
		int a, b;
		f(&a, &b);
		return 0;
	], ac_cv_have___restrict=yes, ac_cv_have___restrict=no)
)
if test "$ac_cv_have___restrict" = yes; then
	AC_DEFINE(HAVE___RESTRICT)
fi

AC_CACHE_CHECK([for long long], ac_cv_have_long_long,
	AC_TRY_COMPILE(, [unsigned long long a; ], ac_cv_have_long_long=yes, ac_cv_have_long_long=no)
)
test "$ac_cv_have_long_long" = yes && AC_DEFINE(HAVE_LONG_LONG)

AC_CACHE_CHECK([for pointer comparison bug], ac_cv_pointer_comparison_bug,
	AC_TRY_RUN([
	int main()
	{
		void *p = (void *)-1L;
		return p != (void *)-1L;
	}
	], ac_cv_pointer_comparison_bug=no, ac_cv_pointer_comparison_bug=yes,
		[if test -n "`echo "$CC"|grep ^tcc`"; then
			ac_cv_pointer_comparison_bug=yes
		else
			ac_cv_pointer_comparison_bug=no
		fi]
	)
)
test "$ac_cv_pointer_comparison_bug" = yes && AC_DEFINE(HAVE_POINTER_COMPARISON_BUG)

if test "$ac_cv_have_long_long" = yes -a "$ac_cv_have_volatile" = yes; then
	AC_CACHE_CHECK([for maxint conversion bug], ac_cv_maxint_conversion_bug,
		AC_TRY_RUN([
		int main()
		{
			volatile long long q = 0x7FFFFFEF;
			return q < 0;
		}
		], ac_cv_maxint_conversion_bug=no, ac_cv_maxint_conversion_bug=yes,
			[if test -n "`echo "$CC"|grep ^cc`" -a "`uname -s`" = HP-UX; then
				ac_cv_maxint_conversion_bug=yes
			else
				ac_cv_maxint_conversion_bug=no
			fi]
		)
	)
	test "$ac_cv_maxint_conversion_bug" = yes && AC_DEFINE(HAVE_MAXINT_CONVERSION_BUG)
fi

dnl AC_CACHE_CHECK([for _FILE_OFFSET_BITS 64], ac_cv_have_file_offset_bits,
dnl 	AC_TRY_COMPILE([
dnl 	#define _FILE_OFFSET_BITS 64
dnl 	#include <stdio.h>
dnl 	], [
dnl 		return 0;
dnl 	], ac_cv_have_file_offset_bits=yes, ac_cv_have_file_offset_bits=no)
dnl )
dnl test "$ac_cv_have_file_offset_bits" = yes && AC_DEFINE(HAVE_FILE_OFFSET_BITS)

dnl note: HAVE_STDLIB_H clashes with defines in jpeglib.h,
dnl so we must use a different name
AC_CACHE_CHECK([for stdlib.h], ac_cv_have_stdlib_h,
	AC_TRY_COMPILE([#include <stdlib.h>],[],
		ac_cv_have_stdlib_h=yes, ac_cv_have_stdlib_h=no)
)
if test "$ac_cv_have_stdlib_h" = yes; then
	AC_DEFINE(HAVE_STDLIB_H_X)
fi


dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(alloca.h arpa/inet.h bsd/string.h cygwin/process.h cygwin/version.h fcntl.h grp.h ieee.h interix/interix.h inttypes.h io.h langinfo.h limits.h linux/falloc.h locale.h malloc.h math.h net/socket.h netinet/in_system.h netinet/in_systm.h netinet/ip.h poll.h process.h pwd.h search.h setjmp.h sgtty.h stdarg.h string.h strings.h sys/cygwin.h sys/file.h sys/fmutex.h sys/ioctl.h sys/resource.h sys/select.h sys/time.h sys/un.h sys/utsname.h termios.h time.h umalloc.h unistd.h unixlib.h utime.h uwin.h values.h)

if test "$ac_cv_header_stdarg_h" != yes; then
	AC_ERROR([stdarg.h not present])
fi

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_CACHE_CHECK([for socklen_t], ac_cv_have_socklen_t,
	AC_TRY_COMPILE([
	#include <sys/types.h>
	#include <sys/socket.h>
	], [
		socklen_t a = 0;
		return a;
	], ac_cv_have_socklen_t=yes, ac_cv_have_socklen_t=no)
)
if test "$ac_cv_have_socklen_t" = yes; then
	AC_DEFINE(HAVE_SOCKLEN_T)
fi
AC_CACHE_CHECK([for errno], ac_cv_have_errno,
	AC_TRY_COMPILE([
	#include <errno.h>
	], [
		errno = 0;
		return errno;
	], ac_cv_have_errno=yes, ac_cv_have_errno=no)
)
if test "$ac_cv_have_errno" = yes; then
	AC_DEFINE(HAVE_ERRNO)
fi

AC_HEADER_TIME
AC_STRUCT_TM

if test "$ac_cv_have_emx" = yes; then
	default_short=2
	default_int=4
	default_long=4
	default_long_long=8
else
	default_short=0
	default_int=0
	default_long=0
	default_long_long=0
fi

dnl Check for compiler type sizes
dnl AC_CHECK_SIZEOF(short, "$default_short")
AC_CHECK_SIZEOF(unsigned short, "$default_short")
dnl AC_CHECK_SIZEOF(int, "$default_int")
AC_CHECK_SIZEOF(unsigned, "$default_int")
dnl AC_CHECK_SIZEOF(long, "$default_long")
AC_CHECK_SIZEOF(unsigned long, "$default_long")
if test "$ac_cv_have_long_long" = yes; then
dnl 	AC_CHECK_SIZEOF(long long, "$default_long_long")
	AC_CHECK_SIZEOF(unsigned long long, "$default_long_long")
fi
if test "$ac_cv_sizeof_unsigned" -ne 0 && test "$ac_cv_sizeof_unsigned" -lt 4; then
	AC_ERROR([integer must have at least 32 bits])
fi
AC_CACHE_CHECK([for big endian], ac_cv_big_endian,
	AC_TRY_RUN([
	long l;
	char *c = (char *)&l;
	int main()
	{
		l = 0x12345678L;
		return !(c[[sizeof(long) - 1]] == 0x78 && c[[sizeof(long) - 2]] == 0x56 && c[[sizeof(long) - 3]] == 0x34 && c[[sizeof(long) - 4]] == 0x12);
	}
	], ac_cv_big_endian=yes, ac_cv_big_endian=no, ac_cv_big_endian=no)
)
AC_CACHE_CHECK([for little endian], ac_cv_little_endian,
	AC_TRY_RUN([
	long l;
	char *c = (char *)&l;
	int main()
	{
		l = 0x12345678L;
		return !(c[[0]] == 0x78 && c[[1]] == 0x56 && c[[2]] == 0x34 && c[[3]] == 0x12);
	}
	], ac_cv_little_endian=yes, ac_cv_little_endian=no, ac_cv_little_endian="$ac_cv_have_emx")
)

if test "$ac_cv_big_endian" = yes; then
	AC_DEFINE(C_BIG_ENDIAN)
else if test "$ac_cv_little_endian" = yes; then
	AC_DEFINE(C_LITTLE_ENDIAN)
fi
fi

AC_CACHE_CHECK([if rename can replace existing files], ac_cv_rename_over_existing_files,
	AC_TRY_RUN([
	#include <fcntl.h>
	#include <stdio.h>
	#include <unistd.h>

	int main()
	{
		int ret;
		close(creat("conftest.rename1", 0600));
		close(creat("conftest.rename2", 0600));
		ret = rename("conftest.rename1", "conftest.rename2");
		unlink("conftest.rename1");
		unlink("conftest.rename2");
		return !!ret;
	}
	], ac_cv_rename_over_existing_files=yes, ac_cv_rename_over_existing_files=no, ac_cv_rename_over_existing_files=no)
)

if test "$ac_cv_rename_over_existing_files" = yes; then
	AC_DEFINE(RENAME_OVER_EXISTING_FILES)
fi

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_HAVE_FUNCS(bcmp bcopy bzero calloc cfmakeraw chmod cygwin_conv_path cygwin_conv_to_full_win32_path dirfd fallocate freelocale getcwd getgrgid gethostname getpagesize getpid getpwuid getrlimit gettimeofday kqueue malloc_trim mallopt mktime newlocale nl_langinfo poll popen posix_fallocate raise select setlocale setpgid setrlimit setsid sigaction sigblock sigdelset sigprocmask sigsetmask snprintf strdup strerror_l strptime strtod strtoimax strtol strtoll strtoq strtoul sysconf tdelete tempnam tfind tsearch uname unixpath2win utime utimes uwin_path winpath2unix _heapmin _msize _ucreate _udefault _udestroy _uopen __strtoll)


AC_HAVE_FUNCS(strlen)
AC_CACHE_CHECK([for strlen], ac_cv_have_strlen,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; return strlen(str);], ac_cv_have_strlen=yes, ac_cv_have_strlen=no)
)
if test "$ac_cv_have_strlen" = yes; then
	AC_DEFINE(HAVE_STRLEN)
fi

AC_HAVE_FUNCS(strnlen)
AC_CACHE_CHECK([for strnlen], ac_cv_have_strnlen,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; return strnlen(str, 3);], ac_cv_have_strnlen=yes, ac_cv_have_strnlen=no)
)
if test "$ac_cv_have_strnlen" = yes; then
	AC_DEFINE(HAVE_STRNLEN)
fi

AC_HAVE_FUNCS(strcpy)
AC_CACHE_CHECK([for strcpy], ac_cv_have_strcpy,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char a[[100]]; strcpy(a, str); return a[[0]];], ac_cv_have_strcpy=yes, ac_cv_have_strcpy=no)
)
if test "$ac_cv_have_strcpy" = yes; then
	AC_DEFINE(HAVE_STRCPY)
fi

AC_HAVE_FUNCS(strncpy)
AC_CACHE_CHECK([for strncpy], ac_cv_have_strncpy,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char a[[100]]; volatile int l = 1; strncpy(a, str, l); return a[[0]];], ac_cv_have_strncpy=yes, ac_cv_have_strncpy=no)
)
if test "$ac_cv_have_strncpy" = yes; then
	AC_DEFINE(HAVE_STRNCPY)
fi

AC_HAVE_FUNCS(strchr)
AC_CACHE_CHECK([for strchr], ac_cv_have_strchr,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; return !!strchr(str, 0);], ac_cv_have_strchr=yes, ac_cv_have_strchr=no)
)
if test "$ac_cv_have_strchr" = yes; then
	AC_DEFINE(HAVE_STRCHR)
fi

AC_HAVE_FUNCS(strrchr)
AC_CACHE_CHECK([for strrchr], ac_cv_have_strrchr,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; return !!strrchr(str, 0);], ac_cv_have_strrchr=yes, ac_cv_have_strrchr=no)
)
if test "$ac_cv_have_strrchr" = yes; then
	AC_DEFINE(HAVE_STRRCHR)
fi

AC_HAVE_FUNCS(strcmp)
AC_CACHE_CHECK([for strcmp], ac_cv_have_strcmp,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char * volatile str2 = ""; return strcmp(str2, str);], ac_cv_have_strcmp=yes, ac_cv_have_strcmp=no)
)
if test "$ac_cv_have_strcmp" = yes; then
	AC_DEFINE(HAVE_STRCMP)
fi

AC_HAVE_FUNCS(strncmp)
AC_CACHE_CHECK([for strncmp], ac_cv_have_strncmp,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char * volatile str2 = ""; volatile int l = 1; return strncmp(str2, str, l);], ac_cv_have_strncmp=yes, ac_cv_have_strncmp=no)
)
if test "$ac_cv_have_strncmp" = yes; then
	AC_DEFINE(HAVE_STRNCMP)
fi

AC_HAVE_FUNCS(strcspn)
AC_CACHE_CHECK([for strcspn], ac_cv_have_strcspn,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char * volatile str2 = ""; return strcspn(str2, str);], ac_cv_have_strcspn=yes, ac_cv_have_strcspn=no)
)
if test "$ac_cv_have_strcspn" = yes; then
	AC_DEFINE(HAVE_STRCSPN)
fi

AC_HAVE_FUNCS(strspn)
AC_CACHE_CHECK([for strspn], ac_cv_have_strspn,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char * volatile str2 = ""; return strspn(str2, str);], ac_cv_have_strspn=yes, ac_cv_have_strspn=no)
)
if test "$ac_cv_have_strspn" = yes; then
	AC_DEFINE(HAVE_STRSPN)
fi

AC_HAVE_FUNCS(strstr)
AC_CACHE_CHECK([for strstr], ac_cv_have_strstr,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char * volatile str2 = ""; return !!strstr(str2, str);], ac_cv_have_strstr=yes, ac_cv_have_strstr=no)
)
if test "$ac_cv_have_strstr" = yes; then
	AC_DEFINE(HAVE_STRSTR)
fi

AC_HAVE_FUNCS(memchr)
AC_CACHE_CHECK([for memchr], ac_cv_have_memchr,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; volatile int l = 1; return !!memchr(str, 0, l);], ac_cv_have_memchr=yes, ac_cv_have_memchr=no)
)
if test "$ac_cv_have_memchr" = yes; then
	AC_DEFINE(HAVE_MEMCHR)
fi

AC_HAVE_FUNCS(memrchr)
AC_CACHE_CHECK([for memrchr], ac_cv_have_memrchr,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; volatile int l = 1; return !!memrchr(str, 0, l);], ac_cv_have_memrchr=yes, ac_cv_have_memrchr=no)
)
if test "$ac_cv_have_memrchr" = yes; then
	AC_DEFINE(HAVE_MEMRCHR)
fi

AC_HAVE_FUNCS(memcmp)
AC_CACHE_CHECK([for memcmp], ac_cv_have_memcmp,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char * volatile str2 = ""; volatile int l = 1; return memcmp(str2, str, l);], ac_cv_have_memcmp=yes, ac_cv_have_memcmp=no)
)
if test "$ac_cv_have_memcmp" = yes; then
	AC_DEFINE(HAVE_MEMCMP)
fi

AC_HAVE_FUNCS(memcpy)
AC_CACHE_CHECK([for memcpy], ac_cv_have_memcpy,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char a[[100]]; volatile int l = 1; memcpy(a, str, l); return a[[0]];], ac_cv_have_memcpy=yes, ac_cv_have_memcpy=no)
)
if test "$ac_cv_have_memcpy" = yes; then
	AC_DEFINE(HAVE_MEMCPY)
fi

AC_HAVE_FUNCS(memmove)
AC_CACHE_CHECK([for memmove], ac_cv_have_memmove,
	AC_TRY_LINK([#include <string.h>], [char * volatile str = ""; char a[[100]]; volatile int l = 1; memmove(a, str, l); return a[[0]];], ac_cv_have_memmove=yes, ac_cv_have_memmove=no)
)
if test "$ac_cv_have_memmove" = yes; then
	AC_DEFINE(HAVE_MEMMOVE)
fi

AC_HAVE_FUNCS(memset)
AC_CACHE_CHECK([for memset], ac_cv_have_memset,
	AC_TRY_LINK([#include <string.h>], [char a[[100]]; char * volatile str = a; volatile int l = 1; memset(str, 0, l); return a[[0]];], ac_cv_have_memset=yes, ac_cv_have_memset=no)
)
if test "$ac_cv_have_memset" = yes; then
	AC_DEFINE(HAVE_MEMSET)
fi

AC_HAVE_FUNCS(memmem)
AC_CACHE_CHECK([for memmem], ac_cv_have_memmem,
	AC_TRY_LINK([#define _GNU_SOURCE
#include <string.h>], [char * volatile str = ""; char * volatile str2 = ""; volatile int l = 1; volatile int l2 = 1; return !!memmem(str2, l2, str, l);], ac_cv_have_memmem=yes, ac_cv_have_memmem=no)
)
if test "$ac_cv_have_memmem" = yes; then
	AC_DEFINE(HAVE_MEMMEM)
fi

AC_HAVE_FUNCS(strerror)
AC_CACHE_CHECK([for strerror], ac_cv_have_strerror,
	AC_TRY_LINK([#include <string.h>], [volatile int e = 1; return strerror(e)[[0]];], ac_cv_have_strerror=yes, ac_cv_have_strerror=no)
)
if test "$ac_cv_have_strerror" = yes; then
	AC_DEFINE(HAVE_STRERROR)
fi

AC_CACHE_CHECK([for sigfillset], ac_cv_have_sigfillset,
	AC_TRY_LINK([#include <signal.h>], [sigset_t set; sigfillset(&set);], ac_cv_have_sigfillset=yes, ac_cv_have_sigfillset=no)
)
if test "$ac_cv_have_sigfillset" = yes; then
	AC_DEFINE(HAVE_SIGFILLSET)
fi

AC_CACHE_CHECK([for sigsetjmp/siglongjmp], ac_cv_have_sigsetjmp,
	AC_TRY_LINK([#include <setjmp.h>], [sigjmp_buf env;sigsetjmp(env, 1);siglongjmp(env, 2);], ac_cv_have_sigsetjmp=yes, ac_cv_have_sigsetjmp=no)
)
if test "$ac_cv_have_sigsetjmp" = yes; then
	AC_DEFINE(HAVE_SIGSETJMP)
fi

AC_CACHE_CHECK([for gcc assembler], ac_cv_have_gcc_assembler,
	AC_TRY_RUN([
int main(void)
{
	void *o = (void *)0, *i = (void *)-1L;
	__asm__ volatile ("" : "=r"(o) : "0"(i) : "memory");
	if (o != (void *)-1L)
		return 1;
#if defined(__i386__) || defined(__x86_64__)
	{
		int x = (int)((unsigned)-1 >> 1);
		int y = 1;
		int result = 0;
		unsigned char ovf = 0;
		__asm__ ("addl %2, %0; seto %1":"=r"(result), "=q"(ovf):"g"(y),"0"(x));
		if (result != ~x || ovf != 1)
			return 1;
	}
#endif
#if defined(__x86_64__) && !defined(__TINYC__)
	{
		static const unsigned char zero;
		__asm__ ("jmp 1f; movntdqa %0, %%xmm0; 1:" : : "m"(zero) : "xmm0");
	}
#endif
#if defined(__alpha__)
	__asm__ volatile (".p2align 3; nop; .p2align 3" ::: "memory");
#endif
	return 0;
}
], ac_cv_have_gcc_assembler=yes, ac_cv_have_gcc_assembler=no, ac_cv_have_gcc_assembler="$ac_cv_have_emx")
)
if test "$ac_cv_have_gcc_assembler" = yes; then
	AC_DEFINE(HAVE_GCC_ASSEMBLER)
fi

AC_CACHE_CHECK([for __builtin_add_overflow], ac_cv_have___builtin_add_overflow,
	AC_TRY_LINK([], [volatile int a = 1, b = 2; int c; return __builtin_add_overflow(a, b, &c);], ac_cv_have___builtin_add_overflow=yes, ac_cv_have___builtin_add_overflow=no)
)
if test "$ac_cv_have___builtin_add_overflow" = yes; then
	AC_DEFINE(HAVE___BUILTIN_ADD_OVERFLOW)
fi

AC_CACHE_CHECK([for __builtin_clz], ac_cv_have___builtin_clz,
	AC_TRY_LINK([], [volatile unsigned a = 1; return __builtin_clz(a);], ac_cv_have___builtin_clz=yes, ac_cv_have___builtin_clz=no)
)
if test "$ac_cv_have___builtin_clz" = yes; then
	AC_DEFINE(HAVE___BUILTIN_CLZ)
fi


if test "$ac_cv_func_select" != yes; then
	AC_ERROR([select function not present])
fi

AC_CHECK_LIB(bsd, strmode)

dnl User option

AC_MSG_CHECKING([for requested debug level])
AC_ARG_ENABLE(debuglevel, [  --enable-debuglevel     set internal checking level
	-1 - recover from segmentation faults
	 0 - no checks (fastest)
	 1 - check memory leaks
	 2 - check memory leaks, red zone
	 3 - check memory leaks, red zone, pattern filling], cf_debuglevel="$enableval", cf_debuglevel=0)
if test "$cf_debuglevel" = no; then cf_debuglevel=0; fi
if test "$cf_debuglevel" = yes; then cf_debuglevel=2; fi
AC_MSG_RESULT($cf_debuglevel)
if test "$cf_debuglevel" != -1 && test "$cf_debuglevel" != 0 && test "$cf_debuglevel" != 1 && test "$cf_debuglevel" != 2 && test "$cf_debuglevel" != 3; then
	AC_ERROR([Invalid debuglevel specified])
fi
AC_DEFINE_UNQUOTED(DEBUGLEVEL, $cf_debuglevel)

AC_MSG_CHECKING([if you want to enable javascript])
cf_use_javascript=no
AC_ARG_ENABLE(javascript, [  --enable-javascript     DELETE1], cf_use_javascript="$enableval")
AC_MSG_RESULT($cf_use_javascript)
if test "$cf_use_javascript" = yes; then
	AC_DEFINE(JS)
	AC_MSG_CHECKING([if you want to link with system libfl])
	cf_use_libfl=no
	AC_ARG_WITH(libfl, [  --with-libfl            DELETE2], cf_use_libfl="$withval")
	AC_MSG_RESULT($cf_use_libfl)
	if test "$cf_use_libfl" != no; then
		LIBS="$LIBS -lfl"
	else
		AC_DEFINE(CHCEME_FLEXI_LIBU)
	fi

	reg_exp_mode="NONE"
	PKG_CHECK_MODULES(LIBPCRE, libpcre, pkgconfig_libpcre=yes, pkgconfig_libpcre=no)
	if test "$pkgconfig_libpcre" = "yes"; then
		CPPFLAGS="$CPPFLAGS $LIBPCRE_CFLAGS"
		LIBS="$LIBPCRE_LIBS $LIBS"
	fi
	AC_CHECK_LIB(pcre, pcre_compile)
	AC_CHECK_HEADERS(pcre.h)
	if test "$ac_cv_lib_pcre_pcre_compile" = yes && test "$ac_cv_header_pcre_h" = yes; then
		AC_DEFINE(HAVE_PCRE)
		reg_exp_mode="PCRE"
	else
		AC_HAVE_FUNCS(regcomp)
		AC_CHECK_HEADERS(regex.h)
		if test "$ac_cv_func_regcomp" = yes && test "$ac_cv_header_regex_h" = yes; then
			AC_DEFINE(HAVE_REGEX)
			reg_exp_mode="LIBC"
		fi
	fi
	AC_CHECK_LIB(m, fmod)
fi

cf_use_graphics=no
AC_MSG_CHECKING([if you want to use graphics])
AC_ARG_ENABLE(graphics, [  --enable-graphics       use graphics], cf_use_graphics="$enableval" )
AC_MSG_RESULT($cf_use_graphics)

AC_MSG_CHECKING([if you want to enable UTF-8 terminal])
cf_enable_utf8=yes
AC_ARG_ENABLE(utf8, [  --disable-utf8          disable UTF-8 terminal (saves memory)], cf_enable_utf8="$enableval" )
test "$ac_cv_have_emx" = yes && cf_enable_utf8=no
test "$ac_cv_have_djgpp" = yes && cf_enable_utf8=no
AC_MSG_RESULT($cf_enable_utf8)

if test "$cf_enable_utf8" != no; then
	AC_DEFINE(ENABLE_UTF8)
fi


dnl Checks for libraries.

AC_HAVE_FUNCS(clock_gettime)
if test $ac_cv_func_clock_gettime = no; then
	AC_CHECK_LIB(rt, clock_gettime)
	if test $ac_cv_lib_rt_clock_gettime = yes; then
		AC_DEFINE(HAVE_CLOCK_GETTIME)
	fi
fi

AC_CHECK_FUNC(socket, cf_result=yes, cf_result=no)
if test "$cf_result" = no; then
	AC_CHECK_LIB(socket, socket)
	if test "$ac_cv_lib_socket_socket" = no; then
		AC_CHECK_LIB(xnet, socket)
		if test "$ac_cv_lib_xnet_socket" = no; then
			AC_CHECK_LIB(network, socket)
			if test "$ac_cv_lib_network_socket" = no; then
				AC_CHECK_LIB(watt, socket)
				if test "$ac_cv_lib_watt_socket" = no; then
					AC_ERROR([socket function not present])
				fi
			fi
		fi
	fi
fi
AC_CHECK_FUNC(setsockopt, cf_result=yes, cf_result=no)
if test "$cf_result" = no; then
	AC_CHECK_LIB(socket, setsockopt)
fi

AC_CHECK_FUNC(gethostbyname, cf_result=yes, cf_result=no)
if test "$cf_result" = no; then
	AC_CHECK_LIB(socket, gethostbyname)
	cf_result="$ac_cv_lib_socket_gethostbyname"
	if test "$ac_cv_lib_socket_gethostbyname" = no; then
		AC_CHECK_LIB(nsl, gethostbyname)
		cf_result="$ac_cv_lib_nsl_gethostbyname"
	fi
fi
test "$cf_result" = yes && AC_DEFINE(HAVE_GETHOSTBYNAME)

if test "$cf_result" = yes && test "$ac_cv_have_watcom" = yes -o "`uname -s`" = SunOS; then
	AC_CACHE_CHECK([for flawed gethostbyname], ac_cv_gethostbyname_bug,
		AC_TRY_RUN([
		#include <netdb.h>
		int main()
		{
			return !gethostbyname("www.gnu.org");
		}
		], ac_cv_gethostbyname_bug=no, ac_cv_gethostbyname_bug=yes, ac_cv_gethostbyname_bug="$ac_cv_have_watcom")
	)
	test "$ac_cv_gethostbyname_bug" = yes && AC_DEFINE(HAVE_GETHOSTBYNAME_BUG)
fi

AC_ARG_WITH(getaddrinfo, [  --without-getaddrinfo   compile without getaddrinfo function],[if test "$withval" = no; then disable_getaddrinfo=yes; else disable_getaddrinfo=no; fi])

if test "$disable_getaddrinfo" != yes; then
	AC_HAVE_FUNCS(getaddrinfo freeaddrinfo gai_strerror)
	if test "$ac_cv_func_getaddrinfo" = yes -a "$ac_cv_func_freeaddrinfo" = yes; then
		cf_have_getaddrinfo=yes
	else
		cf_have_getaddrinfo=no
	fi
else
	cf_have_getaddrinfo=no
fi

AC_HAVE_FUNCS(inet_ntop inet_pton herror)

AC_ARG_WITH(ipv6, [  --without-ipv6          compile without ipv6],[if test "$withval" = no; then disable_ipv6=yes; else disable_ipv6=no; fi])

AC_CACHE_CHECK([for ipv6], ac_cv_have_ipv6,
	AC_TRY_COMPILE([
		#include <sys/types.h>
		#include <sys/socket.h>
		#include <netinet/in.h>
	], [
		struct sockaddr_in6 sin6;
		sin6.sin6_family = AF_INET6;
	], ac_cv_have_ipv6=yes, ac_cv_have_ipv6=no)
)
if test "$disable_ipv6" != yes -a "$ac_cv_have_ipv6" = yes -a "$cf_have_getaddrinfo" = yes; then
	cf_have_ipv6=yes
	AC_DEFINE(SUPPORT_IPV6)
else
	cf_have_ipv6=no
fi
AC_CACHE_CHECK([for sockaddr_in6.sin6_scope_id], ac_cv_have_sin6_scope_id,
	AC_TRY_COMPILE([
		#include <sys/types.h>
		#include <sys/socket.h>
		#include <netinet/in.h>
	], [
		struct sockaddr_in6 sin6;
		sin6.sin6_scope_id = 0;
	], ac_cv_have_sin6_scope_id=yes, ac_cv_have_sin6_scope_id=no)
)
test "$ac_cv_have_sin6_scope_id" = yes && AC_DEFINE(SUPPORT_IPV6_SCOPE)

AC_ARG_WITH(libevent, [  --without-libevent      compile without libevent],[if test "$withval" = no; then disable_libevent=yes; else disable_libevent=no; fi])

cf_have_libevent=no
if test "$disable_libevent" != yes; then
	AC_CHECK_HEADERS(event.h ev-event.h)
	if test "$ac_cv_header_event_h" = yes; then
		AC_CHECK_LIB(event, event_loop)
		if test "$ac_cv_lib_event_event_loop" = yes; then
			cf_have_libevent=libevent
		fi
	fi
	if test "$cf_have_libevent" = no; then
		if test "$ac_cv_header_event_h" = yes -o "$ac_cv_header_ev_event_h" = yes; then
			AC_CHECK_LIB(ev, event_loop)
			if test "$ac_cv_lib_ev_event_loop" = yes; then
				cf_have_libevent=libev
			fi
		fi
	fi
fi
if test "$cf_have_libevent" != no; then
	AC_HAVE_FUNCS(event_base_set event_get_version event_get_method event_base_free event_base_new event_reinit event_base_get_method event_config_set_flag event_get_struct_event_size)
fi

if test "$cf_use_graphics" != no; then
	AC_CHECK_LIB(m, pow)
	if test "$ac_cv_lib_m_pow" = no; then
		AC_CHECK_LIB(m, main)
	fi
	AC_CACHE_CHECK([for pow], ac_cv_have_pow,
		AC_TRY_LINK([#include <math.h>], [volatile double a = 1.1; volatile double b = 2.2; return pow(a, b);], ac_cv_have_pow=yes, ac_cv_have_pow=no)
	)
	if test "$ac_cv_have_pow" = yes; then
		AC_DEFINE(HAVE_POW)
	fi
	AC_CACHE_CHECK([for powf], ac_cv_have_powf,
		AC_TRY_LINK([#include <math.h>], [volatile float a = 1.1; volatile float b = 2.2; return powf(a, b);], ac_cv_have_powf=yes, ac_cv_have_powf=no)
	)
	if test "$ac_cv_have_powf" = yes; then
		AC_DEFINE(HAVE_POWF)
	fi
	if test "$ac_cv_have_pow" != yes -a "$ac_cv_have_powf" != yes; then
		AC_ERROR([pow and powf functions not present])
	fi
fi

AC_ARG_WITH(gpm, [  --without-gpm           compile without gpm mouse],[if test "$withval" = no; then disable_gpm=yes; else disable_gpm=no; fi])

if test "$disable_gpm" != yes -a "$ac_cv_have_djgpp" != yes; then
	AC_CHECK_HEADERS(gpm.h)
	AC_CHECK_LIB(gpm, Gpm_Open)
	AC_HAVE_FUNCS(Gpm_GetLibVersion)
	if test "$ac_cv_lib_gpm_Gpm_Open" = yes && test "$ac_cv_header_gpm_h" = yes; then
		cf_have_gpm=yes
		AC_CACHE_CHECK([for Gpm_Event wdx and wdy], ac_cv_have_wdx_wdy,
			AC_TRY_COMPILE([
#include <sys/time.h>
#include <gpm.h>
], [
	Gpm_Event e;
	e.wdx = 1;
	e.wdy = 2;
	return e.wdx + e.wdy
], ac_cv_have_wdx_wdy=yes, ac_cv_have_wdx_wdy=no)
		)
		if test "$ac_cv_have_wdx_wdy" = yes; then
			AC_DEFINE(HAVE_WDX_WDY)
		fi
	else
		cf_have_gpm=no
	fi
else
	cf_have_gpm=no
fi

AC_CACHE_CHECK([for OS/2 threads], ac_cv_have_beginthread,
	CFLAGS_X="$CFLAGS"
	CFLAGS="$CFLAGS -Zmt"
	AC_TRY_LINK([#include <stdlib.h>], [_beginthread(NULL, NULL, 0, NULL)], ac_cv_have_beginthread=yes, ac_cv_have_beginthread=no)
	CFLAGS="$CFLAGS_X"
)
if test "$ac_cv_have_beginthread" = yes; then
	CFLAGS="$CFLAGS -Zmt"
	AC_DEFINE(HAVE_BEGINTHREAD)
fi
AC_CHECK_HEADERS(atheos/threads.h)
AC_HAVE_FUNCS(spawn_thread resume_thread)

AC_HAVE_FUNCS(MouOpen _read_kbd)
AC_CACHE_CHECK([for XFree for OS/2], ac_cv_have_x2,
	CPPFLAGS_X="$CPPFLAGS"
	LIBS_X="$LIBS"
	ac_cv_have_x2=no
	if test -n "$X11ROOT"; then
		CPPFLAGS="$CPPFLAGS_X -I$X11ROOT/XFree86/include"
		LIBS="$LIBS_X -L$X11ROOT/XFree86/lib -lxf86_gcc"
		AC_TRY_LINK([#include <pty.h>], [struct winsize win;ptioctl(1, TIOCGWINSZ, &win)], ac_cv_have_x2=xf86_gcc, ac_cv_have_x2=no)
		if test "$ac_cv_have_x2" = no; then
			LIBS="$LIBS_X -L$X11ROOT/XFree86/lib -lxf86"
			AC_TRY_LINK([#include <pty.h>], [struct winsize win;ptioctl(1, TIOCGWINSZ, &win)], ac_cv_have_x2=xf86, ac_cv_have_x2=no)
		fi
	fi
	CPPFLAGS="$CPPFLAGS_X"
	LIBS="$LIBS_X"
)
if test "$ac_cv_have_x2" != no; then
	CPPFLAGS="$CPPFLAGS -I$X11ROOT/XFree86/include"
	LIBS="$LIBS -L$X11ROOT/XFree86/lib -l$ac_cv_have_x2"
	AC_DEFINE(X2)
fi

cf_result=no
#ifdef HAVE_SSL
ssld=yes
withval=
AC_ARG_WITH(ssl, [  --with-ssl(=directory)  enable SSL support
  --with-ssl=nss          enable SSL support through NSS OpenSSL emulation], [if test "$withval" = no; then disable_ssl=yes; else ssld="$withval"; fi])
AC_ARG_ENABLE(ssl-pkgconfig, [  --disable-ssl-pkgconfig don't use pkgconfig when searching for openssl], cf_openssl_pkgconfig="$enableval", cf_openssl_pkgconfig=yes)
if test -z "$disable_ssl"; then
	CPPFLAGS_X="$CPPFLAGS"
	LIBS_X="$LIBS"
	if test "$static_link" != 0; then
		AC_CHECK_LIB(dl, dlopen)
		AC_CHECK_LIB(z, inflate)
	fi
	CPPFLAGS_XX="$CPPFLAGS"
	LIBS_XX="$LIBS"
	if test "$cf_result" = no && test "$ssld" = yes -o "$ssld" = openssl; then
		if test "$cf_openssl_pkgconfig" = no; then
			pkgconfig_openssl=no
		else
			PKG_CHECK_MODULES(OPENSSL, openssl, pkgconfig_openssl=yes, pkgconfig_openssl=no)
			if test "$PKG_CONFIG" != no -a "$pkgconfig_openssl" = no; then
				AC_MSG_RESULT(no)
			fi
		fi
		if test "$pkgconfig_openssl" = yes; then
			AC_MSG_CHECKING([for OpenSSL])
			CPPFLAGS="$CPPFLAGS_XX $OPENSSL_CFLAGS"
			LIBS="$OPENSSL_LIBS $LIBS_XX"
			AC_TRY_LINK([#include <stdio.h>
#include <openssl/ssl.h>], [SSL_CTX_new((void *)0)], cf_result=openssl, cf_result=no)
			AC_MSG_RESULT($cf_result)
		fi
	fi

	if test "$cf_result" = no && test "$ssld" != nss; then
		AC_MSG_CHECKING([for OpenSSL])
		if test "$ssld" = yes -o "$ssld" = openssl; then
			ssld=". /usr /usr/local /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/local/www /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl"
		fi
		for ssldir in $ssld; do
			if test "$cf_result" = no; then
				if test ! -z "$ssldir" && test "$ssldir" != /usr && test "$ssldir" != .; then
					LIBS="-L$ssldir/lib -lssl -lcrypto $LIBS_XX"
					CPPFLAGS="$CPPFLAGS_XX -I$ssldir/include"
				else
					LIBS="-lssl -lcrypto $LIBS_XX"
					CPPFLAGS="$CPPFLAGS_XX"
				fi
				AC_TRY_LINK([#include <stdio.h>
#include <openssl/ssl.h>], [SSL_CTX_new((void *)0)], cf_result=openssl, cf_result=no)
			fi
		done
		AC_MSG_RESULT($cf_result)
	fi

	if test "$cf_result" = no && test "$ssld" = yes -o "$ssld" = nss; then
		if test "$cf_openssl_pkgconfig" = no; then
			pkgconfig_nss=no
		else
			PKG_CHECK_MODULES(NSS, nss, pkgconfig_nss=yes, pkgconfig_nss=no)
			if test "$PKG_CONFIG" != no -a "$pkgconfig_nss" = no; then
				AC_MSG_RESULT(no)
			fi
		fi
		if test "$pkgconfig_nss" = no; then
			NSS_CFLAGS=""
			NSS_LIBS=""
		fi
		CPPFLAGS="$CPPFLAGS_X $NSS_CFLAGS"
		LIBS="-lnss_compat_ossl $NSS_LIBS $LIBS_X"
		AC_MSG_CHECKING([for NSS-compat-ossl])
		AC_TRY_LINK([#include <nss_compat_ossl/nss_compat_ossl.h>], [SSL_CTX_new((void *)0)], cf_result=nss, cf_result=no)
		AC_MSG_RESULT($cf_result)
	fi

	if test "$cf_result" = no; then
		if test -n "$withval" -a "$withval" != no; then
			AC_MSG_ERROR("OpenSSL not found")
		fi
	        CPPFLAGS="$CPPFLAGS_X"
        	LIBS="$LIBS_X"
	else
		AC_DEFINE(HAVE_SSL)
		if test "$cf_result" = openssl; then
			AC_DEFINE(HAVE_OPENSSL)
			AC_CHECK_HEADERS(openssl/x509v3.h)
		fi
		if test "$cf_result" = nss; then
			AC_DEFINE(HAVE_NSS)
		fi
		AC_HAVE_FUNCS(ASN1_STRING_get0_data ASN1_STRING_to_UTF8 OPENSSL_cleanup OPENSSL_init_ssl RAND_add RAND_egd RAND_file_name RAND_load_file RAND_write_file SSL_SESSION_is_resumable SSL_get0_verified_chain SSL_get1_peer_certificate SSL_get1_session SSL_load_error_strings SSL_set_security_level X509_check_host X509_check_ip)
		AC_CACHE_CHECK([for CRYPTO_set_mem_functions without file/line], ac_cv_have_crypto_set_mem_functions_1,
			AC_TRY_LINK([#include <openssl/crypto.h>
			static int csmf(void *(*m)(size_t), void *(*r)(void *, size_t), void (*f)(void *)) { return 0; }
			], [return (int)(CRYPTO_set_mem_functions - csmf);], ac_cv_have_crypto_set_mem_functions_1=yes, ac_cv_have_crypto_set_mem_functions_1=no)
		)
		if test "$ac_cv_have_crypto_set_mem_functions_1" = yes; then
			AC_DEFINE(HAVE_CRYPTO_SET_MEM_FUNCTIONS_1)
		fi
		AC_CACHE_CHECK([for CRYPTO_set_mem_functions with file/line], ac_cv_have_crypto_set_mem_functions_2,
			AC_TRY_LINK([#include <openssl/crypto.h>
			static int csmf(void *(*m)(size_t, const char *, int), void *(*r)(void *, size_t, const char *, int), void (*f)(void *, const char *, int)) { return 0; }
			], [return (int)(CRYPTO_set_mem_functions - csmf);], ac_cv_have_crypto_set_mem_functions_2=yes, ac_cv_have_crypto_set_mem_functions_2=no)
		)
		if test "$ac_cv_have_crypto_set_mem_functions_2" = yes; then
			AC_DEFINE(HAVE_CRYPTO_SET_MEM_FUNCTIONS_2)
		fi
	fi
fi
#endif
cf_have_ssl=$cf_result

AC_ARG_WITH(zlib, [  --without-zlib          compile without zlib compression],[if test "$withval" = no; then disable_zlib=yes; else disable_zlib=no; fi])
AC_ARG_WITH(brotli, [  --without-brotli        compile without brotli compression],[if test "$withval" = no; then disable_brotli=yes; else disable_brotli=no; fi])
AC_ARG_WITH(zstd, [  --without-zstd          compile without zstandard compression],[if test "$withval" = no; then disable_zstd=yes; else disable_zstd=no; fi])
AC_ARG_WITH(bzip2, [  --without-bzip2         compile without bzip2 compression],[if test "$withval" = no; then disable_bzip2=yes; else disable_bzip2=no; fi])
AC_ARG_WITH(lzma, [  --without-lzma          compile without lzma compression],[if test "$withval" = no; then disable_lzma=yes; else disable_lzma=no; fi])
AC_ARG_WITH(lzip, [  --without-lzip          compile without lzip compression],[if test "$withval" = no; then disable_lzip=yes; else disable_lzip=no; fi])
compression=""

if test "$disable_zlib" != yes; then
	AC_CHECK_HEADERS(zlib.h)
	AC_CHECK_LIB(z, inflate)
	if test "$ac_cv_header_zlib_h" = yes && test "$ac_cv_lib_z_inflate" = yes; then
		AC_DEFINE(HAVE_ZLIB)
		compression="$compression ZLIB"
	fi
fi

if test "$disable_brotli" != yes; then
	AC_CHECK_HEADERS(brotli/decode.h)
	AC_CHECK_LIB(brotlidec, BrotliDecoderDecompressStream)
	if test "$ac_cv_header_brotli_decode_h" = yes && test "$ac_cv_lib_brotlidec_BrotliDecoderDecompressStream" = yes; then
		AC_DEFINE(HAVE_BROTLI)
		compression="$compression BROTLI"
	fi
fi

if test "$disable_zstd" != yes; then
	AC_CHECK_HEADERS(zstd.h)
	AC_CHECK_LIB(zstd, ZSTD_decompressStream)
	if test "$ac_cv_header_zstd_h" = yes && test "$ac_cv_lib_zstd_ZSTD_decompressStream" = yes; then
		AC_HAVE_FUNCS(ZSTD_getErrorCode)
		AC_DEFINE(HAVE_ZSTD)
		compression="$compression ZSTD"
	fi
fi

if test "$disable_bzip2" != yes; then
	AC_CHECK_HEADERS(bzlib.h)
	AC_CHECK_LIB(bz2, BZ2_bzDecompress)
	if test "$ac_cv_header_bzlib_h" = yes && test "$ac_cv_lib_bz2_BZ2_bzDecompress" = yes; then
		AC_DEFINE(HAVE_BZIP2)
		compression="$compression BZIP2"
	fi
fi

if test "$disable_lzma" != yes; then
	AC_CHECK_HEADERS(lzma.h)
	AC_CHECK_LIB(lzma, lzma_auto_decoder)
	if test "$ac_cv_header_lzma_h" = yes && test "$ac_cv_lib_lzma_lzma_auto_decoder" = yes; then
		AC_DEFINE(HAVE_LZMA)
		compression="$compression LZMA"
	fi
fi

if test "$disable_lzip" != yes; then
	AC_CHECK_HEADERS(lzlib.h)
	AC_CHECK_LIB(lz, LZ_decompress_open)
	if test "$ac_cv_header_lzlib_h" = yes && test "$ac_cv_lib_lz_LZ_decompress_open" = yes; then
		AC_DEFINE(HAVE_LZIP)
		compression="$compression LZIP"
	fi
fi


cf_have_atheos=no
cf_have_haiku=no

if test "$cf_use_graphics" != no; then
	AC_DEFINE(G)

AC_ARG_WITH(openmp, [  --without-openmp        compile without OpenMP],[if test "$withval" = no; then disable_openmp=yes; else disable_openmp=no; fi])
cf_have_openmp=no
if test "$disable_openmp" != yes; then
	AC_CACHE_CHECK([for OpenMP], ac_cv_have_openmp,
		ac_cv_have_openmp=no
		for openmp_cflags in "" -fopenmp -openmp -fopenmp=libgomp -mp -xopenmp -omp -qsmp=omp "-mp -lstdc++"; do
			CFLAGS_X="$CFLAGS"
			CFLAGS="$CFLAGS $openmp_cflags"
			AC_TRY_LINK([#include <omp.h>], [
			int enabled = 1;
			int i = 1;
			int j = 3;
			omp_set_dynamic(0);
			i += omp_get_max_threads();
			omp_set_num_threads(4);
#pragma omp parallel default(none) firstprivate(i) shared(j) if (enabled)
			{
				int n;
				i += omp_get_num_threads() + omp_get_thread_num();
#pragma omp for nowait
				for (n = 0; n < 10; n++)
					i += j / i;
			}
			], ac_cv_have_openmp="$openmp_cflags")
			CFLAGS="$CFLAGS_X"
			if test "$ac_cv_have_openmp" != no; then
				break
			fi
		done
	)
	if test "$ac_cv_have_openmp" != no; then
		CFLAGS="$CFLAGS $ac_cv_have_openmp"
		cf_have_openmp=yes
		AC_DEFINE(HAVE_OPENMP)
	fi
fi

AC_ARG_WITH(svgalib, [  --without-svgalib       compile without svgalib graphics driver],[if test "$withval" = no; then disable_svgalib=yes; else disable_svgalib=no; fi])
AC_ARG_WITH(x, [  --without-x             compile without X Window System graphics driver],[if test "$withval" = no; then disable_x=yes; else disable_x=no; fi])
AC_ARG_WITH(fb, [  --without-fb            compile without Linux Framebuffer graphics driver],[if test "$withval" = no; then disable_fb=yes; else disable_fb=no; fi])
AC_ARG_WITH(directfb, [  --without-directfb      compile without DirectFB graphics driver],[if test "$withval" = no; then disable_directfb=yes; else disable_directfb=no; fi])
dnl AC_ARG_WITH(sdl, [  --without-sdl           compile without SDL graphics driver],[if test "$withval" = no; then disable_sdl=yes; else disable_sdl=no; fi])
AC_ARG_WITH(pmshell, [  --without-pmshell       compile without PMShell graphics driver],[if test "$withval" = no; then disable_pmshell=yes; else disable_pmshell=no; fi])
AC_ARG_WITH(windows, [  --without-windows       compile without Windows graphics driver],[if test "$withval" = no; then disable_windows=yes; else disable_windows=no; fi])
AC_ARG_WITH(atheos, [  --without-atheos        compile without Atheos graphics driver],[if test "$withval" = no; then disable_atheos=yes; else disable_atheos=no; fi])
AC_ARG_WITH(haiku, [  --without-haiku         compile without Haiku graphics driver],[if test "$withval" = no; then disable_haiku=yes; else disable_haiku=no; fi])
AC_ARG_WITH(grx, [  --without-grx           compile without DOS GRX graphics driver],[if test "$withval" = no; then disable_grx=yes; else disable_grx=no; fi])

	drivers=""

if test "$disable_svgalib" != yes; then
	LIBS_X="$LIBS"
	if test "$static_link" != 0; then
		AC_CHECK_LIB(x86, LRMI_init)
	fi
	LIBS="-lvga $LIBS"
	AC_CACHE_CHECK([for svgalib], ac_cv_have_svgalib,
		AC_TRY_LINK([#include <vga.h>], [vga_setmode(0)], ac_cv_have_svgalib=yes, ac_cv_have_svgalib=no)
	)

	if test "$ac_cv_have_svgalib" = yes; then
		AC_HAVE_FUNCS(vga_runinbackground_version mouse_getposition_6d)
		AC_DEFINE(GRDRV_SVGALIB)
		drivers="$drivers SVGALIB"
	else
		LIBS="$LIBS_X"
	fi
fi

if test "$disable_fb" != yes; then
	AC_CHECK_HEADERS(linux/fb.h linux/kd.h linux/vt.h sys/mman.h)
	if test "$ac_cv_header_linux_fb_h" = yes && test "$ac_cv_header_linux_kd_h" = yes && test "$ac_cv_header_linux_vt_h" = yes && test "$ac_cv_header_sys_mman_h" = yes && test "$ac_cv_header_sys_ioctl_h" = yes && test "$cf_have_gpm" = yes; then
		AC_DEFINE(GRDRV_FB)
		drivers="$drivers FB"
	fi
fi

if test "$disable_directfb" != yes; then
	AC_PATH_PROG(DIRECTFB_CONFIG, directfb-config, no)
	if test "$DIRECTFB_CONFIG" != "no"; then
	        AC_MSG_CHECKING(for DirectFB >= 0.9.17)
        	directfb_version=`$DIRECTFB_CONFIG --version`
		if expr $directfb_version \>= 0.9.17 >/dev/null; then
			AC_MSG_RESULT(yes)

			DIRECTFB_CFLAGS="`$DIRECTFB_CONFIG --cflags`"
			DIRECTFB_LIBS="`$DIRECTFB_CONFIG --libs`"
			pkgconfig_directfb=yes
		else
			AC_MSG_RESULT(no)
			pkgconfig_directfb=no
		fi
	else
		PKG_CHECK_MODULES(DIRECTFB, directfb, pkgconfig_directfb=yes, pkgconfig_directfb=no)
		if test "$PKG_CONFIG" != no -a "$pkgconfig_directfb" = no; then
			AC_MSG_RESULT(no)
		fi
	fi

	if test "$pkgconfig_directfb" = "yes"; then
		CPPFLAGS_X="$CPPFLAGS"
		LIBS_X="$LIBS"

		CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
		LIBS="$DIRECTFB_LIBS $LIBS"

		AC_CACHE_CHECK([for DirectFBInit], ac_cv_have_directfbinit,
			AC_TRY_LINK([#include <directfb.h>], [DirectFBInit(NULL, NULL)], ac_cv_have_directfbinit=yes, ac_cv_have_directfbinit=no)
		)

		if test "$ac_cv_have_directfbinit" = yes; then
			AC_DEFINE(GRDRV_DIRECTFB)
			drivers="$drivers DIRECTFB"
		else
			CPPFLAGS="$CPPFLAGS_X"
			LIBS="$LIBS_X"
		fi
	fi
fi

if test "$disable_x" != yes; then
	CPPFLAGS_X="$CPPFLAGS"
	LIBS_X="$LIBS"

	AC_PATH_X

	if test "$static_link" != 0; then
		AC_CHECK_LIB(pthread, pthread_create)
		AC_CHECK_LIB(dl, dlopen)
		AC_CHECK_LIB(Xdmcp, XdmcpWrap)
		AC_CHECK_LIB(Xau, XauGetBestAuthByAddr)
		AC_CHECK_LIB(xcb, xcb_connect)
		AC_CHECK_LIB(xcb-xlib, xcb_get_request_sent)
	fi

	LIBS="-lX11 $LIBS"
	if test "$have_x" = yes; then
		test -n "$x_libraries" && LIBS="-L$x_libraries $LIBS"
		test -n "$x_includes" && CPPFLAGS="$CPPFLAGS -I$x_includes"
	fi

	AC_CHECK_HEADERS(X11/Xlib.h X11/X.h X11/Xutil.h X11/Xatom.h X11/Xlocale.h X11/keysymdef.h)

	AC_HAVE_FUNCS(XOpenDisplay XOpenIM XCloseIM XCreateIC XDestroyIC XwcLookupString Xutf8LookupString XSupportsLocale XmbTextListToTextProperty)

	AC_CACHE_CHECK([for Xsetlocale], ac_cv_have_Xsetlocale,
		AC_TRY_LINK([#include <X11/Xlocale.h>], [setlocale(0, NULL); return 0;], ac_cv_have_Xsetlocale=yes, ac_cv_have_Xsetlocale=no)
	)
	if test "$ac_cv_have_Xsetlocale" = yes; then
		AC_DEFINE(HAVE_XSETLOCALE)
	fi


	if test "$have_x" = yes -o "$ac_cv_have_x2" != no && test "$ac_cv_func_XOpenDisplay" = yes && test "$ac_cv_header_X11_Xlib_h" = yes && test "$ac_cv_header_X11_X_h" = yes && test "$ac_cv_header_X11_Xutil_h" = yes && test "$ac_cv_header_X11_Xatom_h" = yes && test "$ac_cv_header_X11_keysymdef_h" = yes; then
		AC_DEFINE(GRDRV_X)
		drivers="$drivers X"
	else
		CPPFLAGS="$CPPFLAGS_X"
		LIBS="$LIBS_X"
	fi
fi

dnl if test "$disable_sdl" != yes; then
dnl 	AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
dnl 	if test "$SDL_CONFIG" != "no"; then
dnl 	        AC_MSG_CHECKING(for SDL >= 1.2.0)
dnl         	sdl_version="`$SDL_CONFIG --version`"
dnl 		if expr "$sdl_version" \>= 1.2.0 >/dev/null; then
dnl 			AC_MSG_RESULT(yes)
dnl 			SDL_CFLAGS="`$SDL_CONFIG --cflags`"
dnl 			SDL_LIBS="`$SDL_CONFIG --libs`"
dnl 	           	AC_DEFINE(GRDRV_SDL)
dnl         	   	drivers="$drivers SDL"
dnl 			CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"
dnl 			AC_CHECK_LIB(Xext, XextAddDisplay)
dnl 			LIBS="$SDL_LIBS $LIBS"
dnl 		else
dnl 			AC_MSG_RESULT(no)
dnl 		fi
dnl 	fi
dnl fi

if test "$disable_pmshell" != yes && test "$ac_cv_header_sys_fmutex_h" = yes && test "$ac_cv_have_beginthread" = yes; then
	AC_CACHE_CHECK([for pmshell], ac_cv_have_pmshell,
		AC_TRY_LINK([#define INCL_WIN
			#define INCL_GPI
			#include <os2.h>
			#include <sys/fmutex.h>],
			[_fmutex mutex;
			WinDrawText(NULLHANDLE, -1, NULL, NULL, 0, 0, 0),
			GpiSetPel(NULLHANDLE, NULL)],
		ac_cv_have_pmshell=yes, ac_cv_have_pmshell=no)
	)

	if test "$ac_cv_have_pmshell" = yes; then
		AC_DEFINE(GRDRV_PMSHELL)
		drivers="$drivers PMSHELL"
	fi
fi

if test "$disable_windows" != yes; then
	LIBS_X="$LIBS"
	AC_CHECK_HEADERS(windowsx.h)
	AC_CACHE_CHECK([for ReleaseDC], ac_cv_have_windows11,
		AC_TRY_LINK([
			#include <windows.h>
			#include <pthread.h>],
			[ReleaseDC(NULL, NULL)],
		ac_cv_have_windows11=yes, ac_cv_have_windows11=no)
	)
	if test "$ac_cv_have_windows11" = no; then
		LIBS="-luser32 $LIBS"
		AC_CACHE_CHECK([for ReleaseDC in -luser32], ac_cv_have_windows12,
			AC_TRY_LINK([
				#include <windows.h>
				#include <pthread.h>],
				[ReleaseDC(NULL, NULL)],
			ac_cv_have_windows12=yes, ac_cv_have_windows12=no)
		)
	fi
	AC_CACHE_CHECK([for GdiFlush], ac_cv_have_windows21,
		AC_TRY_LINK([
			#include <windows.h>
			#include <pthread.h>],
			[GdiFlush()],
		ac_cv_have_windows21=yes, ac_cv_have_windows21=no)
	)
	if test "$ac_cv_have_windows21" = no; then
		LIBS="-lgdi32 $LIBS"
		AC_CACHE_CHECK([for GdiFlush in -lgdi32], ac_cv_have_windows22,
			AC_TRY_LINK([
				#include <windows.h>
				#include <pthread.h>],
				[GdiFlush()],
			ac_cv_have_windows22=yes, ac_cv_have_windows22=no)
		)
	fi
	if test "$ac_cv_have_windows11" = yes -o "$ac_cv_have_windows12" = yes &&
	   test "$ac_cv_have_windows21" = yes -o "$ac_cv_have_windows22" = yes; then
		AC_DEFINE(GRDRV_PMSHELL)
		drivers="$drivers WINDOWS"
	else
		LIBS="$LIBS_X"
	fi
fi

if test "$disable_atheos" != yes; then
	old_ext="$ac_ext"
	ac_ext=cpp
	AC_CHECK_HEADERS(gui/view.h gui/window.h gui/desktop.h gui/bitmap.h util/locker.h util/application.h)
	ac_ext="$old_ext"

	if test "$ac_cv_header_atheos_threads_h" = yes &&
	   test "$ac_cv_header_gui_view_h" = yes &&
	   test "$ac_cv_header_gui_window_h" = yes &&
	   test "$ac_cv_header_gui_desktop_h" = yes &&
	   test "$ac_cv_header_gui_bitmap_h" = yes &&
	   test "$ac_cv_header_util_locker_h" = yes &&
	   test "$ac_cv_header_util_application_h" = yes; then
		AC_CHECK_LIB(stdc++, main)
		AC_CHECK_LIB(atheos, main)
		if test "$ac_cv_lib_atheos_main" = no; then
			AC_CHECK_LIB(syllable, main)
		fi
		if test "$ac_cv_lib_atheos_main" = yes -o "$ac_cv_lib_syllable_main" = yes; then
			AC_PROG_CXX
			AC_DEFINE(GRDRV_ATHEOS)
			drivers="$drivers ATHEOS"
			cf_have_atheos=yes
		fi
	fi
fi

if test "$disable_haiku" != yes ; then
	old_ext="$ac_ext"
	ac_ext=cpp
	AC_CHECK_HEADERS(interface/View.h interface/Window.h interface/Screen.h interface/Bitmap.h support/Locker.h app/Application.h)
	ac_ext="$old_ext"

	if test "$ac_cv_header_interface_View_h" = yes &&
	   test "$ac_cv_header_interface_Window_h" = yes &&
	   test "$ac_cv_header_interface_Screen_h" = yes &&
	   test "$ac_cv_header_interface_Bitmap_h" = yes &&
	   test "$ac_cv_header_support_Locker_h" = yes &&
	   test "$ac_cv_header_app_Application_h" = yes; then
		AC_CHECK_LIB(stdc++, main)
		AC_CHECK_LIB(be, main)
		if test "$ac_cv_lib_be_main" = yes; then
			AC_PROG_CXX
			AC_DEFINE(GRDRV_HAIKU)
			drivers="$drivers HAIKU"
			cf_have_haiku=yes
		fi
	fi
fi

if test "$disable_grx" != yes -a "$ac_cv_have_djgpp" = yes; then
	LIBS_X="$LIBS"
	AC_CHECK_HEADERS(grx20.h)
	AC_CHECK_LIB(grx20, GrSetMode)
	if test "$ac_cv_header_grx20_h" = yes &&
	   test "$ac_cv_lib_grx20_GrSetMode" = yes; then
		AC_DEFINE(GRDRV_GRX)
		drivers="$drivers GRX"
	else
		LIBS="$LIBS_X"
	fi
fi


	AC_ARG_WITH(freetype, [  --without-freetype      compile without freetype support],[if test "$withval" = no; then disable_freetype=yes; else disable_freetype=no; fi])
	font_rendering=INTERNAL
	if test "$disable_freetype" != yes; then
		CPPFLAGS_X="$CPPFLAGS"
		LIBS_X="$LIBS"
		AC_ARG_ENABLE(freetype-pkgconfig, [  --disable-freetype-pkgconfig don't use pkgconfig when searching for libfreetype], cf_libfreetype_pkgconfig="$enableval", cf_libfreetype_pkgconfig=yes)
		if test "$cf_libfreetype_pkgconfig" != no; then
			PKG_CHECK_MODULES(LIBFREETYPE, freetype2 fontconfig, pkgconfig_libfreetype=yes, pkgconfig_libfreetype=no)
			if test "$PKG_CONFIG" != no -a "$pkgconfig_libfreetype" = no; then
				AC_MSG_RESULT(no)
			fi
			if test "$pkgconfig_libfreetype" = "yes"; then
				CPPFLAGS="$CPPFLAGS $LIBFREETYPE_CFLAGS"
				LIBS="$LIBFREETYPE_LIBS $LIBS"
			fi
		fi

		AC_CHECK_HEADERS(fontconfig/fontconfig.h ft2build.h)
		AC_HAVE_FUNCS(FcInit FT_Init_FreeType)
		if test "$ac_cv_func_FT_Init_FreeType" != yes; then
			AC_CHECK_LIB(freetype, FT_Init_FreeType)
		fi
		if test "$ac_cv_func_FcInit" != yes; then
			AC_CHECK_LIB(fontconfig, FcInit)
		fi
		if test "$ac_cv_header_ft2build_h" = yes -a "$ac_cv_header_fontconfig_fontconfig_h" = yes &&
		   test "$ac_cv_func_FT_Init_FreeType" = yes -o "$ac_cv_lib_freetype_FT_Init_FreeType" = yes &&
		   test "$ac_cv_func_FcInit" = yes -o "$ac_cv_lib_fontconfig_FcInit" = yes; then
			AC_CHECK_FUNCS(FcGetVersion FT_Library_Version)
			AC_DEFINE(HAVE_FREETYPE)
			font_rendering=FREETYPE
		else
			CPPFLAGS="$CPPFLAGS_X"
			LIBS="$LIBS_X"
		fi
	fi



	AC_ARG_ENABLE(png-pkgconfig, [  --disable-png-pkgconfig don't use pkgconfig when searching for libpng], cf_libpng_pkgconfig="$enableval", cf_libpng_pkgconfig=yes)

	if test "$static_link" != 0; then
		AC_CHECK_LIB(z, inflate)
	fi
	if test "$cf_libpng_pkgconfig" != no; then
		PKG_CHECK_MODULES(LIBPNG, libpng >= 1.0.0, pkgconfig_libpng=yes, pkgconfig_libpng=no)
		if test "$PKG_CONFIG" != no -a "$pkgconfig_libpng" = no; then
			AC_MSG_RESULT(no)
		fi
		if test "$pkgconfig_libpng" = "yes"; then
			CPPFLAGS="$CPPFLAGS $LIBPNG_CFLAGS"
			LIBS="$LIBPNG_LIBS $LIBS"
		else
			PKG_CHECK_MODULES(LIBPNG12, libpng12, pkgconfig_libpng12=yes, pkgconfig_libpng12=no)
			if test "$PKG_CONFIG" != no -a "$pkgconfig_libpng12" = no; then
				AC_MSG_RESULT(no)
			fi
			if test "$pkgconfig_libpng12" = "yes"; then
				CPPFLAGS="$CPPFLAGS $LIBPNG12_CFLAGS"
				LIBS="$LIBPNG12_LIBS $LIBS"
			fi
		fi
	fi
	AC_CHECK_HEADERS(png.h libpng/png.h)
	AC_HAVE_FUNCS(png_create_info_struct)
	if test "$ac_cv_func_png_create_info_struct" != yes; then
		AC_CHECK_LIB(png, png_create_info_struct)
	fi
	if test "$ac_cv_header_png_h" != yes -a "$ac_cv_header_libpng_png_h" != yes || test "$ac_cv_func_png_create_info_struct" != yes -a "$ac_cv_lib_png_png_create_info_struct" != yes; then
		AC_ERROR([You need libpng to compile Links in graphics mode])
	fi

	AC_HAVE_FUNCS(png_set_rgb_to_gray png_get_libpng_ver png_get_image_width png_get_image_height png_get_gAMA png_get_color_type png_get_bit_depth png_set_strip_alpha png_get_valid png_get_sRGB)
	if test "$ac_cv_func_png_get_image_width" != yes ||
	   test "$ac_cv_func_png_get_image_height" != yes ||
	   test "$ac_cv_func_png_get_gAMA" != yes ||
	   test "$ac_cv_func_png_get_color_type" != yes ||
	   test "$ac_cv_func_png_get_bit_depth" != yes ||
	   test "$ac_cv_func_png_set_strip_alpha" != yes ||
	   test "$ac_cv_func_png_get_valid" != yes ||
	   test "$ac_cv_func_png_get_sRGB" != yes; then
		AC_ERROR([Your libpng is too old])
	fi

	AC_ARG_WITH(libjpeg, [  --without-libjpeg	  compile without JPEG support],[if test "$withval" = no; then disable_jpeg=yes; else disable_jpeg=no; fi])
	cf_have_jpeg=no
	if test "$disable_jpeg" != yes; then
		AC_CHECK_HEADERS(jpeglib.h)
		AC_CHECK_LIB(jpeg, jpeg_destroy_decompress)
		if test "$ac_cv_header_jpeglib_h" = yes && test "$ac_cv_lib_jpeg_jpeg_destroy_decompress" = yes; then
			AC_DEFINE(HAVE_JPEG)
			cf_have_jpeg=yes
			image_formats="$image_formats JPEG"
		fi
	fi

	AC_ARG_WITH(libtiff, [  --without-libtiff       compile without TIFF support],[if test "$withval" = no; then disable_tiff=yes; else disable_tiff=no; fi])
	cf_have_tiff=no
	if test "$disable_tiff" != yes; then
		if test "$static_link" != 0; then
			AC_CHECK_LIB(jbig, jbg_enc_init)
		fi
		AC_CHECK_HEADERS(tiffio.h)
		AC_CHECK_LIB(tiff, TIFFClientOpen)
		if test "$ac_cv_header_tiffio_h" = yes && test "$ac_cv_lib_tiff_TIFFClientOpen" = yes; then
			AC_DEFINE(HAVE_TIFF)
			cf_have_tiff=yes
			image_formats="$image_formats TIFF"
		fi
	fi

	AC_ARG_WITH(librsvg, [  --without-librsvg       compile without SVG support],[if test "$withval" = no; then disable_svg=yes; else disable_svg=no; fi])
	cf_have_svg=no
	if test "$disable_svg" != yes && test "$font_rendering" = FREETYPE; then
		CPPFLAGS_X="$CPPFLAGS"
		LIBS_X="$LIBS"
		AC_ARG_ENABLE(svg-pkgconfig, [  --disable-svg-pkgconfig don't use pkgconfig when searching for librsvg], cf_librsvg_pkgconfig="$enableval", cf_librsvg_pkgconfig=yes)
		if test "$cf_librsvg_pkgconfig" != no; then
			PKG_CHECK_MODULES(LIBRSVG, librsvg-2.0 >= 2.0.0 cairo, pkgconfig_librsvg=yes, pkgconfig_librsvg=no)
			if test "$PKG_CONFIG" != no -a "$pkgconfig_librsvg" = no; then
				AC_MSG_RESULT(no)
			fi
			if test "$pkgconfig_librsvg" = "yes"; then
				CPPFLAGS="$CPPFLAGS $LIBRSVG_CFLAGS"
				LIBS="$LIBRSVG_LIBS $LIBS"
			fi
		fi

		AC_CHECK_HEADERS(cairo.h librsvg/rsvg.h librsvg/rsvg-cairo.h librsvg/librsvg-features.h)
		AC_HAVE_FUNCS(rsvg_handle_render_cairo rsvg_handle_read_stream_sync)
		if test "$ac_cv_func_rsvg_handle_render_cairo" != yes; then
			AC_CHECK_LIB(rsvg-2, rsvg_handle_render_cairo)
		fi
		if test "$ac_cv_header_cairo_h" = yes -a "$ac_cv_header_librsvg_rsvg_h" = yes && test "$ac_cv_func_rsvg_handle_render_cairo" = yes -o "$ac_cv_lib_rsvg_2_rsvg_handle_render_cairo" = yes; then
			AC_DEFINE(HAVE_SVG)
			cf_have_svg=yes
			image_formats="$image_formats SVG"
		else
			CPPFLAGS="$CPPFLAGS_X"
			LIBS="$LIBS_X"
		fi
	fi


	if test -z "$drivers" && test "$cf_use_graphics" != no; then
		AC_MSG_ERROR([No graphics drivers found.])
dnl	else
dnl		AC_MSG_RESULT([The following graphics drivers are available:$drivers])
	fi
fi


AM_CONDITIONAL(JAVASCRIPT, test "$cf_use_javascript" = yes)

AM_CONDITIONAL(ATHEOS_GR, test "$cf_have_atheos" = yes)
AM_CONDITIONAL(HAIKU_GR, test "$cf_have_haiku" = yes)

test "$ac_cv_have_emx" = yes && LDFLAGS="$LDFLAGS -Zexe"

AC_HAVE_FUNCS(pthread_sigmask)

if test "$ac_cv_func_pthread_sigmask" = yes; then
	AC_CHECK_LIB(pthread, pthread_sigmask)
fi

AC_OUTPUT(Makefile)

echo "---------------------------------------------------------"
echo "Configuration results:"
echo ""
echo "Event handler:		`echo $cf_have_libevent|tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`"
if test "$cf_have_ipv6" = yes; then
	echo "IPv6:			YES"
else
	echo "IPv6:			NO"
fi
compression="`echo "$compression"|sed 's/^ //'`"
if test -z "$compression"; then compression="NO"; fi
echo "Supported compression:	$compression"
echo "SSL support:		`echo $cf_have_ssl|tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`"
if test "$cf_use_javascript" = yes; then
	echo "Javascript enabled:	YES"
	echo "Regular expressions:	$reg_exp_mode"
fi
if test "$cf_enable_utf8" != no; then
	echo "UTF-8 terminal:		YES"
else
	echo "UTF-8 terminal:		NO"
fi
if test "$cf_have_gpm" = yes; then
	echo "GPM support:		YES"
else
	echo "GPM support:		NO"
fi
if test "$ac_cv_have_emx" = yes; then
	if test "$ac_cv_have_x2" != no; then
		echo "xterm for OS/2 support:	YES"
	else
		echo "xterm for OS/2 support:	NO"
	fi
fi
if test "$cf_use_graphics" != no; then
	echo "Graphics enabled:	YES"
	echo "Graphics drivers:	`echo "$drivers"|sed 's/^ //'`"
	echo "Font rendering:		$font_rendering"
	echo "Image formats:		$image_formats"
	echo "OpenMP:			`echo $cf_have_openmp|tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`"
else echo "Graphics enabled:	NO"; fi
echo "---------------------------------------------------------"
if test "$cf_have_ssl" = "nss"; then
	echo "!!! WARNING !!! NSS encryption library doesn't verify"
	echo "certificates and it can cause lockup of the whole browser"
	echo "if the server is not responding."
	echo "It is recommended to use OpenSSL instead."
	echo "---------------------------------------------------------"
fi
if test -n "`echo "$drivers"|grep -w X`" -a "$ac_cv_header_interix_interix_h" = yes; then
	echo "!!! WARNING !!! Xwindow in Interix is unreliable and it"
	echo "may cause browser lockup."
	echo "It is recommended to use Cygwin instead."
	echo "---------------------------------------------------------"
fi
if test -n "`echo "$drivers"|grep -w WINDOWS`" -a "$ac_cv_func_uwin_path" = yes; then
	echo "!!! WARNING !!! Windows driver in UWIN is buggy."
	echo "It is recommended to use Cygwin instead."
	echo "---------------------------------------------------------"
fi


dnl mv Makefile Makefile.tmp
dnl grep -v DEPS_MAGIC Makefile.tmp >Makefile
dnl rm Makefile.tmp