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