-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
1639 lines (1474 loc) · 58.3 KB
/
configure.ac
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
dnl Process this file with autoconf to produce a configure script.
dnl NB When updating the version for a release, update LIBRARY_VERSION_INFO
dnl below too.
AC_INIT([xapian-core], [1.4.9], [https://xapian.org/bugs])
dnl See HACKING document for details of the reasons for required versions.
AC_PREREQ([2.64])
dnl Extract from the libtool info manual:
dnl
dnl Here are a set of rules to help you update your library version information:
dnl
dnl 1. Start with version information of '0:0:0' for each libtool library.
dnl
dnl 2. Update the version information only immediately before a public
dnl release of your software. More frequent updates are unnecessary,
dnl and only guarantee that the current interface number gets larger
dnl faster.
dnl
dnl 3. If the library source code has changed at all since the last
dnl update, then increment REVISION ('C:R:A' becomes 'C:r+1:A').
dnl
dnl 4. If any interfaces have been added, removed, or changed since the
dnl last update, increment CURRENT, and set REVISION to 0.
dnl
dnl 5. If any interfaces have been added since the last public release,
dnl then increment AGE.
dnl
dnl 6. If any interfaces have been removed since the last public release
dnl then set AGE to 0.
dnl
dnl LIBRARY_VERSION_INFO for libxapian:
dnl 29:1:7 1.2.23 No API changes (except new inline methods)
dnl 30:0:0 1.4.0 Extensive API changes
dnl 31:0:1 1.4.1 New Weight subclasses, etc
dnl 32:0:2 1.4.2 Database::get_document() with flags
dnl 33:0:3 1.4.3 Database::locked() method
dnl 33:1:3 1.4.4 No API changes
dnl 34:0:4 1.4.5 Database::get_total_length() method
dnl 35:0:5 1.4.6 C++11 move support added
dnl 35:1:5 1.4.7 No API changes
dnl 36:0:6 1.4.8 STEM_SOME_FULL_POS added
dnl 36:1:6 1.4.9 No API changes
LIBRARY_VERSION_INFO=36:1:6
AC_SUBST([LIBRARY_VERSION_INFO])
LIBRARY_VERSION_SUFFIX=
AC_SUBST([LIBRARY_VERSION_SUFFIX])
dnl Disabled for stable release series.
test x"$program_suffix" != xNONE || program_suffix=
dnl Where xapian.h, etc go. In development release append "/xapian-1.3".
incdir=$includedir
AC_SUBST([incdir])
dnl Check the build directory doesn't contain a space, so we die early with
dnl a helpful error.
case `pwd` in
*' '*)
AC_MSG_ERROR([You can't build in a directory whose path contains a space])
;;
esac
dnl Check the source directory doesn't contain a space, so we die early with
dnl a helpful error. FIXME: Unfortunately, configure seems to choke before
dnl it gets to us so this code doesn't get a chance to fire.
case $0 in
*' '*)
dnl Note: for in-tree builds, the build directory test above will fire
dnl before this can.
AC_MSG_ERROR([You can't build with sources in a directory whose path contains a space])
;;
esac
dnl Check the prefix to install in doesn't contain a space, so we die early with
dnl a helpful error.
case $prefix in
*' '*)
AC_MSG_ERROR([You can't install in a directory whose path contains a space])
;;
esac
dnl Note if the user specified a particular C++ compiler so we can give a more
dnl appropriate error message if we can't link a simple C++ program.
original_CXX=
if test -n "$CXX" ; then
original_CXX="CXX=$CXX"
elif test -n "$CCC" ; then
original_CXX="CCC=$CCC"
fi
dnl See HACKING document for details of the reasons for required versions.
AM_INIT_AUTOMAKE([1.11 -Wportability tar-ustar no-dist-gzip dist-xz std-options])
AC_CONFIG_SRCDIR([matcher/multiandpostlist.cc])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_PROG_AR
dnl Use libtool to manage our libraries.
LT_PREREQ([2.2.8])
dnl Default to only building shared libraries.
dnl
dnl Building both shared and static means having to compile the files which
dnl make up the library twice on most platforms. Shared libraries are the
dnl better option for most users, and if anyone really wants static libraries,
dnl they can configure with --enable-static (or --enable-static=xapian-core if
dnl configuring a combined tree with the bindings).
dnl
dnl We don't export any data items from the library, so it should be safe to
dnl enable win32-dll without decorating any declarations specially.
LT_INIT([disable-static win32-dll])
dnl -no-undefined causes problems on Solaris with Sun CC in C++11 mode, so only
dnl pass -no-undefined on platforms where it is required in order to link a
dnl shared library at all (Windows is the main one).
NO_UNDEFINED=
if test unsupported = "$allow_undefined_flag" ; then
NO_UNDEFINED=-no-undefined
fi
AC_SUBST(NO_UNDEFINED)
AM_CXXFLAGS=
dnl A standard "gotcha" for mingw and cygwin users is to not set up their
dnl PATH correctly, so that MSDOS FIND.EXE is found before Unix find. Help
dnl them out by checking for this condition, rather than letting libtool
dnl fail in obscure ways. NB check the *BUILD* OS, not the host one!
case $build_os in
*mingw* | *cygwin* | pw32*)
find /dirunlikelytoexist >/dev/null 2>&1
if test $? = 2 ; then
dnl Unix find will return 1 if the directory didn't exist, or 0 if
dnl it did.
AC_MSG_ERROR([
*** You appear to have an MSDOS-like FIND.EXE in your PATH ahead of any
*** UNIX-like find. This misconfiguration will confuse libtool - you'll need
*** to make sure you have a UNIX-like find installed and fix your PATH, then
*** rerun configure. For more information, see:
***
*** https://www.cygwin.com/faq/faq.html#faq.using.find
])
fi
;;
esac
dnl Add parameters for aclocal
dnl (This must come after AM_INIT_AUTOMAKE, since it modifies ACLOCAL)
ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
dnl disable "maintainer only" rules by default
AM_MAINTAINER_MODE
dnl Checks for programs.
AC_PROG_CXX
AC_CANONICAL_HOST
# 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
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
dnl On these platforms, libtool emits a warning if -no-install is passed,
dnl and uses -no-fast-install instead - the least ugly way to avoid that
dnl warnings seems to be to duplicate the above list of platforms from
dnl libtool and use -no-fast-install on them directly.
NO_INSTALL=-no-fast-install ;;
*)
NO_INSTALL=-no-install ;;
esac
AC_SUBST([NO_INSTALL])
dnl For reasons which are beyond me, if autoconf can't find a C++ compiler
dnl it will set CXX to g++ (which obviously won't work) rather than actually
dnl telling the user that it couldn't find a C++ compiler and telling them
dnl to either install one or set CXX if there's one configure failed to find.
dnl It's probably worthwhile checking that the C++ compiler actually works
dnl anyway!
if test -n "$CXX" ; then
AC_LANG_CPLUSPLUS
AC_MSG_CHECKING([whether $CXX is a working C++ compiler])
AC_CACHE_VAL([xo_cv_cxx_works],
[
AC_TRY_RUN([int main() {}],
xo_cv_cxx_works=yes,
xo_cv_cxx_works=no,
AC_TRY_LINK([], [], xo_cv_cxx_works=yes, xo_cv_cxx_works=no))
])
AC_MSG_RESULT([$xo_cv_cxx_works])
else
xo_cv_cxx_works=no
fi
if test no = "$xo_cv_cxx_works" ; then
case $original_CXX in
CCC=*)
dnl CCC is handled in a slightly odd way - if its value isn't an
dnl executable (taking PATH into account) then it is ignored!
test "$original_CXX" = "CCC=$CXX" || original_CXX=
;;
esac
if test -z "$original_CXX" ; then
AC_MSG_ERROR([
*** You need a working C++ compiler to compile Xapian, but configure failed to
*** find one. If you have a working C++ compiler, you can tell configure where
*** to find it by invoking it like so:
***
*** ./configure CXX=/opt/bin/c++
])
else
AC_MSG_ERROR([
*** You need a working C++ compiler to compile Xapian, but the compiler you
*** specified (with '$original_CXX') doesn't appear to be able to successfully
*** compile and link a simple program.
])
fi
fi
dnl Probe for any options needed to enable C++11 support.
AX_CXX_COMPILE_STDCXX_11
dnl We don't use a C compiler to compile Xapian's code, but on some platforms
dnl (e.g. mingw) libtool uses $LTCC which defaults to $CC, and it's also use to
dnl build auxiliary tools like snowball and lemon.
AC_PROG_CC
dnl Check endianness.
AC_C_BIGENDIAN
dnl We want a non-cross-compiling C compiler for building lemon with.
if test -z "$CC_FOR_BUILD" ; then
if test yes = "$cross_compiling"; then
CC_FOR_BUILD=cc
else
CC_FOR_BUILD="$CC"
fi
fi
AC_ARG_VAR([CC_FOR_BUILD], [C compiler command for native compilation (needed to compile build tools during cross-builds)])
dnl Run tests using the C++ compiler.
AC_LANG_CPLUSPLUS
dnl Enable large file support if possible.
AC_SYS_LARGEFILE
dnl With xlC on AIX, -D_LARGE_FILES changes the ABI of std::string, so it
dnl also needs to be used when compiling user code.
abi_affecting_cxxflags=
if $GREP '^#define _LARGE_FILES 1$' confdefs.h > /dev/null 2>&1 ; then
abi_affecting_cxxflags=-D_LARGE_FILES
fi
AC_SUBST([abi_affecting_cxxflags])
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
#if defined __WIN32__ || defined _WIN32
#error WIN32
#endif
]])], [win32=no], [win32=yes])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
#ifdef _MSC_VER
#error MSVC
#endif
]])], [msvc=no], [msvc=yes])
XAPIAN_LDFLAGS=
XAPIAN_LIBS=
AC_SUBST([XAPIAN_LDFLAGS])
AC_SUBST([XAPIAN_LIBS])
AC_DEFUN([XAPIAN_TEST_LINKER_FLAG],
[
AC_MSG_CHECKING([for $CXX -Wl,$1])
AC_CACHE_VAL([xo_cv_ldflag_$2],
[
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,$1"
flag=$1
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[xo_cv_ldflag_$2=yes
$3],
[xo_cv_ldflag_$2=no
$4])
LDFLAGS=$save_LDFLAGS
])
AC_MSG_RESULT([$xo_cv_ldflag_$2])
])
dnl Test if the compiler works with $1 added to CXXFLAGS; if it does, add $1 to
dnl variable $2. If the test passes, also do $3; if it fails, also do $4.
AC_DEFUN([XAPIAN_TEST_CXXFLAGS],
[
XTC_save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $1"
AC_TRY_COMPILE([], [],
[CXXFLAGS=$XTC_save_CXXFLAGS
$2="${$2} $1"
$3],
[CXXFLAGS=$XTC_save_CXXFLAGS
$4])
])
ldflags=
if test yesyes = "$GXX$enable_shared" ; then
case $host_os in
*mingw* | *cygwin*)
XAPIAN_TEST_LINKER_FLAG([--enable-runtime-pseudo-reloc], [enable_runtime_pseudo_reloc],
[ldflags="-Wl,$flag"],
[
dnl Can't use AC_DISABLE_SHARED after AC_PROG_LIBTOOL, but
dnl this test needs to be after AC_PROG_LIBTOOL, so we can't
dnl just disable the shared build automatically...
AC_MSG_ERROR([ld version too old to support a shared build - configure with --disable-shared, or install binutils 2.13.90-20030111-1 or later])
])
;;
esac
fi
dnl Only works for ldflags which can be specified anywhere on the link line.
AC_SUBST([ldflags])
dnl Preserve the default CXXFLAGS.
save_CXXFLAGS=$CXXFLAGS
dnl x86 has excess precision issues with 387 FP instructions, which are
dnl avoided by using SSE instructions instead. This is also faster (~6% in
dnl a CPU bound testcase).
AC_ARG_ENABLE([sse],
[AS_HELP_STRING([--disable-sse],
[disable use of SSE FP instructions on x86])]
[AS_HELP_STRING([[--enable-sse[=sse|sse2]]],
[set which SSE FP instructions to use on x86 (default: sse2)])],
[case ${enableval} in
sse|sse2|yes|no) ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-sse or --disable-sse]) ;;
esac],
[enable_sse=yes])
dnl Some versions of Sun's C++ compiler reportedly need an explicit -lm.
dnl The maths functions we use include: exp log ceil fabs sqrt
AC_MSG_CHECKING([if -lm is required for maths functions])
dnl Don't use constant arguments as the compiler might simply evaluate the
dnl whole expression at compile time, and it might inline certain functions
dnl so test several functions. Also write results using printf() so that
dnl the compiler can't optimise away the computations.
AC_TRY_LINK([#ifdef __SUNPRO_CC
#error Need -lm for Sun C++ 5.9 under libtool 2.2.10
#endif
#include <cmath>
#include <cstdio>
#include <ctime>
using namespace std;], [
double a = log(ceil(time(NULL)/7.0));
printf("%f %f %f\n", a, sqrt(a), exp(fabs(a - 12345.6)));
], [AC_MSG_RESULT([no])], [
LIBS="-lm $LIBS"
AC_TRY_LINK([#include <cmath>
#include <cstdio>
#include <ctime>
using namespace std;], [
double a = log(ceil(time(NULL)/7.0));
printf("%f %f %f\n", a, sqrt(a), exp(fabs(a - 12345.6)));],
[AC_MSG_RESULT([yes])],
[AC_MSG_ERROR([Failed to link a C++ program using <cmath>])
])
])
dnl C++11 should have log2(double), but keep this check for now to allow for
dnl compilers with incomplete library support for C++11.
AC_CHECK_DECLS([log2(double)], [], [],
[#include <cmath>
using namespace std;])
dnl exp10() is a GNU libc extension.
AC_CHECK_DECLS([exp10(double)], [], [],
[#include <cmath>
using namespace std;])
dnl Darwin provides __exp10().
AC_CHECK_DECLS([__exp10(double)], [], [],
[#include <cmath>
using namespace std;])
dnl GCC provides __builtin_exp10() (but notably clang doesn't currently).
dnl On mingw, __builtin_exp10() causes GCC to generate a call to exp10() which
dnl then fails to link, so perform a link check here to catch that.
AC_CACHE_CHECK([for __builtin_exp10], ac_cv_link___builtin_exp10, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <cstdio>
#include <ctime>
using namespace std;]],
[[printf("%f", __builtin_exp10(double(time(NULL)*1e-8)));]])],
[ac_cv_link___builtin_exp10=yes],
[ac_cv_link___builtin_exp10=no])
])
if test $ac_cv_link___builtin_exp10 = yes ; then
AC_DEFINE([HAVE___BUILTIN_EXP10], [1], [Define to 1 if you have the '__builtin_exp10' function.])
fi
dnl See if <typeinfo> can be used in the testsuite - at least for GCC and xlC,
dnl compilation of the test code below fails if RTTI isn't being generated
dnl (g++ -fno-rtti, or by default with xlC).
AC_MSG_CHECKING([if RTTI is supported])
save_CXXFLAGS=$CXXFLAGS
dnl xlC issues a warning for typeid() being used without RTTI being enabled,
dnl so for this test we pass the xlC option to make that warning into an error.
XAPIAN_TEST_CXXFLAGS([-qhaltonmsg=1540-2412], [CXXFLAGS])
AC_TRY_COMPILE([
#include <exception>
#include <typeinfo>],
[
int f();
try {
return f();
} catch (std::exception & e) {
return typeid(e).name()[0];
}],
AC_MSG_RESULT([yes])
AC_DEFINE([USE_RTTI], [1], [Define if the testsuite can use RTTI]),
AC_MSG_RESULT([no]))
CXXFLAGS=$save_CXXFLAGS
dnl We need to specify the argument types for builtin functions, or else
dnl AC_CHECK_DECLS fails to detect them when the compiler is clang.
AC_CHECK_DECLS([__builtin_add_overflow(int, int, int*),
__builtin_mul_overflow(int, int, int*)], [], [], [ ])
AC_CHECK_DECLS([__builtin_bswap16(uint16_t),
__builtin_bswap32(uint32_t)], [], [],
[#include <stdint.h>])
AC_CHECK_DECLS([_byteswap_ushort, _byteswap_ulong], [], [],
[#include <stdlib.h>])
AC_CHECK_DECLS([__builtin_clz(unsigned),
__builtin_clzl(unsigned long),
__builtin_clzll(unsigned long long)], [], [], [ ])
AC_CHECK_DECLS([__builtin_ctz(unsigned),
__builtin_ctzl(unsigned long),
__builtin_ctzll(unsigned long long)], [], [], [ ])
AC_CHECK_DECLS([__builtin_expect(long, long)], [], [], [ ])
AC_CHECK_DECLS([__builtin_popcount(unsigned),
__builtin_popcountl(unsigned long),
__builtin_popcountll(unsigned long long)], [], [], [ ])
AC_CHECK_DECLS([__popcnt, __popcnt64], [], [], [#include <intrin.h>])
dnl Check for time functions.
AC_CHECK_FUNCS([clock_gettime sleep nanosleep gettimeofday ftime])
case $host_os in
*mingw*)
dnl For _ftime64() on mingw we need to tell it we're happy to require
dnl MSVCRT 6.10 or higher, which isn't too onerous a requirement it seems.
AC_DEFINE([__MSVCRT_VERSION__], [0x0601], [Define on mingw to the minimum msvcrt version to assume])
AC_DEFINE([MINGW_HAS_SECURE_API], [1], [Define on mingw to get _s suffixed "secure" functions declared in headers])
;;
esac
dnl We use timer_create() if available to implement a search time limit.
SAVE_LIBS=$LIBS
AC_SEARCH_LIBS([timer_create], [rt],
[
AC_MSG_CHECKING([for timer_create() usability])
dnl Several platforms have timer_create() but it's non-functional.
dnl
dnl Some of these (at least those with a stub implementation which always
dnl fails with ENOSYS) could be probed for, but we'd have to run code
dnl which isn't possible when cross-compiling, so just maintain a list
dnl of such platforms for now.
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#if defined _AIX
#error timer_create always fails with EAGAIN on AIX 7.1
#elif defined __GNU__
#error timer_create always fails with ENOSYS on GNU Hurd
#elif defined __NetBSD__
#error timer_create timers never fire on NetBSD 7.1
#elif defined __OpenBSD__
#error timer_create always fails with ENOSYS on OpenBSD 6.2 (and no prototype)
#endif]])],
[AC_MSG_RESULT([yes])
XAPIAN_LIBS="$LIBS $XAPIAN_LIBS"
AC_DEFINE([HAVE_TIMER_CREATE], [1], [Define to 1 if you have the 'timer_create' function.])]
,
[AC_MSG_RESULT([no])
])
])
LIBS=$SAVE_LIBS
dnl Used by tests/soaktest/soaktest.cc
AC_CHECK_FUNCS([srandom random])
dnl Used by tests/harness/testsuite.cc
AC_CHECK_FUNCS([sigaction])
AC_MSG_CHECKING([for sigsetjmp and siglongjmp])
AC_TRY_COMPILE([#include <setjmp.h>],
[sigjmp_buf jb; if (sigsetjmp(jb, 1)) { siglongjmp(jb, 1); }],
AC_DEFINE([HAVE_SIGSETJMP], [1], [Define to 1 if you have the 'sigsetjmp' function])
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))
dnl Used by tests/harness/cputimer.cc:
AC_CHECK_FUNCS([getrusage times sysconf])
dnl Used by tests/harness/unixcmd.cc
AC_CHECK_FUNCS([nftw])
dnl Used by tests/api_replicate.cc.
dnl
dnl Solaris < 10 only has putenv().
dnl
dnl Microsoft have marked putenv() as deprecated, so we use _putenv_s() under
dnl MSVC to avoid deprecation warnings. We probe here since mingw doesn't
dnl currently (v3.20) provide _putenv_s(), so we can't just use it conditional
dnl on __WIN32__ being defined. We need to check for a declaration rather
dnl than just seeing if the symbol exists, as the symbol will exist in the C
dnl runtime DLL even if mingw doesn't declare it in its headers.
AC_CHECK_FUNCS([setenv])
AC_CHECK_DECLS([_putenv_s(const char *,const char *)], [], [],
[#include <stdlib.h>])
dnl See if we have closefrom(), or some functions that are useful to implement
dnl closefrom() on platforms which don't provide it.
AC_CHECK_FUNCS([closefrom getdirentries getrlimit])
dnl See if ftime returns void (as it does on mingw)
AC_MSG_CHECKING([return type of ftime])
if test $ac_cv_func_ftime = yes ; then
AC_TRY_COMPILE([#include <sys/timeb.h>],
[struct timeb tp; int i = ftime(&tp);],
AC_MSG_RESULT([int]),
AC_MSG_RESULT([void])
AC_DEFINE([FTIME_RETURNS_VOID], [1], [Define if ftime returns void]))
fi
dnl Check how to find the hostname: uname() in sys/utsname.h, or gethostname()
AC_CHECK_HEADERS([sys/utsname.h], [], [], [ ])
AC_CHECK_FUNCS([gethostname])
dnl mingw (for instance) lacks ssize_t
AC_TYPE_SSIZE_T
AC_TYPE_PID_T
AC_TYPE_MODE_T
AC_CHECK_SIZEOF([short])
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([long long])
AC_CHECK_HEADERS([sys/types.h])
AC_MSG_CHECKING([for 32 bit integer type])
case 4 in
"$ac_cv_sizeof_int") INT32_T=int ;;
"$ac_cv_sizeof_long") INT32_T=long ;;
"$ac_cv_sizeof_short") INT32_T=short ;;
*)
AC_MSG_RESULT([none found])
AC_MSG_ERROR([No 32 bit integer type found])
esac
AC_MSG_RESULT([$INT32_T])
AC_MSG_CHECKING([for 64 bit integer type])
case 8 in
"$ac_cv_sizeof_int") INT64_T=int ;;
"$ac_cv_sizeof_long") INT64_T=long ;;
"$ac_cv_sizeof_long_long") INT64_T='long long' ;;
*)
AC_MSG_RESULT([none found])
AC_MSG_ERROR([No 64 bit integer type found])
esac
AC_MSG_RESULT([$INT64_T])
dnl Check for perl (needed to generate some sources and documentation).
AC_PATH_PROG([PERL], [perl], [])
if test x$USE_MAINTAINER_MODE = xyes; then
test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
fi
AC_ARG_ENABLE([64bit_docid],
[AS_HELP_STRING([--enable-64bit-docid], [enable 64bit docid [default=no]])],
[case ${enableval} in
yes|no) ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-docid]) ;;
esac],
[enable_64bit_docid=no])
AC_ARG_ENABLE([64bit_termcount],
[AS_HELP_STRING([--enable-64bit-termcount], [enable 64bit termcount [default=no]])],
[case ${enableval} in
yes|no) ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-termcount]) ;;
esac],
[enable_64bit_termcount=no])
AC_ARG_ENABLE([64bit_termpos],
[AS_HELP_STRING([--enable-64bit-termpos], [enable 64bit termpos [default=no]])],
[case ${enableval} in
yes|no) ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-termpos]) ;;
esac],
[enable_64bit_termpos=no])
AC_ARG_ENABLE([documentation],
[AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
[case ${enableval} in
yes|no) ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
esac],
[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 x"$enable_documentation" = xyes ; then
dnl Checks for dot. (Diagrams in the documentation)
AC_PATH_PROG([DOT], [dot])
test -z "$DOT" && AC_MSG_ERROR([dot (part of the graphviz package) is required to build documentation])
DOXYGEN_DOT_PATH=`echo "$DOT" | sed 's!/dot$!!'`
AC_SUBST([DOXYGEN_DOT_PATH])
dnl Check for doxygen. (Needed to make some more of the documentation)
AC_PATH_PROG([DOXYGEN], [doxygen], [])
test -z "$DOXYGEN" && AC_MSG_ERROR([doxygen is required to build documentation])
dnl Check for help2man. (Needed to make man pages from "--help" output).
AC_PATH_PROG([HELP2MAN], [help2man], [])
test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
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)])
dnl Check for pngcrush, which we optionally use to reduce the size of the
dnl PNG files which doxygen generates. We can get by without it, so don't
dnl fail here if it's not found.
AC_PATH_PROG([PNGCRUSH], [pngcrush], [])
fi
dnl Checks for header files.
AC_CHECK_HEADERS([fcntl.h limits.h sys/errno.h sys/select.h], [], [], [ ])
AC_CHECK_HEADERS([sys/resource.h],
[], [], [#include <sys/types.h>])
dnl cxxabi.h was added in GCC 3.1, but clang lies and defines __GNUC__ yet
dnl doesn't seem to reliably provide this header, so probe for it.
AC_CHECK_HEADERS([cxxabi.h], [], [], [ ])
dnl If valgrind is installed and new enough, we use it for leak checking in the
dnl testsuite. If VALGRIND is set to an empty value, then skip the check and
dnl don't use valgrind.
if test -n "${VALGRIND-unset}" ; then
AC_PATH_PROG([VALGRIND], [valgrind], [])
if test -n "$VALGRIND" ; then
dnl Check that the installed valgrind version works, and supports the
dnl options we use. This means we won't try to use valgrind < 3.3.0
dnl (released 7/12/2007) since before that --log-file didn't expand
dnl %p (and appended the process id).
dnl
dnl No need to check for VALGRIND_COUNT_LEAKS now - that was added before
dnl 2.0.0.
AC_MSG_CHECKING([if valgrind supports --log-file with %p and --child-silent-after-fork=yes])
vglog=config.vglog.%p.tmp
vglogwild="config.vglog.*.tmp*"
rm -f $vglogwild
if $VALGRIND --log-file="$vglog" --child-silent-after-fork=yes -q true 2>&AS_MESSAGE_LOG_FD ; then
for f in $vglogwild ; do
case $f in
$vglog*) VALGRIND= ;;
esac
done
if test x"$VALGRIND" = x ; then
AC_MSG_RESULT([no])
else
AC_MSG_RESULT([yes])
AC_CHECK_HEADERS([valgrind/memcheck.h], [], [VALGRIND=], [ ])
fi
else
dnl The valgrind detected doesn't seem to work! Perhaps this is an
dnl x86_64 box with a 32 bit valgrind.
AC_MSG_RESULT([$VALGRIND doesn't work])
VALGRIND=
fi
rm -f $vglogwild
fi
fi
if test -n "$VALGRIND" ; then
AC_DEFINE([HAVE_VALGRIND], [1], [Define if a suitable valgrind is installed])
fi
dnl If eatmydata is installed, we run the testsuite under it to speed it up.
dnl If EATMYDATA is set to an empty value, then skip this check and don't use
dnl eatmydata.
if test -n "${EATMYDATA-unset}" ; then
AC_PATH_PROG([EATMYDATA], [eatmydata], [])
fi
dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_STRERROR_R
AC_CACHE_CHECK([for sys_errlist and sys_nerr], ac_cv_sys_errlist_and_sys_nerr, [
AC_LINK_IFELSE([AC_LANG_PROGRAM(
dnl On Linux, sys_errlist and sys_nerr need <stdio.h>, though the man page
dnl says <errno.h>. The man page seems to match other platforms such as
dnl NetBSD, so include both headers to ensure we get them.
[[#include <errno.h>
#include <stdio.h>]],
[[ printf("%s", sys_errlist[sys_nerr - 1]);]])],
[ ac_cv_sys_errlist_and_sys_nerr=yes ],
[ ac_cv_sys_errlist_and_sys_nerr=no ])
])
if test "x$ac_cv_sys_errlist_and_sys_nerr" = "xyes" ; then
AC_DEFINE([HAVE_SYS_ERRLIST_AND_SYS_NERR], [1],[Define if you have 'sys_errlist' and 'sys_nerr'])
fi
AC_CACHE_CHECK([for _sys_errlist and _sys_nerr], ac_cv__sys_errlist_and__sys_nerr, [
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <errno.h>
#include <stdio.h>]],
[[ printf("%s", _sys_errlist[_sys_nerr - 1]);]])],
[ ac_cv__sys_errlist_and__sys_nerr=yes ],
[ ac_cv__sys_errlist_and__sys_nerr=no
])
])
if test "x$ac_cv__sys_errlist_and__sys_nerr" = "xyes" ; then
AC_DEFINE([HAVE__SYS_ERRLIST_AND__SYS_NERR], [1],[Define if you have '_sys_errlist' and '_sys_nerr'])
fi
dnl Check that snprintf actually works as it's meant to.
dnl
dnl Linux 'man snprintf' warns:
dnl Linux libc4.[45] does not have a snprintf, but provides a libbsd that
dnl contains an snprintf equivalent to sprintf, i.e., one that ignores the
dnl size argument. Thus, the use of snprintf with early libc4 leads to
dnl serious security problems.
dnl
dnl It also warns that glibc < 2.0.6 (and presumably other pre-C99
dnl implementations) return -1 when truncating so check that we get the
dnl ISO C99 semantics for the returned length when truncating. If we
dnl have a working snprintf but with non-ISO return semantics, handle
dnl that case separately as it may still be useful in many cases.
dnl
dnl mingw has _snprintf so check for that too.
AC_MSG_CHECKING([for working ISO C99 conforming snprintf])
ac_cv_func_snprintf_noniso=no
for func in snprintf _snprintf ; do
AC_RUN_IFELSE([
AC_LANG_PROGRAM(
[[
#include <cstdio>
#include <cstring>
using namespace std;
]],
dnl Return different exit status for each error so we can see which
dnl check failed by consulting config.log.
[[
char buffer[4] = "abc";
int res1 = $func(buffer, 2, "%s", "XYZ");
if (memcmp(buffer, "X\0c", 4) != 0) return 2;
int res2 = $func(buffer, 2, "%x", 0x12);
if (memcmp(buffer, "1\0c", 4) != 0) return 3;
if (res1 == -1 && res2 == -1) return 15; /* Pre-ISO semantics. */
if (res1 != 3) return 4;
if (res2 != 2) return 5;
]]
)],
[ac_cv_func_snprintf=$func;break],
[
if test 15no = "$?$ac_cv_func_snprintf_noniso" ; then
ac_cv_func_snprintf_noniso=$func
fi
ac_cv_func_snprintf=no
],
[ac_cv_func_snprintf=unknown;break]
)
done
AC_MSG_RESULT([$ac_cv_func_snprintf])
case $ac_cv_func_snprintf in
no)
AC_MSG_CHECKING([for working non-ISO C99 conforming snprintf])
AC_MSG_RESULT([$ac_cv_func_snprintf_noniso])
if test no != "$ac_cv_func_snprintf_noniso" ; then
AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf_noniso],
[Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
fi
;;
unknown)
dnl be conservative when crosscompiling
;;
*)
AC_DEFINE_UNQUOTED([SNPRINTF_ISO], [$ac_cv_func_snprintf],
[Define to the name of a function implementing snprintf with ISO C99 semantics (if one exists)])
AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf],
[Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
;;
esac
dnl ***************************
dnl * Select modules to build *
dnl ***************************
dnl Check which database backends should be built.
AC_DEFUN([_XAPIAN_BACKEND_ENABLE],
[AC_ARG_ENABLE([backend_$1],
[AS_HELP_STRING([--enable-backend-$1], [build the $1 database backend [default=$3]])],
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([Invalid option: '--enable-backend-$1=$enableval']) ;;
esac], [enable_backend_$1=$2])
])
AC_DEFUN([XAPIAN_BACKEND_ENABLE],
[_XAPIAN_BACKEND_ENABLE([$1],
m4_default([$2], [yes]),
m4_default([$3], [yes]))
])
dnl When adding a new backend, update INSTALL too.
XAPIAN_BACKEND_ENABLE([chert])
XAPIAN_BACKEND_ENABLE([glass])
XAPIAN_BACKEND_ENABLE([inmemory])
default_enable_backend_remote=yes
case $host_os in
*djgpp* | *msdos* )
dnl We don't currently support the remote backend on this platform so
dnl disable it by default.
default_enable_backend_remote=no
;;
esac
XAPIAN_BACKEND_ENABLE([remote], [$default_enable_backend_remote], [yes (except for MSDOS)])
win32_need_lws2_32=0
case $enable_backend_chert$enable_backend_glass in
*yes*)
dnl We use zlib for compressing tags in chert/glass. We could
dnl automatically disable support if zlib isn't found, but overall that
dnl probably does more harm than good - it's most likely that someone just
dnl forgot to install the -dev package for zlib.
dnl
dnl Similarly for uuid support.
dnl Check for zlib.h.
AC_CHECK_HEADERS([zlib.h], [], [
AC_MSG_ERROR([zlib.h not found - required for chert and glass (you may need to install the zlib1g-dev or zlib-devel package)])
], [ ])
dnl Check for zlibVersion in -lz.
SAVE_LIBS=$LIBS
dnl mingw build needs -lzlib or -lzdll.
AC_SEARCH_LIBS([zlibVersion], [z zlib zdll], [], [
AC_MSG_ERROR([zlibVersion() not found in -lz, -lzlib, or -lzdll - required for chert and glass (you may need to install the zlib1g-dev or zlib-devel package)])
])
if test x != x"$LIBS" ; then
XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
fi
LIBS=$SAVE_LIBS
dnl Find the UUID library (from e2fsprogs/util-linux-ng, not the OSSP one).
case $host_os-$win32 in
*-yes | *cygwin*) dnl Use built-in win32 API.
AC_DEFINE([USE_WIN32_UUID_API], [1],
[Define to 1 to use UuidCreate(), etc])
if test $win32 = yes ; then
dnl We need -lws2_32 for htonl(), etc, but not for Cygwin which
dnl provides these functions in its libc.
win32_need_lws2_32=1
fi
XAPIAN_LIBS="$XAPIAN_LIBS -lrpcrt4"
;;
*)
dnl Check for uuid/uuid.h (e2fsprogs/util-linux-ng) or uuid.h
dnl (FreeBSD/NetBSD).
AC_CHECK_HEADERS([uuid/uuid.h], [
dnl util-linux-ng's uuid/uuid.h found - check for uuid_generate in
dnl -luuid.
SAVE_LIBS=$LIBS
AC_SEARCH_LIBS([uuid_generate], [uuid], [], [
AC_MSG_ERROR([uuid_generate() not found in -luuid - required for chert and glass (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
])
if test x != x"$LIBS" ; then
XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
fi
], [
dnl Try uuid.h as found on FreeBSD/NetBSD, with associated code in libc.
AC_CHECK_HEADERS([uuid.h], [
dnl Check for uuid_create with no extra libraries required.
AC_CHECK_FUNC([uuid_create], [], [
AC_MSG_ERROR([uuid.h found, but uuid_create() not found. You probably wants to install libuuid from util-linux-ng or e2fsprogs (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
])
], [
dnl Especially useful for Android.
AC_MSG_CHECKING([if host platform supports /proc/sys/kernel/random/uuid])
case $host_os in
linux*)
AC_DEFINE([USE_PROC_FOR_UUID], [1],
[Define to 1 to read UUID from '/proc/sys/kernel/random/uuid'])
AC_MSG_RESULT([yes])
;;
*)
AC_MSG_RESULT([no])
AC_MSG_ERROR([Failed to find a way to generate UUIDs, required for chert and glass backends (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
;;
esac
], [ ])
], [ ])
;;
esac
LIBS=$SAVE_LIBS
case $host_os in
*djgpp* | *msdos* )
dnl DJGPP has a dummy implementation of fork which always fails.
dnl
dnl For disk-based backends, use flock() for locking, which doesn't need
dnl fork() or socketpair().
AC_DEFINE([FLINTLOCK_USE_FLOCK], 1, [Define to use flock() for flint-compatible locking])
;;
esac
;;
esac
if test "$enable_backend_remote" = yes ; then
case $host_os-$win32 in
*-yes )
dnl For mingw and msvc we have an alternative implementation which
dnl doesn't need fork() or socketpair().
dnl
dnl We need -lws2_32 for getaddrinfo(), etc.
win32_need_lws2_32=1
dnl Vista is needed for the AI_ADDRCONFIG flag to getaddrinfo().
AC_DEFINE([WINVER], [0x600],
[Version of Windows to assume (0x600 => Vista).])
AC_DEFINE([_WIN32_WINNT], [WINVER],
[Version of Windows to assume.])
;;
*djgpp* | *msdos* )
dnl DJGPP has a dummy implementation of fork which always fails. If
dnl someone actually wanted remote backend support, then DJGPP has a
dnl pthreads port, so using threads like we do on Windows would make more
dnl sense.
AC_MSG_ERROR([The remote backend is not currently supported on this platform.])
;;
*)
dnl On Unix, we need fork and socketpair for the remotebackend.
SAVE_LIBS=$LIBS
AC_CHECK_FUNCS([fork], [], [
AC_MSG_ERROR([fork() required for the remote backend - if an extra library is needed, pass LIBS=-lfoo to configure. Or --disable-backend-remote to disable it.)])
])
dnl Check if -lsocket is required for socketpair (Solaris needs it).
dnl And on Haiku it's in -lnetwork.
AC_SEARCH_LIBS([socketpair], [socket network], [], [
AC_MSG_ERROR([socketpair() required for the remote backend - if an extra library is needed, pass LIBS=-lfoo to configure. Or --disable-backend-remote to disable it.)])
])
AC_DEFINE([HAVE_SOCKETPAIR], [1],
[Define to 1 if you have the 'socketpair' function.])
dnl Check if extra libraries are needed for getaddrinfo or inet_ntop()
dnl (e.g. on Solaris).
dnl
dnl We're currently assuming that any system that is worth trying to
dnl support has getaddrinfo() and inet_ntop(), since these are the
dnl standard route for supporting IPv6, and that's pretty much essential
dnl for platforms to support now.
AC_SEARCH_LIBS([getaddrinfo], [nsl socket], [], [
AC_MSG_ERROR([getaddrinfo() required for the remote backend - if an extra library is needed, pass LIBS=-lfoo to configure. Or --disable-backend-remote to disable it.)])
])
AC_SEARCH_LIBS([inet_ntop], [nsl socket], [], [
AC_MSG_ERROR([inet_ntop() required for the remote backend - if an extra library is needed, pass LIBS=-lfoo to configure. Or --disable-backend-remote to disable it.)])
])
XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
LIBS=$SAVE_LIBS
;;
esac
TYPE_SOCKLEN_T
fi
if test "$win32_need_lws2_32" = 1 ; then
XAPIAN_LIBS="$XAPIAN_LIBS -lws2_32"
fi
AC_ARG_ENABLE([visibility],
[AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
[case ${enableval} in
yes|no) ;;