forked from libguestfs/nbdkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
1661 lines (1538 loc) · 55.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
# nbdkit
# Copyright (C) 2013-2023 Red Hat Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of Red Hat nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
m4_define([NBDKIT_VERSION_MAJOR], [1])
m4_define([NBDKIT_VERSION_MINOR], [33])
m4_define([NBDKIT_VERSION_MICRO], [10])
AC_INIT([nbdkit],
NBDKIT_VERSION_MAJOR.NBDKIT_VERSION_MINOR.NBDKIT_VERSION_MICRO)
AC_CONFIG_MACRO_DIR([m4])
dnl This must be used very early else you will get
dnl "warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS"
m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],[],
[m4_define([AC_USE_SYSTEM_EXTENSIONS],[])])
AC_USE_SYSTEM_EXTENSIONS
dnl NB: Do not [quote] this parameter.
AM_INIT_AUTOMAKE(foreign)
LT_INIT([win32-dll])
dnl Extra string, a freeform string defined by downstream packagers.
dnl eg. If you are packaging nbdkit for Linux distro X 1.1, you could
dnl ./configure --with-extra="X release 1.1"
AC_ARG_WITH([extra],
[AS_HELP_STRING([--with-extra=...],
[extra version information (for use by packagers)])],
[NBDKIT_VERSION_EXTRA="$withval"],
[NBDKIT_VERSION_EXTRA=]
)
AC_DEFINE_UNQUOTED([NBDKIT_VERSION_EXTRA], ["$NBDKIT_VERSION_EXTRA"],
[Extra version information (for use by packagers)])
AC_MSG_NOTICE([nbdkit version NBDKIT_VERSION_MAJOR.NBDKIT_VERSION_MINOR.NBDKIT_VERSION_MICRO ($NBDKIT_VERSION_EXTRA)])
dnl List of plugins and filters.
lang_plugins="\
cc \
golang \
lua \
ocaml \
perl \
python \
ruby \
rust \
sh \
tcl \
"
non_lang_plugins="\
blkio \
cdi \
curl \
data \
eval \
example1 \
example2 \
example3 \
example4 \
file \
floppy \
full \
guestfs \
info \
iso \
libvirt \
linuxdisk \
memory \
nbd \
null \
ondemand \
partitioning \
pattern \
random \
S3 \
sparse-random \
split \
ssh \
tmpdisk \
torrent \
vddk \
zero \
"
plugins="$(echo $(printf %s\\n $lang_plugins $non_lang_plugins | sort -u))"
filters="\
blocksize \
blocksize-policy \
cache \
cacheextents \
checkwrite \
cow \
ddrescue \
delay \
error \
exitlast \
exitwhen \
exportname \
ext2 \
extentlist \
fua \
gzip \
ip \
limit \
log \
luks \
multi-conn \
nocache \
noextents \
nofilter \
noparallel \
nozero \
offset \
partition \
pause \
protect \
rate \
readahead \
retry \
retry-request \
scan \
stats \
swab \
tar \
tls-fallback \
truncate \
xz \
"
AC_SUBST([plugins])
AC_SUBST([lang_plugins])
AC_SUBST([non_lang_plugins])
AC_SUBST([filters])
dnl Some very basic tools.
AC_PROG_SED
AC_PROG_RANLIB
dnl Check for basic C environment.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_CPP
AC_SYS_LARGEFILE
AC_C_PROTOTYPES
test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
AM_PROG_CC_C_O
dnl Define the host CPU architecture (defines 'host_cpu').
AC_CANONICAL_HOST
AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
dnl Define 'host_os'.
AC_DEFINE_UNQUOTED([host_os],["$host_os"],[Host operating system.])
dnl Defines WORDS_BIGENDIAN on big endian platforms.
AC_C_BIGENDIAN
dnl These are defined in <unistd.h> which is included by
dnl AC_DEFAULT_INCLUDES.
AC_CHECK_SIZEOF([pid_t])
AC_CHECK_SIZEOF([uid_t])
AC_CHECK_SIZEOF([gid_t])
dnl Check for C++ (optional, we just use this to test the header
dnl can be included from C++ code).
AC_PROG_CXX
dnl The C++ compiler test is pretty useless because even if it fails
dnl it sets CXX=g++. So test the compiler actually works.
AC_MSG_CHECKING([if the C++ compiler really really works])
AS_IF([$CXX --version >&AS_MESSAGE_LOG_FD 2>&1],[have_cxx=yes],[have_cxx=no])
AC_MSG_RESULT([$have_cxx])
AM_CONDITIONAL([HAVE_CXX], [test "$have_cxx" = "yes"])
AC_ARG_ENABLE([gcc-warnings],
[AS_HELP_STRING([--enable-gcc-warnings],
[turn on lots of GCC warnings (for developers)])],
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
esac
gcc_warnings=$enableval],
[gcc_warnings=no]
)
if test "x$gcc_warnings" = "xyes"; then
WARNINGS_CFLAGS="-Wall -Wshadow -Wvla -Werror"
AC_SUBST([WARNINGS_CFLAGS])
fi
dnl Check if the compiler supports -std=c90 flag. This is only used
dnl during a test. OpenBSD GCC does not support this flag so we skip
dnl that test.
AC_MSG_CHECKING([if the compiler supports -std=c90 for ANSI C test])
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -std=c90"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[supports_std_c90=yes],
[supports_std_c90=no])
CFLAGS="$old_CFLAGS"
AC_MSG_RESULT([$supports_std_c90])
AM_CONDITIONAL([CAN_TEST_ANSI_C], [test "x$supports_std_c90" = "xyes"])
dnl Check for __builtin_*_overflow. We need the dummy parameters
dnl else detection doesn't work correctly for some reason.
AC_CHECK_DECLS([__builtin_add_overflow(int, int, int *),
__builtin_mul_overflow(int, int, int *)],
[], [], [])
dnl On Haiku we must use BSD-compatibility headers to get the endian
dnl macros we use.
AC_MSG_CHECKING(whether OS-dependent include paths are required)
AS_CASE([$host_os],
[haiku*], [CFLAGS="$CFLAGS -I`findpaths -p /system B_FIND_PATH_HEADERS_DIRECTORY`/bsd"; AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
dnl On Linux /tmp is often tmpfs which is not large enough, so use /var/tmp.
dnl But Haiku only has /tmp.
AC_MSG_CHECKING([for temporary directory for large files])
AS_CASE([$host_os],
[haiku*], [LARGE_TMPDIR=/tmp],
[LARGE_TMPDIR=/var/tmp]
)
AC_MSG_RESULT([$LARGE_TMPDIR])
AC_DEFINE_UNQUOTED([LARGE_TMPDIR],["$LARGE_TMPDIR"],
[Temporary directory for large files])
dnl Check if libc has program_invocation_short_name.
AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
AX_PTHREAD
dnl Check if __attribute__((cleanup(...))) works.
dnl Set -Werror, otherwise gcc will only emit a warning for attributes
dnl that it doesn't understand.
acx_nbdkit_save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -Werror"
AC_MSG_CHECKING([if __attribute__((cleanup(...))) works with this compiler])
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
void
freep (void *ptr)
{
exit (EXIT_SUCCESS);
}
void
test (void)
{
__attribute__((cleanup(freep))) char *ptr = malloc (100);
(void)ptr;
}
int
main (int argc, char *argv[])
{
test ();
exit (EXIT_FAILURE);
}
]])
],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
AC_MSG_ERROR(
['__attribute__((cleanup(...)))' does not work.
You may not be using a sufficiently recent version of GCC or CLANG, or
you may be using a C compiler which does not support this attribute,
or the configure test may be wrong.
This code requires the attribute to work for proper locking between threads.])])
CFLAGS="${acx_nbdkit_save_CFLAGS}"
dnl Check for __auto_type (GCC extension).
AC_MSG_CHECKING([if __auto_type is available in this compiler])
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([[
static int
test (int a)
{
__auto_type at = a;
return at;
}
]])
],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_AUTO_TYPE],[1],[__auto_type is available])
],[
AC_MSG_RESULT([no])
]
)
dnl 'environ' is not always declared in public header files:
dnl Linux => <unistd.h> Haiku => <stdlib.h>
dnl FreeBSD & OpenBSD => not declared
dnl On platforms where it's not declared we must add an extern decl.
AC_MSG_CHECKING([if environ is declared in header files])
AC_COMPILE_IFELSE([
AC_LANG_SOURCE([[
#include <stdlib.h>
#include <unistd.h>
static int
test (void)
{
const char **env = environ;
return env ? 1 : 0; // this just forces env to be used
}
]])
],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_ENVIRON_DECL],[1],[environ is declared in headers])
],[
AC_MSG_RESULT([no])
]
)
dnl Check for other headers, all optional.
AC_CHECK_HEADERS([\
alloca.h \
afunix.h \
arpa/inet.h \
byteswap.h \
endian.h \
grp.h \
linux/fs.h \
netdb.h \
netinet/in.h \
netinet/tcp.h \
pwd.h \
termios.h \
stdatomic.h \
syslog.h \
sys/endian.h \
sys/ioctl.h \
sys/mman.h \
sys/prctl.h \
sys/procctl.h \
sys/socket.h \
sys/statvfs.h \
sys/ucred.h \
sys/un.h \
sys/vsock.h \
sys/wait.h \
winsock2.h])
AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [#include <sys/socket.h>])
dnl Check for functions in libc, all optional.
AC_CHECK_FUNCS([\
accept4 \
fdatasync \
flockfile \
funlockfile \
inet_ntop \
inet_pton \
mkostemp \
mlock \
mlockall \
munlock \
open_memstream \
pipe \
pipe2 \
ppoll \
posix_fadvise \
posix_memalign \
valloc])
dnl Check for structs and members.
AC_CHECK_MEMBERS([struct dirent.d_type], [], [], [[#include <dirent.h>]])
AC_CHECK_MEMBERS([struct ucred.uid], [], [],
[[
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UCRED_H
#include <sys/ucred.h>
#endif
]])
AC_CHECK_MEMBERS([struct sockpeercred.uid], [], [],
[[
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
]])
dnl Replacement functions that we provide for some platforms.
AC_CONFIG_LIBOBJ_DIR([common/replacements])
AC_REPLACE_FUNCS([\
fdatasync \
fsync \
get_current_dir_name \
getdelim \
getline \
openlog \
open_memstream \
poll \
posix_memalign \
pread \
pwrite \
realpath \
strndup \
sysconf \
syslog \
vsyslog])
dnl Check whether printf("%m") works
AC_CACHE_CHECK([whether the printf family supports %m],
[nbdkit_cv_func_printf_percent_m],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <stdio.h>
#include <string.h>
#include <errno.h>
]], [[
char buf[200] = "";
errno = EINVAL;
snprintf(buf, sizeof buf, "%m");
return !!strcmp (buf, strerror (EINVAL));
]])],
[nbdkit_cv_func_printf_percent_m=yes],
[nbdkit_cv_func_printf_percent_m=no],
[[
case "$host_os" in
*-gnu* | gnu*) nbdkit_cv_func_printf_percent_m=yes;;
*) nbdkit_cv_func_printf_percent_m="guessing no";;
esac
]])])
AS_IF([test "x$nbdkit_cv_func_printf_percent_m" = xyes],
[AC_DEFINE([HAVE_VFPRINTF_PERCENT_M],[1],
[Define to 1 if vfprintf supports %m.])])
old_LIBS="$LIBS"
AC_SEARCH_LIBS([dlsym], [dl dld], [
AS_IF([test "x$ac_cv_search_dlsym" != "xnone required"],
[DL_LIBS="$ac_cv_search_dlsym"], [DL_LIBS=])
AC_SUBST([DL_LIBS])
], [AC_MSG_ERROR([unable to find the dlsym() function])
])
LIBS="$old_LIBS"
dnl Test if <iconv.h> header can build working binaries.
dnl
dnl On FreeBSD: iconv and libiconv both exist, both can be installed
dnl simultaneously, <iconv.h> can exist in two separate places, and
dnl if you get the wrong header/library mix everything breaks.
dnl
dnl On Haiku: libiconv is required to link to iconv_* functions.
AC_ARG_WITH([iconv],
[AS_HELP_STRING([--without-iconv],
[don't try to link against iconv @<:@default=check@:>@])],
[],
[with_iconv=check])
AS_IF([test "x$with_iconv" != "xno"],[
AC_CHECK_HEADER([iconv.h],[
AC_MSG_CHECKING([if <iconv.h> can be used to link a program])
AC_LINK_IFELSE([
AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
#include <iconv.h>
int
main (int argc, char *argv[])
{
iconv_t ic = iconv_open ("", "");
iconv_close (ic);
exit (0);
}
]])
],[
AC_MSG_RESULT([yes])
iconv_working=yes
],[
AC_MSG_RESULT([no])
])
])
])
AM_CONDITIONAL([HAVE_ICONV], [test "x$iconv_working" = "xyes"])
use_linker_script=yes
dnl Don't use linker script on FreeBSD because FreeBSD's linker is
dnl broken. See eg:
dnl https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190851
dnl Also on macOS (darwin) which fails with:
dnl ld: unknown option: --version-script=./nbdkit.syms
dnl clang: error: linker command failed with exit code 1
AC_MSG_CHECKING([if we should disable the linker script (FreeBSD, macOS)])
AS_CASE([$host_os],
[freebsd*|darwin*], [
use_linker_script=no
AC_MSG_RESULT([yes])
],
[AC_MSG_RESULT([no])]
)
dnl Check if -rdynamic linker flag works.
acx_nbdkit_save_LDFLAGS="${LDFLAGS}"
LDFLAGS="${LDFLAGS} -rdynamic"
AC_MSG_CHECKING([if linker supports -rdynamic])
AC_LINK_IFELSE([
AC_LANG_SOURCE([[
#include <stdlib.h>
int
main (int argc, char *argv[])
{
exit (EXIT_SUCCESS);
}
]])
],[
AC_MSG_RESULT([yes])
DL_LDFLAGS=-rdynamic
],[
AC_MSG_RESULT([no])
])
dnl restore CFLAGS
LDFLAGS="${acx_nbdkit_save_LDFLAGS}"
AC_SUBST([DL_LDFLAGS])
dnl Check for dladdr in -ldl, optional. This is a glibc extension.
old_LIBS="$LIBS"
LIBS="$DL_LIBS $LIBS"
AC_CHECK_FUNCS([dladdr])
LIBS="$old_LIBS"
dnl Is this Windows?
AC_MSG_CHECKING([if the target is Windows])
AS_CASE([$host_os],
[mingw*|msys*], [
is_windows=yes
LIBS="$LIBS -lmsvcrt -lkernel32 -luser32 -lws2_32"
NO_UNDEFINED_ON_WINDOWS="-no-undefined"
IMPORT_LIBRARY_ON_WINDOWS='-Wl,-L$(top_builddir)/server -Wl,-lnbdkit'
SOEXT="dll"
DIR_SEPARATOR_STR='\\'
],
[is_windows=no
SOEXT="so"
DIR_SEPARATOR_STR=/]
)
AC_MSG_RESULT([$is_windows])
AC_SUBST([NO_UNDEFINED_ON_WINDOWS])
AC_SUBST([IMPORT_LIBRARY_ON_WINDOWS])
AC_SUBST([SOEXT])
AC_DEFINE_UNQUOTED([SOEXT],["$SOEXT"],[Extension used for shared objects/DLLs.])
AC_DEFINE_UNQUOTED([EXEEXT],["$EXEEXT"],[Extension used for executables.])
AC_DEFINE_UNQUOTED([DIR_SEPARATOR_STR],["$DIR_SEPARATOR_STR"],
[String that separates path elements.])
AM_CONDITIONAL([IS_WINDOWS],[test "x$is_windows" = "xyes"])
AS_IF([test "x$is_windows" = "xyes"],[
dnl For Windows, look for the mc/windmc utility.
dnl XXX Do we need to check for mc.exe as well?
AC_CHECK_TOOLS([MC],[windmc mc],[no])
AS_IF([test "x$MC" = "xno"],
[AC_MSG_ERROR([mc/windmc utility must be available when compiling for Windows])])
dnl On Windows look for dlltool.
AC_CHECK_TOOLS([DLLTOOL],[dlltool],[no])
AS_IF([test "x$DLLTOOL" = "xno"],
[AC_MSG_ERROR([dlltool utility must be available when compiling for Windows])])
])
AC_SEARCH_LIBS([getaddrinfo], [network socket])
dnl Does this platform require libc_malloc_debug.so.0 (glibc >= 2.34)?
AC_MSG_CHECKING([if this is glibc >= 2.34])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <limits.h>
#if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 34)
#error "not glibc 2.34"
#endif
]])], [is_glibc_234=yes], [is_glibc_234=no]
)
AC_MSG_RESULT([$is_glibc_234])
AM_CONDITIONAL([HAVE_GLIBC_234], [test "x$is_glibc_234" = "xyes"])
dnl Check for SELinux socket labelling (optional).
AC_ARG_WITH([selinux],
AS_HELP_STRING([--without-selinux], [disable SELinux support, used for socket labelling @<:@default=check@:>@]))
AS_IF([test "x$with_selinux" != xno], [
PKG_CHECK_MODULES([LIBSELINUX], [libselinux], [
AC_SUBST([LIBSELINUX_CFLAGS])
AC_SUBST([LIBSELINUX_LIBS])
AC_DEFINE([HAVE_LIBSELINUX],[1],[libselinux found at compile time.])
], [AC_MSG_WARN([libselinux not found, sockets will not be labeled.])])
])
AS_IF([test "x$with_selinux" = xyes && test "x$LIBSELINUX_LIBS" = x], [
AC_MSG_ERROR([selinux requested but not found])
])
dnl Check for GnuTLS (optional, for TLS support).
AC_ARG_WITH([gnutls],
[AS_HELP_STRING([--without-gnutls], [disable TLS support via GnuTLS @<:@default=check@:>@])],
[],
[: m4_divert_text([DEFAULTS], [with_manpages=check])])
AS_IF([test "x$with_gnutls" != xno], [
PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0], [
AC_SUBST([GNUTLS_CFLAGS])
AC_SUBST([GNUTLS_LIBS])
AC_DEFINE([HAVE_GNUTLS],[1],[gnutls found at compile time.])
], [
AC_MSG_WARN([gnutls not found or < 3.3.0, TLS support will be disabled.])
])
])
AS_IF([test "x$with_gnutls" = xyes && test x"$GNUTLS_LIBS" = x], [
AC_MSG_ERROR([gnutls requested but not found])
])
AM_CONDITIONAL([HAVE_GNUTLS], [test "x$GNUTLS_LIBS" != "x"])
AS_IF([test "x$GNUTLS_LIBS" != "x"],[
AC_MSG_CHECKING([for default TLS session priority string])
AC_ARG_WITH([tls-priority],
[AS_HELP_STRING([--with-tls-priority=...],
[default TLS session priority string @<:@default=NORMAL@:>@])],
[tls_priority=$withval],
[tls_priority=NORMAL])
AC_MSG_RESULT([$tls_priority])
AC_DEFINE_UNQUOTED([TLS_PRIORITY],["$tls_priority"],
[Default TLS session priority string])
# Check for APIs which may not be present.
old_LIBS="$LIBS"
LIBS="$GNUTLS_LIBS $LIBS"
AC_CHECK_FUNCS([\
gnutls_base64_decode2 \
gnutls_certificate_set_known_dh_params \
gnutls_group_get \
gnutls_group_get_name \
gnutls_pbkdf2 \
gnutls_session_set_verify_cert \
gnutls_srp_server_get_username \
gnutls_transport_is_ktls_enabled \
])
AC_CHECK_HEADERS([gnutls/socket.h])
LIBS="$old_LIBS"
dnl macOS has its own program called certtool and packages the
dnl GnuTLS tool as "gnutls-certtool".
AC_CHECK_PROGS([CERTTOOL],[gnutls-certtool certtool],[certtool])
])
AM_CONDITIONAL([HAVE_GNUTLS_PBKDF2],
[test "x$GNUTLS_LIBS" != "x" && test "x$ac_cv_func_gnutls_pbkdf2" = xyes])
dnl Check for some commands used by the tests which should be the GNU
dnl coreutils variants. On macOS these are prefixed with 'g' or 'gnu'.
AC_CHECK_PROGS([CUT],[gnucut cut],[cut])
AC_CHECK_PROGS([STAT],[gstat stat],[stat])
AC_CHECK_PROGS([TRUNCATE],[gtruncate truncate],[truncate])
AC_ARG_ENABLE([linuxdisk],
[AS_HELP_STRING([--disable-linuxdisk],
[disable linuxdisk plugin @<:@default=check@:>@])],
[],
[enable_linuxdisk=check])
dnl Check for mke2fs -d (used by linuxdisk plugin). There are two
dnl possible outcomes that we care about: (1) We have mke2fs and
dnl it supports the -d option. (2) We either don't have mke2fs
dnl or it's too old to support the -d option (eg. on RHEL 7).
mke2fs_with_d=no
AS_IF([test "$enable_linuxdisk" != "no"], [
AC_MSG_CHECKING([for mke2fs supporting the -d option])
AS_IF([mke2fs -V >/dev/null 2>&1], [
AS_IF([LANG=C mke2fs -d 2>&1 | grep -sq "option requires an argument"], [
mke2fs_with_d=yes
])
])
AC_MSG_RESULT([$mke2fs_with_d])
])
AM_CONDITIONAL([HAVE_MKE2FS_WITH_D],[test "x$mke2fs_with_d" = "xyes"])
dnl Check for valgrind.
AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[no])
dnl If valgrind headers are available (optional).
dnl Although the runtime check adds only a trivial amount of code, you can
dnl avoid it with explicit --disable-valgrind.
AC_ARG_ENABLE([valgrind],
[AS_HELP_STRING([--disable-valgrind],
[disable Valgrind probe])],
[],
[enable_valgrind=check])
AS_IF([test "x$enable_valgrind" != "xno"],[
PKG_CHECK_MODULES([VALGRIND], [valgrind], [
AC_SUBST([VALGRIND_CFLAGS])
AC_SUBST([VALGRIND_LIBS])
AC_DEFINE([HAVE_VALGRIND],[1],[Valgrind headers found at compile time])
],[
AS_IF([test "x$enable_valgrind" = "xyes"], [
AC_MSG_ERROR([--enable-valgrind given, but Valgrind headers are not available])
])
])
])
dnl Build the special libFuzzer version of nbdkit. DO NOT USE THIS for
dnl normal builds. See fuzzing/README.
AC_ARG_ENABLE([libfuzzer],
[AS_HELP_STRING([--enable-libfuzzer],
[build libFuzzer test binary (developers only)])],
[],
[enable_libfuzzer=no])
AS_IF([test "x$enable_libfuzzer" = "xyes"],[
AC_DEFINE([ENABLE_LIBFUZZER],[1],[Enable special libFuzzer binary])
# We have to disable the linker script for libFuzzer because Clang
# adds loads of fuzzer and ASAN-related symbols that are required
# by the plugins but which our linker script tries to hide.
use_linker_script=no
])
AM_CONDITIONAL([ENABLE_LIBFUZZER],[test "x$enable_libfuzzer" = "xyes"])
dnl Should we use the linker script (ld --version-script)? Note
dnl some tests above may set this variable.
AC_ARG_ENABLE([linker-script],
[AS_HELP_STRING([--disable-linker-script],
[disable linker script for server (developers only)])],
[use_linker_script=$enableval],
[])
AM_CONDITIONAL([USE_LINKER_SCRIPT],
[test "x$use_linker_script" = "xyes"])
dnl Bash completion.
AC_ARG_WITH([bash-completions],
[AS_HELP_STRING([--without-bash-completions], [disable installing bash completions @<:@default=check@:>@])],
[],
[: m4_divert_text([DEFAULTS], [with_readline=check])])
AS_IF([test "x$with_bash_completions" != xno], [
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], [
bash_completion=yes
AC_MSG_CHECKING([for bash-completions directory])
m4_ifdef([PKG_CHECK_VAR],[
PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir])
])
AS_IF([test -z "$bashcompdir"], [
bashcompdir="${sysconfdir}/bash_completion.d"
])
AC_MSG_RESULT([$bashcompdir])
AC_SUBST([bashcompdir])
],[
bash_completion=no
AC_MSG_WARN([bash-completion not installed])
])
])
AS_IF([test "x$bash_completion" = xno && test "x$with_bash_completions" = xyes], [
AC_MSG_ERROR([bash-completions requested but required packages not found])
])
AM_CONDITIONAL([HAVE_BASH_COMPLETION],[test "x$bash_completion" = "xyes"])
dnl Check we have enough to run podwrapper.
AC_ARG_WITH([manpages],
[AS_HELP_STRING([--without-manpages], [Do not build man pages @<:@default=check@:>@])],
[],
[: m4_divert_text([DEFAULTS], [with_manpages=check])])
enable_pod=no
AC_CHECK_PROGS([PERL], [perl], [])
AS_IF([test "x$enable_manpages" != xno], [
AS_IF([test "x$PERL" != "x"],[
AC_MSG_CHECKING([if we have perl Pod::Man and Pod::Simple])
AS_IF([$PERL -MPod::Man -MPod::Simple -e 1 >&AS_MESSAGE_LOG_FD 2>&1],[
enable_pod=yes
])
AC_MSG_RESULT([$enable_pod])
])
])
AS_IF([test "x$enable_pod" = xno && test "x$enable_manpages" = xyes], [
AC_MSG_ERROR([man-pages requested but required packages not found])
])
AM_CONDITIONAL([HAVE_POD],
[test "x$PERL" != "xno" && test "x$enable_pod" = "xyes"])
dnl Define the path to the podwrapper program.
PODWRAPPER="$PERL $(pwd)/podwrapper.pl"
AC_SUBST([PODWRAPPER])
dnl Allow all plugins and filters to be disabled.
AC_ARG_ENABLE([plugins],
[AS_HELP_STRING([--disable-plugins],
[disable all bundled plugins and filters])])
AM_CONDITIONAL([HAVE_PLUGINS], [test "x$enable_plugins" != "xno"])
dnl Check for Perl, for embedding in the perl plugin.
dnl Note that the perl binary is checked above.
AC_ARG_ENABLE([perl],
[AS_HELP_STRING([--disable-perl], [disable Perl embed plugin])],
[],
[enable_perl=yes])
AS_IF([test "x$PERL" != "xno" && test "x$enable_perl" != "xno"],[
dnl Check for Perl archlib.
AC_MSG_CHECKING([for Perl embed archlib])
PERL_ARCHLIB="$($PERL -MConfig -e 'print $Config{archlib}')"
AS_IF([ test -n "$PERL_ARCHLIB" ],[
AC_MSG_RESULT([$PERL_ARCHLIB])
],[
AC_MSG_NOTICE([Perl embed module disabled])
enable_perl=no
])
dnl Check for Perl CFLAGS.
AC_MSG_CHECKING([for Perl embed CFLAGS])
PERL_CFLAGS="$($PERL -MExtUtils::Embed -e 'ccflags')"
AS_IF([ test -n "$PERL_CFLAGS" ],[
AC_MSG_RESULT([$PERL_CFLAGS])
],[
AC_MSG_NOTICE([Perl embed module disabled])
enable_perl=no
])
dnl Check for Perl LDOPTS.
AC_MSG_CHECKING([for Perl embed LDOPTS])
PERL_LDOPTS="$($PERL -MExtUtils::Embed -e 'ldopts')"
AC_MSG_RESULT([$PERL_LDOPTS])
dnl Check these actually work.
AC_MSG_CHECKING([whether Perl modules will compile])
old_CFLAGS="$CFLAGS"
old_LIBS="$LIBS"
CFLAGS="$PERL_CFLAGS -I$PERL_ARCHLIB/CORE $CFLAGS"
LIBS="$PERL_LDOPTS $LIBS"
AC_CHECK_FUNCS([perl_alloc])
CFLAGS="$old_CFLAGS"
LIBS="$old_LIBS"
if test "x$ac_cv_func_perl_alloc" != xyes; then
enable_perl=no
fi
])
AM_CONDITIONAL([HAVE_PERL],[test "x$enable_perl" != "xno" && test "x$PERL" != "xno"])
AC_SUBST([PERL_ARCHLIB])
AC_SUBST([PERL_CFLAGS])
AC_SUBST([PERL_LDOPTS])
dnl Check for Python 3, for embedding in the python plugin.
AC_PATH_PROGS([PYTHON],[python3 python],[no])
AC_ARG_ENABLE([python],
[AS_HELP_STRING([--disable-python], [disable Python embed plugin])],
[],
[enable_python=yes])
AS_IF([test "x$PYTHON" != "xno" && test "x$enable_python" != "xno"],[
AC_MSG_CHECKING([version of $PYTHON])
PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info@<:@0@:>@)"`
PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info@<:@1@:>@)"`
PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
AS_IF([test -n "$PYTHON_VERSION"],[
AC_MSG_RESULT([$PYTHON_VERSION])
],[
AC_MSG_NOTICE([Python embed module disabled])
enable_python=no
])
AC_MSG_CHECKING([Python major version is 3])
AS_IF([test "x$PYTHON_VERSION_MAJOR" = "x3"],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
AC_MSG_ERROR([Python $PYTHON_VERSION_MAJOR <> 3 is no longer supported.
Python 2 end of life is 2020-01-01 and nbdkit >= 1.16 no longer
supports it.
If you want to use Python 2, you will need to use nbdkit 1.14.])
])
dnl Check for Python CFLAGS, libraries.
dnl For Python >= 3.8 we have to use python-<VERSION>-embed.pc, see:
dnl https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
dnl The python.pc is called python-<VERSION>.pc on Debian and
dnl later versions of Fedora, and python.pc on older versions
dnl of Fedora.
PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"-embed], [
AC_SUBST([PYTHON_CFLAGS])
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYTHON_VERSION])
AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
],[
PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"], [
AC_SUBST([PYTHON_CFLAGS])
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYTHON_VERSION])
AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
],[
PKG_CHECK_MODULES([PYTHON], [python], [
AC_SUBST([PYTHON_CFLAGS])
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYTHON_VERSION])
AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
],[
AC_MSG_WARN([python $PYTHON_VERSION not found])
enable_python=no
])])])
])
AM_CONDITIONAL([HAVE_PYTHON],[test "x$enable_python" != "xno" && test "x$PYTHON" != "xno"])
AC_SUBST([PYTHON_CFLAGS])
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYTHON_LDFLAGS])
dnl For the OCaml plugin, you can set OCAMLOPTFLAGS before running
dnl ./configure to specify any extra flags you want to pass to
dnl ocamlopt. For example to enable OCaml warnings:
dnl OCAMLOPTFLAGS="-warn-error +A-3"
AC_SUBST([OCAMLOPTFLAGS])
dnl Check for OCaml, for embedding in the ocaml plugin.
AC_PROG_OCAML
AC_ARG_ENABLE([ocaml],
[AS_HELP_STRING([--disable-ocaml], [disable OCaml embed plugin])],
[],
[enable_ocaml=yes])
AS_IF([test "x$OCAMLOPT" != "xno" && test "x$enable_ocaml" != "xno"],[
dnl Check OCaml can create a shared library (see README for details).
AC_MSG_CHECKING([if $OCAMLOPT can create a shared library])
echo 'print_endline "test"' > conftest.ml
AS_IF([$OCAMLOPT $OCAMLOPTFLAGS -output-obj -runtime-variant _pic -o conftest.so conftest.ml >&AS_MESSAGE_LOG_FD 2>&1],[
AC_MSG_RESULT([yes])
ocaml_link_shared=yes
],[
AC_MSG_RESULT([no])
])
rm -f conftest.ml conftest.cmi conftest.cmx conftest.so conftest.o
])
AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLOPT" != "xno" &&
test "x$ocaml_link_shared" = "xyes"])
AM_CONDITIONAL([HAVE_OCAMLDOC],[test "x$OCAMLDOC" != "xno"])
dnl Check if OCaml has caml_alloc_initialized_string (added 2017).
AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \
test "x$enable_ocaml" = "xyes"],[
AC_MSG_CHECKING([for caml_alloc_initialized_string])
cat >conftest.c <<'EOF'
#include <caml/alloc.h>
int main () { char *p = (void *) caml_alloc_initialized_string; return 0; }
EOF
AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_CAML_ALLOC_INITIALIZED_STRING],[1],
[caml_alloc_initialized_string found at compile time.])
],[
AC_MSG_RESULT([no])
])
rm -f conftest.c conftest.o
])
dnl Check if OCaml has caml_shutdown (added 2014).
AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \
test "x$enable_ocaml" = "xyes"],[
AC_MSG_CHECKING([for caml_shutdown])
cat >conftest.c <<'EOF'
#include <caml/callback.h>
int main () { char *p = (void *) caml_shutdown; return 0; }
EOF
AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_CAML_SHUTDOWN],[1],
[caml_shutdown found at compile time.])
],[
AC_MSG_RESULT([no])
])
rm -f conftest.c conftest.o
])
dnl For developing plugins in Rust, optional.
dnl Rust does not play nicely with VPATH builds