docs, tests: Improved method to probe for plugins and filters.
[nbdkit/ericb.git] / configure.ac
blobd3202d218fef65ebfe9916586dba0b818498dfb2
1 # nbdkit
2 # Copyright (C) 2013-2019 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], [17])
34 m4_define([NBDKIT_VERSION_MICRO], [5])
35 AC_INIT([nbdkit],
36         NBDKIT_VERSION_MAJOR.NBDKIT_VERSION_MINOR.NBDKIT_VERSION_MICRO)
37 AC_CONFIG_MACRO_DIR([m4])
38 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],[],
39          [m4_define([AC_USE_SYSTEM_EXTENSIONS],[])])
41 dnl This must be used very early else you will get
42 dnl "warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS"
43 AC_USE_SYSTEM_EXTENSIONS
45 dnl NB: Do not [quote] this parameter.
46 AM_INIT_AUTOMAKE(foreign subdir-objects)
47 AC_PROG_LIBTOOL
48 LT_INIT
50 dnl List of plugins and filters.
51 lang_plugins="\
52         lua \
53         ocaml \
54         perl \
55         python \
56         ruby \
57         rust \
58         sh \
59         tcl \
60         "
61 non_lang_plugins="\
62         curl \
63         data \
64         eval \
65         example1 \
66         example2 \
67         example3 \
68         example4 \
69         ext2 \
70         file \
71         floppy \
72         full \
73         guestfs \
74         gzip \
75         info \
76         iso \
77         libvirt \
78         linuxdisk \
79         memory \
80         nbd \
81         null \
82         partitioning \
83         pattern \
84         random \
85         split \
86         ssh \
87         streaming \
88         tar \
89         vddk \
90         zero \
91         "
92 plugins="$(echo $(printf %s\\n $lang_plugins $non_lang_plugins | sort -u))"
93 filters="\
94         blocksize \
95         cache \
96         cacheextents \
97         cow \
98         delay \
99         error \
100         fua \
101         ip \
102         log \
103         nocache \
104         noextents \
105         nofilter \
106         noparallel \
107         nozero \
108         offset \
109         partition \
110         rate \
111         readahead \
112         retry \
113         stats \
114         truncate \
115         xz \
116         "
117 AC_SUBST([plugins])
118 AC_SUBST([lang_plugins])
119 AC_SUBST([non_lang_plugins])
120 AC_SUBST([filters])
122 dnl Some very basic tools.
123 AC_PROG_SED
125 dnl Check for basic C environment.
126 AC_PROG_CC_STDC
127 AC_PROG_INSTALL
128 AC_PROG_CPP
129 AC_CANONICAL_HOST
130 AC_SYS_LARGEFILE
132 AC_C_PROTOTYPES
133 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
135 AM_PROG_CC_C_O
137 dnl Check for C++ (optional, we just use this to test the header
138 dnl can be included from C++ code).
139 AC_PROG_CXX
141 dnl The C++ compiler test is pretty useless because even if it fails
142 dnl it sets CXX=g++.  So test the compiler actually works.
143 AC_MSG_CHECKING([if the C++ compiler really really works])
144 AS_IF([$CXX --version >&AS_MESSAGE_LOG_FD 2>&1],[have_cxx=yes],[have_cxx=no])
145 AC_MSG_RESULT([$have_cxx])
146 AM_CONDITIONAL([HAVE_CXX], [test "$have_cxx" = "yes"])
148 AC_ARG_ENABLE([gcc-warnings],
149     [AS_HELP_STRING([--enable-gcc-warnings],
150                     [turn on lots of GCC warnings (for developers)])],
151      [case $enableval in
152       yes|no) ;;
153       *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
154       esac
155       gcc_warnings=$enableval],
156       [gcc_warnings=no]
158 if test "x$gcc_warnings" = "xyes"; then
159     WARNINGS_CFLAGS="-Wall -Wshadow -Wvla -Werror"
160     AC_SUBST([WARNINGS_CFLAGS])
163 dnl Check if the compiler supports -std=c90 flag.  This is only used
164 dnl during a test.  OpenBSD GCC does not support this flag so we skip
165 dnl that test.
166 AC_MSG_CHECKING([if the compiler supports -std=c90 for ANSI C test])
167 old_CFLAGS="$CFLAGS"
168 CFLAGS="$CFLAGS -std=c90"
169 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
170     [supports_std_c90=yes],
171     [supports_std_c90=no])
172 CFLAGS="$old_CFLAGS"
173 AC_MSG_RESULT([$supports_std_c90])
174 AM_CONDITIONAL([CAN_TEST_ANSI_C], [test "x$supports_std_c90" = "xyes"])
176 dnl On Haiku we must use BSD-compatibility headers to get the endian
177 dnl macros we use.
178 AC_MSG_CHECKING(whether OS-dependent include paths are required)
179 AS_CASE([$host_os],
180   [haiku*], [CFLAGS="$CFLAGS -I`findpaths -p /system B_FIND_PATH_HEADERS_DIRECTORY`/bsd"; AC_MSG_RESULT(yes)],
181   [AC_MSG_RESULT(no)]
184 dnl On Linux /tmp is often tmpfs which is not large enough, so use /var/tmp.
185 dnl But Haiku only has /tmp.
186 AC_MSG_CHECKING([for temporary directory for large files])
187 AS_CASE([$host_os],
188   [haiku*], [LARGE_TMPDIR=/tmp],
189   [LARGE_TMPDIR=/var/tmp]
191 AC_MSG_RESULT([$LARGE_TMPDIR])
192 AC_DEFINE_UNQUOTED([LARGE_TMPDIR],["$LARGE_TMPDIR"],
193                    [Temporary directory for large files])
195 dnl Check if libc has program_invocation_short_name.
196 AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
198 AX_PTHREAD
200 dnl Check if __attribute__((cleanup(...))) works.
201 dnl Set -Werror, otherwise gcc will only emit a warning for attributes
202 dnl that it doesn't understand.
203 acx_nbdkit_save_CFLAGS="${CFLAGS}"
204 CFLAGS="${CFLAGS} -Werror"
205 AC_MSG_CHECKING([if __attribute__((cleanup(...))) works with this compiler])
206 AC_COMPILE_IFELSE([
207 AC_LANG_SOURCE([[
208 #include <stdio.h>
209 #include <stdlib.h>
211 void
212 freep (void *ptr)
214   exit (EXIT_SUCCESS);
217 void
218 test (void)
220   __attribute__((cleanup(freep))) char *ptr = malloc (100);
224 main (int argc, char *argv[])
226   test ();
227   exit (EXIT_FAILURE);
230     ],[
231     AC_MSG_RESULT([yes])
232     ],[
233     AC_MSG_RESULT([no])
234     AC_MSG_ERROR(
235 ['__attribute__((cleanup(...)))' does not work.
237 You may not be using a sufficiently recent version of GCC or CLANG, or
238 you may be using a C compiler which does not support this attribute,
239 or the configure test may be wrong.
241 This code requires the attribute to work for proper locking between threads.])])
242 CFLAGS="${acx_nbdkit_save_CFLAGS}"
244 dnl Check for __auto_type (GCC extension).
245 AC_MSG_CHECKING([if __auto_type is available in this compiler])
246 AC_COMPILE_IFELSE([
247 AC_LANG_SOURCE([[
248 static int
249 test (int a)
251   __auto_type at = a;
252   return at;
255     ],[
256     AC_MSG_RESULT([yes])
257     AC_DEFINE([HAVE_AUTO_TYPE],[1],[__auto_type is available])
258     ],[
259     AC_MSG_RESULT([no])
260     ]
263 dnl Check for other headers, all optional.
264 AC_CHECK_HEADERS([\
265         alloca.h \
266         byteswap.h \
267         endian.h \
268         sys/endian.h \
269         sys/mman.h \
270         sys/prctl.h \
271         sys/procctl.h])
273 AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [#include <sys/socket.h>])
275 dnl Check for functions in libc, all optional.
276 AC_CHECK_FUNCS([\
277         accept4 \
278         fdatasync \
279         get_current_dir_name \
280         mkostemp \
281         mlockall \
282         pipe2 \
283         ppoll \
284         posix_fadvise])
286 dnl Check whether printf("%m") works
287 AC_CACHE_CHECK([whether the printf family supports %m],
288   [nbdkit_cv_func_printf_percent_m],
289   [AC_RUN_IFELSE(
290     [AC_LANG_PROGRAM([[
291 #include <stdio.h>
292 #include <string.h>
293 #include <errno.h>
294     ]], [[
295     char buf[200] = "";
296     errno = EINVAL;
297     snprintf(buf, sizeof buf, "%m");
298     return !!strcmp (buf, strerror (EINVAL));
299     ]])],
300     [nbdkit_cv_func_printf_percent_m=yes],
301     [nbdkit_cv_func_printf_percent_m=no],
302     [[
303     case "$host_os" in
304       *-gnu* | gnu*) nbdkit_cv_func_printf_percent_m=yes;;
305       *) nbdkit_cv_func_printf_percent_m="guessing no";;
306     esac
307     ]])])
308 AS_IF([test "x$nbdkit_cv_func_printf_percent_m" = xyes],
309   [AC_DEFINE([HAVE_VFPRINTF_PERCENT_M],[1],
310     [Define to 1 if vfprintf supports %m.])])
312 old_LIBS="$LIBS"
313 AC_SEARCH_LIBS([dlsym], [dl dld], [
314         AS_IF([test "x$ac_cv_search_dlsym" != "xnone required"],
315             [DL_LIBS="$ac_cv_search_dlsym"], [DL_LIBS=])
316         AC_SUBST([DL_LIBS])
317     ], [AC_MSG_ERROR([unable to find the dlsym() function])
319 LIBS="$old_LIBS"
321 dnl Test if <iconv.h> header can build working binaries.
323 dnl On FreeBSD: iconv and libiconv both exist, both can be installed
324 dnl simultaneously, <iconv.h> can exist in two separate places, and
325 dnl if you get the wrong header/library mix everything breaks.
327 dnl On Haiku: libiconv is required to link to iconv_* functions.
328 AC_ARG_WITH([iconv],
329     [AS_HELP_STRING([--without-iconv],
330                     [don't try to link against iconv @<:@default=check@:>@])],
331     [],
332     [with_iconv=check])
333 AS_IF([test "x$with_iconv" != "xno"],[
334     AC_CHECK_HEADER([iconv.h],[
335         AC_MSG_CHECKING([if <iconv.h> can be used to link a program])
336         AC_LINK_IFELSE([
337 AC_LANG_SOURCE([[
338 #include <stdio.h>
339 #include <stdlib.h>
340 #include <iconv.h>
342 main (int argc, char *argv[])
344   iconv_t ic = iconv_open ("", "");
345   iconv_close (ic);
346   exit (0);
349             ],[
350             AC_MSG_RESULT([yes])
351             iconv_working=yes
352             ],[
353             AC_MSG_RESULT([no])
354             ])
355         ])
356     ])
357 AM_CONDITIONAL([HAVE_ICONV], [test "x$iconv_working" = "xyes"])
359 dnl Don't use linker script for the server on FreeBSD because
360 dnl FreeBSD's linker is broken.  See eg:
361 dnl https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190851
362 AC_MSG_CHECKING([if we should use a linker script for the server])
363 AS_CASE([$host_os],
364   [freebsd*], [use_linker_script_for_server=no],
365   [use_linker_script_for_server=yes]
367 AC_MSG_RESULT([$use_linker_script_for_server])
368 AM_CONDITIONAL([USE_LINKER_SCRIPT_FOR_SERVER],
369                [test "x$use_linker_script_for_server" = "xyes"])
371 dnl Check if -rdynamic linker flag works.
372 acx_nbdkit_save_LDFLAGS="${LDFLAGS}"
373 LDFLAGS="${LDFLAGS} -rdynamic"
374 AC_MSG_CHECKING([if linker supports -rdynamic])
375 AC_LINK_IFELSE([
376 AC_LANG_SOURCE([[
377 #include <stdlib.h>
379 main (int argc, char *argv[])
381   exit (EXIT_SUCCESS);
384     ],[
385     AC_MSG_RESULT([yes])
386     DL_LDFLAGS=-rdynamic
387     ],[
388     AC_MSG_RESULT([no])
390 dnl restore CFLAGS
391 LDFLAGS="${acx_nbdkit_save_LDFLAGS}"
392 AC_SUBST([DL_LDFLAGS])
394 dnl Check for dladdr in -ldl, optional.  This is a glibc extension.
395 old_LIBS="$LIBS"
396 LIBS="$DL_LIBS $LIBS"
397 AC_CHECK_FUNCS([dladdr])
398 LIBS="$old_LIBS"
400 AC_SEARCH_LIBS([getaddrinfo], [network socket])
402 dnl Check for SELinux socket labelling (optional).
403 PKG_CHECK_MODULES([LIBSELINUX], [libselinux], [
404     AC_SUBST([LIBSELINUX_CFLAGS])
405     AC_SUBST([LIBSELINUX_LIBS])
406     AC_DEFINE([HAVE_LIBSELINUX],[1],[libselinux found at compile time.])
407 ], [
408     AC_MSG_WARN([libselinux not found, SELinux socket labelling support will be disabled.])
411 dnl Check for GnuTLS (optional, for TLS support).
412 PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0], [
413     AC_SUBST([GNUTLS_CFLAGS])
414     AC_SUBST([GNUTLS_LIBS])
415     AC_DEFINE([HAVE_GNUTLS],[1],[gnutls found at compile time.])
416 ], [
417     AC_MSG_WARN([gnutls not found or < 3.3.0, TLS support will be disabled.])
420 AS_IF([test "$GNUTLS_LIBS" != ""],[
421     AC_MSG_CHECKING([for default TLS session priority string])
422     AC_ARG_WITH([tls-priority],
423         [AS_HELP_STRING([--with-tls-priority],
424                         [default TLS session priority string @<:@default=NORMAL@:>@])],
425         [tls_priority=$withval],
426         [tls_priority=NORMAL])
427     AC_MSG_RESULT([$tls_priority])
428     AC_DEFINE_UNQUOTED([TLS_PRIORITY],["$tls_priority"],
429                        [Default TLS session priority string])
431     # Check for APIs which may not be present.
432     old_LIBS="$LIBS"
433     LIBS="$GNUTLS_LIBS $LIBS"
434     AC_CHECK_FUNCS([\
435         gnutls_base64_decode2 \
436         gnutls_certificate_set_known_dh_params \
437         gnutls_session_set_verify_cert])
438     LIBS="$old_LIBS"
441 dnl Check for valgrind.
442 AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[no])
444 dnl If valgrind headers are available (optional).
445 dnl Since this is only useful for developers, you have to enable
446 dnl it explicitly using --enable-valgrind.
447 AC_ARG_ENABLE([valgrind],
448     [AS_HELP_STRING([--enable-valgrind],
449                     [enable Valgrind extensions (for developers)])],
450     [enable_valgrind=yes],
451     [enable_valgrind=no])
452 AS_IF([test "x$enable_valgrind" = "xyes"],[
453     PKG_CHECK_MODULES([VALGRIND], [valgrind], [
454         AC_SUBST([VALGRIND_CFLAGS])
455         AC_SUBST([VALGRIND_LIBS])
456         AC_DEFINE([HAVE_VALGRIND],[1],[Valgrind headers found at compile time])
457     ],[
458         AC_MSG_ERROR([--enable-valgrind given, but Valgrind headers are not available])
459     ])
462 dnl Build the special libFuzzer version of nbdkit.  DO NOT USE THIS for
463 dnl normal builds.  See fuzzing/README.
464 AC_ARG_ENABLE([libfuzzer],
465     [AS_HELP_STRING([--enable-libfuzzer],
466                     [build libFuzzer test binary (developers only)])],
467     [enable_libfuzzer=yes],
468     [enable_libfuzzer=no])
469 AS_IF([test "x$enable_libfuzzer" = "xyes"],[
470     AC_DEFINE([ENABLE_LIBFUZZER],[1],[Enable special libFuzzer binary])
472 AM_CONDITIONAL([ENABLE_LIBFUZZER],[test "x$enable_libfuzzer" = "xyes"])
474 dnl Bash completion.
475 PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], [
476     bash_completion=yes
477     AC_MSG_CHECKING([for bash-completions directory])
478     m4_ifdef([PKG_CHECK_VAR],[
479         PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir])
480     ])
481     AS_IF([test -z "$bashcompdir"], [
482         bashcompdir="${sysconfdir}/bash_completion.d"
483     ])
484     AC_MSG_RESULT([$bashcompdir])
485     AC_SUBST([bashcompdir])
487     bash_completion=no
488     AC_MSG_WARN([bash-completion not installed])
490 AM_CONDITIONAL([HAVE_BASH_COMPLETION],[test "x$bash_completion" = "xyes"])
492 dnl Check we have enough to run podwrapper.
493 AC_CHECK_PROG([PERL],[perl],[perl],[no])
494 AS_IF([test "x$PERL" != "xno"],[
495     AC_MSG_CHECKING([if we have perl Pod::Man and Pod::Simple])
496     AS_IF([$PERL -MPod::Man -MPod::Simple -e 1 >&AS_MESSAGE_LOG_FD 2>&1],[
497         enable_pod=yes
498     ],[
499         enable_pod=no
500     ])
501     AC_MSG_RESULT([$enable_pod])
503 AM_CONDITIONAL([HAVE_POD],
504                [test "x$PERL" != "xno" && test "x$enable_pod" = "xyes"])
506 dnl Define the path to the podwrapper program.
507 PODWRAPPER="$PERL $(pwd)/podwrapper.pl"
508 AC_SUBST([PODWRAPPER])
510 dnl Allow all plugins and filters to be disabled.
511 AC_ARG_ENABLE([plugins],
512     [AS_HELP_STRING([--disable-plugins],
513                     [disable all bundled plugins and filters])])
514 AM_CONDITIONAL([HAVE_PLUGINS], [test "x$enable_plugins" != "xno"])
516 dnl Check for Perl, for embedding in the perl plugin.
517 dnl Note that the perl binary is checked above.
518 AC_ARG_ENABLE([perl],
519     [AS_HELP_STRING([--disable-perl], [disable Perl embed plugin])],
520     [],
521     [enable_perl=yes])
522 AS_IF([test "x$PERL" != "xno" && test "x$enable_perl" != "xno"],[
523     dnl Check for Perl archlib.
524     AC_MSG_CHECKING([for Perl embed archlib])
525     PERL_ARCHLIB="$($PERL -MConfig -e 'print $Config{archlib}')"
526     AS_IF([ test -n "$PERL_ARCHLIB" ],[
527         AC_MSG_RESULT([$PERL_ARCHLIB])
528     ],[
529         AC_MSG_NOTICE([Perl embed module disabled])
530         enable_perl=no
531     ])
533     dnl Check for Perl CFLAGS.
534     AC_MSG_CHECKING([for Perl embed CFLAGS])
535     PERL_CFLAGS="$($PERL -MExtUtils::Embed -e 'ccflags')"
536     AS_IF([ test -n "$PERL_CFLAGS" ],[
537         AC_MSG_RESULT([$PERL_CFLAGS])
538     ],[
539         AC_MSG_NOTICE([Perl embed module disabled])
540         enable_perl=no
541     ])
543     dnl Check for Perl LDOPTS.
544     AC_MSG_CHECKING([for Perl embed LDOPTS])
545     PERL_LDOPTS="$($PERL -MExtUtils::Embed -e 'ldopts')"
546     AC_MSG_RESULT([$PERL_LDOPTS])
548     dnl XXX Could check these actually work.
550 AM_CONDITIONAL([HAVE_PERL],[test "x$enable_perl" != "xno" && test "x$PERL" != "xno"])
551 AC_SUBST([PERL_ARCHLIB])
552 AC_SUBST([PERL_CFLAGS])
553 AC_SUBST([PERL_LDOPTS])
555 dnl Check for Python 3, for embedding in the python plugin.
556 AC_PATH_PROGS([PYTHON],[python3 python],[no])
557 AC_ARG_ENABLE([python],
558     [AS_HELP_STRING([--disable-python], [disable Python embed plugin])],
559     [],
560     [enable_python=yes])
561 AS_IF([test "x$PYTHON" != "xno" && test "x$enable_python" != "xno"],[
562     AC_MSG_CHECKING([version of $PYTHON])
563     PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info@<:@0@:>@)"`
564     PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info@<:@1@:>@)"`
565     PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
566     AS_IF([test -n "$PYTHON_VERSION"],[
567         AC_MSG_RESULT([$PYTHON_VERSION])
568     ],[
569         AC_MSG_NOTICE([Python embed module disabled])
570         enable_python=no
571     ])
573     AC_MSG_CHECKING([Python major version is 3])
574     AS_IF([test "x$PYTHON_VERSION_MAJOR" = "x3"],[
575         AC_MSG_RESULT([yes])
576     ],[
577         AC_MSG_RESULT([no])
578         AC_MSG_ERROR([Python $PYTHON_VERSION_MAJOR <> 3 is no longer supported.
580 Python 2 end of life is 2020-01-01 and nbdkit >= 1.16 no longer
581 supports it.
583 If you want to use Python 2, you will need to use nbdkit 1.14.])
584     ])
586     dnl Check for Python CFLAGS, libraries.
587     dnl For Python >= 3.8 we have to use python-<VERSION>-embed.pc, see:
588     dnl https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
589     dnl The python.pc is called python-<VERSION>.pc on Debian and
590     dnl later versions of Fedora, and python.pc on older versions
591     dnl of Fedora.
592     PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"-embed], [
593         AC_SUBST([PYTHON_CFLAGS])
594         AC_SUBST([PYTHON_LIBS])
595         AC_SUBST([PYTHON_VERSION])
596         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
597     ],[
598     PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"], [
599         AC_SUBST([PYTHON_CFLAGS])
600         AC_SUBST([PYTHON_LIBS])
601         AC_SUBST([PYTHON_VERSION])
602         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
603     ],[
604     PKG_CHECK_MODULES([PYTHON], [python], [
605         AC_SUBST([PYTHON_CFLAGS])
606         AC_SUBST([PYTHON_LIBS])
607         AC_SUBST([PYTHON_VERSION])
608         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
609     ],[
610         AC_MSG_WARN([python $PYTHON_VERSION not found])
611         enable_python=no
612     ])])])
614 AM_CONDITIONAL([HAVE_PYTHON],[test "x$enable_python" != "xno" && test "x$PYTHON" != "xno"])
615 AC_SUBST([PYTHON_CFLAGS])
616 AC_SUBST([PYTHON_LIBS])
617 AC_SUBST([PYTHON_LDFLAGS])
619 dnl For the OCaml plugin, you can set OCAMLOPTFLAGS before running
620 dnl ./configure to specify any extra flags you want to pass to
621 dnl ocamlopt.
622 AC_SUBST([OCAMLOPTFLAGS])
624 dnl Check for OCaml, for embedding in the ocaml plugin.
625 AC_PROG_OCAML
626 AC_ARG_ENABLE([ocaml],
627     [AS_HELP_STRING([--disable-ocaml], [disable OCaml embed plugin])],
628     [],
629     [enable_ocaml=yes])
630 AS_IF([test "x$OCAMLOPT" != "xno" && test "x$enable_ocaml" != "xno"],[
631     dnl Check OCaml can create a shared library (see README for details).
632     AC_MSG_CHECKING([if $OCAMLOPT can create a shared library])
633     echo 'print_endline "test"' > conftest.ml
634     AS_IF([$OCAMLOPT $OCAMLOPTFLAGS -output-obj -runtime-variant _pic -o conftest.so conftest.ml >&AS_MESSAGE_LOG_FD 2>&1],[
635         AC_MSG_RESULT([yes])
636         ocaml_link_shared=yes
637     ],[
638         AC_MSG_RESULT([no])
639     ])
640     rm -f conftest.ml conftest.cmi conftest.cmx conftest.so conftest.o
642 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLOPT" != "xno" &&
643                              test "x$ocaml_link_shared" = "xyes"])
645 dnl For developing plugins in Rust, optional.
646 AC_CHECK_PROG([CARGO],[cargo],[cargo],[no])
647 AC_ARG_ENABLE([rust],
648     [AS_HELP_STRING([--disable-rust], [disable Rust plugin])],
649     [],
650     [enable_rust=yes])
651 AM_CONDITIONAL([HAVE_RUST],
652                [test "x$CARGO" != "xno" && test "x$enable_rust" != "xno"])
654 dnl Check for Ruby, for embedding in the Ruby plugin.
655 AC_CHECK_PROG([RUBY],[ruby],[ruby],[no])
656 AC_ARG_ENABLE([ruby],
657     [AS_HELP_STRING([--disable-ruby], [disable Ruby plugin])],
658     [],
659     [enable_ruby=yes])
660 AS_IF([test "x$RUBY" != "xno" && test "x$enable_ruby" != "xno"],[
661     PKG_CHECK_MODULES([RUBY], [ruby], [
662         AC_SUBST([RUBY_CFLAGS])
663         AC_SUBST([RUBY_LIBS])
664     ],[
665         AC_MSG_WARN([ruby not found])
666         enable_ruby=no
667     ])
669 AM_CONDITIONAL([HAVE_RUBY],[test "x$RUBY" != "xno" &&
670                             test "x$enable_ruby" = "xyes"])
672 dnl Check for Tcl, for embedding in the Tcl plugin.
673 AC_ARG_ENABLE([tcl],
674     [AS_HELP_STRING([--disable-tcl], [disable Tcl plugin])],
675     [],
676     [enable_tcl=yes])
677 AS_IF([test "x$enable_tcl" != "xno"],[
678     PKG_CHECK_MODULES([TCL], [tcl], [
679         AC_SUBST([TCL_CFLAGS])
680         AC_SUBST([TCL_LIBS])
681     ],[
682         AC_MSG_WARN([Tcl not found])
683         enable_tcl=no
684     ])
686 AM_CONDITIONAL([HAVE_TCL],[test "x$enable_tcl" = "xyes"])
688 dnl Check for Lua, for embedding in the Lua plugin.
689 AC_ARG_ENABLE([lua],
690     [AS_HELP_STRING([--disable-lua], [disable Lua plugin])],
691     [],
692     [enable_lua=yes])
693 AS_IF([test "x$enable_lua" != "xno"],[
694     PKG_CHECK_MODULES([LUA], [lua], [
695         AC_SUBST([LUA_CFLAGS])
696         AC_SUBST([LUA_LIBS])
698         dnl Lua 5.1 used by RHEL 7 does not have lua_isinteger.
699         old_LIBS="$LIBS"
700         LIBS="$LUA_LIBS $LIBS"
701         AC_CHECK_FUNCS([lua_isinteger])
702         LIBS="$old_LIBS"
703     ],[
704         AC_MSG_WARN([Lua not found])
705         enable_lua=no
706     ])
708 AM_CONDITIONAL([HAVE_LUA],[test "x$enable_lua" = "xyes"])
710 dnl Check for curl (only if you want to compile the curl plugin).
711 AC_ARG_WITH([curl],
712     [AS_HELP_STRING([--without-curl],
713                     [disable curl plugin @<:@default=check@:>@])],
714     [],
715     [with_curl=check])
716 AS_IF([test "$with_curl" != "no"],[
717     PKG_CHECK_MODULES([CURL], [libcurl],[
718         AC_SUBST([CURL_CFLAGS])
719         AC_SUBST([CURL_LIBS])
720         AC_DEFINE([HAVE_CURL],[1],[curl found at compile time.])
721         AC_CHECK_DECL([CURLOPT_UNIX_SOCKET_PATH], [
722             AC_DEFINE([HAVE_CURLOPT_UNIX_SOCKET_PATH],[1],
723                       [CURLOPT_UNIX_SOCKET_PATH found at compile time.])
724             ], [], [#include <curl/curl.h>])
725     ],
726     [AC_MSG_WARN([curl not found, curl plugin will be disabled])])
728 AM_CONDITIONAL([HAVE_CURL],[test "x$CURL_LIBS" != "x"])
730 dnl Check for libssh (only if you want to compile the ssh plugin).
731 AC_ARG_WITH([ssh],
732     [AS_HELP_STRING([--without-ssh],
733                     [disable ssh plugin @<:@default=check@:>@])],
734     [],
735     [with_ssh=check])
736 AS_IF([test "$with_ssh" != "no"],[
737     PKG_CHECK_MODULES([SSH], [libssh >= 0.8.0],[
738         AC_SUBST([SSH_CFLAGS])
739         AC_SUBST([SSH_LIBS])
740     ],
741     [AC_MSG_WARN([libssh not found, ssh plugin will be disabled])])
743 AM_CONDITIONAL([HAVE_SSH],[test "x$SSH_LIBS" != "x"])
745 dnl Check for genisoimage or mkisofs
746 dnl (only if you want to compile the iso plugin).
747 ISOPROG="no"
748 AC_ARG_WITH([iso],
749     [AS_HELP_STRING([--without-iso],
750                     [disable iso plugin @<:@default=check@:>@])],
751     [],
752     [with_iso=check])
753 AS_IF([test "$with_iso" != "no"],[
754     AC_CHECK_PROG([GENISOIMAGE],[genisoimage],[genisoimage],[no])
755     AC_CHECK_PROG([MKISOFS],[mkisofs],[mkisofs],[no])
756     AS_IF([test "x$GENISOIMAGE" != "xno"],[
757         ISOPROG="$GENISOIMAGE"
758     ],[
759         AS_IF([test "x$MKISOFS" != "xno"],[
760             ISOPROG="$MKISOFS"
761         ])
762     ])
763     AS_IF([test "x$ISOPROG" != "xno"],[
764         AC_DEFINE_UNQUOTED([ISOPROG],["$ISOPROG"],
765                            [Program used by iso plugin to make ISOs.])
766     ])
768 AC_SUBST([ISOPROG])
769 AM_CONDITIONAL([HAVE_ISO],[test "x$ISOPROG" != "xno"])
771 dnl Check for libvirt (only if you want to compile the libvirt plugin).
772 AC_ARG_WITH([libvirt],
773     [AS_HELP_STRING([--without-libvirt],
774                     [disable libvirt plugin @<:@default=check@:>@])],
775     [],
776     [with_libvirt=check])
777 AS_IF([test "$with_libvirt" != "no"],[
778     PKG_CHECK_MODULES([LIBVIRT], [libvirt],[
779         AC_SUBST([LIBVIRT_CFLAGS])
780         AC_SUBST([LIBVIRT_LIBS])
781         AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.])
782     ],
783     [AC_MSG_WARN([libvirt not found, libvirt plugin will be disabled])])
785 AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
787 dnl Check for zlib (only if you want to compile the gzip plugin).
788 AC_ARG_WITH([zlib],
789     [AS_HELP_STRING([--without-zlib],
790                     [disable gzip plugin @<:@default=check@:>@])],
791     [],
792     [with_zlib=check])
793 AS_IF([test "$with_zlib" != "no"],[
794     PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3.5],[
795         AC_SUBST([ZLIB_CFLAGS])
796         AC_SUBST([ZLIB_LIBS])
797         AC_DEFINE([HAVE_ZLIB],[1],[zlib found at compile time.])
798     ],
799     [AC_MSG_WARN([zlib >= 1.2.3.5 not found, gzip plugin will be disabled])])
801 AM_CONDITIONAL([HAVE_ZLIB],[test "x$ZLIB_LIBS" != "x"])
803 dnl Check for libnbd (only if you want to compile the full nbd plugin).
804 AC_ARG_WITH([libnbd],
805     [AS_HELP_STRING([--without-libnbd],
806                     [disable full nbd plugin @<:@default=check@:>@])],
807     [],
808     [with_libnbd=check])
809 AS_IF([test "$with_libnbd" != "no"],[
810     PKG_CHECK_MODULES([LIBNBD], [libnbd >= 0.9.8],[
811         AC_SUBST([LIBNBD_CFLAGS])
812         AC_SUBST([LIBNBD_LIBS])
813         AC_DEFINE([HAVE_LIBNBD],[1],[libnbd found at compile time.])
814     ],
815     [AC_MSG_WARN([libnbd >= 0.9.8 not found, nbd plugin will be crippled])])
817 AM_CONDITIONAL([HAVE_LIBNBD], [test "x$LIBNBD_LIBS" != "x"])
819 dnl Also you can disable the whole nbd plugin.
820 AC_ARG_ENABLE([nbd-plugin],
821     [AS_HELP_STRING([--disable-nbd-plugin], [disable nbd plugin])],
822     [],
823     [enable_nbd_plugin=yes])
824 AM_CONDITIONAL([HAVE_NBD_PLUGIN],[test "x$enable_nbd_plugin" = "xyes"])
826 dnl Check for liblzma (only if you want to compile the xz filter).
827 AC_ARG_WITH([liblzma],
828     [AS_HELP_STRING([--without-liblzma],
829                     [disable xz filter @<:@default=check@:>@])],
830     [],
831     [with_liblzma=check])
832 AS_IF([test "$with_liblzma" != "no"],[
833     PKG_CHECK_MODULES([LIBLZMA], [liblzma],[
834         AC_SUBST([LIBLZMA_CFLAGS])
835         AC_SUBST([LIBLZMA_LIBS])
836         AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma found at compile time.])
837     ],
838     [AC_MSG_WARN([liblzma not found, xz filter will be disabled])])
840 AM_CONDITIONAL([HAVE_LIBLZMA],[test "x$LIBLZMA_LIBS" != "x"])
842 dnl Check for libguestfs (only for the guestfs plugin and the test suite).
843 AC_ARG_WITH([libguestfs],
844     [AS_HELP_STRING([--without-libguestfs],
845                     [disable guestfs plugin and tests @<:@default=check@:>@])],
846     [],
847     [with_libguestfs=check])
848 AS_IF([test "$with_libguestfs" != "no"],[
849     PKG_CHECK_MODULES([LIBGUESTFS], [libguestfs],[
850         # Although the library was found, we want to make sure it supports nbd
851         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
852 #include <guestfs.h>
853         ]], [[
854 #ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
855 #error unsupported
856 #endif
857         ]])], [
858         AC_SUBST([LIBGUESTFS_CFLAGS])
859         AC_SUBST([LIBGUESTFS_LIBS])
860         AC_DEFINE([HAVE_LIBGUESTFS],[1],[libguestfs found at compile time.])
861         ],[
862         LIBGUESTFS_LIBS=
863         AC_MSG_WARN([libguestfs too old, guestfs plugin and tests will be disabled])])
864     ],
865     [AC_MSG_WARN([libguestfs not found, guestfs plugin and tests will be disabled])])
867 AM_CONDITIONAL([HAVE_LIBGUESTFS],[test "x$LIBGUESTFS_LIBS" != "x"])
869 dnl Check for guestfish (only needed for some of the tests).
870 AC_CHECK_PROG([GUESTFISH], [guestfish], [guestfish], [no])
871 AM_CONDITIONAL([HAVE_GUESTFISH], [test "x$GUESTFISH" != "xno"])
873 dnl Check for ext2fs and com_err, for the ext2 plugin.
874 AC_ARG_WITH([ext2],
875     [AS_HELP_STRING([--without-ext2],
876                     [disable ext2 plugin @<:@default=check@:>@])],
877     [],
878     [with_ext2=check])
879 AS_IF([test "$with_ext2" != "no"], [
880     PKG_CHECK_MODULES([EXT2FS], [ext2fs], [
881         AC_SUBST([EXT2FS_CFLAGS])
882         AC_SUBST([EXT2FS_LIBS])
883         AC_DEFINE([HAVE_EXT2FS],[1],[ext2fs found at compile time.])
884     ],
885     [AC_MSG_WARN([ext2fs not found, ext2 plugin will be disabled])])
886     PKG_CHECK_MODULES([COM_ERR], [com_err], [
887         AC_SUBST([COM_ERR_CFLAGS])
888         AC_SUBST([COM_ERR_LIBS])
889         AC_DEFINE([HAVE_COM_ERR],[1],[com_err found at compile time.])
890     ],
891     [AC_MSG_WARN([com_err not found, ext2 plugin will be disabled])])
893 AM_CONDITIONAL([HAVE_EXT2],
894                [test "x$EXT2FS_LIBS" != "x" && test "x$COM_ERR_LIBS" != "x"])
896 dnl Check if the user wants to disable VDDK support.
897 dnl See plugins/vddk/README.VDDK.
898 AC_ARG_ENABLE([vddk],
899     [AS_HELP_STRING([--disable-vddk],
900                     [disable VMware VDDK plugin])],
901     [],
902     [
903      dnl VDDK is only available on i686 up to 5.1.1, and only x86-64
904      dnl after that.  Don't compile on other platforms.
905      AC_MSG_CHECKING([if the host CPU is compatible with VDDK])
906      AS_IF([test "$host_cpu" = "x86_64" || test "$host_cpu" = "i686"],[
907         AC_MSG_RESULT([yes ($host_cpu)])
908         enable_vddk=yes
909      ],[
910         AC_MSG_RESULT([no ($host_cpu)])
911         enable_vddk=no
912      ])
913     ])
914 AM_CONDITIONAL([HAVE_VDDK], [test "x$enable_vddk" = "xyes"])
916 dnl Expose version information to the public headers
917 [NBDKIT_]VERSION_MAJOR=NBDKIT_VERSION_MAJOR
918 [NBDKIT_]VERSION_MINOR=NBDKIT_VERSION_MINOR
919 [NBDKIT_]VERSION_MICRO=NBDKIT_VERSION_MICRO
920 AC_SUBST([NBDKIT_VERSION_MAJOR])
921 AC_SUBST([NBDKIT_VERSION_MINOR])
922 AC_SUBST([NBDKIT_VERSION_MICRO])
924 dnl Produce output files.
925 AC_CONFIG_HEADERS([config.h])
926 AC_CONFIG_FILES([podwrapper.pl],
927                 [chmod +x,-w podwrapper.pl])
928 AC_CONFIG_FILES([common/protocol/generate-protostrings.sh],
929                 [chmod +x,-w common/protocol/generate-protostrings.sh])
930 AC_CONFIG_FILES([Makefile
931                  bash/Makefile
932                  common/bitmap/Makefile
933                  common/gpt/Makefile
934                  common/include/Makefile
935                  common/protocol/Makefile
936                  common/regions/Makefile
937                  common/sparse/Makefile
938                  common/utils/Makefile
939                  docs/Makefile
940                  include/Makefile
941                  include/nbdkit-version.h
942                  plugins/Makefile
943                  plugins/curl/Makefile
944                  plugins/data/Makefile
945                  plugins/eval/Makefile
946                  plugins/example1/Makefile
947                  plugins/example2/Makefile
948                  plugins/example3/Makefile
949                  plugins/example4/Makefile
950                  plugins/ext2/Makefile
951                  plugins/file/Makefile
952                  plugins/floppy/Makefile
953                  plugins/full/Makefile
954                  plugins/guestfs/Makefile
955                  plugins/gzip/Makefile
956                  plugins/info/Makefile
957                  plugins/iso/Makefile
958                  plugins/libvirt/Makefile
959                  plugins/linuxdisk/Makefile
960                  plugins/lua/Makefile
961                  plugins/memory/Makefile
962                  plugins/nbd/Makefile
963                  plugins/null/Makefile
964                  plugins/ocaml/Makefile
965                  plugins/partitioning/Makefile
966                  plugins/pattern/Makefile
967                  plugins/perl/Makefile
968                  plugins/python/Makefile
969                  plugins/random/Makefile
970                  plugins/ruby/Makefile
971                  plugins/rust/Cargo.toml
972                  plugins/rust/Makefile
973                  plugins/sh/Makefile
974                  plugins/ssh/Makefile
975                  plugins/split/Makefile
976                  plugins/streaming/Makefile
977                  plugins/tar/Makefile
978                  plugins/tcl/Makefile
979                  plugins/vddk/Makefile
980                  plugins/zero/Makefile
981                  filters/Makefile
982                  filters/blocksize/Makefile
983                  filters/cache/Makefile
984                  filters/cacheextents/Makefile
985                  filters/cow/Makefile
986                  filters/delay/Makefile
987                  filters/error/Makefile
988                  filters/fua/Makefile
989                  filters/ip/Makefile
990                  filters/log/Makefile
991                  filters/nocache/Makefile
992                  filters/noextents/Makefile
993                  filters/nofilter/Makefile
994                  filters/noparallel/Makefile
995                  filters/nozero/Makefile
996                  filters/offset/Makefile
997                  filters/partition/Makefile
998                  filters/rate/Makefile
999                  filters/readahead/Makefile
1000                  filters/retry/Makefile
1001                  filters/stats/Makefile
1002                  filters/truncate/Makefile
1003                  filters/xz/Makefile
1004                  fuzzing/Makefile
1005                  server/Makefile
1006                  server/nbdkit.pc
1007                  tests/functions.sh
1008                  tests/Makefile
1009                  valgrind/Makefile])
1011 AC_OUTPUT
1013 dnl Summary.
1014 echo
1015 echo
1016 echo "----------------------------------------------------------------------"
1017 echo "Thank you for downloading $PACKAGE_STRING"
1018 echo
1019 echo "This is how we have configured the optional components for you today:"
1020 echo
1022 feature ()
1024     printf %s "    $1"
1025     shift
1026     if $@; then echo "yes"; else echo "no"; fi
1029 echo "Optional server features:"
1030 echo
1031 feature "bash-completion ........................ " \
1032         test "x$HAVE_BASH_COMPLETION_TRUE" = "x"
1033 feature "manual pages ........................... " \
1034         test "x$HAVE_POD_TRUE" = "x"
1035 feature "SELinux ................................ " \
1036         test "x$LIBSELINUX_LIBS" != "x"
1037 feature "TLS .................................... " \
1038         test "x$GNUTLS_LIBS" != "x"
1040 echo
1041 echo "Optional plugins:"
1042 echo
1043 feature "curl ................................... " \
1044         test "x$HAVE_CURL_TRUE" = "x"
1045 feature "example4 ............................... " \
1046         test "x$HAVE_PERL_TRUE" = "x"
1047 feature "ext2 ................................... " \
1048         test "x$HAVE_EXT2_TRUE" = "x"
1049 feature "floppy ................................. " \
1050         test "x$HAVE_ICONV_TRUE" = "x"
1051 feature "guestfs ................................ " \
1052         test "x$HAVE_LIBGUESTFS_TRUE" = "x"
1053 feature "gzip ................................... " \
1054         test "x$HAVE_ZLIB_TRUE" = "x"
1055 feature "iso .................................... " \
1056         test "x$HAVE_ISO_TRUE" = "x"
1057 feature "libvirt ................................ " \
1058         test "x$HAVE_LIBVIRT_TRUE" = "x"
1059 feature "nbd .................................... " \
1060         test "x$HAVE_NBD_PLUGIN_TRUE" = "x"
1061 feature "ssh .................................... " \
1062         test "x$HAVE_SSH_TRUE" = "x"
1063 feature "tar .................................... " \
1064         test "x$HAVE_PERL_TRUE" = "x"
1065 feature "vddk ................................... " \
1066         test "x$HAVE_VDDK_TRUE" = "x"
1069 echo
1070 echo "Languages:"
1071 echo
1072 feature "lua .................................... " \
1073         test "x$HAVE_LUA_TRUE" = "x"
1074 feature "ocaml .................................. " \
1075         test "x$HAVE_OCAML_TRUE" = "x"
1076 feature "perl ................................... " \
1077         test "x$HAVE_PERL_TRUE" = "x"
1078 feature "python ................................. " \
1079         test "x$HAVE_PYTHON_TRUE" = "x"
1080 feature "ruby ................................... " \
1081         test "x$HAVE_RUBY_TRUE" = "x"
1082 feature "rust ................................... " \
1083         test "x$HAVE_RUST_TRUE" = "x"
1084 feature "tcl .................................... " \
1085         test "x$HAVE_TCL_TRUE" = "x"
1088 echo
1089 echo "Optional filters:"
1090 echo
1091 feature "xz ..................................... " \
1092         test "x$HAVE_LIBLZMA_TRUE" = "x"
1094 echo
1095 echo "If any optional component is configured ‘no’ when you expected ‘yes’"
1096 echo "then you should check the preceding messages and README."
1097 echo
1098 echo "Please report bugs back to the mailing list:"
1099 echo "http://www.redhat.com/mailman/listinfo/libguestfs"
1100 echo
1101 echo "Next you should type 'make' to build the package,"
1102 echo "then 'make check' to run the tests."