vddk: advise user on obscure thumbprint mismatch error condition
[nbdkit.git] / configure.ac
blob9a94b04f5ebb04cca964b1b7cbbfbea1aa0200eb
1 # nbdkit
2 # Copyright (C) 2013-2022 Red Hat Inc.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # * Neither the name of Red Hat nor the names of its contributors may be
16 # used to endorse or promote products derived from this software without
17 # specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
20 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
23 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # SUCH DAMAGE.
32 m4_define([NBDKIT_VERSION_MAJOR], [1])
33 m4_define([NBDKIT_VERSION_MINOR], [31])
34 m4_define([NBDKIT_VERSION_MICRO], [6])
35 AC_INIT([nbdkit],
36         NBDKIT_VERSION_MAJOR.NBDKIT_VERSION_MINOR.NBDKIT_VERSION_MICRO)
37 AC_CONFIG_MACRO_DIR([m4])
39 dnl This must be used very early else you will get
40 dnl "warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS"
41 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],[],
42          [m4_define([AC_USE_SYSTEM_EXTENSIONS],[])])
43 AC_USE_SYSTEM_EXTENSIONS
45 dnl NB: Do not [quote] this parameter.
46 AM_INIT_AUTOMAKE(foreign)
47 LT_INIT([win32-dll])
49 dnl Extra string, a freeform string defined by downstream packagers.
50 dnl eg. If you are packaging nbdkit for Linux distro X 1.1, you could
51 dnl   ./configure --with-extra="X release 1.1"
52 AC_ARG_WITH([extra],
53     [AS_HELP_STRING([--with-extra],
54                     [extra version information (for use by packagers)])],
55     [NBDKIT_VERSION_EXTRA="$withval"],
56     [NBDKIT_VERSION_EXTRA=]
58 AC_DEFINE_UNQUOTED([NBDKIT_VERSION_EXTRA], ["$NBDKIT_VERSION_EXTRA"],
59                    [Extra version information (for use by packagers)])
61 AC_MSG_NOTICE([nbdkit version NBDKIT_VERSION_MAJOR.NBDKIT_VERSION_MINOR.NBDKIT_VERSION_MICRO ($NBDKIT_VERSION_EXTRA)])
63 dnl List of plugins and filters.
64 lang_plugins="\
65         cc \
66         golang \
67         lua \
68         ocaml \
69         perl \
70         python \
71         ruby \
72         rust \
73         sh \
74         tcl \
75         "
76 non_lang_plugins="\
77         cdi \
78         curl \
79         data \
80         eval \
81         example1 \
82         example2 \
83         example3 \
84         example4 \
85         file \
86         floppy \
87         full \
88         guestfs \
89         info \
90         iso \
91         libvirt \
92         linuxdisk \
93         memory \
94         nbd \
95         null \
96         ondemand \
97         partitioning \
98         pattern \
99         random \
100         S3 \
101         sparse-random \
102         split \
103         ssh \
104         tmpdisk \
105         torrent \
106         vddk \
107         zero \
108         "
109 plugins="$(echo $(printf %s\\n $lang_plugins $non_lang_plugins | sort -u))"
110 filters="\
111         blocksize \
112         blocksize-policy \
113         cache \
114         cacheextents \
115         checkwrite \
116         cow \
117         ddrescue \
118         delay \
119         error \
120         exitlast \
121         exitwhen \
122         exportname \
123         ext2 \
124         extentlist \
125         fua \
126         gzip \
127         ip \
128         limit \
129         log \
130         luks \
131         multi-conn \
132         nocache \
133         noextents \
134         nofilter \
135         noparallel \
136         nozero \
137         offset \
138         partition \
139         pause \
140         protect \
141         rate \
142         readahead \
143         retry \
144         retry-request \
145         scan \
146         stats \
147         swab \
148         tar \
149         tls-fallback \
150         truncate \
151         xz \
152         "
153 AC_SUBST([plugins])
154 AC_SUBST([lang_plugins])
155 AC_SUBST([non_lang_plugins])
156 AC_SUBST([filters])
158 dnl Some very basic tools.
159 AC_PROG_SED
161 dnl Check for basic C environment.
162 AC_PROG_CC
163 AC_PROG_INSTALL
164 AC_PROG_CPP
165 AC_SYS_LARGEFILE
167 AC_C_PROTOTYPES
168 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
170 AM_PROG_CC_C_O
172 dnl Define the host CPU architecture (defines 'host_cpu').
173 AC_CANONICAL_HOST
174 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
176 dnl Define 'host_os'.
177 AC_DEFINE_UNQUOTED([host_os],["$host_os"],[Host operating system.])
179 dnl Defines WORDS_BIGENDIAN on big endian platforms.
180 AC_C_BIGENDIAN
182 dnl These are defined in <unistd.h> which is included by
183 dnl AC_DEFAULT_INCLUDES.
184 AC_CHECK_SIZEOF([pid_t])
185 AC_CHECK_SIZEOF([uid_t])
186 AC_CHECK_SIZEOF([gid_t])
188 dnl Check for C++ (optional, we just use this to test the header
189 dnl can be included from C++ code).
190 AC_PROG_CXX
192 dnl The C++ compiler test is pretty useless because even if it fails
193 dnl it sets CXX=g++.  So test the compiler actually works.
194 AC_MSG_CHECKING([if the C++ compiler really really works])
195 AS_IF([$CXX --version >&AS_MESSAGE_LOG_FD 2>&1],[have_cxx=yes],[have_cxx=no])
196 AC_MSG_RESULT([$have_cxx])
197 AM_CONDITIONAL([HAVE_CXX], [test "$have_cxx" = "yes"])
199 AC_ARG_ENABLE([gcc-warnings],
200     [AS_HELP_STRING([--enable-gcc-warnings],
201                     [turn on lots of GCC warnings (for developers)])],
202      [case $enableval in
203       yes|no) ;;
204       *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
205       esac
206       gcc_warnings=$enableval],
207       [gcc_warnings=no]
209 if test "x$gcc_warnings" = "xyes"; then
210     WARNINGS_CFLAGS="-Wall -Wshadow -Wvla -Werror"
211     AC_SUBST([WARNINGS_CFLAGS])
214 dnl Check if the compiler supports -std=c90 flag.  This is only used
215 dnl during a test.  OpenBSD GCC does not support this flag so we skip
216 dnl that test.
217 AC_MSG_CHECKING([if the compiler supports -std=c90 for ANSI C test])
218 old_CFLAGS="$CFLAGS"
219 CFLAGS="$CFLAGS -std=c90"
220 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
221     [supports_std_c90=yes],
222     [supports_std_c90=no])
223 CFLAGS="$old_CFLAGS"
224 AC_MSG_RESULT([$supports_std_c90])
225 AM_CONDITIONAL([CAN_TEST_ANSI_C], [test "x$supports_std_c90" = "xyes"])
227 dnl Check for __builtin_*_overflow.  We need the dummy parameters
228 dnl else detection doesn't work correctly for some reason.
229 AC_CHECK_DECLS([__builtin_add_overflow(int, int, int *),
230                 __builtin_mul_overflow(int, int, int *)],
231                 [], [], [])
233 dnl On Haiku we must use BSD-compatibility headers to get the endian
234 dnl macros we use.
235 AC_MSG_CHECKING(whether OS-dependent include paths are required)
236 AS_CASE([$host_os],
237   [haiku*], [CFLAGS="$CFLAGS -I`findpaths -p /system B_FIND_PATH_HEADERS_DIRECTORY`/bsd"; AC_MSG_RESULT(yes)],
238   [AC_MSG_RESULT(no)]
241 dnl On Linux /tmp is often tmpfs which is not large enough, so use /var/tmp.
242 dnl But Haiku only has /tmp.
243 AC_MSG_CHECKING([for temporary directory for large files])
244 AS_CASE([$host_os],
245   [haiku*], [LARGE_TMPDIR=/tmp],
246   [LARGE_TMPDIR=/var/tmp]
248 AC_MSG_RESULT([$LARGE_TMPDIR])
249 AC_DEFINE_UNQUOTED([LARGE_TMPDIR],["$LARGE_TMPDIR"],
250                    [Temporary directory for large files])
252 dnl Check if libc has program_invocation_short_name.
253 AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
255 AX_PTHREAD
257 dnl Check if __attribute__((cleanup(...))) works.
258 dnl Set -Werror, otherwise gcc will only emit a warning for attributes
259 dnl that it doesn't understand.
260 acx_nbdkit_save_CFLAGS="${CFLAGS}"
261 CFLAGS="${CFLAGS} -Werror"
262 AC_MSG_CHECKING([if __attribute__((cleanup(...))) works with this compiler])
263 AC_COMPILE_IFELSE([
264 AC_LANG_SOURCE([[
265 #include <stdio.h>
266 #include <stdlib.h>
268 void
269 freep (void *ptr)
271   exit (EXIT_SUCCESS);
274 void
275 test (void)
277   __attribute__((cleanup(freep))) char *ptr = malloc (100);
278   (void)ptr;
282 main (int argc, char *argv[])
284   test ();
285   exit (EXIT_FAILURE);
288     ],[
289     AC_MSG_RESULT([yes])
290     ],[
291     AC_MSG_RESULT([no])
292     AC_MSG_ERROR(
293 ['__attribute__((cleanup(...)))' does not work.
295 You may not be using a sufficiently recent version of GCC or CLANG, or
296 you may be using a C compiler which does not support this attribute,
297 or the configure test may be wrong.
299 This code requires the attribute to work for proper locking between threads.])])
300 CFLAGS="${acx_nbdkit_save_CFLAGS}"
302 dnl Check for __auto_type (GCC extension).
303 AC_MSG_CHECKING([if __auto_type is available in this compiler])
304 AC_COMPILE_IFELSE([
305 AC_LANG_SOURCE([[
306 static int
307 test (int a)
309   __auto_type at = a;
310   return at;
313     ],[
314     AC_MSG_RESULT([yes])
315     AC_DEFINE([HAVE_AUTO_TYPE],[1],[__auto_type is available])
316     ],[
317     AC_MSG_RESULT([no])
318     ]
321 dnl 'environ' is not always declared in public header files:
322 dnl Linux => <unistd.h>  Haiku => <stdlib.h>
323 dnl FreeBSD & OpenBSD => not declared
324 dnl On platforms where it's not declared we must add an extern decl.
325 AC_MSG_CHECKING([if environ is declared in header files])
326 AC_COMPILE_IFELSE([
327 AC_LANG_SOURCE([[
328 #include <stdlib.h>
329 #include <unistd.h>
330 static int
331 test (void)
333   const char **env = environ;
334   return env ? 1 : 0; // this just forces env to be used
337     ],[
338     AC_MSG_RESULT([yes])
339     AC_DEFINE([HAVE_ENVIRON_DECL],[1],[environ is declared in headers])
340     ],[
341     AC_MSG_RESULT([no])
342     ]
345 dnl Check for other headers, all optional.
346 AC_CHECK_HEADERS([\
347         alloca.h \
348         afunix.h \
349         arpa/inet.h \
350         byteswap.h \
351         endian.h \
352         grp.h \
353         linux/fs.h \
354         netdb.h \
355         netinet/in.h \
356         netinet/tcp.h \
357         pwd.h \
358         termios.h \
359         stdatomic.h \
360         syslog.h \
361         sys/endian.h \
362         sys/ioctl.h \
363         sys/mman.h \
364         sys/prctl.h \
365         sys/procctl.h \
366         sys/socket.h \
367         sys/statvfs.h \
368         sys/ucred.h \
369         sys/un.h \
370         sys/vsock.h \
371         sys/wait.h \
372         winsock2.h])
374 AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [#include <sys/socket.h>])
376 dnl Check for functions in libc, all optional.
377 AC_CHECK_FUNCS([\
378         accept4 \
379         fdatasync \
380         flockfile \
381         funlockfile \
382         inet_ntop \
383         inet_pton \
384         mkostemp \
385         mlock \
386         mlockall \
387         munlock \
388         open_memstream \
389         pipe \
390         pipe2 \
391         ppoll \
392         posix_fadvise \
393         posix_memalign \
394         valloc])
396 dnl Check for structs and members.
397 AC_CHECK_MEMBERS([struct dirent.d_type], [], [], [[#include <dirent.h>]])
398 AC_CHECK_MEMBERS([struct ucred.uid], [], [],
399                  [[
400 #ifdef HAVE_SYS_SOCKET_H
401 #include <sys/socket.h>
402 #endif
403 #ifdef HAVE_SYS_UCRED_H
404 #include <sys/ucred.h>
405 #endif
407 AC_CHECK_MEMBERS([struct sockpeercred.uid], [], [],
408                  [[
409 #ifdef HAVE_SYS_SOCKET_H
410 #include <sys/socket.h>
411 #endif
414 dnl Replacement functions that we provide for some platforms.
415 AC_CONFIG_LIBOBJ_DIR([common/replacements])
416 AC_REPLACE_FUNCS([\
417         fdatasync \
418         fsync \
419         get_current_dir_name \
420         getdelim \
421         getline \
422         openlog \
423         open_memstream \
424         poll \
425         posix_memalign \
426         pread \
427         pwrite \
428         realpath \
429         strndup \
430         sysconf \
431         syslog \
432         vsyslog])
434 dnl Check whether printf("%m") works
435 AC_CACHE_CHECK([whether the printf family supports %m],
436   [nbdkit_cv_func_printf_percent_m],
437   [AC_RUN_IFELSE(
438     [AC_LANG_PROGRAM([[
439 #include <stdio.h>
440 #include <string.h>
441 #include <errno.h>
442     ]], [[
443     char buf[200] = "";
444     errno = EINVAL;
445     snprintf(buf, sizeof buf, "%m");
446     return !!strcmp (buf, strerror (EINVAL));
447     ]])],
448     [nbdkit_cv_func_printf_percent_m=yes],
449     [nbdkit_cv_func_printf_percent_m=no],
450     [[
451     case "$host_os" in
452       *-gnu* | gnu*) nbdkit_cv_func_printf_percent_m=yes;;
453       *) nbdkit_cv_func_printf_percent_m="guessing no";;
454     esac
455     ]])])
456 AS_IF([test "x$nbdkit_cv_func_printf_percent_m" = xyes],
457   [AC_DEFINE([HAVE_VFPRINTF_PERCENT_M],[1],
458     [Define to 1 if vfprintf supports %m.])])
460 old_LIBS="$LIBS"
461 AC_SEARCH_LIBS([dlsym], [dl dld], [
462         AS_IF([test "x$ac_cv_search_dlsym" != "xnone required"],
463             [DL_LIBS="$ac_cv_search_dlsym"], [DL_LIBS=])
464         AC_SUBST([DL_LIBS])
465     ], [AC_MSG_ERROR([unable to find the dlsym() function])
467 LIBS="$old_LIBS"
469 dnl Test if <iconv.h> header can build working binaries.
471 dnl On FreeBSD: iconv and libiconv both exist, both can be installed
472 dnl simultaneously, <iconv.h> can exist in two separate places, and
473 dnl if you get the wrong header/library mix everything breaks.
475 dnl On Haiku: libiconv is required to link to iconv_* functions.
476 AC_ARG_WITH([iconv],
477     [AS_HELP_STRING([--without-iconv],
478                     [don't try to link against iconv @<:@default=check@:>@])],
479     [],
480     [with_iconv=check])
481 AS_IF([test "x$with_iconv" != "xno"],[
482     AC_CHECK_HEADER([iconv.h],[
483         AC_MSG_CHECKING([if <iconv.h> can be used to link a program])
484         AC_LINK_IFELSE([
485 AC_LANG_SOURCE([[
486 #include <stdio.h>
487 #include <stdlib.h>
488 #include <iconv.h>
490 main (int argc, char *argv[])
492   iconv_t ic = iconv_open ("", "");
493   iconv_close (ic);
494   exit (0);
497             ],[
498             AC_MSG_RESULT([yes])
499             iconv_working=yes
500             ],[
501             AC_MSG_RESULT([no])
502             ])
503         ])
504     ])
505 AM_CONDITIONAL([HAVE_ICONV], [test "x$iconv_working" = "xyes"])
507 use_linker_script_for_server=yes
509 dnl Don't use linker script for the server on FreeBSD because
510 dnl FreeBSD's linker is broken.  See eg:
511 dnl https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190851
512 AC_MSG_CHECKING([if we should disable the linker script (FreeBSD only)])
513 AS_CASE([$host_os],
514   [freebsd*], [
515       use_linker_script_for_server=no
516       AC_MSG_RESULT([yes])
517   ],
518   [AC_MSG_RESULT([no])]
521 dnl Check if -rdynamic linker flag works.
522 acx_nbdkit_save_LDFLAGS="${LDFLAGS}"
523 LDFLAGS="${LDFLAGS} -rdynamic"
524 AC_MSG_CHECKING([if linker supports -rdynamic])
525 AC_LINK_IFELSE([
526 AC_LANG_SOURCE([[
527 #include <stdlib.h>
529 main (int argc, char *argv[])
531   exit (EXIT_SUCCESS);
534     ],[
535     AC_MSG_RESULT([yes])
536     DL_LDFLAGS=-rdynamic
537     ],[
538     AC_MSG_RESULT([no])
540 dnl restore CFLAGS
541 LDFLAGS="${acx_nbdkit_save_LDFLAGS}"
542 AC_SUBST([DL_LDFLAGS])
544 dnl Check for dladdr in -ldl, optional.  This is a glibc extension.
545 old_LIBS="$LIBS"
546 LIBS="$DL_LIBS $LIBS"
547 AC_CHECK_FUNCS([dladdr])
548 LIBS="$old_LIBS"
550 dnl Is this Windows?
551 AC_MSG_CHECKING([if the target is Windows])
552 AS_CASE([$host_os],
553     [mingw*|msys*], [
554         is_windows=yes
555         LIBS="$LIBS -lmsvcrt -lkernel32 -luser32 -lws2_32"
556         NO_UNDEFINED_ON_WINDOWS="-no-undefined"
557         IMPORT_LIBRARY_ON_WINDOWS='-Wl,-L$(top_builddir)/server -Wl,-lnbdkit'
558         SOEXT="dll"
559         DIR_SEPARATOR_STR='\\'
560     ],
561     [is_windows=no
562      SOEXT="so"
563      DIR_SEPARATOR_STR=/]
565 AC_MSG_RESULT([$is_windows])
566 AC_SUBST([NO_UNDEFINED_ON_WINDOWS])
567 AC_SUBST([IMPORT_LIBRARY_ON_WINDOWS])
568 AC_SUBST([SOEXT])
569 AC_DEFINE_UNQUOTED([SOEXT],["$SOEXT"],[Extension used for shared objects/DLLs.])
570 AC_DEFINE_UNQUOTED([EXEEXT],["$EXEEXT"],[Extension used for executables.])
571 AC_DEFINE_UNQUOTED([DIR_SEPARATOR_STR],["$DIR_SEPARATOR_STR"],
572                    [String that separates path elements.])
573 AM_CONDITIONAL([IS_WINDOWS],[test "x$is_windows" = "xyes"])
575 AS_IF([test "x$is_windows" = "xyes"],[
576     dnl For Windows, look for the mc/windmc utility.
577     dnl XXX Do we need to check for mc.exe as well?
578     AC_CHECK_TOOLS([MC],[windmc mc],[no])
579     AS_IF([test "x$MC" = "xno"],
580           [AC_MSG_ERROR([mc/windmc utility must be available when compiling for Windows])])
582     dnl On Windows look for dlltool.
583     AC_CHECK_TOOLS([DLLTOOL],[dlltool],[no])
584     AS_IF([test "x$DLLTOOL" = "xno"],
585           [AC_MSG_ERROR([dlltool utility must be available when compiling for Windows])])
588 AC_SEARCH_LIBS([getaddrinfo], [network socket])
590 dnl Does this platform require libc_malloc_debug.so.0 (glibc >= 2.34)?
591 AC_MSG_CHECKING([if this is glibc >= 2.34])
592 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
593 #include <limits.h>
594 #if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 34)
595 #error "not glibc 2.34"
596 #endif
597         ]])], [is_glibc_234=yes], [is_glibc_234=no]
599 AC_MSG_RESULT([$is_glibc_234])
600 AM_CONDITIONAL([HAVE_GLIBC_234], [test "x$is_glibc_234" = "xyes"])
602 dnl Check for SELinux socket labelling (optional).
603 PKG_CHECK_MODULES([LIBSELINUX], [libselinux], [
604     AC_SUBST([LIBSELINUX_CFLAGS])
605     AC_SUBST([LIBSELINUX_LIBS])
606     AC_DEFINE([HAVE_LIBSELINUX],[1],[libselinux found at compile time.])
607 ], [
608     AC_MSG_WARN([libselinux not found, SELinux socket labelling support will be disabled.])
611 dnl Check for GnuTLS (optional, for TLS support).
612 PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0], [
613     AC_SUBST([GNUTLS_CFLAGS])
614     AC_SUBST([GNUTLS_LIBS])
615     AC_DEFINE([HAVE_GNUTLS],[1],[gnutls found at compile time.])
616 ], [
617     AC_MSG_WARN([gnutls not found or < 3.3.0, TLS support will be disabled.])
619 AM_CONDITIONAL([HAVE_GNUTLS], [test "x$GNUTLS_LIBS" != "x"])
621 AS_IF([test "x$GNUTLS_LIBS" != "x"],[
622     AC_MSG_CHECKING([for default TLS session priority string])
623     AC_ARG_WITH([tls-priority],
624         [AS_HELP_STRING([--with-tls-priority],
625                         [default TLS session priority string @<:@default=NORMAL@:>@])],
626         [tls_priority=$withval],
627         [tls_priority=NORMAL])
628     AC_MSG_RESULT([$tls_priority])
629     AC_DEFINE_UNQUOTED([TLS_PRIORITY],["$tls_priority"],
630                        [Default TLS session priority string])
632     # Check for APIs which may not be present.
633     old_LIBS="$LIBS"
634     LIBS="$GNUTLS_LIBS $LIBS"
635     AC_CHECK_FUNCS([\
636         gnutls_base64_decode2 \
637         gnutls_certificate_set_known_dh_params \
638         gnutls_group_get \
639         gnutls_group_get_name \
640         gnutls_pbkdf2 \
641         gnutls_session_set_verify_cert \
642         gnutls_srp_server_get_username \
643     ])
644     LIBS="$old_LIBS"
646 AM_CONDITIONAL([HAVE_GNUTLS_PBKDF2],
647     [test "x$GNUTLS_LIBS" != "x" && test "x$ac_cv_func_gnutls_pbkdf2" = xyes])
649 AC_ARG_ENABLE([linuxdisk],
650     [AS_HELP_STRING([--disable-linuxdisk],
651                     [disable linuxdisk plugin @<:@default=check@:>@])],
652     [],
653     [enable_linuxdisk=check])
654 dnl Check for mke2fs -d (used by linuxdisk plugin).  There are two
655 dnl possible outcomes that we care about: (1) We have mke2fs and
656 dnl it supports the -d option.  (2) We either don't have mke2fs
657 dnl or it's too old to support the -d option (eg. on RHEL 7).
658 mke2fs_with_d=no
659 AS_IF([test "$enable_linuxdisk" != "no"], [
660     AC_MSG_CHECKING([for mke2fs supporting the -d option])
661     AS_IF([mke2fs -V >/dev/null 2>&1], [
662         AS_IF([LANG=C mke2fs -d 2>&1 | grep -sq "option requires an argument"], [
663             mke2fs_with_d=yes
664         ])
665     ])
666     AC_MSG_RESULT([$mke2fs_with_d])
668 AM_CONDITIONAL([HAVE_MKE2FS_WITH_D],[test "x$mke2fs_with_d" = "xyes"])
670 dnl Check for valgrind.
671 AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[no])
673 dnl If valgrind headers are available (optional).
674 dnl Although the runtime check adds only a trivial amount of code, you can
675 dnl avoid it with explicit --disable-valgrind.
676 AC_ARG_ENABLE([valgrind],
677     [AS_HELP_STRING([--disable-valgrind],
678                     [disable Valgrind probe])],
679     [],
680     [enable_valgrind=check])
681 AS_IF([test "x$enable_valgrind" != "xno"],[
682     PKG_CHECK_MODULES([VALGRIND], [valgrind], [
683         AC_SUBST([VALGRIND_CFLAGS])
684         AC_SUBST([VALGRIND_LIBS])
685         AC_DEFINE([HAVE_VALGRIND],[1],[Valgrind headers found at compile time])
686     ],[
687         AS_IF([test "x$enable_valgrind" = "xyes"], [
688             AC_MSG_ERROR([--enable-valgrind given, but Valgrind headers are not available])
689         ])
690     ])
693 dnl Build the special libFuzzer version of nbdkit.  DO NOT USE THIS for
694 dnl normal builds.  See fuzzing/README.
695 AC_ARG_ENABLE([libfuzzer],
696     [AS_HELP_STRING([--enable-libfuzzer],
697                     [build libFuzzer test binary (developers only)])],
698     [],
699     [enable_libfuzzer=no])
700 AS_IF([test "x$enable_libfuzzer" = "xyes"],[
701     AC_DEFINE([ENABLE_LIBFUZZER],[1],[Enable special libFuzzer binary])
702     # We have to disable the linker script for libFuzzer because Clang
703     # adds loads of fuzzer and ASAN-related symbols that are required
704     # by the plugins but which our linker script tries to hide.
705     use_linker_script_for_server=no
707 AM_CONDITIONAL([ENABLE_LIBFUZZER],[test "x$enable_libfuzzer" = "xyes"])
709 dnl Should we use the linker script with the server?  Note
710 dnl some tests above may set this variable.
711 AC_ARG_ENABLE([linker-script],
712     [AS_HELP_STRING([--disable-linker-script],
713                     [disable linker script for server (developers only)])],
714     [use_linker_script_for_server=$enableval],
715     [])
716 AM_CONDITIONAL([USE_LINKER_SCRIPT_FOR_SERVER],
717                [test "x$use_linker_script_for_server" = "xyes"])
719 dnl Bash completion.
720 PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], [
721     bash_completion=yes
722     AC_MSG_CHECKING([for bash-completions directory])
723     m4_ifdef([PKG_CHECK_VAR],[
724         PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir])
725     ])
726     AS_IF([test -z "$bashcompdir"], [
727         bashcompdir="${sysconfdir}/bash_completion.d"
728     ])
729     AC_MSG_RESULT([$bashcompdir])
730     AC_SUBST([bashcompdir])
732     bash_completion=no
733     AC_MSG_WARN([bash-completion not installed])
735 AM_CONDITIONAL([HAVE_BASH_COMPLETION],[test "x$bash_completion" = "xyes"])
737 dnl Check we have enough to run podwrapper.
738 AC_CHECK_PROG([PERL],[perl],[perl],[no])
739 AS_IF([test "x$PERL" != "xno"],[
740     AC_MSG_CHECKING([if we have perl Pod::Man and Pod::Simple])
741     AS_IF([$PERL -MPod::Man -MPod::Simple -e 1 >&AS_MESSAGE_LOG_FD 2>&1],[
742         enable_pod=yes
743     ],[
744         enable_pod=no
745     ])
746     AC_MSG_RESULT([$enable_pod])
748 AM_CONDITIONAL([HAVE_POD],
749                [test "x$PERL" != "xno" && test "x$enable_pod" = "xyes"])
751 dnl Define the path to the podwrapper program.
752 PODWRAPPER="$PERL $(pwd)/podwrapper.pl"
753 AC_SUBST([PODWRAPPER])
755 dnl Allow all plugins and filters to be disabled.
756 AC_ARG_ENABLE([plugins],
757     [AS_HELP_STRING([--disable-plugins],
758                     [disable all bundled plugins and filters])])
759 AM_CONDITIONAL([HAVE_PLUGINS], [test "x$enable_plugins" != "xno"])
761 dnl Check for Perl, for embedding in the perl plugin.
762 dnl Note that the perl binary is checked above.
763 AC_ARG_ENABLE([perl],
764     [AS_HELP_STRING([--disable-perl], [disable Perl embed plugin])],
765     [],
766     [enable_perl=yes])
767 AS_IF([test "x$PERL" != "xno" && test "x$enable_perl" != "xno"],[
768     dnl Check for Perl archlib.
769     AC_MSG_CHECKING([for Perl embed archlib])
770     PERL_ARCHLIB="$($PERL -MConfig -e 'print $Config{archlib}')"
771     AS_IF([ test -n "$PERL_ARCHLIB" ],[
772         AC_MSG_RESULT([$PERL_ARCHLIB])
773     ],[
774         AC_MSG_NOTICE([Perl embed module disabled])
775         enable_perl=no
776     ])
778     dnl Check for Perl CFLAGS.
779     AC_MSG_CHECKING([for Perl embed CFLAGS])
780     PERL_CFLAGS="$($PERL -MExtUtils::Embed -e 'ccflags')"
781     AS_IF([ test -n "$PERL_CFLAGS" ],[
782         AC_MSG_RESULT([$PERL_CFLAGS])
783     ],[
784         AC_MSG_NOTICE([Perl embed module disabled])
785         enable_perl=no
786     ])
788     dnl Check for Perl LDOPTS.
789     AC_MSG_CHECKING([for Perl embed LDOPTS])
790     PERL_LDOPTS="$($PERL -MExtUtils::Embed -e 'ldopts')"
791     AC_MSG_RESULT([$PERL_LDOPTS])
793     dnl XXX Could check these actually work.
795 AM_CONDITIONAL([HAVE_PERL],[test "x$enable_perl" != "xno" && test "x$PERL" != "xno"])
796 AC_SUBST([PERL_ARCHLIB])
797 AC_SUBST([PERL_CFLAGS])
798 AC_SUBST([PERL_LDOPTS])
800 dnl Check for Python 3, for embedding in the python plugin.
801 AC_PATH_PROGS([PYTHON],[python3 python],[no])
802 AC_ARG_ENABLE([python],
803     [AS_HELP_STRING([--disable-python], [disable Python embed plugin])],
804     [],
805     [enable_python=yes])
806 AS_IF([test "x$PYTHON" != "xno" && test "x$enable_python" != "xno"],[
807     AC_MSG_CHECKING([version of $PYTHON])
808     PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info@<:@0@:>@)"`
809     PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info@<:@1@:>@)"`
810     PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
811     AS_IF([test -n "$PYTHON_VERSION"],[
812         AC_MSG_RESULT([$PYTHON_VERSION])
813     ],[
814         AC_MSG_NOTICE([Python embed module disabled])
815         enable_python=no
816     ])
818     AC_MSG_CHECKING([Python major version is 3])
819     AS_IF([test "x$PYTHON_VERSION_MAJOR" = "x3"],[
820         AC_MSG_RESULT([yes])
821     ],[
822         AC_MSG_RESULT([no])
823         AC_MSG_ERROR([Python $PYTHON_VERSION_MAJOR <> 3 is no longer supported.
825 Python 2 end of life is 2020-01-01 and nbdkit >= 1.16 no longer
826 supports it.
828 If you want to use Python 2, you will need to use nbdkit 1.14.])
829     ])
831     dnl Check for Python CFLAGS, libraries.
832     dnl For Python >= 3.8 we have to use python-<VERSION>-embed.pc, see:
833     dnl https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
834     dnl The python.pc is called python-<VERSION>.pc on Debian and
835     dnl later versions of Fedora, and python.pc on older versions
836     dnl of Fedora.
837     PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"-embed], [
838         AC_SUBST([PYTHON_CFLAGS])
839         AC_SUBST([PYTHON_LIBS])
840         AC_SUBST([PYTHON_VERSION])
841         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
842     ],[
843     PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"], [
844         AC_SUBST([PYTHON_CFLAGS])
845         AC_SUBST([PYTHON_LIBS])
846         AC_SUBST([PYTHON_VERSION])
847         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
848     ],[
849     PKG_CHECK_MODULES([PYTHON], [python], [
850         AC_SUBST([PYTHON_CFLAGS])
851         AC_SUBST([PYTHON_LIBS])
852         AC_SUBST([PYTHON_VERSION])
853         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
854     ],[
855         AC_MSG_WARN([python $PYTHON_VERSION not found])
856         enable_python=no
857     ])])])
859 AM_CONDITIONAL([HAVE_PYTHON],[test "x$enable_python" != "xno" && test "x$PYTHON" != "xno"])
860 AC_SUBST([PYTHON_CFLAGS])
861 AC_SUBST([PYTHON_LIBS])
862 AC_SUBST([PYTHON_LDFLAGS])
864 dnl For the OCaml plugin, you can set OCAMLOPTFLAGS before running
865 dnl ./configure to specify any extra flags you want to pass to
866 dnl ocamlopt.  For example to enable OCaml warnings:
867 dnl OCAMLOPTFLAGS="-warn-error +A-3"
868 AC_SUBST([OCAMLOPTFLAGS])
870 dnl Check for OCaml, for embedding in the ocaml plugin.
871 AC_PROG_OCAML
872 AC_ARG_ENABLE([ocaml],
873     [AS_HELP_STRING([--disable-ocaml], [disable OCaml embed plugin])],
874     [],
875     [enable_ocaml=yes])
876 AS_IF([test "x$OCAMLOPT" != "xno" && test "x$enable_ocaml" != "xno"],[
877     dnl Check OCaml can create a shared library (see README for details).
878     AC_MSG_CHECKING([if $OCAMLOPT can create a shared library])
879     echo 'print_endline "test"' > conftest.ml
880     AS_IF([$OCAMLOPT $OCAMLOPTFLAGS -output-obj -runtime-variant _pic -o conftest.so conftest.ml >&AS_MESSAGE_LOG_FD 2>&1],[
881         AC_MSG_RESULT([yes])
882         ocaml_link_shared=yes
883     ],[
884         AC_MSG_RESULT([no])
885     ])
886     rm -f conftest.ml conftest.cmi conftest.cmx conftest.so conftest.o
888 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLOPT" != "xno" &&
889                              test "x$ocaml_link_shared" = "xyes"])
890 AM_CONDITIONAL([HAVE_OCAMLDOC],[test "x$OCAMLDOC" != "xno"])
892 dnl Check if OCaml has caml_alloc_initialized_string (added 2017).
893 AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \
894        test "x$enable_ocaml" = "xyes"],[
895     AC_MSG_CHECKING([for caml_alloc_initialized_string])
896     cat >conftest.c <<'EOF'
897 #include <caml/alloc.h>
898 int main () { char *p = (void *) caml_alloc_initialized_string; return 0; }
900     AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[
901         AC_MSG_RESULT([yes])
902         AC_DEFINE([HAVE_CAML_ALLOC_INITIALIZED_STRING],[1],
903                   [caml_alloc_initialized_string found at compile time.])
904     ],[
905         AC_MSG_RESULT([no])
906     ])
907     rm -f conftest.c conftest.o
910 dnl Check if OCaml has caml_shutdown (added 2014).
911 AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \
912        test "x$enable_ocaml" = "xyes"],[
913     AC_MSG_CHECKING([for caml_shutdown])
914     cat >conftest.c <<'EOF'
915 #include <caml/callback.h>
916 int main () { char *p = (void *) caml_shutdown; return 0; }
918     AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[
919         AC_MSG_RESULT([yes])
920         AC_DEFINE([HAVE_CAML_SHUTDOWN],[1],
921                   [caml_shutdown found at compile time.])
922     ],[
923         AC_MSG_RESULT([no])
924     ])
925     rm -f conftest.c conftest.o
928 dnl For developing plugins in Rust, optional.
929 AC_CHECK_PROG([CARGO],[cargo],[cargo],[no])
930 AC_ARG_ENABLE([rust],
931     [AS_HELP_STRING([--disable-rust], [disable Rust plugin])],
932     [],
933     [enable_rust=yes])
934 AM_CONDITIONAL([HAVE_RUST],
935                [test "x$CARGO" != "xno" && test "x$enable_rust" != "xno"])
937 dnl Check for Ruby, for embedding in the Ruby plugin.
938 AC_CHECK_PROG([RUBY],[ruby],[ruby],[no])
939 AC_ARG_ENABLE([ruby],
940     [AS_HELP_STRING([--disable-ruby], [disable Ruby plugin])],
941     [],
942     [enable_ruby=yes])
943 AS_IF([test "x$RUBY" != "xno" && test "x$enable_ruby" != "xno"],[
944     PKG_CHECK_MODULES([RUBY], [ruby], [
945         AC_SUBST([RUBY_CFLAGS])
946         AC_SUBST([RUBY_LIBS])
947     ],[
948         AC_MSG_WARN([ruby not found])
949         enable_ruby=no
950     ])
952 AM_CONDITIONAL([HAVE_RUBY],[test "x$RUBY" != "xno" &&
953                             test "x$enable_ruby" = "xyes"])
955 dnl Check for Tcl, for embedding in the Tcl plugin.
956 AC_ARG_ENABLE([tcl],
957     [AS_HELP_STRING([--disable-tcl], [disable Tcl plugin])],
958     [],
959     [enable_tcl=yes])
960 AS_IF([test "x$enable_tcl" != "xno"],[
961     PKG_CHECK_MODULES([TCL], [tcl], [
962         AC_SUBST([TCL_CFLAGS])
963         AC_SUBST([TCL_LIBS])
964     ],[
965         AC_MSG_WARN([Tcl not found])
966         enable_tcl=no
967     ])
969 AM_CONDITIONAL([HAVE_TCL],[test "x$enable_tcl" = "xyes"])
971 dnl Check for Lua, for embedding in the Lua plugin.
972 AC_ARG_ENABLE([lua],
973     [AS_HELP_STRING([--disable-lua], [disable Lua plugin])],
974     [],
975     [enable_lua=yes])
976 AS_IF([test "x$enable_lua" != "xno"],[
977     PKG_CHECK_MODULES([LUA], [lua], [
978         AC_SUBST([LUA_CFLAGS])
979         AC_SUBST([LUA_LIBS])
981         dnl Lua 5.1 used by RHEL 7 does not have lua_isinteger.
982         old_LIBS="$LIBS"
983         LIBS="$LUA_LIBS $LIBS"
984         AC_CHECK_FUNCS([lua_isinteger])
985         LIBS="$old_LIBS"
986     ],[
987         AC_MSG_WARN([Lua not found])
988         enable_lua=no
989     ])
991 AM_CONDITIONAL([HAVE_LUA],[test "x$enable_lua" = "xyes"])
993 dnl Check for golang.
994 AC_ARG_ENABLE([golang],
995     AS_HELP_STRING([--disable-golang], [disable Go language plugin]),
996         [],
997         [enable_golang=yes])
998 AS_IF([test "x$enable_golang" != "xno"],[
999     AC_CHECK_PROG([GOLANG],[go],[go],[no])
1000     AS_IF([test "x$GOLANG" != "xno"],[
1001         AC_MSG_CHECKING([if $GOLANG is usable])
1002         AS_IF([$GOLANG run $srcdir/plugins/golang/config-test.go 2>&AS_MESSAGE_LOG_FD && \
1003                $GOLANG help modules 2>&AS_MESSAGE_LOG_FD 1>&2],[
1004             AC_MSG_RESULT([yes])
1006             # Substitute some golang environment.
1007             GOOS=`$GOLANG env GOOS`
1008             GOARCH=`$GOLANG env GOARCH`
1009             GOROOT=`$GOLANG env GOROOT`
1010             AC_SUBST([GOOS])
1011             AC_SUBST([GOARCH])
1012             AC_SUBST([GOROOT])
1013         ],[
1014             AC_MSG_RESULT([no])
1015             AC_MSG_WARN([golang ($GOLANG) is installed but not usable])
1016             GOLANG=no
1017         ])
1018     ])
1019 ],[GOLANG=no])
1020 AM_CONDITIONAL([HAVE_GOLANG],[test "x$GOLANG" != "xno"])
1022 dnl Check for curl (only if you want to compile the curl plugin).
1023 AC_ARG_WITH([curl],
1024     [AS_HELP_STRING([--without-curl],
1025                     [disable curl plugin @<:@default=check@:>@])],
1026     [],
1027     [with_curl=check])
1028 AS_IF([test "$with_curl" != "no"],[
1029     PKG_CHECK_MODULES([CURL], [libcurl],[
1030         AC_SUBST([CURL_CFLAGS])
1031         AC_SUBST([CURL_LIBS])
1032         AC_DEFINE([HAVE_CURL],[1],[curl found at compile time.])
1033         AC_CHECK_DECL([CURLOPT_UNIX_SOCKET_PATH], [
1034             AC_DEFINE([HAVE_CURLOPT_UNIX_SOCKET_PATH],[1],
1035                       [CURLOPT_UNIX_SOCKET_PATH found at compile time.])
1036             ], [], [#include <curl/curl.h>])
1037     ],
1038     [AC_MSG_WARN([curl not found, curl plugin will be disabled])])
1040 AM_CONDITIONAL([HAVE_CURL],[test "x$CURL_LIBS" != "x"])
1042 dnl Check for libssh (only if you want to compile the ssh plugin).
1043 AC_ARG_WITH([ssh],
1044     [AS_HELP_STRING([--without-ssh],
1045                     [disable ssh plugin @<:@default=check@:>@])],
1046     [],
1047     [with_ssh=check])
1048 AS_IF([test "$with_ssh" != "no"],[
1049     PKG_CHECK_MODULES([SSH], [libssh >= 0.8.0],[
1050         # Ubuntu 18.04 shipped prerelease of libssh-0.8.0 without
1051         # SSH_OPTIONS_NODELAY
1052         old_CFLAGS="$CFLAGS"
1053         CFLAGS="$CFLAGS $SSH_CFLAGS"
1054         AC_CHECK_DECL([SSH_OPTIONS_NODELAY], [
1055             AC_SUBST([SSH_CFLAGS])
1056             AC_SUBST([SSH_LIBS])
1057             # We don't need this in the code, just in this configure
1058             HAVE_SSH_OPTIONS_NODELAY=1
1059             ], [], [
1060             #include <libssh/libssh.h>
1061         ])
1062         CFLAGS="$old_CFLAGS"
1063     ],
1064     [AC_MSG_WARN([libssh not found, ssh plugin will be disabled])])
1066 AM_CONDITIONAL([HAVE_SSH],[test "x$HAVE_SSH_OPTIONS_NODELAY" != "x"])
1068 dnl Check for xorriso or genisoimage or mkisofs
1069 dnl (only if you want to compile the iso plugin).
1070 ISOPROG="no"
1071 is_xorriso=0
1072 AC_ARG_WITH([iso],
1073     [AS_HELP_STRING([--without-iso],
1074                     [disable iso plugin @<:@default=check@:>@])],
1075     [],
1076     [with_iso=check])
1077 AS_IF([test "$with_iso" != "no"],[
1078     AC_CHECK_PROG([XORRISO],[xorriso],[xorriso],[no])
1079     AC_CHECK_PROG([GENISOIMAGE],[genisoimage],[genisoimage],[no])
1080     AC_CHECK_PROG([MKISOFS],[mkisofs],[mkisofs],[no])
1081     AS_IF([test "x$XORRISO" != "xno"],[
1082         ISOPROG="$XORRISO"
1083         is_xorriso=1
1084     ],[
1085         AS_IF([test "x$GENISOIMAGE" != "xno"],[
1086             ISOPROG="$GENISOIMAGE"
1087         ],[
1088             AS_IF([test "x$MKISOFS" != "xno"],[
1089                 ISOPROG="$MKISOFS"
1090             ])
1091         ])
1092     ])
1093     AS_IF([test "x$ISOPROG" != "xno"],[
1094         AC_MSG_RESULT([Picked $ISOPROG for nbdkit-iso-plugin])
1095         AC_DEFINE_UNQUOTED([ISOPROG],["$ISOPROG"],
1096                            [Program used by iso plugin to make ISOs.])
1097         AS_IF([test "x$is_xorriso" = "x1"], [
1098             AC_DEFINE([ISOPROG_IS_XORRISO],[1],
1099                       [ISO program behaves like xorriso.])
1100         ])
1101     ])
1103 AC_SUBST([ISOPROG])
1104 AM_CONDITIONAL([HAVE_ISO],[test "x$ISOPROG" != "xno"])
1106 dnl Check for libvirt (only if you want to compile the libvirt plugin).
1107 AC_ARG_WITH([libvirt],
1108     [AS_HELP_STRING([--without-libvirt],
1109                     [disable libvirt plugin @<:@default=check@:>@])],
1110     [],
1111     [with_libvirt=check])
1112 AS_IF([test "$with_libvirt" != "no"],[
1113     PKG_CHECK_MODULES([LIBVIRT], [libvirt],[
1114         AC_SUBST([LIBVIRT_CFLAGS])
1115         AC_SUBST([LIBVIRT_LIBS])
1116         AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.])
1117     ],
1118     [AC_MSG_WARN([libvirt not found, libvirt plugin will be disabled])])
1120 AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
1122 dnl Check for zlib (only if you want to compile the gzip filter).
1123 AC_ARG_WITH([zlib],
1124     [AS_HELP_STRING([--without-zlib],
1125                     [disable gzip filter @<:@default=check@:>@])],
1126     [],
1127     [with_zlib=check])
1128 AS_IF([test "$with_zlib" != "no"],[
1129     PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3.5],[
1130         AC_SUBST([ZLIB_CFLAGS])
1131         AC_SUBST([ZLIB_LIBS])
1132         AC_DEFINE([HAVE_ZLIB],[1],[zlib found at compile time.])
1133     ],
1134     [AC_MSG_WARN([zlib >= 1.2.3.5 not found, gzip filter will be disabled])])
1136 AM_CONDITIONAL([HAVE_ZLIB],[test "x$ZLIB_LIBS" != "x"])
1138 dnl Check for libnbd (only if you want to compile the nbd plugin).
1139 AC_ARG_WITH([libnbd],
1140     [AS_HELP_STRING([--without-libnbd],
1141                     [disable nbd plugin @<:@default=check@:>@])],
1142     [],
1143     [with_libnbd=check])
1144 AS_IF([test "$with_libnbd" != "no"],[
1145     PKG_CHECK_MODULES([LIBNBD], [libnbd >= 0.9.8],[
1146         AC_SUBST([LIBNBD_CFLAGS])
1147         AC_SUBST([LIBNBD_LIBS])
1148         AC_DEFINE([HAVE_LIBNBD],[1],[libnbd found at compile time.])
1149     ],
1150     [AC_MSG_WARN([libnbd >= 0.9.8 not found, nbd plugin will be crippled])])
1153 dnl For backwards compatibilty, we have a second way to disable the nbd plugin.
1154 AC_ARG_ENABLE([nbd-plugin],
1155     [AS_HELP_STRING([--disable-nbd-plugin], [disable nbd plugin (deprecated, use --without-libnbd)])],
1156     [],
1157     [enable_nbd_plugin=yes])
1158 AM_CONDITIONAL([HAVE_LIBNBD],
1159   [test "x$LIBNBD_LIBS" != "x" && test "x$enable_nbd_plugin" = "xyes"])
1161 dnl Check for liblzma (only if you want to compile the xz filter).
1162 AC_ARG_WITH([liblzma],
1163     [AS_HELP_STRING([--without-liblzma],
1164                     [disable xz filter @<:@default=check@:>@])],
1165     [],
1166     [with_liblzma=check])
1167 AS_IF([test "$with_liblzma" != "no"],[
1168     PKG_CHECK_MODULES([LIBLZMA], [liblzma],[
1169         AC_SUBST([LIBLZMA_CFLAGS])
1170         AC_SUBST([LIBLZMA_LIBS])
1171         AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma found at compile time.])
1172     ],
1173     [AC_MSG_WARN([liblzma not found, xz filter will be disabled])])
1175 AM_CONDITIONAL([HAVE_LIBLZMA],[test "x$LIBLZMA_LIBS" != "x"])
1177 dnl Check for zstd (only if you want to compile allocator=zstd).
1178 AC_ARG_WITH([libzstd],
1179     [AS_HELP_STRING([--without-libzstd],
1180                     [disable allocator=zstd @<:@default=check@:>@])],
1181     [],
1182     [with_libzstd=check])
1183 AS_IF([test "$with_libzstd" != "no"],[
1184     PKG_CHECK_MODULES([LIBZSTD], [libzstd],[
1185         AC_SUBST([LIBZSTD_CFLAGS])
1186         AC_SUBST([LIBZSTD_LIBS])
1187         AC_DEFINE([HAVE_LIBZSTD],[1],[libzstd found at compile time.])
1188     ],
1189     [AC_MSG_WARN([libzstd not found, allocator=zstd will be disabled])])
1191 AM_CONDITIONAL([HAVE_LIBZSTD],[test "x$LIBZSTD_LIBS" != "x"])
1193 dnl Check for libguestfs (only for the guestfs plugin and parts of
1194 dnl the test suite).
1195 AC_ARG_WITH([libguestfs],
1196     [AS_HELP_STRING([--without-libguestfs],
1197                     [disable guestfs plugin and tests @<:@default=check@:>@])],
1198     [],
1199     [with_libguestfs=check])
1200 AS_IF([test "$with_libguestfs" != "no"],[
1201     PKG_CHECK_MODULES([LIBGUESTFS], [libguestfs],[
1202         # Although the library was found, we want to make sure it supports nbd
1203         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1204 #include <guestfs.h>
1205         ]], [[
1206 #ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
1207 #error unsupported
1208 #endif
1209         ]])], [
1210         AC_SUBST([LIBGUESTFS_CFLAGS])
1211         AC_SUBST([LIBGUESTFS_LIBS])
1212         AC_DEFINE([HAVE_LIBGUESTFS],[1],[libguestfs found at compile time.])
1213         ],[
1214         LIBGUESTFS_LIBS=
1215         AC_MSG_WARN([libguestfs too old, guestfs plugin and tests will be disabled])])
1216     ],
1217     [AC_MSG_WARN([libguestfs not found, guestfs plugin and tests will be disabled])])
1219 AM_CONDITIONAL([HAVE_LIBGUESTFS],[test "x$LIBGUESTFS_LIBS" != "x"])
1221 dnl Disable tests which need libguestfs.
1222 AC_ARG_ENABLE([libguestfs-tests],
1223     [AS_HELP_STRING([--disable-libguestfs-tests],
1224                     [disable tests which need libguestfs])],
1225     [],
1226     [enable_libguestfs_tests=check]
1228 AM_CONDITIONAL([USE_LIBGUESTFS_FOR_TESTS],
1229                [test "x$LIBGUESTFS_LIBS" != "x" && \
1230                 test "x$enable_libguestfs_tests" != "xno"])
1232 dnl Check for ext2fs and com_err, for the ext2 filter.
1233 AC_ARG_WITH([ext2],
1234     [AS_HELP_STRING([--without-ext2],
1235                     [disable ext2 filter @<:@default=check@:>@])],
1236     [],
1237     [with_ext2=check])
1238 AS_IF([test "$with_ext2" != "no"], [
1239     PKG_CHECK_MODULES([EXT2FS], [ext2fs], [
1240         AC_SUBST([EXT2FS_CFLAGS])
1241         AC_SUBST([EXT2FS_LIBS])
1242         AC_DEFINE([HAVE_EXT2FS],[1],[ext2fs found at compile time.])
1243     ],
1244     [AC_MSG_WARN([ext2fs not found, ext2 filter will be disabled])])
1245     PKG_CHECK_MODULES([COM_ERR], [com_err], [
1246         AC_SUBST([COM_ERR_CFLAGS])
1247         AC_SUBST([COM_ERR_LIBS])
1248         AC_DEFINE([HAVE_COM_ERR],[1],[com_err found at compile time.])
1249     ],
1250     [AC_MSG_WARN([com_err not found, ext2 filter will be disabled])])
1252     AC_CHECK_MEMBERS([struct struct_io_manager.cache_readahead,
1253                       struct struct_io_manager.zeroout])
1255 AM_CONDITIONAL([HAVE_EXT2],
1256                [test "x$EXT2FS_LIBS" != "x" && test "x$COM_ERR_LIBS" != "x"])
1258 dnl libtorrent-rasterbar for the bittorrent plugin.
1259 AC_ARG_ENABLE([torrent],
1260     [AS_HELP_STRING([--disable-torrent],
1261                     [disable bittorrent plugin])],
1262     [],
1263     [enable_torrent=check]
1265 AS_IF([test "x$enable_torrent" != "xno"], [
1266     PKG_CHECK_MODULES([LIBTORRENT], [libtorrent-rasterbar], [
1267         AC_SUBST([LIBTORRENT_CFLAGS])
1268         AC_SUBST([LIBTORRENT_LIBS])
1269     ],
1270     [AC_MSG_WARN([libtorrent-rasterbar not found, bittorrent plugin will be disabled])])
1272 AM_CONDITIONAL([HAVE_TORRENT],
1273                [test "x$have_cxx" = "xyes" && test "x$LIBTORRENT_LIBS" != "x"])
1275 dnl Check if the user wants to disable VDDK support.
1276 dnl See plugins/vddk/README.VDDK.
1277 AC_ARG_ENABLE([vddk],
1278     [AS_HELP_STRING([--disable-vddk],
1279                     [disable VMware VDDK plugin])],
1280     [],
1281     [
1282      dnl While VDDK was available on i686 in 5.1.1, we only support
1283      dnl newer versions which are supported only on x86-64.  Don't
1284      dnl compile on other platforms.
1285      AC_MSG_CHECKING([if the host CPU is compatible with VDDK])
1286      AS_IF([test "$host_cpu" = "x86_64"],[
1287         AC_MSG_RESULT([yes ($host_cpu)])
1288         enable_vddk=yes
1289      ],[
1290         AC_MSG_RESULT([no ($host_cpu)])
1291         enable_vddk=no
1292      ])
1293     ])
1294 AM_CONDITIONAL([HAVE_VDDK], [test "x$enable_vddk" = "xyes"])
1296 dnl Expose version information to the public headers
1297 [NBDKIT_]VERSION_MAJOR=NBDKIT_VERSION_MAJOR
1298 [NBDKIT_]VERSION_MINOR=NBDKIT_VERSION_MINOR
1299 [NBDKIT_]VERSION_MICRO=NBDKIT_VERSION_MICRO
1300 AC_SUBST([NBDKIT_VERSION_MAJOR])
1301 AC_SUBST([NBDKIT_VERSION_MINOR])
1302 AC_SUBST([NBDKIT_VERSION_MICRO])
1304 dnl Produce output files.
1305 AC_CONFIG_HEADERS([config.h])
1306 AC_CONFIG_FILES([podwrapper.pl],
1307                 [chmod +x,-w podwrapper.pl])
1308 AC_CONFIG_FILES([scripts/vddk-esxi-open.sh],
1309                 [chmod +x,-w scripts/vddk-esxi-open.sh])
1310 AC_CONFIG_FILES([scripts/vddk-vcenter-open.sh],
1311                 [chmod +x,-w scripts/vddk-vcenter-open.sh])
1312 AC_CONFIG_FILES([common/protocol/generate-protostrings.sh],
1313                 [chmod +x,-w common/protocol/generate-protostrings.sh])
1314 AC_CONFIG_FILES([Makefile
1315                  bash-completion/Makefile
1316                  common/allocators/Makefile
1317                  common/bitmap/Makefile
1318                  common/gpt/Makefile
1319                  common/include/Makefile
1320                  common/protocol/Makefile
1321                  common/regions/Makefile
1322                  common/replacements/Makefile
1323                  common/replacements/win32/Makefile
1324                  common/utils/Makefile
1325                  docs/Makefile
1326                  include/Makefile
1327                  include/nbdkit-version.h
1328                  plugins/Makefile
1329                  plugins/cc/Makefile
1330                  plugins/cdi/Makefile
1331                  plugins/curl/Makefile
1332                  plugins/data/Makefile
1333                  plugins/eval/Makefile
1334                  plugins/example1/Makefile
1335                  plugins/example2/Makefile
1336                  plugins/example3/Makefile
1337                  plugins/example4/Makefile
1338                  plugins/file/Makefile
1339                  plugins/floppy/Makefile
1340                  plugins/full/Makefile
1341                  plugins/golang/Makefile
1342                  plugins/guestfs/Makefile
1343                  plugins/info/Makefile
1344                  plugins/iso/Makefile
1345                  plugins/libvirt/Makefile
1346                  plugins/linuxdisk/Makefile
1347                  plugins/lua/Makefile
1348                  plugins/memory/Makefile
1349                  plugins/nbd/Makefile
1350                  plugins/null/Makefile
1351                  plugins/ocaml/Makefile
1352                  plugins/ondemand/Makefile
1353                  plugins/partitioning/Makefile
1354                  plugins/pattern/Makefile
1355                  plugins/perl/Makefile
1356                  plugins/python/Makefile
1357                  plugins/random/Makefile
1358                  plugins/ruby/Makefile
1359                  plugins/rust/Makefile
1360                  plugins/S3/Makefile
1361                  plugins/sh/Makefile
1362                  plugins/ssh/Makefile
1363                  plugins/sparse-random/Makefile
1364                  plugins/split/Makefile
1365                  plugins/tcl/Makefile
1366                  plugins/tmpdisk/Makefile
1367                  plugins/torrent/Makefile
1368                  plugins/vddk/Makefile
1369                  plugins/zero/Makefile
1370                  filters/Makefile
1371                  filters/blocksize/Makefile
1372                  filters/blocksize-policy/Makefile
1373                  filters/cache/Makefile
1374                  filters/cacheextents/Makefile
1375                  filters/checkwrite/Makefile
1376                  filters/cow/Makefile
1377                  filters/ddrescue/Makefile
1378                  filters/delay/Makefile
1379                  filters/error/Makefile
1380                  filters/exitlast/Makefile
1381                  filters/exitwhen/Makefile
1382                  filters/exportname/Makefile
1383                  filters/ext2/Makefile
1384                  filters/extentlist/Makefile
1385                  filters/fua/Makefile
1386                  filters/gzip/Makefile
1387                  filters/ip/Makefile
1388                  filters/limit/Makefile
1389                  filters/log/Makefile
1390                  filters/luks/Makefile
1391                  filters/multi-conn/Makefile
1392                  filters/nocache/Makefile
1393                  filters/noextents/Makefile
1394                  filters/nofilter/Makefile
1395                  filters/noparallel/Makefile
1396                  filters/nozero/Makefile
1397                  filters/offset/Makefile
1398                  filters/partition/Makefile
1399                  filters/pause/Makefile
1400                  filters/protect/Makefile
1401                  filters/rate/Makefile
1402                  filters/readahead/Makefile
1403                  filters/retry/Makefile
1404                  filters/retry-request/Makefile
1405                  filters/scan/Makefile
1406                  filters/stats/Makefile
1407                  filters/swab/Makefile
1408                  filters/tar/Makefile
1409                  filters/tls-fallback/Makefile
1410                  filters/truncate/Makefile
1411                  filters/xz/Makefile
1412                  fuzzing/Makefile
1413                  server/local/nbdkit.pc
1414                  server/Makefile
1415                  server/nbdkit.pc
1416                  tests/functions.sh
1417                  tests/Makefile
1418                  valgrind/Makefile])
1420 AC_OUTPUT
1422 dnl Summary.
1423 echo
1424 echo
1425 echo "----------------------------------------------------------------------"
1426 echo "Thank you for downloading $PACKAGE_STRING"
1427 echo
1428 echo "This is how we have configured the optional components for you today:"
1429 echo
1431 feature ()
1433     printf %s "    $1"
1434     shift
1435     if "$@"; then echo "yes"; else echo "no"; fi
1438 echo "Optional server features:"
1439 echo
1440 feature "bash-completion ........................ " \
1441         test "x$HAVE_BASH_COMPLETION_TRUE" = "x"
1442 feature "libfuzzer .............................. " \
1443         test "x$ENABLE_LIBFUZZER_TRUE" = "x"
1444 feature "linker script .......................... " \
1445         test "x$USE_LINKER_SCRIPT_FOR_SERVER_TRUE" = "x"
1446 feature "manual pages ........................... " \
1447         test "x$HAVE_POD_TRUE" = "x"
1448 feature "SELinux ................................ " \
1449         test "x$LIBSELINUX_LIBS" != "x"
1450 feature "TLS .................................... " \
1451         test "x$GNUTLS_LIBS" != "x"
1453 echo
1454 echo "Optional plugins:"
1455 echo
1456 feature "curl ................................... " \
1457         test "x$HAVE_CURL_TRUE" = "x"
1458 feature "example4 ............................... " \
1459         test "x$HAVE_PERL_TRUE" = "x"
1460 feature "floppy ................................. " \
1461         test "x$HAVE_ICONV_TRUE" = "x"
1462 feature "guestfs ................................ " \
1463         test "x$HAVE_LIBGUESTFS_TRUE" = "x"
1464 feature "iso .................................... " \
1465         test "x$HAVE_ISO_TRUE" = "x"
1466 feature "libvirt ................................ " \
1467         test "x$HAVE_LIBVIRT_TRUE" = "x"
1468 feature "linuxdisk .............................. " \
1469         test "x$HAVE_MKE2FS_WITH_D_TRUE" = "x"
1470 feature "nbd .................................... " \
1471         test "x$HAVE_LIBNBD_TRUE" = "x"
1472 feature "S3 ..................................... " \
1473         test "x$HAVE_PYTHON_TRUE" = "x"
1474 feature "ssh .................................... " \
1475         test "x$HAVE_SSH_TRUE" = "x"
1476 feature "torrent ................................ " \
1477         test "x$HAVE_TORRENT_TRUE" = "x"
1478 feature "vddk ................................... " \
1479         test "x$HAVE_VDDK_TRUE" = "x"
1481 echo
1482 echo "Languages:"
1483 echo
1484 feature "go ..................................... " \
1485         test "x$HAVE_GOLANG_TRUE" = "x"
1486 feature "lua .................................... " \
1487         test "x$HAVE_LUA_TRUE" = "x"
1488 feature "ocaml .................................. " \
1489         test "x$HAVE_OCAML_TRUE" = "x"
1490 feature "perl ................................... " \
1491         test "x$HAVE_PERL_TRUE" = "x"
1492 feature "python ................................. " \
1493         test "x$HAVE_PYTHON_TRUE" = "x"
1494 feature "ruby ................................... " \
1495         test "x$HAVE_RUBY_TRUE" = "x"
1496 feature "rust ................................... " \
1497         test "x$HAVE_RUST_TRUE" = "x"
1498 feature "tcl .................................... " \
1499         test "x$HAVE_TCL_TRUE" = "x"
1501 echo
1502 echo "Optional filters:"
1503 echo
1504 feature "ext2 ................................... " \
1505         test "x$HAVE_EXT2_TRUE" = "x"
1506 feature "gzip ................................... " \
1507         test "x$HAVE_ZLIB_TRUE" = "x"
1508 feature "luks ................................... " \
1509         test "x$HAVE_GNUTLS_PBKDF2_TRUE" = "x"
1510 feature "stats .................................. " \
1511         test "x$HAVE_CXX_TRUE" = "x"
1512 feature "xz ..................................... " \
1513         test "x$HAVE_LIBLZMA_TRUE" = "x"
1515 echo
1516 echo "Other optional features:"
1517 echo
1518 feature "allocator=zstd ......................... " \
1519         test "x$HAVE_LIBZSTD_TRUE" = "x"
1520 feature "tests using libguestfs ................. " \
1521         test "x$HAVE_LIBGUESTFS_TRUE" = "x" -a      \
1522              "x$USE_LIBGUESTFS_FOR_TESTS_TRUE" = "x"
1524 echo
1525 echo "If any optional component is configured ‘no’ when you expected ‘yes’"
1526 echo "then you should check the preceding messages and README."
1527 echo
1528 echo "Please report bugs back to the mailing list:"
1529 echo "http://www.redhat.com/mailman/listinfo/libguestfs"
1530 echo
1531 echo "Next you should type 'make' to build the package,"
1532 echo "then 'make check' to run the tests."