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