File: configure.ac

package info (click to toggle)
xapian-bindings 1.4.11-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 22,396 kB
  • sloc: cpp: 395,547; python: 10,047; php: 9,193; cs: 8,291; java: 6,032; perl: 4,571; sh: 4,262; makefile: 1,327; ruby: 693; tcl: 251
file content (1490 lines) | stat: -rw-r--r-- 50,774 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
dnl Process this file with autoconf to produce a configure script.

dnl See xapian-core's HACKING document for details of the reasons for required
dnl versions.
AC_PREREQ([2.63])

m4_define([project_version], [1.4.11])
AC_INIT([xapian-bindings], project_version, [https://xapian.org/bugs])

dnl See xapian-core's HACKING document for details of the reasons for required
dnl versions.
AM_INIT_AUTOMAKE([1.12.2 parallel-tests -Wportability subdir-objects tar-ustar no-dist-gzip dist-xz])
AC_CONFIG_SRCDIR([xapian-headers.i])

AC_CONFIG_HEADERS([config.h])

AC_CONFIG_MACRO_DIR([m4])

dnl Mac OS X needs MACOSX_DEPLOYMENT_TARGET set to 10.3 (or higher) to
dnl successfully link the SWIG generated modules.  The link always fails on
dnl earlier versions of Mac OS X (10.1.4 and 10.2.8 tested), and these versions
dnl are long obsolete now, so we just ensure that MACOSX_DEPLOYMENT_TARGET is
dnl set to at least 10.3.
dnl
dnl NB we must do this *BEFORE* LT_INIT since that is what checks
dnl MACOSX_DEPLOYMENT_TARGET.
AC_CANONICAL_HOST
OVERRIDE_MACOSX_DEPLOYMENT_TARGET=
case $host in
*86*-darwin8*|*-darwin[[91]]*)
  dnl On 10.5 or later, and 10.4 on x86, the deployment target defaults to the
  dnl OS version, so we don't need to override on these.
  ;;
*-darwin*)
  case $MACOSX_DEPLOYMENT_TARGET in
  "")
    OVERRIDE_MACOSX_DEPLOYMENT_TARGET=10.3 ;;
  10.[[012]])
    AC_MSG_WARN([Overriding MACOSX_DEPLOYMENT_TARGET from $MACOSX_DEPLOYMENT_TARGET to 10.3])
    OVERRIDE_MACOSX_DEPLOYMENT_TARGET=10.3 ;;
  esac
  ;;
esac
AM_CONDITIONAL(OVERRIDE_MACOSX_DEPLOYMENT_TARGET, test -n "$OVERRIDE_MACOSX_DEPLOYMENT_TARGET")
AC_SUBST(OVERRIDE_MACOSX_DEPLOYMENT_TARGET)
if test -n "$OVERRIDE_MACOSX_DEPLOYMENT_TARGET" ; then
  MACOSX_DEPLOYMENT_TARGET=$OVERRIDE_MACOSX_DEPLOYMENT_TARGET
fi

dnl Use libtool to manage our libraries, but don't build static libraries as
dnl the bindings only have a use for dynamic ones.
LT_PREREQ([2.2.6])
LT_INIT([disable-static])

dnl -no-undefined causes problems on Mac OS X with at least some
dnl MACOSX_DEPLOYMENT_TARGET settings, so only pass -no-undefined on
dnl platforms where it is required in order to link a shared library at
dnl all (Windows is the main one).
NO_UNDEFINED=
if test unsupported = "$allow_undefined_flag" ; then
  NO_UNDEFINED=-no-undefined
fi
AC_SUBST(NO_UNDEFINED)

dnl Checks for programs.
AC_PROG_CXX

# Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
case $host_os in
  linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
    dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
    link_all_deplibs_CXX=no
    ;;
esac

case $host_os in
  linux*)
    dnl Extract search path from ldconfig which is more reliable than the way
    dnl vanilla libtool extracts them from ld.so.conf.
    d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
    test -z "$d" || sys_lib_dlsearch_path_spec=$d
    ;;
esac

dnl Run tests using the C++ compiler.
AC_LANG_CPLUSPLUS

dnl Probe for any options needed to enable C++11 support.
AX_CXX_COMPILE_STDCXX_11

dnl Check for xapian-core.
XO_LIB_XAPIAN([], [],
    [xapian-config]regexp(project_version,
			  [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
XO_REQUIRE([1.4.0])

NEED_JNILIB_EXT=no
NEED_INTREE_DYLD=no
INTREE_DYLD_PATH=
case $host_os in
darwin*)
  NEED_JNILIB_EXT=yes
  dnl If we're building against an uninstalled xapian-core, xapian-config
  dnl --libs will give an error.
  if $XAPIAN_CONFIG --libs >/dev/null 2>/dev/null ; then
    :
  else
    NEED_INTREE_DYLD=yes
    dnl $XAPIAN_LIBS may have some options first, so grab the last argument,
    dnl which should be the .la file.
    set x $XAPIAN_LIBS
    as_fn_arith $# - 1
    shift $as_val
    INTREE_DYLD_PATH=$1
    dnl Make sure the path is absolute.
    case $INTREE_DYLD_PATH in
      /*) ;;
      *) INTREE_DYLD_PATH=`pwd`/$INTREE_DYLD_PATH ;;
    esac
    dnl Add .libs or equivalent.
    INTREE_DYLD_PATH=`echo "$INTREE_DYLD_PATH"|sed 's,\(.*/\).*,\1,'`$lt_cv_objdir
    AC_SUBST([INTREE_DYLD_PATH])
  fi
  ;;
esac
AM_CONDITIONAL(NEED_JNILIB_EXT, test yes = "$NEED_JNILIB_EXT")
AM_CONDITIONAL(NEED_INTREE_DYLD, test yes = "$NEED_INTREE_DYLD")

dnl We want XAPIAN_CXXFLAGS to be used for configure tests, so add it to
dnl CXXFLAGS for the duration of configure.
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"

dnl COMPAT_VERSION is the version of xapian-core that "matches" our version.
dnl We allow for bindings being version 0.8.5.1 while xapian-core is 0.8.5.
dnl COMPAT_VERSION also ignores any _git123 suffix which snapshots will have.
COMPAT_VERSION=[`echo "$PACKAGE_VERSION"|sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/'`]
AC_SUBST(COMPAT_VERSION)

dnl VERSION_NO_SNAPSHOT simply has any _git123 suffix removed.
VERSION_NO_SNAPSHOT=[`echo "$PACKAGE_VERSION"|sed 's/_.*$//'`]
AC_SUBST(VERSION_NO_SNAPSHOT)

dnl We only need to set docdir for compatibility with autoconf < 2.60 - this
dnl code can be removed once we move to requiring autoconf 2.60 or newer.
test -n "$docdir" || docdir='${datadir}/doc/${PACKAGE_TARNAME}'
AC_SUBST(docdir)

AC_ARG_ENABLE(visibility,
  [AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
  [case ${enableval} in
    yes|no) ;;
    *) AC_MSG_ERROR([bad value ${enableval} for --disable-visibility]) ;;
  esac])

dnl Only probe for SWIG and enable SWIG rules in makefiles if
dnl configure --enable-maintainer-mode is used.
AM_MAINTAINER_MODE

AC_ARG_ENABLE(documentation,
  [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild shipped documentation [default=maintainer-mode]])],
  [case ${enableval} in
    yes|no) ;;
    *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
  esac])
test -z "$enable_documentation" && enable_documentation=$USE_MAINTAINER_MODE
AM_CONDITIONAL(DOCUMENTATION_RULES, test x"$enable_documentation" = xyes)
AM_CONDITIONAL(MAINTAINER_NO_DOCS, test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno)

if test yes = "$enable_documentation" ; then
  dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
  dnl Also look for rst2html.py, which archlinux reportedly installs it as.
  AC_PATH_PROGS(RST2HTML, [rst2html rst2html.py], [])
  test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python-docutils)])
fi

if test x$USE_MAINTAINER_MODE = xyes; then
  dnl Check for swig - this does most of the work for the bindings.
  dnl AC_PATH_PROGS only honours an already set SWIG if it's a full
  dnl path.  Listing it in the "to be searched" list like this allows
  dnl ./configure SWIG=myswig to work.
  swigoverridden=${SWIG+yes}
  AC_PATH_PROGS(SWIG, ["${SWIG-swig}"], [])
  AC_ARG_VAR(SWIG, [SWIG interface generator (only needed by Xapian developers)])
  if test -z "$SWIG" ; then
    AC_MSG_ERROR([Can't find SWIG utility])
  fi
  dnl Check for new enough SWIG.
  dnl
  dnl 3.0.6 fixes compiling the Perl bindings under C++11 ("seed" macro issue).
  dnl 3.0.8 fixes conversion of integers large than an int in Python 3.
  dnl 3.0.9 fixes generation of unnecessary _swigconstant helpers for Python.
  dnl 3.0.12 fixes segfault on unload with PHP 7.1
  v=`$SWIG -version 2>&1|sed 's/^SWIG Version \([[0-9\.]]*\).*/\1/p;d'`
  case $v in
    [[012].*|3.0.?|3.0.1[01]|""])
      msg="SWIG >= 3.0.12 required (you have ${v:-an unknown version})"
      if test -n "$swigoverridden" ; then
	dnl If SWIG was explicitly set, make this a warning only.
	AC_MSG_WARN([$msg])
      else
	AC_MSG_ERROR([$msg])
      fi ;;
  esac
  SWIG_FLAGS=`$XAPIAN_CONFIG --swigflags`
  AC_SUBST(SWIG_FLAGS)
  XAPIAN_HEADER_DIRS=
  XAPIAN_HEADERS=
  for a in $SWIG_FLAGS ; do
    case $a in
    -I*)
      d=`echo "x$a"|sed 's/^x-I//'`
      dnl Quote each entry in XAPIAN_HEADER_DIRS with "".
      XAPIAN_HEADER_DIRS=$XAPIAN_HEADER_DIRS' "'$d'"'
      for f in "$d/"*.h "$d/xapian/*.h" ; do
	if test -f "$f" ; then
	  XAPIAN_HEADERS="$XAPIAN_HEADERS $f"
	fi
      done
      ;;
    esac
  done
  AC_SUBST([XAPIAN_HEADER_DIRS])
  AC_SUBST([XAPIAN_HEADERS])

  dnl Need perl in maintainer mode to generate the except.i file for python.
  AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
  test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
  dnl Need doxygen in maintainer mode to convert C++ doxygen comments to Python
  dnl docstrings.
  AC_PATH_PROG(DOXYGEN, doxygen, [])
  test -z "$DOXYGEN" && AC_MSG_ERROR([doxygen is required to build documentation])
fi

AC_ARG_WITH(python,
  AC_HELP_STRING([--with-python], [enable Python 2 bindings]),
  [],
  [with_python=])

AC_ARG_WITH(python3,
  AC_HELP_STRING([--with-python3], [enable Python 3 bindings]),
  [],
  [with_python3=])

AC_ARG_WITH(php,
  AC_HELP_STRING([--with-php], [enable PHP 5 bindings]),
  [],
  [with_php=])

AC_ARG_WITH(php7,
  AC_HELP_STRING([--with-php7], [enable PHP 7 bindings]),
  [],
  [with_php7=])

AC_ARG_WITH(ruby,
  AC_HELP_STRING([--with-ruby], [enable Ruby bindings]),
  [],
  [with_ruby=])

AC_ARG_WITH(tcl,
  AC_HELP_STRING([--with-tcl], [enable Tcl bindings]),
  [],
  [with_tcl=])

AC_ARG_WITH(csharp,
  AC_HELP_STRING([--with-csharp], [enable CSharp bindings]),
  [],
  [with_csharp=])

AC_ARG_WITH(java,
  AC_HELP_STRING([--with-java], [enable Java bindings]),
  [],
  [with_java=])

AC_ARG_WITH(perl,
  AC_HELP_STRING([--with-perl], [enable Perl bindings]),
  [],
  [with_perl=])

AC_ARG_WITH(lua,
  AC_HELP_STRING([--with-lua], [enable Lua bindings]),
  [],
  [with_lua=])

case $with_python$with_python3$with_php$with_php7$with_ruby$with_tcl$with_csharp$with_java$with_perl$with_lua in
*yes*)
  dnl Default unspecified values to no.
  test -z "$with_python" && with_python=no
  test -z "$with_python3" && with_python3=no
  test -z "$with_php" && with_php=no
  test -z "$with_php7" && with_php7=no
  test -z "$with_tcl" && with_tcl=no
  test -z "$with_csharp" && with_csharp=no
  test -z "$with_java" && with_java=no
  test -z "$with_ruby" && with_ruby=no
  test -z "$with_perl" && with_perl=no
  test -z "$with_lua" && with_lua=no
  ;;
esac

BINDINGS=

if test no != "$with_python" ; then
  dnl For backward compatibility:
  : ${PYTHON2="$PYTHON"}
  : ${PYTHON2_INC="$PYTHON_INC"}
  : ${PYTHON2_LIB="$PYTHON_LIB"}
  : ${PYTHON2_LIBS="$PYTHON_LIBS"}
  : ${PYTHON2_SO="$PYTHON_SO"}
  dnl See comment for AC_PATH_PROGS(SWIG, ...).
  if test -n "$PYTHON2" ; then
    AC_PATH_PROGS(PYTHON2, ["$PYTHON2"], [])
  else
    AC_PATH_PROGS(PYTHON2, [python2 python], [])
  fi
  AC_ARG_VAR(PYTHON2, [Python 2 interpreter])
  if test -n "$PYTHON2" ; then
    dnl Require Python 2.6 or newer.  Older versions are essentially
    dnl unsupported upstream.
    AC_MSG_CHECKING([$PYTHON2 version])
    version=`$PYTHON2 -c 'import sys;print("%d.%d" % sys.version_info[[:2]])' 2>/dev/null`
    case $version in
    [2.[6-9]*|2.[1-5][0-9]*])
      AC_MSG_RESULT([$version])
      ;;
    [[3-9].*])
      AC_MSG_RESULT([$version (too new - use --with-python3 for Python 3 support)])
      if test yes = "$with_python" ; then
	AC_MSG_ERROR([Use --with-python3 for Python 3 support ($PYTHON2 is $version)])
      fi
      PYTHON2=
      ;;
    *)
      AC_MSG_RESULT([$version (too old)])
      if test yes = "$with_python" ; then
	AC_MSG_ERROR([Only Python 2.6 or newer is supported ($PYTHON2 is $version)])
      fi
      PYTHON2=
      ;;
    esac
    if test -n "$PYTHON2" ; then
      if $PYTHON2 -c 'import distutils.sysconfig' 2>/dev/null ; then
	PYTHON2_INC=`$PYTHON2 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_inc().replace(os.sep,"/"))'`
	AC_SUBST(PYTHON2_INC)
      else
	if test yes = "$with_python" ; then
	  AC_MSG_ERROR([Couldn't import Python module distutils.sysconfig - you probably need to install a python-dev or python-devel package])
	else
	  AC_MSG_WARN([Couldn't import Python module distutils.sysconfig - you probably don't have a python-dev or python-devel package installed])
	  PYTHON2=
	fi
      fi
    fi
    AC_MSG_CHECKING([for python2 sphinx module])
    if $PYTHON2 -c 'import sphinx;print(repr(sphinx.main))' >&5 2>&5 ; then
      AC_MSG_RESULT([yes])
    else
      AC_MSG_RESULT([no])
      if test yes = "$with_python" ; then
	AC_MSG_ERROR([Couldn't import sphinx module and call sphinx.main() for Python2 - try package python-sphinx])
      fi
      PYTHON2=
    fi
    if test -n "$PYTHON2" ; then
      dnl Check that Python.h is there, which is a good way to check that
      dnl the appropriate python-dev package has been installed.
      AC_MSG_CHECKING([for $PYTHON2_INC/Python.h])
      if test -f "$PYTHON2_INC/Python.h" ; then
	AC_MSG_RESULT(yes)
	AC_MSG_CHECKING([for directory to install python2 bindings in])
	if test -z "$PYTHON2_LIB" ; then
	  PYTHON2_LIB=`$PYTHON2 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_lib(1).replace(os.sep,"/"))'`
	fi
	AC_MSG_RESULT([$PYTHON2_LIB])
	AC_ARG_VAR(PYTHON2_LIB, [Directory to install python2 bindings in])

	AC_MSG_CHECKING([for python2 libraries to link against])
	case $host_os in
	mingw* | pw32*)
	  PYTHON2_LIBS=`$PYTHON2 -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
	cygwin*)
	  PYTHON2_LIBS=`$PYTHON2 -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
	*)
	  PYTHON2_LIBS= ;;
	esac
	AC_SUBST(PYTHON2_LIBS)
	AC_MSG_RESULT([$PYTHON2_LIBS])

	AC_MSG_CHECKING([for python2 module extension])
	dnl Usually ".so", but for example, Mac OS X uses ".dylib".
	PYTHON2_SO=`$PYTHON2 -c 'import distutils.sysconfig;print(distutils.sysconfig.get_config_vars("SO")[[0]])'`
	AC_SUBST(PYTHON2_SO)
	AC_MSG_RESULT([$PYTHON2_SO])
	BINDINGS="$BINDINGS python"
      else
	AC_MSG_RESULT([no (install python-dev or python-devel package or similar)])
	if test yes = "$with_python" ; then
	  AC_MSG_ERROR([Python.h not found])
	fi
      fi
    fi
  fi
fi

if test no != "$with_python3" ; then
  dnl See comment for AC_PATH_PROGS(SWIG, ...).
  if test -n "$PYTHON3" ; then
    AC_PATH_PROGS(PYTHON3, ["$PYTHON3"], [])
  else
    AC_PATH_PROGS(PYTHON3, [python3 python], [])
  fi
  AC_ARG_VAR(PYTHON3, [Python 3 interpreter])
  if test -n "$PYTHON3" ; then
    dnl Require Python 3.2 or newer, as that's the oldest version we can
    dnl easily test with.  If anyone's keen to support older versions, please
    dnl test and send in any patches needed to get it to work.
    AC_MSG_CHECKING([$PYTHON3 version])
    version=`$PYTHON3 -c 'import sys;print("%d.%d" % sys.version_info[[:2]])' 2>/dev/null`
    case $version in
    [3.[2-9]*|3.1[0-9]*|[4-9].*])
      AC_MSG_RESULT([$version])
      ;;
    *)
      AC_MSG_RESULT([$version (too old)])
      if test yes = "$with_python3" ; then
	AC_MSG_ERROR([Only Python 3.2 or newer is supported ($python3 is $version)])
      fi
      PYTHON3=
      ;;
    esac
    if test -n "$PYTHON3" ; then
      if $PYTHON3 -c 'import distutils.sysconfig' 2>/dev/null ; then
	PYTHON3_INC=`$PYTHON3 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_inc().replace(os.sep,"/"))'`
	AC_SUBST(PYTHON3_INC)
      else
	if test yes = "$with_python3" ; then
	  AC_MSG_ERROR([Couldn't import Python module distutils.sysconfig - you probably need to install a python3-dev or python3-devel package])
	else
	  AC_MSG_WARN([Couldn't import Python module distutils.sysconfig - you probably don't have a python3-dev or python3-devel package installed])
	  PYTHON3=
	fi
      fi
    fi
    AC_MSG_CHECKING([for python3 sphinx module])
    if $PYTHON3 -c 'import sphinx;print(repr(sphinx.main))' >&5 2>&5 ; then
      AC_MSG_RESULT([yes])
    else
      AC_MSG_RESULT([no])
      if test yes = "$with_python3" ; then
	AC_MSG_ERROR([Couldn't import sphinx module and call sphinx.main() for Python3 - try package python3-sphinx])
      fi
      PYTHON3=
    fi
    if test -n "$PYTHON3" ; then
      dnl Check that Python.h is there, which is a good way to check that
      dnl the appropriate python3-dev package has been installed.
      AC_MSG_CHECKING([for $PYTHON3_INC/Python.h])
      if test -f "$PYTHON3_INC/Python.h" ; then
	AC_MSG_RESULT(yes)
	AC_MSG_CHECKING([for directory to install python3 bindings in])
	if test -z "$PYTHON3_LIB" ; then
	  PYTHON3_LIB=`$PYTHON3 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_lib(1).replace(os.sep,"/"))'`
	fi
	AC_MSG_RESULT([$PYTHON3_LIB])
	AC_ARG_VAR(PYTHON3_LIB, [Directory to install python3 bindings in])

	AC_MSG_CHECKING([for python3 libraries to link against])
	case $host_os in
	mingw* | pw32*)
	  PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
	cygwin*)
	  PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
	*)
	  PYTHON3_LIBS= ;;
	esac
	AC_SUBST(PYTHON3_LIBS)
	AC_MSG_RESULT([$PYTHON3_LIBS])

	AC_MSG_CHECKING([for python3 module extension])
	dnl Usually ".so", but for example, Mac OS X uses ".dylib".
	PYTHON3_SO=`$PYTHON3 -c 'import distutils.sysconfig;print(distutils.sysconfig.get_config_vars("SO")[[0]])'`
	AC_SUBST(PYTHON3_SO)
	AC_MSG_RESULT([$PYTHON3_SO])

	AC_MSG_CHECKING([for tag for cached compiled scripts])
	PYTHON3_CACHE_TAG=`$PYTHON3 -c 'import imp;print(imp.get_tag())'`
	AC_SUBST(PYTHON3_CACHE_TAG)
	AC_MSG_RESULT([$PYTHON3_CACHE_TAG])

	AC_MSG_CHECKING([for extension of cached and optimized python3 bytecode])
	PYTHON3_CACHE_OPT1_EXT=`$PYTHON3 -c 'import imp,sys;print("%s.pyo"%imp.get_tag()) if sys.version_info.minor<5 else print("{1}{2}".format(*imp.util.cache_from_source("",optimization=1).rpartition(imp.get_tag())))'`
	AC_SUBST(PYTHON3_CACHE_OPT1_EXT)
	AC_MSG_RESULT([$PYTHON3_CACHE_OPT1_EXT])

	BINDINGS="$BINDINGS python3"
      else
	AC_MSG_RESULT([no (install python3-dev or python3-devel package or similar)])
	if test yes = "$with_python3" ; then
	  AC_MSG_ERROR([Python.h not found])
	fi
      fi
    fi
  fi
fi

if test x$USE_MAINTAINER_MODE = xyes; then
  dnl Need python in maintainer mode to run doxy2swig.py.
  dnl Either Python 2 or 3 is OK for this.
  if test -n "$PYTHON2" ; then
    PYTHON=$PYTHON2
  elif test -n "$PYTHON3" ; then
    PYTHON=$PYTHON3
  else
    AC_PATH_PROGS(PYTHON, [python2 python python3], [])
  fi
  test -z "$PYTHON" && AC_MSG_ERROR([python is required in maintainer mode])
fi

if test no != "$with_php" ; then
  dnl See comment for AC_PATH_PROGS(SWIG, ...).
  if test -n "$PHP_CONFIG" ; then
    AC_PATH_PROGS(PHP_CONFIG, ["$PHP_CONFIG"], [])
  fi
  if test -z "$PHP_CONFIG" ; then
    AC_PATH_PROGS(PHP_CONFIG, [php-config5 php-config], [])
  fi
  AC_ARG_VAR(PHP_CONFIG, [php-config utility for PHP5])
  AC_ARG_VAR(PHP, [PHP5 interpreter (optional - only needed to run PHP5 testsuite with)])
  if test -n "$PHP_CONFIG" ; then
    AC_MSG_CHECKING([$PHP_CONFIG version])
    version=`$PHP_CONFIG --version 2>/dev/null`
    case $version in
    [[01234].*|5.[01234].*|[6789].*])
      AC_MSG_RESULT([$version (not supported, PHP5 bindings need PHP 5.x where x >= 5)])
      if test yes = "$with_php" ; then
	AC_MSG_ERROR([$PHP_CONFIG reports version $version - PHP5 bindings need PHP 5.x where x >= 5])
      fi
      with_php=no
      ;;
    *)
      AC_MSG_RESULT([$version])
      PHP_MAJOR_VERSION=`echo "$version"|cut -d. -f1`
      ;;
    esac
    AC_SUBST(PHP_MAJOR_VERSION)

    if test no != "$with_php" ; then
      AC_MSG_CHECKING([for PHP5 extension directory])
      if test -z "$PHP_EXTENSION_DIR" ; then
	PHP_EXTENSION_DIR=`$PHP_CONFIG --extension-dir`
      fi
      AC_MSG_RESULT([$PHP_EXTENSION_DIR])
      AC_ARG_VAR(PHP_EXTENSION_DIR, [Directory to install PHP5 extensions in])
    fi

    if test no != "$with_php" ; then
      PHP_INC=`$PHP_CONFIG --includes`
      AC_SUBST(PHP_INC)
      save_CPPFLAGS=$CPPFLAGS
      CPPFLAGS="$CPPFLAGS $PHP_INC"
      dnl One of SGI's SuSE boxes has php-config but no headers.
      AC_CHECK_HEADER(zend.h, [], [
	if test yes = "$with_php" ; then
	  AC_MSG_ERROR(['$PHP_CONFIG --includes' reports '$PHP_INC' but zend.h can't be included from there])
	fi
	with_php=no], [ ])
      CPPFLAGS=$save_CPPFLAGS
    fi

    if test no != "$with_php" ; then
      if test x"$PHP" = x ; then
	AC_MSG_CHECKING([for PHP5 interpreter])
	dnl PHP5's php-config supports --php-binary, so just use that.
	PHP=`$PHP_CONFIG --php-binary 2>/dev/null`
	if test x"$PHP" != x ; then
	  if $PHP -r 'exit(0);' 2> /dev/null ; then
	    if $PHP -r 'exit(PHP_MAJOR_VERSION==5?0:1);' 2> /dev/null ; then
	      AC_MSG_RESULT([$PHP])
	    else
	      dnl We get /usr/bin/php on Debian, which might be PHP7:
	      dnl https://bugs.debian.org/819139
	      if ${PHP}5 -r 'exit(PHP_MAJOR_VERSION==5?0:1);' 2> /dev/null ; then
		PHP=${PHP}5
		AC_MSG_RESULT([$PHP])
	      else
		AC_MSG_RESULT([no ($PHP isn't PHP5)])
		PHP=
	      fi
	    fi
	  else
	    AC_MSG_RESULT([no ($PHP does not work)])
	    PHP=
	  fi
	else
	  AC_MSG_RESULT([not found])
	fi
      else
	AC_PATH_PROGS(PHP, ["$PHP"], [])
      fi
      if test x"$PHP" = x ; then
	AC_MSG_WARN([No PHP5 interpreter found - PHP5 bindings tests will be skipped])
	dnl The skiptest script just returns exit code 77.
	PHP='$(top_srcdir)/skiptest'
      else
	AC_MSG_CHECKING([for PHP5 path separator])
	PHP_PATH_SEPARATOR=`$PHP -r 'echo PATH_SEPARATOR;'`
	AC_SUBST([PHP_PATH_SEPARATOR])
	AC_MSG_RESULT([$PHP_PATH_SEPARATOR])
      fi

      case $host_os in
      mingw* | pw32*)
	dnl This is a bit of an informed guess, pending more information from
	dnl someone who actually has mingw and wants to build the PHP bindings
	dnl there.  FIXME.
	PHP_LIBS="-L`$PHP_CONFIG --prefix` -lphp${PHP_MAJOR_VERSION}ts" ;;
      cygwin*)
	PHP_LIBS="-lphp${PHP_MAJOR_VERSION}lib" ;;
      *)
	PHP_LIBS= ;;
      esac
      AC_SUBST(PHP_LIBS)
      BINDINGS="$BINDINGS php"
    fi
  fi
fi

if test no != "$with_php7" ; then
  dnl See comment for AC_PATH_PROGS(SWIG, ...).
  if test -n "$PHP_CONFIG7" ; then
    AC_PATH_PROGS(PHP_CONFIG7, ["$PHP_CONFIG7"], [])
  fi
  if test -z "$PHP_CONFIG7" ; then
    AC_PATH_PROGS(PHP_CONFIG7, [php-config7.3 php-config7.2 php-config7.1 php-config7.0 php-config], [])
  fi
  AC_ARG_VAR(PHP_CONFIG7, [php-config utility for PHP7])
  AC_ARG_VAR(PHP7, [PHP7 interpreter (optional - only needed to run PHP7 testsuite with)])
  if test -n "$PHP_CONFIG7" ; then
    AC_MSG_CHECKING([$PHP_CONFIG7 version])
    version=`$PHP_CONFIG7 --version 2>/dev/null`
    case $version in
    [[0123456].*])
      AC_MSG_RESULT([$version (not supported, PHP7 bindings need PHP >= 7.0)])
      if test yes = "$with_php7" ; then
	AC_MSG_ERROR([$PHP_CONFIG7 reports version $version - PHP7 bindings need >= 7.0])
      fi
      with_php7=no
      ;;
    *)
      AC_MSG_RESULT([$version])
      PHP7_MAJOR_VERSION=`echo "$version"|cut -d. -f1`
      ;;
    esac
    AC_SUBST(PHP7_MAJOR_VERSION)

    if test no != "$with_php7" ; then
      AC_MSG_CHECKING([for PHP7 extension directory])
      if test -z "$PHP7_EXTENSION_DIR" ; then
	PHP7_EXTENSION_DIR=`$PHP_CONFIG7 --extension-dir`
      fi
      AC_MSG_RESULT([$PHP7_EXTENSION_DIR])
      AC_ARG_VAR(PHP7_EXTENSION_DIR, [Directory to install PHP7 extensions in])
    fi

    if test no != "$with_php7" ; then
      PHP7_INC=`$PHP_CONFIG7 --includes`
      AC_SUBST(PHP7_INC)
    fi

    if test no != "$with_php7" ; then
      if test x"$PHP7" = x ; then
	AC_MSG_CHECKING([for PHP7 interpreter])
	dnl PHP7's php-config supports --php-binary, so just use that.
	PHP7=`$PHP_CONFIG7 --php-binary 2>/dev/null`
	if test x"$PHP7" != x ; then
	  if $PHP7 -r 'exit(0);' 2> /dev/null ; then
	    if $PHP7 -r 'exit(PHP_MAJOR_VERSION==7?0:1);' 2> /dev/null ; then
	      AC_MSG_RESULT([$PHP7])
	    else
	      AC_MSG_RESULT([no ($PHP7 isn't PHP7)])
	      PHP7=
	    fi
	  else
	    AC_MSG_RESULT([no ($PHP7 does not work)])
	    PHP7=
	  fi
	else
	  AC_MSG_RESULT([not found])
	fi
      else
	AC_PATH_PROGS(PHP7, ["$PHP7"], [])
      fi
      if test x"$PHP7" = x ; then
	AC_MSG_WARN([No PHP7 interpreter found - PHP7 bindings tests will be skipped])
	dnl The skiptest script just returns exit code 77.
	PHP7='$(top_srcdir)/skiptest'
      else
	AC_MSG_CHECKING([for PHP7 path separator])
	PHP7_PATH_SEPARATOR=`$PHP7 -r 'echo PATH_SEPARATOR;'`
	AC_SUBST([PHP7_PATH_SEPARATOR])
	AC_MSG_RESULT([$PHP7_PATH_SEPARATOR])
      fi

      case $host_os in
      mingw* | pw32*)
	dnl This is a bit of an informed guess, pending more information from
	dnl someone who actually has mingw and wants to build the PHP bindings
	dnl there.  FIXME.
	PHP7_LIBS="-L`$PHP_CONFIG7 --prefix` -lphp${PHP7_MAJOR_VERSION}ts" ;;
      cygwin*)
	PHP7_LIBS="-lphp${PHP7_MAJOR_VERSION}lib" ;;
      *)
	PHP7_LIBS= ;;
      esac
      AC_SUBST(PHP7_LIBS)
      BINDINGS="$BINDINGS php7"
    fi
  fi
fi

if test no != "$with_tcl" ; then
  dnl The documented minimum requirement is Tcl 8.5.  Older versions may work,
  dnl but we don't test with them regularly, and they are no longer supported
  dnl upstream.  Also ::tcl::pckconfig was added in Tcl 8.5, which makes the
  dnl tests below simpler and more reliable.
  dnl
  dnl If you really want to build with an older version, run configure with
  dnl a lower tcl_min and specify at least TCL_INC explicitly:
  dnl
  dnl ./configure tcl_min=8.4 TCL_INC=/usr/include/tcl8.4
  dnl
  dnl We definitely need at least Tcl 8.1 for TCL_STUBS.
  : ${tcl_min=8.5}
  AC_PATH_PROGS(TCLSH, ["${TCLSH-tclsh}"], [])
  AC_ARG_VAR(TCLSH, [Tcl interpreter])
  if test -n "$TCLSH" ; then
    AC_MSG_CHECKING([$TCLSH version])
    if echo 'if {$tcl_version < '"$tcl_min"' } { exit 1 }'|$TCLSH 2> /dev/null ; then
      tcl_version=`echo 'puts "$tcl_version"'|$TCLSH`
      AC_MSG_RESULT([$tcl_version])

      AC_ARG_VAR(TCL_LIB, [Directory to install Tcl files into])
      if test -z "$TCL_LIB" ; then
	[TCL_LIB=`echo 'foreach d $tcl_pkgPath {if {![regexp {/share(/|$)} $d]} {break}};puts $d'|$TCLSH`]
      fi
      AC_SUBST(TCL_LIB)

      AC_ARG_VAR([TCL_INC], [Directory to include for Tcl headers])
      if test -z "$TCL_INC" ; then
	dnl ::tcl::pkgconfig was added in Tcl 8.5.
	[TCL_INC=`echo 'puts [::tcl::pkgconfig get includedir,runtime]'|$TCLSH 2> /dev/null`]
      fi

      dnl Check that the headers are there (the tcl8.N-dev package
      dnl may not be installed).
      TCL_CPPFLAGS=
      AC_MSG_CHECKING([for tcl.h from Tcl $tcl_version])
      if test x"$TCL_INC" != x && test -f "$TCL_INC/tcl.h" ; then
	tcl_hdr_version=`awk '($1 == "#define" && $2 == "TCL_VERSION") {print $3}' "$TCL_INC/tcl.h"|sed 's/"//g'`
	if test x"$tcl_hdr_version" = x"$tcl_version" ; then
	  AC_MSG_RESULT([$TCL_INC/tcl.h])
	  BINDINGS="$BINDINGS tcl8"
	  if test x"$TCL_INC" != x"/usr/include" ; then
	    TCL_CPPFLAGS="-I$TCL_INC"
	  fi
	else
	  AC_MSG_RESULT([not found])
	  if test yes = "$with_tcl" ; then
	    AC_MSG_ERROR([Found tcl.h from version $tcl_hdr_version, not $tcl_version - specify TCL_INC on configure command line])
	  fi
	  TCLSH=
	fi
      else
	AC_MSG_RESULT([not found])
	if test yes = "$with_tcl" ; then
	  AC_MSG_ERROR([Can't find tcl.h])
	fi
	TCLSH=
      fi

      if test -n "$TCLSH" ; then
	dnl Cygwin needs to link with -ltcl8.5 or similar.
	TCL_LIBS=
	case $host_os in
	cygwin*)
	  AC_CHECK_LIB([tcl$tcl_version], [Tcl_Init],
		       [TCL_LIBS="-ltcl$tcl_version"],
		       [AC_MSG_ERROR([libtcl$tcl_version not found])])
	  ;;
	*)
	  dnl ::tcl::pkgconfig was added in Tcl 8.5, but prior to 8.6 it isn't
	  dnl necessary to link against -ltclstub anyway.
	  [tcl_libdir_runtime=`echo 'puts [::tcl::pkgconfig get libdir,runtime]'|$TCLSH 2> /dev/null`]
	  if test -n "$tcl_libdir_runtime" ; then
	    for x in "/tcl$tcl_version" "" ; do
	      TCLCONFIG_SH=$tcl_libdir_runtime$x/tclConfig.sh
	      if test -r "$TCLCONFIG_SH" ; then
		eval "`sed 's/^TCL_STUB_LIB_SPEC=/TCL_LIBS=/p;d' $TCLCONFIG_SH`"
		break
	      fi
	    done
	  fi
	  TCL_CPPFLAGS="$TCL_CPPFLAGS -DUSE_TCL_STUBS" ;;
	esac
      fi

      AC_SUBST(TCL_CPPFLAGS)
      AC_SUBST(TCL_LIBS)
    else
      AC_MSG_RESULT([< $tcl_min (too old)])
      if test yes = "$with_tcl" ; then
	AC_MSG_ERROR([$TCLSH too old (Tcl $tcl_min or newer required)])
      fi
    fi
  else
    if test yes = "$with_tcl" ; then
      AC_MSG_ERROR([tclsh not found])
    fi
  fi
fi

if test no != "$with_csharp" ; then
  csc_note=
  AC_ARG_VAR(CSC, [CSharp compiler command])
  if test -n "$CSC" ; then
    AC_PATH_PROGS(CSC, ["$CSC"], [])
  fi
  if test -z "$CSC" ; then
    dnl First we try cli-csc and mono-csc, which are used by Debian and Ubuntu
    dnl as "alternatives" which can be mapped to the CSharp compiler the admin
    dnl favours.
    AC_PATH_PROGS(CSC, [cli-csc mono-csc], [])
    if test -z "$CSC" ; then
      dnl mcs is the Mono CSharp compiler, which is a unified compiler
      dnl available from Mono 2.11 (and also the compiler in Mono 1.0, but
      dnl that's no longer relevant).
      AC_PATH_PROGS(CSC, [mcs], [])
      if test -n "$CSC" ; then
	dnl There are other tools called mcs (such as /usr/bin/mcs on Tru64),
	dnl so we check that the mcs we found understands --version which is
	dnl sufficient to distinguish mono's mcs from the Tru64 one.
	AC_MSG_CHECKING([whether $CSC is from GNU Mono])
	if (exec >&5 2>&5;$CSC --version </dev/null;exit $?) ; then
	  AC_MSG_RESULT(yes)
	else
	  AC_MSG_RESULT(no)
	  CSC=
	  csc_note="$csc_note (found different mcs program)"
	fi
      fi
    fi
    if test -z "$CSC" ; then
      dnl csc is the Microsoft CSharp compiler.
      AC_PATH_PROGS(CSC, [csc], [])
      if test -n "$CSC" ; then
	dnl Chicken (the Scheme-to-C compiler) includes a tool called csc so we
	dnl check if the output from "csc -version" includes the word chicken
	dnl which is sufficient to distinguish Chicken's csc from Microsoft's
	dnl csc.exe.
	AC_MSG_CHECKING([whether $CSC is for CSharp])
	if $CSC -version 2>/dev/null|grep chicken > /dev/null ; then
	  AC_MSG_RESULT(no)
	  CSC=
	  csc_note="$csc_note (found Chicken csc program)"
	else
	  AC_MSG_RESULT(yes)
	fi
      fi
    fi
  fi

  if test -n "$CSC" ; then
    AC_ARG_VAR(GACUTIL, [gacutil utility to use for CSharp bindings])
    if test -n "$GACUTIL" ; then
      AC_PATH_PROGS(GACUTIL, ["$GACUTIL"], [])
    fi
    if test -z "$GACUTIL" ; then
      AC_PATH_PROGS(GACUTIL, [cli-gacutil gacutil], [])
    fi

    AC_ARG_VAR(SN, [sn utility to use for CSharp bindings])
    if test -n "$SN" ; then
      AC_PATH_PROGS(SN, ["$SN"], [])
    fi
    if test -z "$SN" ; then
      AC_PATH_PROGS(SN, [cli-sn sn], [])
    fi
    if test -n "$GACUTIL" -a -n "$SN" ; then
      AC_MSG_CHECKING([whether the CSharp compiler works])
      [echo 'class conftest { public static void Main() { System.Console.WriteLine("OK"); } }' > conftest.cs]
      if (exec >&5 2>&5;$CSC /out:conftest.exe conftest.cs;exit $?) ; then
	AC_MSG_RESULT(yes)
	AC_MSG_CHECKING([whether CSharp programs can just be run])
	if test OK = "`./conftest.exe 2> /dev/null`" ; then
	  AC_MSG_RESULT(yes)
	  RUN_CSHARP=
	else
	  AC_MSG_RESULT(no)
	  AC_PATH_PROGS(CLI, ["${CLI-cli}"], [])
	  if test -z "$CLI" ; then
	    AC_PATH_PROGS(CLI, [mono ilrun], [])
	  fi
	  AC_ARG_VAR(CLI, [CSharp bytecode interpreter (optional - only needed to run CSharp testsuite with)])
	  if test -n "$CLI" ; then
	    AC_MSG_CHECKING([whether $CLI can run CSharp programs])
	    if test OK = "`$CLI ./conftest.exe 2> /dev/null`" ; then
	      AC_MSG_RESULT(yes)
	      RUN_CSHARP=$CLI
	    else
	      AC_MSG_RESULT([no - CSharp tests will be skipped])
	      RUN_CSHARP='\$(top_srcdir)/skiptest'
	    fi
	  else
	    AC_MSG_RESULT([not found - CSharp tests will be skipped])
	    RUN_CSHARP='\$(top_srcdir)/skiptest'
	  fi
	fi
	AC_SUBST(RUN_CSHARP)

	AC_MSG_CHECKING([for extra flags for $GACUTIL])
	GACUTIL_FLAGS='/package $(ASSEMBLY) /gacdir $(libdir) /root $(DESTDIR)$(libdir)'
	dnl Microsoft's gacutil accepts fewer options than Mono's
	$GACUTIL /\?|grep '\<Mono\>' >/dev/null || GACUTIL_FLAGS=
	AC_SUBST([GACUTIL_FLAGS])
	if test -z "$GACUTIL_FLAGS" ; then
	  AC_MSG_RESULT([no])
	else
	  AC_MSG_RESULT([$GACUTIL_FLAGS])
	fi

	BINDINGS="$BINDINGS csharp"
      else
	AC_MSG_RESULT(no)
	if test yes = "$with_csharp" ; then
	  AC_MSG_ERROR([CSharp compiler $CSC doesn't work])
	fi
      fi
    else
      if test yes = "$with_csharp" ; then
	if test -z "$GACUTIL" ; then
	  AC_MSG_ERROR([Mono gacutil not found])
	elif test -z "$SN" ; then
	  AC_MSG_ERROR([Mono sn not found])
	fi
      fi
    fi
  else
    if test yes = "$with_csharp" ; then
      AC_MSG_ERROR([CSharp compiler not found$csc_note])
    fi
  fi
fi

JAVA_CPPFLAGS=
if test no != "$with_java" ; then
  AC_PATH_PROGS(JAVA, ["${JAVA-java}"], [],
	[${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
  AC_PATH_PROGS(JAVAC, ["${JAVAC-javac}"], [],
	[${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
  AC_PATH_PROGS(JAR, ["${JAR-jar}"], [],
	[${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
  AC_ARG_VAR(JAVA, [Java interpreter command])
  AC_ARG_VAR(JAVAC, [Java compiler command])
  AC_ARG_VAR(JAR, [java jar utility])
  AC_ARG_VAR(JAVA_HOME, [Pathname of the directory where the JDK is installed])
  AC_ARG_VAR(JDK_HOME, [Pathname of the directory where the JDK is installed])
  AC_ARG_VAR(JNI_INCLUDE_DIR, [Pathname of the directory where jni.h is installed])
  if test -n "$JAVA" -a -n "$JAVAC" -a -n "$JAR" ; then
    dnl Eric says:
    dnl  The JNI library *requires* "Java 2", which is 1.2 or better.
    dnl
    dnl So checking for jni.h presumably implicitly checks we have "Java 2".
    dnl Note: jni.h #defines JNI_VERSION_1_[12468] (but not 3, 5 or 7 it seems).
    dnl So we could check for one of these if we want to check for a particular
    dnl JDK version...
    java_ok=no
    AC_CHECK_HEADER([jni.h], [java_ok=yes], [
      dnl We need to look for jni.h in /usr/lib/jvm/java-gcj/include on some
      dnl Debian and Ubuntu boxes at least.  And on Mac OS X, jni.h lives
      dnl in /System/Library/Frameworks/JavaVM.framework/Headers.
      SAVE_CPPFLAGS=$CPPFLAGS
      real_javac=$JAVAC
      dnl Avoid endlessly traversing if there's a symlink loop.
      for count in 1 2 3 4 5 6 7 8 9 ; do
	r=`readlink "$real_javac"`
	test -n "$r" || break
	real_javac=$r
      done
      dnl Translate ".../bin/javac" to ".../include".
      [rel_jnidir=`echo "$real_javac"|sed 's!/[^/]*/[^/]*$!/include!'`]
      for jnidir in \
	  $JNI_INCLUDE_DIR \
	  ${JAVA_HOME+"$JAVA_HOME/include"} \
	  ${JDK_HOME+"$JDK_HOME/include"} \
	  "$rel_jnidir" \
	  /System/Library/Frameworks/JavaVM.framework/Headers ; do
	CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
	AC_MSG_CHECKING([for jni.h in $jnidir])
	if test -f "$jnidir/jni.h" ; then
	  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
	  if test yes = $java_ok ; then
	    AC_MSG_RESULT([yes])
	    JAVA_CPPFLAGS=-I$jnidir
	    break
	  fi

	  dnl For OpenJDK (and maybe others) we have to specify an extra -I
	  dnl option for an OS-specific subdirectory containing a "jni_md.h"
	  dnl header which is included by "jni.h".  Sadly we seem to need to
	  dnl hardcode a mapping for these platform names - the list below
	  dnl was determined by inspecting the source code of OpenJDK 8.
	  jni_host_os=
	  case $host_os in
	    linux*)
	      jni_host_os=linux ;;
	    solaris*)
	      jni_host_os=solaris ;;
	    mingw* | pw32* | cygwin*)
	      jni_host_os=win32 ;;
	    darwin*)
	      jni_host_os=darwin ;;
	    *bsd*)
	      jni_host_os=bsd ;;
	    aix*)
	      jni_host_os=aix ;;
	  esac
	  if test -n "$jni_host_os" ; then
	    CPPFLAGS="$CPPFLAGS -I$jnidir/$jni_host_os"
	    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
	    if test yes = $java_ok ; then
	      AC_MSG_RESULT([yes, requires additional -I$jnidir/$jni_host_os])
	      JAVA_CPPFLAGS="-I$jnidir -I$jnidir/$jni_host_os"
	      break
	    fi
	  fi
	  AC_MSG_RESULT([found, but not usable])

	  CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
	else
	  AC_MSG_RESULT([no])
	fi
      done
      CPPFLAGS=$SAVE_CPPFLAGS
      test noyes = $java_ok$with_java && AC_MSG_ERROR([jni.h not found])
      ], [ ])
    AC_SUBST(JAVA_CPPFLAGS)
    if test yes = $java_ok ; then
      AC_MSG_CHECKING([for Java path separator])
      [echo 'public class conftest { public static void main(String[] args) { System.out.println(System.getProperty("path.separator")); } }' > conftest.java]
      if (exec >&5 2>&5;$JAVAC conftest.java;exit $?) ; then
	JAVA_PATHSEP=`$JAVA conftest 2>&5`
	AC_SUBST(JAVA_PATHSEP)
	if test -n "$JAVA_PATHSEP" ; then
	  AC_MSG_RESULT($JAVA_PATHSEP)
	  BINDINGS="$BINDINGS java"

	  dnl If -Xcheck:jni is supported then run tests with it.
	  dnl
	  dnl ... except that with OpenJDK 8 and 9 -Xcheck:jni seems to report
	  dnl false positives and so can't usefully be turned on in this
	  dnl situation.  Recheck this with future versions.
dnl	  AC_MSG_CHECKING([for $JAVA -Xcheck:jni option])
dnl	  JAVA_PATHSEP2=`$JAVA conftest 2>&5`
	  JAVA_CHECK_JNI_OPTION=
dnl	  if test "$JAVA_PATHSEP" = "$JAVA_PATHSEP2" ; then
dnl	    JAVA_CHECK_JNI_OPTION=-Xcheck:jni
dnl	    AC_MSG_RESULT([yes])
dnl	  else
dnl	    AC_MSG_RESULT([no])
dnl	  fi
	  AC_SUBST([JAVA_CHECK_JNI_OPTION])
	else
	  AC_MSG_RESULT([failed to run test program])
	  java_ok=no
	fi
      else
	AC_MSG_RESULT([failed to compile test program])
	java_ok=no
      fi
      if test no = "$java_ok" ; then
	test yes = "$with_java" && AC_MSG_ERROR([Couldn't compile and run a simple Java test program])
      fi
    fi
  else
    if test yes = "$with_java" ; then
      if test -z "$JAVA" ; then
	AC_MSG_ERROR([java not found])
      elif test -z "$JAVAC" ; then
	AC_MSG_ERROR([javac not found])
      elif test -z "$JAR" ; then
	AC_MSG_ERROR([jar not found])
      fi
    fi
  fi
fi

if test no != "$with_ruby" ; then
  dnl See comment for AC_PATH_PROGS(SWIG, ...).
  if test -n "$RUBY" ; then
    AC_PATH_PROGS(RUBY, ["$RUBY"], [])
  else
    AC_PATH_PROGS(RUBY, [ruby], [])
  fi
  AC_ARG_VAR(RUBY, [Ruby interpreter])
  if test -n "$RUBY" ; then
    dnl Require Ruby 2.1 or newer.
    AC_MSG_CHECKING([$RUBY version])
    dnl RUBY_VERSION works with 1.6.  Once we've checked we have at least 1.8
    dnl we can safely use RbConfig below (RbConfig requires Ruby 1.8).
    version=`$RUBY -e 'print RUBY_VERSION' 2>/dev/null`
    case $version in
    "")
      AC_MSG_RESULT([\$RUBY -e 'print RUBY_VERSION' didn't work])
      if test yes = "$with_ruby" ; then
	AC_MSG_ERROR([Working Ruby interpreter not found])
      fi
      RUBY=
      ;;
    [[01].*|2.0.*])
      AC_MSG_RESULT([$version (too old)])
      if test yes = "$with_ruby" ; then
	AC_MSG_ERROR([Only Ruby 2.1 or newer is supported ($RUBY is $version)])
      fi
      RUBY=
      ;;
    esac
    if test -n "$RUBY" ; then
      AC_MSG_RESULT([$version])
      AC_ARG_VAR(RUBY_INC, [Directory where ruby.h can be found])
      if test -z "$RUBY_INC" ; then
	dnl Ruby 1.9 added rubyhdrdir.
	[RUBY_INC=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyhdrdir"]'`]
      fi
      AC_SUBST(RUBY_INC)
      dnl Check that ruby.h is there, which is a good way to check that
      dnl the appropriate ruby-dev package has been installed.
      AC_MSG_CHECKING([for $RUBY_INC/ruby.h])
      if test -f "$RUBY_INC/ruby.h" ; then
	AC_MSG_RESULT(yes)

	AC_ARG_VAR(RUBY_INC_ARCH, [Directory where ruby/config.h can be found])
	if test -z "$RUBY_INC_ARCH" ; then
	  dnl Ruby 2.0 and later have rubyarchhdrdir.
	  [RUBY_INC_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyarchhdrdir"]'`]
	fi
	AC_SUBST(RUBY_INC_ARCH)

	AC_ARG_VAR(RUBY_LIB, [Directory to install ruby files into])
	if test -z "$RUBY_LIB" ; then
	  [RUBY_LIB=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitelibdir"]'`]
	fi
	AC_SUBST(RUBY_LIB)

	AC_ARG_VAR(RUBY_LIB_ARCH, [Directory to install ruby binary modules into])
	if test -z "$RUBY_LIB_ARCH" ; then
	  [RUBY_LIB_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitearchdir"]'`]
	fi
	AC_SUBST(RUBY_LIB_ARCH)

	RUBY_LIBS=
	if test unsupported = "$allow_undefined_flag" ; then
	  dnl For Microsoft Windows and a few other platforms.
	  [RUBY_LIBS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["LIBRUBYARG"]'`]
	fi
	AC_SUBST(RUBY_LIBS)

	dnl rdoc is included as part of the Ruby core distribution, so run it
	dnl at build time rather shipping the rather large generated output in
	dnl our source tarball.
	if test -n "$RDOC" ; then
	  AC_PATH_PROGS(RDOC, ["$RDOC"], [])
	else
	  dnl Try replace the *last* 'ruby' with 'rdoc'.
	  rdoc_best_guess=`echo "$RUBY"|sed 's,\(.*\)ruby,\1rdoc,'`
	  AC_PATH_PROGS(RDOC, ["$rdoc_best_guess"], [])
	  if test -z "$RDOC"; then
	    AC_PATH_PROGS(RDOC, [rdoc], [])
	  fi
	fi
	if test -n "$RDOC"; then
	  BINDINGS="$BINDINGS ruby"
	fi
      else
	AC_MSG_RESULT([no (install ruby-dev or ruby-devel package or similar)])
	if test yes = "$with_ruby" ; then
	  AC_MSG_ERROR([ruby.h not found])
	fi
      fi
      RUBY_DLEXT=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["DLEXT"]]'`
      AC_SUBST(RUBY_DLEXT)
    fi
  fi
fi

if test no != "$with_perl" ; then
  AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
  AC_ARG_VAR(PERL, [perl interpreter])
  if test -n "$PERL" ; then
    if test -z "$PERL_INC" ; then
      PERL_INC=`$PERL -MConfig -e 'print $Config{archlibexp}, "/CORE"'`
    fi
    AC_SUBST(PERL_INC)

    AC_ARG_VAR(PERL_ARCH, [Directory to install architecture-dependent perl files into])
    if test -z "$PERL_ARCH" ; then
      PERL_ARCH=`$PERL -MConfig -e 'print $Config{installsitearch}'`
    fi
    AC_SUBST(PERL_ARCH)

    AC_ARG_VAR(PERL_LIB, [Directory to install architecture-independent perl files into])
    if test -z "$PERL_LIB" ; then
      PERL_LIB=`$PERL -MConfig -e 'print $Config{installsitelib}'`
    fi
    AC_SUBST(PERL_LIB)

    AC_ARG_VAR(PERL_SO, [Extension for compiled Perl modules])
    if test -z "$PERL_SO" ; then
      PERL_SO=`$PERL -MConfig -e 'print ".", $Config{dlext}'`
    fi
    AC_SUBST(PERL_SO)

    if test -z "$PERL_XAPIAN_VERSION" ; then
      dnl snapshot versions look like 1.2.3_git123 or 1.2.3_svn14971
      case $PACKAGE_VERSION in
      *_git*)
	PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_git/./'` ;;
      *_svn*)
	PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_svn/./'` ;;
      *)
	PERL_XAPIAN_VERSION=$PACKAGE_VERSION.0 ;;
      esac
    fi
    AC_SUBST(PERL_XAPIAN_VERSION)

    BINDINGS="$BINDINGS perl"
  else
    if test yes = "$with_perl" ; then
      AC_MSG_ERROR([perl not found])
    fi
  fi
fi

if test no != "$with_lua" ; then
  AC_PATH_PROGS(LUA, ["${LUA-lua}"], [])
  AC_ARG_VAR(LUA, [lua interpreter])
  if test -n "$LUA" ; then
    dnl We need Lua 5.1 or later.
    AC_MSG_CHECKING([$LUA version])
    lua_version=`$LUA -e 'print(_VERSION)' | cut -f 2 -d ' ' 2>&AS_MESSAGE_LOG_FD`

    case $lua_version in
    [[01234]].*|5.0|5.0.*)
      AC_MSG_RESULT([$lua_version < 5.1 (too old)])
      if test yes = "$with_lua" ; then
        AC_MSG_ERROR([$LUA too old (Lua 5.1 or newer required)])
      fi
      LUA=
      ;;
    "")
      AC_MSG_RESULT([\$LUA -e 'print(_VERSION)' | cut -f 2 -d ' ' didn't work])

      if test yes = "$with_lua" ; then
        AC_MSG_ERROR([Working Lua interpreter not found])
      fi
      LUA=
      ;;
    esac

    if test -n "$LUA" ; then
      AC_MSG_RESULT([$lua_version])

      AC_ARG_VAR([LUA_LIB], [Directory to install compiled Lua modules into])
      AC_ARG_VAR([LUA_SO], [Extension for compiled Lua modules (e.g. LUA_SO=.so)])
      AC_MSG_CHECKING([for directory to install compiled Lua modules into])
      if test -z "$LUA_LIB" -o -z "$LUA_SO" ; then
	lua_cpath=`$LUA -e 'require("package") print(package.cpath)'`
	dnl Look for the first absolute path in lua_cpath which has leaf
	dnl "?.<ext>" and put the directory part into lua_lib and <ext> into
	dnl lua_so.  If LUA_SO was specified by the user, only consider
	dnl entries where <ext> matches LUA_SO.
	lua_lib=
	lua_so=
	case $LUA_SO in
	  "")
	   [lua_so_pat='[a-zA-Z][a-zA-Z]*'] ;;
	  .*)
	    dnl If LUA_SO has a leading '.', remove it.
	    lua_so_pat=`AS_ECHO("$LUA_SO")|sed 's/^\.//'` ;;
	  *)
	    dnl If LUA_SO was specified without a leading '.', add one to the
	    dnl value substituted into Makefile.in.
	    lua_so_pat=$LUA_SO
	    LUA_SO=.$LUA_SO
	    ;;
	esac
	while test x"$lua_cpath" != x ; do
	  [lua_lib=`expr X"$lua_cpath" : X'\([^;]*\)'`]
	  lua_so=.`expr X"$lua_lib" : X'/.*/?\.\('"$lua_so_pat"'\)$'`
	  case $lua_so in
	    .|.lua)
	      dnl If someone has foolishly put ?.lua in cpath, ignore them.
	      lua_lib=
	      ;;
	    *)
	      lua_lib=`expr X"$lua_lib" : X'\(/.*\)/?\.'"$lua_so_pat"'$'`
	      break ;;
	  esac
	  [lua_cpath=`expr X"$lua_cpath" : X'[^;]*;*\(.*\)'`]
	done
	test -n "$LUA_LIB" || LUA_LIB=$lua_lib
	test -n "$LUA_SO" || LUA_SO=$lua_so
      fi
      if test -z "$LUA_LIB"; then
	AC_MSG_RESULT([not found])
      else
	AC_MSG_RESULT([$LUA_LIB])
      fi
      AC_SUBST([LUA_LIB])

      AC_MSG_CHECKING([for extension to use for compiled Lua modules])
      if test -z "$LUA_SO"; then
	AC_MSG_RESULT([not found])
      else
	AC_MSG_RESULT([$LUA_SO])
      fi
      AC_SUBST([LUA_SO])

      AC_MSG_CHECKING([for Lua header files])
      AC_ARG_VAR([LUA_INC], [Directory to include for lua headers])
      if test -z "$LUA_INC" ; then
        dirs="/usr/include/lua$lua_version /usr/local/include/lua$lua_version"
        for i in $dirs ; do
          if test -r "$i/lua.h"; then
            LUA_INC=$i
            break
          fi
        done
      fi

      if test -z "$LUA_INC" ; then
        AC_MSG_RESULT([not found])
      else
        AC_MSG_RESULT([$LUA_INC])
        BINDINGS="$BINDINGS lua"
        LUA_CPPFLAGS="-I$LUA_INC"
      fi
      AC_SUBST([LUA_CPPFLAGS])
    fi
  else
    if test yes = "$with_lua" ; then
      AC_MSG_ERROR([lua not found])
    fi
  fi
fi

AC_SUBST(BINDINGS)

case $BINDINGS in
*python*) dnl Matches python and/or python3
  dnl C++11 has thread_local
  dnl GCC and some others have __thread
  dnl MSVC and some others have __declspec(thread)
  AC_MSG_CHECKING([for thread-local storage qualifier])
  AC_ARG_VAR([THREAD_LOCAL], [thread-local storage qualifier])
  if test -z "$THREAD_LOCAL" ; then
    for t in thread_local __thread '__declspec(thread)' ; do
      AC_COMPILE_IFELSE([AC_LANG_SOURCE([[static $t void * p;]])],
			[THREAD_LOCAL=$t; break])
    done
  fi
  if test -z "$THREAD_LOCAL" ; then
    AC_MSG_RESULT([unknown, disabling thread-local support])
  else
    AC_MSG_RESULT([$THREAD_LOCAL])
    AC_DEFINE_UNQUOTED([THREAD_LOCAL], [$THREAD_LOCAL], [Thread local storage qualifier (undefined if no TLS)])
  fi
  ;;
esac

dnl Set flags to control warnings (enable more, or disable annoying ones)
dnl and other compiler specific flags.
SWIG_CXXFLAGS=
if test yes = "$GXX" ; then
  dnl Python itself is compiled with -fno-strict-aliasing, and it appears
  dnl it's safest to follow this lead when compiling the SWIG generated
  dnl interface code.  E.g.:
  dnl   https://article.gmane.org/gmane.comp.gcc.devel/74692
  dnl The code SWIG generates for other languages seems to have similar
  dnl issues too, so just turn this on for all of them.
  dnl
  dnl There's no need to check -fno-strict-aliasing is supported as it works
  dnl with GCC 2.95 and we don't support anything older.
  SWIG_CXXFLAGS="-fno-strict-aliasing"

  dnl We need to explicitly link against -lstdc++ on OpenBSD (discovered
  dnl on OpenBSD 3.7 with GCC 3.3.5 but this appears to be due to a
  dnl deliberate decision on the part of OpenBSD developers).  Luckily
  dnl we can just always specify -lstdc++ explicitly if GCC is the
  dnl compiler and libtool will eliminate the duplicate on other
  dnl platforms.
  XAPIAN_LIBS="$XAPIAN_LIBS -lstdc++"

  dnl Intel's C++ compiler is identified as "GXX" by autoconf's test - check
  dnl which we actually have.
  AC_EGREP_CPP(yes,
    [#ifdef __INTEL_COMPILER
     yes
     #endif
    ],
    [
      dnl Intel's compiler:
      dnl
      dnl -w1 stops the avalanche of uninteresting "remark" messages.
      dnl -wd... disables warnings which don't have good code workarounds.
      dnl
      dnl Swig generated code gives lots of unused and uninitialized warnings.
      dnl They're non-harmful, so suppress them.
      SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -w1 -wd177,1572"
    ],
    [
      dnl GCC or clang:
      dnl
      dnl Swig generated code gives lots of unused and uninitialized warnings.
      dnl They're non-harmful, so suppress them.
      SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -Wno-unused -Wno-uninitialized"
    ])

  if test no != "$enable_visibility"; then
    dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
    dnl on mingw).
    AC_MSG_CHECKING([if $CXX -fvisibility=hidden works])
    if echo 'int bar() __attribute__((visibility("default"))); int foo() {return 42;}'|$CXX -Werror -fvisibility=hidden -c -oconftest.o -xc++ - >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
      AC_MSG_RESULT([yes])
      SWIG_CXXFLAGS="$SWIG_CXXFLAGS -fvisibility=hidden"
    else
      AC_MSG_RESULT([no])
    fi
  fi
fi
AC_SUBST(SWIG_CXXFLAGS)

dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
CXXFLAGS=$save_CXXFLAGS

dnl Required for auto regeneration to work in a combined maintainer-mode tree.
: ${AUTOM4TE=autom4te}
AC_SUBST([AUTOM4TE])

AC_CONFIG_FILES([Makefile
 doxygen_xml.conf
 xapian-version.h
 python/Makefile python/docs/conf.py python/version.i
 python3/Makefile python3/docs/conf.py python3/version.i
 php/Makefile
 php7/Makefile
 java/Makefile
 tcl8/Makefile tcl8/pkgIndex.tcl
 csharp/Makefile csharp/AssemblyInfo.cs
 ruby/Makefile
 perl/Makefile perl/util.i
 lua/Makefile
 xapian-bindings.spec
 ])
AC_OUTPUT

echo ""
if test -z "$BINDINGS" ; then
  echo "*** Not found the required tools for building bindings for any"
  echo "*** supported language!"
  echo "***"
  echo "*** You may need to install -dev or -devel packages for the languages"
  echo "*** you want to build bindings for."
  echo "***"
  echo "*** For details of how to point configure at tools not on PATH, see:"
  echo "***     ./configure --help"
else
  echo "*** Building bindings for languages:" $BINDINGS
fi
echo ""
if test "$COMPAT_VERSION" != "$XAPIAN_VERSION" ; then
  release_series=[`echo "$COMPAT_VERSION"|sed 's/[0-9][0-9]*$//'`]
  case $XAPIAN_VERSION in
  $release_series*) ;;
  *)
    AC_MSG_ERROR([Xapian library is version ${XAPIAN_VERSION-<0.8.2} which is from a different release series to bindings $PACKAGE_VERSION, so they aren't compatible.])
    ;;
  esac
  dnl 0.8.2 was the first version which set XAPIAN_VERSION
  AC_MSG_WARN([Xapian library is version ${XAPIAN_VERSION-<0.8.2} but the bindings are version $PACKAGE_VERSION - we strongly recommend using matching versions.])
fi