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