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