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