guestfs: Use nbdkit_parse_bool to parse debug and trace parameters.
[nbdkit/ericb.git] / configure.ac
blob78e79ea086f3a1b5ddab0eb52bf7f9186f30cfa6
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], [15])
34 m4_define([NBDKIT_VERSION_MICRO], [2])
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/prctl.h \
204         sys/procctl.h])
206 dnl Check for functions in libc, all optional.
207 AC_CHECK_FUNCS([\
208         accept4 \
209         fdatasync \
210         get_current_dir_name \
211         mkostemp \
212         pipe2 \
213         ppoll \
214         posix_fadvise])
216 dnl Check whether printf("%m") works
217 AC_CACHE_CHECK([whether the printf family supports %m],
218   [nbdkit_cv_func_printf_percent_m],
219   [AC_RUN_IFELSE(
220     [AC_LANG_PROGRAM([[
221 #include <stdio.h>
222 #include <string.h>
223 #include <errno.h>
224     ]], [[
225     char buf[200] = "";
226     errno = EINVAL;
227     snprintf(buf, sizeof buf, "%m");
228     return !!strcmp (buf, strerror (EINVAL));
229     ]])],
230     [nbdkit_cv_func_printf_percent_m=yes],
231     [nbdkit_cv_func_printf_percent_m=no],
232     [[
233     case "$host_os" in
234       *-gnu* | gnu*) nbdkit_cv_func_printf_percent_m=yes;;
235       *) nbdkit_cv_func_printf_percent_m="guessing no";;
236     esac
237     ]])])
238 AS_IF([test "x$nbdkit_cv_func_printf_percent_m" = xyes],
239   [AC_DEFINE([HAVE_VFPRINTF_PERCENT_M],[1],
240     [Define to 1 if vfprintf supports %m.])])
242 old_LIBS="$LIBS"
243 AC_SEARCH_LIBS([dlsym], [dl dld], [
244         AS_IF([test "x$ac_cv_search_dlsym" != "xnone required"],
245             [DL_LIBS="$ac_cv_search_dlsym"], [DL_LIBS=])
246         AC_SUBST([DL_LIBS])
247     ], [AC_MSG_ERROR([unable to find the dlsym() function])
249 LIBS="$old_LIBS"
251 dnl Test if <iconv.h> header can build working binaries.
253 dnl On FreeBSD: iconv and libiconv both exist, both can be installed
254 dnl simultaneously, <iconv.h> can exist in two separate places, and
255 dnl if you get the wrong header/library mix everything breaks.
257 dnl On Haiku: libiconv is required to link to iconv_* functions.
258 AC_ARG_WITH([iconv],
259     [AS_HELP_STRING([--without-iconv],
260                     [don't try to link against iconv @<:@default=check@:>@])],
261     [],
262     [with_iconv=check])
263 AS_IF([test "x$with_iconv" != "xno"],[
264     AC_CHECK_HEADER([iconv.h],[
265         AC_MSG_CHECKING([if <iconv.h> can be used to link a program])
266         AC_LINK_IFELSE([
267 AC_LANG_SOURCE([[
268 #include <stdio.h>
269 #include <stdlib.h>
270 #include <iconv.h>
272 main (int argc, char *argv[])
274   iconv_t ic = iconv_open ("", "");
275   iconv_close (ic);
276   exit (0);
279             ],[
280             AC_MSG_RESULT([yes])
281             iconv_working=yes
282             ],[
283             AC_MSG_RESULT([no])
284             ])
285         ])
286     ])
287 AM_CONDITIONAL([HAVE_ICONV], [test "x$iconv_working" = "xyes"])
289 dnl Don't use linker script for the server on FreeBSD because
290 dnl FreeBSD's linker is broken.  See eg:
291 dnl https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190851
292 AC_MSG_CHECKING([if we should use a linker script for the server])
293 AS_CASE([$host_os],
294   [freebsd*], [use_linker_script_for_server=no],
295   [use_linker_script_for_server=yes]
297 AC_MSG_RESULT([$use_linker_script_for_server])
298 AM_CONDITIONAL([USE_LINKER_SCRIPT_FOR_SERVER],
299                [test "x$use_linker_script_for_server" = "xyes"])
301 dnl Check if -rdynamic linker flag works.
302 acx_nbdkit_save_LDFLAGS="${LDFLAGS}"
303 LDFLAGS="${LDFLAGS} -rdynamic"
304 AC_MSG_CHECKING([if linker supports -rdynamic])
305 AC_LINK_IFELSE([
306 AC_LANG_SOURCE([[
307 #include <stdlib.h>
309 main (int argc, char *argv[])
311   exit (EXIT_SUCCESS);
314     ],[
315     AC_MSG_RESULT([yes])
316     DL_LDFLAGS=-rdynamic
317     ],[
318     AC_MSG_RESULT([no])
320 dnl restore CFLAGS
321 LDFLAGS="${acx_nbdkit_save_LDFLAGS}"
322 AC_SUBST([DL_LDFLAGS])
324 dnl Check for dladdr in -ldl, optional.  This is a glibc extension.
325 old_LIBS="$LIBS"
326 LIBS="$DL_LIBS $LIBS"
327 AC_CHECK_FUNCS([dladdr])
328 LIBS="$old_LIBS"
330 AC_SEARCH_LIBS([getaddrinfo], [network socket])
332 dnl Check for SELinux socket labelling (optional).
333 PKG_CHECK_MODULES([LIBSELINUX], [libselinux], [
334     AC_SUBST([LIBSELINUX_CFLAGS])
335     AC_SUBST([LIBSELINUX_LIBS])
336     AC_DEFINE([HAVE_LIBSELINUX],[1],[libselinux found at compile time.])
337 ], [
338     AC_MSG_WARN([libselinux not found, SELinux socket labelling support will be disabled.])
341 dnl Check for GnuTLS (optional, for TLS support).
342 PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0], [
343     AC_SUBST([GNUTLS_CFLAGS])
344     AC_SUBST([GNUTLS_LIBS])
345     AC_DEFINE([HAVE_GNUTLS],[1],[gnutls found at compile time.])
346 ], [
347     AC_MSG_WARN([gnutls not found or < 3.3.0, TLS support will be disabled.])
350 AS_IF([test "$GNUTLS_LIBS" != ""],[
351     AC_MSG_CHECKING([for default TLS session priority string])
352     AC_ARG_WITH([tls-priority],
353         [AS_HELP_STRING([--with-tls-priority],
354                         [default TLS session priority string @<:@default=NORMAL@:>@])],
355         [tls_priority=$withval],
356         [tls_priority=NORMAL])
357     AC_MSG_RESULT([$tls_priority])
358     AC_DEFINE_UNQUOTED([TLS_PRIORITY],["$tls_priority"],
359                        [Default TLS session priority string])
361     # Check for APIs which may not be present.
362     old_LIBS="$LIBS"
363     LIBS="$GNUTLS_LIBS $LIBS"
364     AC_CHECK_FUNCS([\
365         gnutls_base64_decode2 \
366         gnutls_certificate_set_known_dh_params \
367         gnutls_session_set_verify_cert])
368     LIBS="$old_LIBS"
371 dnl Check for valgrind.
372 AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[no])
374 dnl If valgrind headers are available (optional).
375 dnl Since this is only useful for developers, you have to enable
376 dnl it explicitly using --enable-valgrind.
377 AC_ARG_ENABLE([valgrind],
378     [AS_HELP_STRING([--enable-valgrind],
379                     [enable Valgrind extensions (for developers)])],
380     [enable_valgrind=yes],
381     [enable_valgrind=no])
382 AS_IF([test "x$enable_valgrind" = "xyes"],[
383     PKG_CHECK_MODULES([VALGRIND], [valgrind], [
384         AC_SUBST([VALGRIND_CFLAGS])
385         AC_SUBST([VALGRIND_LIBS])
386         AC_DEFINE([HAVE_VALGRIND],[1],[Valgrind headers found at compile time])
387     ],[
388         AC_MSG_ERROR([--enable-valgrind given, but Valgrind headers are not available])
389     ])
392 dnl Bash completion.
393 PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], [
394     bash_completion=yes
395     AC_MSG_CHECKING([for bash-completions directory])
396     m4_ifdef([PKG_CHECK_VAR],[
397         PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir])
398     ])
399     AS_IF([test -z "$bashcompdir"], [
400         bashcompdir="${sysconfdir}/bash_completion.d"
401     ])
402     AC_MSG_RESULT([$bashcompdir])
403     AC_SUBST([bashcompdir])
405     bash_completion=no
406     AC_MSG_WARN([bash-completion not installed])
408 AM_CONDITIONAL([HAVE_BASH_COMPLETION],[test "x$bash_completion" = "xyes"])
410 dnl Check we have enough to run podwrapper.
411 AC_CHECK_PROG([PERL],[perl],[perl],[no])
412 AS_IF([test "x$PERL" != "xno"],[
413     AC_MSG_CHECKING([if we have perl Pod::Man and Pod::Simple])
414     AS_IF([$PERL -MPod::Man -MPod::Simple -e 1 >&AS_MESSAGE_LOG_FD 2>&1],[
415         enable_pod=yes
416     ],[
417         enable_pod=no
418     ])
419     AC_MSG_RESULT([$enable_pod])
421 AM_CONDITIONAL([HAVE_POD],
422                [test "x$PERL" != "xno" && test "x$enable_pod" = "xyes"])
424 dnl Define the path to the podwrapper program.
425 PODWRAPPER="$PERL $(pwd)/podwrapper.pl"
426 AC_SUBST([PODWRAPPER])
428 dnl Allow all plugins and filters to be disabled.
429 AC_ARG_ENABLE([plugins],
430     [AS_HELP_STRING([--disable-plugins],
431                     [disable all bundled plugins and filters])])
432 AM_CONDITIONAL([HAVE_PLUGINS], [test "x$enable_plugins" != "xno"])
434 dnl Check for Perl, for embedding in the perl plugin.
435 dnl Note that the perl binary is checked above.
436 AC_ARG_ENABLE([perl],
437     [AS_HELP_STRING([--disable-perl], [disable Perl embed plugin])],
438     [],
439     [enable_perl=yes])
440 AS_IF([test "x$PERL" != "xno" && test "x$enable_perl" != "xno"],[
441     dnl Check for Perl archlib.
442     AC_MSG_CHECKING([for Perl embed archlib])
443     PERL_ARCHLIB="$($PERL -MConfig -e 'print $Config{archlib}')"
444     AS_IF([ test -n "$PERL_ARCHLIB" ],[
445         AC_MSG_RESULT([$PERL_ARCHLIB])
446     ],[
447         AC_MSG_NOTICE([Perl embed module disabled])
448         enable_perl=no
449     ])
451     dnl Check for Perl CFLAGS.
452     AC_MSG_CHECKING([for Perl embed CFLAGS])
453     PERL_CFLAGS="$($PERL -MExtUtils::Embed -e 'ccflags')"
454     AS_IF([ test -n "$PERL_CFLAGS" ],[
455         AC_MSG_RESULT([$PERL_CFLAGS])
456     ],[
457         AC_MSG_NOTICE([Perl embed module disabled])
458         enable_perl=no
459     ])
461     dnl Check for Perl LDOPTS.
462     AC_MSG_CHECKING([for Perl embed LDOPTS])
463     PERL_LDOPTS="$($PERL -MExtUtils::Embed -e 'ldopts')"
464     AC_MSG_RESULT([$PERL_LDOPTS])
466     dnl XXX Could check these actually work.
468 AM_CONDITIONAL([HAVE_PERL],[test "x$enable_perl" != "xno" && test "x$PERL" != "xno"])
469 AC_SUBST([PERL_ARCHLIB])
470 AC_SUBST([PERL_CFLAGS])
471 AC_SUBST([PERL_LDOPTS])
473 dnl Check for Python 3, for embedding in the python plugin.
474 AC_CHECK_PROG([PYTHON],[python],[python],[no])
475 AC_ARG_ENABLE([python],
476     [AS_HELP_STRING([--disable-python], [disable Python embed plugin])],
477     [],
478     [enable_python=yes])
479 AS_IF([test "x$PYTHON" != "xno" && test "x$enable_python" != "xno"],[
480     AC_MSG_CHECKING([version of $PYTHON])
481     PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info@<:@0@:>@)"`
482     PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info@<:@1@:>@)"`
483     PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
484     AS_IF([test -n "$PYTHON_VERSION"],[
485         AC_MSG_RESULT([$PYTHON_VERSION])
486     ],[
487         AC_MSG_NOTICE([Python embed module disabled])
488         enable_python=no
489     ])
491     AC_MSG_CHECKING([Python major version is 3])
492     AS_IF([test "x$PYTHON_VERSION_MAJOR" = "x3"],[
493         AC_MSG_RESULT([yes])
494     ],[
495         AC_MSG_RESULT([no])
496         AC_MSG_ERROR([Python $PYTHON_VERSION_MAJOR <> 3 is no longer supported.
498 Python 2 end of life is 2020-01-01 and nbdkit >= 1.16 no longer
499 supports it.
501 If you want to use Python 2, you will need to use nbdkit 1.14.])
502     ])
504     dnl Check for Python CFLAGS, libraries.
505     dnl For Python >= 3.8 we have to use python-<VERSION>-embed.pc, see:
506     dnl https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
507     dnl The python.pc is called python-<VERSION>.pc on Debian and
508     dnl later versions of Fedora, and python.pc on older versions
509     dnl of Fedora.
510     PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"-embed], [
511         AC_SUBST([PYTHON_CFLAGS])
512         AC_SUBST([PYTHON_LIBS])
513         AC_SUBST([PYTHON_VERSION])
514         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
515     ],[
516     PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"], [
517         AC_SUBST([PYTHON_CFLAGS])
518         AC_SUBST([PYTHON_LIBS])
519         AC_SUBST([PYTHON_VERSION])
520         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
521     ],[
522     PKG_CHECK_MODULES([PYTHON], [python], [
523         AC_SUBST([PYTHON_CFLAGS])
524         AC_SUBST([PYTHON_LIBS])
525         AC_SUBST([PYTHON_VERSION])
526         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
527     ],[
528         AC_MSG_WARN([python $PYTHON_VERSION not found])
529         enable_python=no
530     ])])])
532 AM_CONDITIONAL([HAVE_PYTHON],[test "x$enable_python" != "xno" && test "x$PYTHON" != "xno"])
533 AC_SUBST([PYTHON_CFLAGS])
534 AC_SUBST([PYTHON_LIBS])
535 AC_SUBST([PYTHON_LDFLAGS])
537 dnl For the OCaml plugin, you can set OCAMLOPTFLAGS before running
538 dnl ./configure to specify any extra flags you want to pass to
539 dnl ocamlopt.
540 AC_SUBST([OCAMLOPTFLAGS])
542 dnl Check for OCaml, for embedding in the ocaml plugin.
543 AC_PROG_OCAML
544 AC_ARG_ENABLE([ocaml],
545     [AS_HELP_STRING([--disable-ocaml], [disable OCaml embed plugin])],
546     [],
547     [enable_ocaml=yes])
548 AS_IF([test "x$OCAMLOPT" != "xno" && test "x$enable_ocaml" != "xno"],[
549     dnl Check OCaml can create a shared library (see README for details).
550     AC_MSG_CHECKING([if $OCAMLOPT can create a shared library])
551     echo 'print_endline "test"' > conftest.ml
552     AS_IF([$OCAMLOPT $OCAMLOPTFLAGS -output-obj -runtime-variant _pic -o conftest.so conftest.ml >&AS_MESSAGE_LOG_FD 2>&1],[
553         AC_MSG_RESULT([yes])
554         ocaml_link_shared=yes
555     ],[
556         AC_MSG_RESULT([no])
557     ])
558     rm -f conftest.ml conftest.cmi conftest.cmx conftest.so conftest.o
560 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLOPT" != "xno" &&
561                              test "x$ocaml_link_shared" = "xyes"])
563 dnl For developing plugins in Rust, optional.
564 AC_CHECK_PROG([CARGO],[cargo],[cargo],[no])
565 AC_ARG_ENABLE([rust],
566     [AS_HELP_STRING([--disable-rust], [disable Rust plugin])],
567     [],
568     [enable_rust=yes])
569 AM_CONDITIONAL([HAVE_RUST],
570                [test "x$CARGO" != "xno" && test "x$enable_rust" != "xno"])
572 dnl Check for Ruby, for embedding in the Ruby plugin.
573 AC_CHECK_PROG([RUBY],[ruby],[ruby],[no])
574 AC_ARG_ENABLE([ruby],
575     [AS_HELP_STRING([--disable-ruby], [disable Ruby plugin])],
576     [],
577     [enable_ruby=yes])
578 AS_IF([test "x$RUBY" != "xno" && test "x$enable_ruby" != "xno"],[
579     PKG_CHECK_MODULES([RUBY], [ruby], [
580         AC_SUBST([RUBY_CFLAGS])
581         AC_SUBST([RUBY_LIBS])
582     ],[
583         AC_MSG_WARN([ruby not found])
584         enable_ruby=no
585     ])
587 AM_CONDITIONAL([HAVE_RUBY],[test "x$RUBY" != "xno" &&
588                             test "x$enable_ruby" = "xyes"])
590 dnl Check for Tcl, for embedding in the Tcl plugin.
591 AC_ARG_ENABLE([tcl],
592     [AS_HELP_STRING([--disable-tcl], [disable Tcl plugin])],
593     [],
594     [enable_tcl=yes])
595 AS_IF([test "x$enable_tcl" != "xno"],[
596     PKG_CHECK_MODULES([TCL], [tcl], [
597         AC_SUBST([TCL_CFLAGS])
598         AC_SUBST([TCL_LIBS])
599     ],[
600         AC_MSG_WARN([Tcl not found])
601         enable_tcl=no
602     ])
604 AM_CONDITIONAL([HAVE_TCL],[test "x$enable_tcl" = "xyes"])
606 dnl Check for Lua, for embedding in the Lua plugin.
607 AC_ARG_ENABLE([lua],
608     [AS_HELP_STRING([--disable-lua], [disable Lua plugin])],
609     [],
610     [enable_lua=yes])
611 AS_IF([test "x$enable_lua" != "xno"],[
612     PKG_CHECK_MODULES([LUA], [lua], [
613         AC_SUBST([LUA_CFLAGS])
614         AC_SUBST([LUA_LIBS])
616         dnl Lua 5.1 used by RHEL 7 does not have lua_isinteger.
617         old_LIBS="$LIBS"
618         LIBS="$LUA_LIBS $LIBS"
619         AC_CHECK_FUNCS([lua_isinteger])
620         LIBS="$old_LIBS"
621     ],[
622         AC_MSG_WARN([Lua not found])
623         enable_lua=no
624     ])
626 AM_CONDITIONAL([HAVE_LUA],[test "x$enable_lua" = "xyes"])
628 dnl Check for curl (only if you want to compile the curl plugin).
629 AC_ARG_WITH([curl],
630     [AS_HELP_STRING([--without-curl],
631                     [disable curl plugin @<:@default=check@:>@])],
632     [],
633     [with_curl=check])
634 AS_IF([test "$with_curl" != "no"],[
635     PKG_CHECK_MODULES([CURL], [libcurl],[
636         AC_SUBST([CURL_CFLAGS])
637         AC_SUBST([CURL_LIBS])
638         AC_DEFINE([HAVE_CURL],[1],[curl found at compile time.])
639         AC_CHECK_DECL([CURLOPT_UNIX_SOCKET_PATH], [
640             AC_DEFINE([HAVE_CURLOPT_UNIX_SOCKET_PATH],[1],
641                       [CURLOPT_UNIX_SOCKET_PATH found at compile time.])
642             ], [], [#include <curl/curl.h>])
643     ],
644     [AC_MSG_WARN([curl not found, curl plugin will be disabled])])
646 AM_CONDITIONAL([HAVE_CURL],[test "x$CURL_LIBS" != "x"])
648 dnl Check for libssh (only if you want to compile the ssh plugin).
649 AC_ARG_WITH([ssh],
650     [AS_HELP_STRING([--without-ssh],
651                     [disable ssh plugin @<:@default=check@:>@])],
652     [],
653     [with_ssh=check])
654 AS_IF([test "$with_ssh" != "no"],[
655     PKG_CHECK_MODULES([SSH], [libssh >= 0.8.0],[
656         AC_SUBST([SSH_CFLAGS])
657         AC_SUBST([SSH_LIBS])
658     ],
659     [AC_MSG_WARN([libssh not found, ssh plugin will be disabled])])
661 AM_CONDITIONAL([HAVE_SSH],[test "x$SSH_LIBS" != "x"])
663 dnl Check for genisoimage or mkisofs
664 dnl (only if you want to compile the iso plugin).
665 ISOPROG="no"
666 AC_ARG_WITH([iso],
667     [AS_HELP_STRING([--without-iso],
668                     [disable iso plugin @<:@default=check@:>@])],
669     [],
670     [with_iso=check])
671 AS_IF([test "$with_iso" != "no"],[
672     AC_CHECK_PROG([GENISOIMAGE],[genisoimage],[genisoimage],[no])
673     AC_CHECK_PROG([MKISOFS],[mkisofs],[mkisofs],[no])
674     AS_IF([test "x$GENISOIMAGE" != "xno"],[
675         ISOPROG="$GENISOIMAGE"
676     ],[
677         AS_IF([test "x$MKISOFS" != "xno"],[
678             ISOPROG="$MKISOFS"
679         ])
680     ])
681     AS_IF([test "x$ISOPROG" != "xno"],[
682         AC_DEFINE_UNQUOTED([ISOPROG],["$ISOPROG"],
683                            [Program used by iso plugin to make ISOs.])
684     ])
686 AC_SUBST([ISOPROG])
687 AM_CONDITIONAL([HAVE_ISO],[test "x$ISOPROG" != "xno"])
689 dnl Check for libvirt (only if you want to compile the libvirt plugin).
690 AC_ARG_WITH([libvirt],
691     [AS_HELP_STRING([--without-libvirt],
692                     [disable libvirt plugin @<:@default=check@:>@])],
693     [],
694     [with_libvirt=check])
695 AS_IF([test "$with_libvirt" != "no"],[
696     PKG_CHECK_MODULES([LIBVIRT], [libvirt],[
697         AC_SUBST([LIBVIRT_CFLAGS])
698         AC_SUBST([LIBVIRT_LIBS])
699         AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.])
700     ],
701     [AC_MSG_WARN([libvirt not found, libvirt plugin will be disabled])])
703 AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
705 dnl Check for zlib (only if you want to compile the gzip plugin).
706 AC_ARG_WITH([zlib],
707     [AS_HELP_STRING([--without-zlib],
708                     [disable gzip plugin @<:@default=check@:>@])],
709     [],
710     [with_zlib=check])
711 AS_IF([test "$with_zlib" != "no"],[
712     PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3.5],[
713         AC_SUBST([ZLIB_CFLAGS])
714         AC_SUBST([ZLIB_LIBS])
715         AC_DEFINE([HAVE_ZLIB],[1],[zlib found at compile time.])
716     ],
717     [AC_MSG_WARN([zlib >= 1.2.3.5 not found, gzip plugin will be disabled])])
719 AM_CONDITIONAL([HAVE_ZLIB],[test "x$ZLIB_LIBS" != "x"])
721 dnl Check for libnbd (only if you want to compile the full nbd plugin).
722 AC_ARG_WITH([libnbd],
723     [AS_HELP_STRING([--without-libnbd],
724                     [disable nbd plugin @<:@default=check@:>@])],
725     [],
726     [with_libnbd=check])
727 AS_IF([test "$with_libnbd" != "no"],[
728     PKG_CHECK_MODULES([LIBNBD], [libnbd >= 0.9.8],[
729         AC_SUBST([LIBNBD_CFLAGS])
730         AC_SUBST([LIBNBD_LIBS])
731         AC_DEFINE([HAVE_LIBNBD],[1],[libnbd found at compile time.])
732     ],
733     [AC_MSG_WARN([libnbd >= 0.9.8 not found, nbd plugin will be crippled])])
735 AM_CONDITIONAL([HAVE_LIBNBD], [test "x$LIBNBD_LIBS" != "x"])
737 dnl Check for liblzma (only if you want to compile the xz filter).
738 AC_ARG_WITH([liblzma],
739     [AS_HELP_STRING([--without-liblzma],
740                     [disable xz filter @<:@default=check@:>@])],
741     [],
742     [with_liblzma=check])
743 AS_IF([test "$with_liblzma" != "no"],[
744     PKG_CHECK_MODULES([LIBLZMA], [liblzma],[
745         AC_SUBST([LIBLZMA_CFLAGS])
746         AC_SUBST([LIBLZMA_LIBS])
747         AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma found at compile time.])
748     ],
749     [AC_MSG_WARN([liblzma not found, xz filter will be disabled])])
751 AM_CONDITIONAL([HAVE_LIBLZMA],[test "x$LIBLZMA_LIBS" != "x"])
753 dnl Check for libguestfs (only for the guestfs plugin and the test suite).
754 AC_ARG_WITH([libguestfs],
755     [AS_HELP_STRING([--without-libguestfs],
756                     [disable guestfs plugin and tests @<:@default=check@:>@])],
757     [],
758     [with_libguestfs=check])
759 AS_IF([test "$with_libguestfs" != "no"],[
760     PKG_CHECK_MODULES([LIBGUESTFS], [libguestfs],[
761         # Although the library was found, we want to make sure it supports nbd
762         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
763 #include <guestfs.h>
764         ]], [[
765 #ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
766 #error unsupported
767 #endif
768         ]])], [
769         AC_SUBST([LIBGUESTFS_CFLAGS])
770         AC_SUBST([LIBGUESTFS_LIBS])
771         AC_DEFINE([HAVE_LIBGUESTFS],[1],[libguestfs found at compile time.])
772         ],[
773         LIBGUESTFS_LIBS=
774         AC_MSG_WARN([libguestfs too old, guestfs plugin and tests will be disabled])])
775     ],
776     [AC_MSG_WARN([libguestfs not found, guestfs plugin and tests will be disabled])])
778 AM_CONDITIONAL([HAVE_LIBGUESTFS],[test "x$LIBGUESTFS_LIBS" != "x"])
780 dnl Check for guestfish (only needed for some of the tests).
781 AC_CHECK_PROG([GUESTFISH], [guestfish], [guestfish], [no])
782 AM_CONDITIONAL([HAVE_GUESTFISH], [test "x$GUESTFISH" != "xno"])
784 dnl Check for ext2fs and com_err, for the ext2 plugin.
785 AC_ARG_WITH([ext2],
786     [AS_HELP_STRING([--without-ext2],
787                     [disable ext2 plugin @<:@default=check@:>@])],
788     [],
789     [with_ext2=check])
790 AS_IF([test "$with_ext2" != "no"], [
791     PKG_CHECK_MODULES([EXT2FS], [ext2fs], [
792         AC_SUBST([EXT2FS_CFLAGS])
793         AC_SUBST([EXT2FS_LIBS])
794         AC_DEFINE([HAVE_EXT2FS],[1],[ext2fs found at compile time.])
795     ],
796     [AC_MSG_WARN([ext2fs not found, ext2 plugin will be disabled])])
797     PKG_CHECK_MODULES([COM_ERR], [com_err], [
798         AC_SUBST([COM_ERR_CFLAGS])
799         AC_SUBST([COM_ERR_LIBS])
800         AC_DEFINE([HAVE_COM_ERR],[1],[com_err found at compile time.])
801     ],
802     [AC_MSG_WARN([com_err not found, ext2 plugin will be disabled])])
804 AM_CONDITIONAL([HAVE_EXT2],
805                [test "x$EXT2FS_LIBS" != "x" && test "x$COM_ERR_LIBS" != "x"])
807 dnl Check if the user wants to disable VDDK support.
808 dnl See plugins/vddk/README.VDDK.
809 AC_ARG_ENABLE([vddk],
810     [AS_HELP_STRING([--disable-vddk],
811                     [disable VMware VDDK plugin])],
812     [],
813     [enable_vddk=yes])
814 AM_CONDITIONAL([HAVE_VDDK], [test "x$enable_vddk" = "xyes"])
816 dnl List of plugins and filters.
817 lang_plugins="\
818         lua \
819         ocaml \
820         perl \
821         python \
822         ruby \
823         rust \
824         sh \
825         tcl \
826         "
827 non_lang_plugins="\
828         curl \
829         data \
830         example1 \
831         example2 \
832         example3 \
833         example4 \
834         ext2 \
835         file \
836         floppy \
837         full \
838         guestfs \
839         gzip \
840         iso \
841         libvirt \
842         linuxdisk \
843         memory \
844         nbd \
845         null \
846         partitioning \
847         pattern \
848         random \
849         reflection \
850         split \
851         ssh \
852         streaming \
853         tar \
854         vddk \
855         zero \
856         "
857 plugins="$(echo $(printf %s\\n $lang_plugins $non_lang_plugins | sort -u))"
858 filters="\
859         blocksize \
860         cache \
861         cacheextents \
862         cow \
863         delay \
864         error \
865         fua \
866         log \
867         nocache \
868         noextents \
869         noparallel \
870         nozero \
871         offset \
872         partition \
873         rate \
874         readahead \
875         retry \
876         stats \
877         truncate \
878         xz \
879         "
880 AC_SUBST([plugins])
881 AC_SUBST([lang_plugins])
882 AC_SUBST([non_lang_plugins])
883 AC_SUBST([filters])
885 dnl Produce output files.
886 AC_CONFIG_HEADERS([config.h])
887 AC_CONFIG_FILES([podwrapper.pl],
888                 [chmod +x,-w podwrapper.pl])
889 AC_CONFIG_FILES([Makefile
890                  bash/Makefile
891                  common/bitmap/Makefile
892                  common/gpt/Makefile
893                  common/include/Makefile
894                  common/protocol/Makefile
895                  common/regions/Makefile
896                  common/sparse/Makefile
897                  common/utils/Makefile
898                  docs/Makefile
899                  include/Makefile
900                  include/nbdkit-version.h
901                  plugins/Makefile
902                  plugins/curl/Makefile
903                  plugins/data/Makefile
904                  plugins/example1/Makefile
905                  plugins/example2/Makefile
906                  plugins/example3/Makefile
907                  plugins/example4/Makefile
908                  plugins/ext2/Makefile
909                  plugins/file/Makefile
910                  plugins/floppy/Makefile
911                  plugins/full/Makefile
912                  plugins/guestfs/Makefile
913                  plugins/gzip/Makefile
914                  plugins/iso/Makefile
915                  plugins/libvirt/Makefile
916                  plugins/linuxdisk/Makefile
917                  plugins/lua/Makefile
918                  plugins/memory/Makefile
919                  plugins/nbd/Makefile
920                  plugins/null/Makefile
921                  plugins/ocaml/Makefile
922                  plugins/partitioning/Makefile
923                  plugins/pattern/Makefile
924                  plugins/perl/Makefile
925                  plugins/python/Makefile
926                  plugins/random/Makefile
927                  plugins/reflection/Makefile
928                  plugins/ruby/Makefile
929                  plugins/rust/Cargo.toml
930                  plugins/rust/Makefile
931                  plugins/sh/Makefile
932                  plugins/ssh/Makefile
933                  plugins/split/Makefile
934                  plugins/streaming/Makefile
935                  plugins/tar/Makefile
936                  plugins/tcl/Makefile
937                  plugins/vddk/Makefile
938                  plugins/zero/Makefile
939                  filters/Makefile
940                  filters/blocksize/Makefile
941                  filters/cache/Makefile
942                  filters/cacheextents/Makefile
943                  filters/cow/Makefile
944                  filters/delay/Makefile
945                  filters/error/Makefile
946                  filters/fua/Makefile
947                  filters/log/Makefile
948                  filters/nocache/Makefile
949                  filters/noextents/Makefile
950                  filters/noparallel/Makefile
951                  filters/nozero/Makefile
952                  filters/offset/Makefile
953                  filters/partition/Makefile
954                  filters/rate/Makefile
955                  filters/readahead/Makefile
956                  filters/retry/Makefile
957                  filters/stats/Makefile
958                  filters/truncate/Makefile
959                  filters/xz/Makefile
960                  fuzzing/Makefile
961                  server/Makefile
962                  server/nbdkit.pc
963                  tests/functions.sh
964                  tests/Makefile
965                  valgrind/Makefile])
967 AC_OUTPUT
969 dnl Summary.
970 echo
971 echo
972 echo "----------------------------------------------------------------------"
973 echo "Thank you for downloading $PACKAGE_STRING"
974 echo
975 echo "This is how we have configured the optional components for you today:"
976 echo
978 feature ()
980     printf %s "    $1"
981     shift
982     if $@; then echo "yes"; else echo "no"; fi
985 echo "Optional server features:"
986 echo
987 feature "bash-completion ........................ " \
988         test "x$HAVE_BASH_COMPLETION_TRUE" = "x"
989 feature "manual pages ........................... " \
990         test "x$HAVE_POD_TRUE" = "x"
991 feature "SELinux ................................ " \
992         test "x$LIBSELINUX_LIBS" != "x"
993 feature "TLS .................................... " \
994         test "x$GNUTLS_LIBS" != "x"
996 echo
997 echo "Optional plugins:"
998 echo
999 feature "curl ................................... " \
1000         test "x$HAVE_CURL_TRUE" = "x"
1001 feature "example4 ............................... " \
1002         test "x$HAVE_PERL_TRUE" = "x"
1003 feature "ext2 ................................... " \
1004         test "x$HAVE_EXT2_TRUE" = "x"
1005 feature "floppy ................................. " \
1006         test "x$HAVE_ICONV_TRUE" = "x"
1007 feature "guestfs ................................ " \
1008         test "x$HAVE_LIBGUESTFS_TRUE" = "x"
1009 feature "gzip ................................... " \
1010         test "x$HAVE_ZLIB_TRUE" = "x"
1011 feature "iso .................................... " \
1012         test "x$HAVE_ISO_TRUE" = "x"
1013 feature "libvirt ................................ " \
1014         test "x$HAVE_LIBVIRT_TRUE" = "x"
1015 feature "nbd .................................... " \
1016         test "x$HAVE_LIBNBD_TRUE" = "x"
1017 feature "ssh .................................... " \
1018         test "x$HAVE_SSH_TRUE" = "x"
1019 feature "tar .................................... " \
1020         test "x$HAVE_PERL_TRUE" = "x"
1021 feature "vddk ................................... " \
1022         test "x$HAVE_VDDK_TRUE" = "x"
1025 echo
1026 echo "Languages:"
1027 echo
1028 feature "lua .................................... " \
1029         test "x$HAVE_LUA_TRUE" = "x"
1030 feature "ocaml .................................. " \
1031         test "x$HAVE_OCAML_TRUE" = "x"
1032 feature "perl ................................... " \
1033         test "x$HAVE_PERL_TRUE" = "x"
1034 feature "python ................................. " \
1035         test "x$HAVE_PYTHON_TRUE" = "x"
1036 feature "ruby ................................... " \
1037         test "x$HAVE_RUBY_TRUE" = "x"
1038 feature "rust ................................... " \
1039         test "x$HAVE_RUST_TRUE" = "x"
1040 feature "tcl .................................... " \
1041         test "x$HAVE_TCL_TRUE" = "x"
1044 echo
1045 echo "Optional filters:"
1046 echo
1047 feature "xz ..................................... " \
1048         test "x$HAVE_LIBLZMA_TRUE" = "x"
1050 echo
1051 echo "If any optional component is configured ‘no’ when you expected ‘yes’"
1052 echo "then you should check the preceding messages and README."
1053 echo
1054 echo "Please report bugs back to the mailing list:"
1055 echo "http://www.redhat.com/mailman/listinfo/libguestfs"
1056 echo
1057 echo "Next you should type 'make' to build the package,"
1058 echo "then 'make check' to run the tests."