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