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