2 # Copyright (C) 2013-2018 Red Hat Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # * Neither the name of Red Hat nor the names of its contributors may be
17 # used to endorse or promote products derived from this software without
18 # specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
24 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 AC_INIT([nbdkit], [1.5.1])
34 AC_CONFIG_MACRO_DIR([m4])
35 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],[],
36 [m4_define([AC_USE_SYSTEM_EXTENSIONS],[])])
37 AC_USE_SYSTEM_EXTENSIONS
40 dnl NB: Do not [quote] this parameter.
41 AM_INIT_AUTOMAKE(foreign)
47 dnl Check for basic C environment.
53 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
57 dnl Check for C++ (optional, we just use this to test the header
58 dnl can be included from C++ code).
61 dnl The C++ compiler test is pretty useless because even if it fails
62 dnl it sets CXX=g++. So test the compiler actually works.
63 AC_MSG_CHECKING([if the C++ compiler really really works])
64 AS_IF([$CXX --version >&AS_MESSAGE_LOG_FD 2>&1],[have_cxx=yes],[have_cxx=no])
65 AC_MSG_RESULT([$have_cxx])
66 AM_CONDITIONAL([HAVE_CXX], [test "$have_cxx" = "yes"])
68 AC_ARG_ENABLE([gcc-warnings],
69 [AS_HELP_STRING([--enable-gcc-warnings],
70 [turn on lots of GCC warnings (for developers)])],
73 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
75 gcc_warnings=$enableval],
78 if test "x$gcc_warnings" = "xyes"; then
79 WARNINGS_CFLAGS="-Wall -Werror"
80 AC_SUBST([WARNINGS_CFLAGS])
83 dnl Check if libc has program_invocation_short_name.
84 AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
86 dnl Check if __attribute__((cleanup(...))) works.
87 dnl Set -Werror, otherwise gcc will only emit a warning for attributes
88 dnl that it doesn't understand.
89 acx_nbdkit_save_CFLAGS="${CFLAGS}"
90 CFLAGS="${CFLAGS} -Werror"
91 AC_MSG_CHECKING([if __attribute__((cleanup(...))) works with this compiler])
106 __attribute__((cleanup(freep))) char *ptr = malloc (100);
110 main (int argc, char *argv[])
121 ['__attribute__((cleanup(...)))' does not work.
123 You may not be using a sufficiently recent version of GCC or CLANG, or
124 you may be using a C compiler which does not support this attribute,
125 or the configure test may be wrong.
127 This code requires the attribute to work for proper locking between threads.])])
129 CFLAGS="${acx_nbdkit_save_CFLAGS}"
131 dnl Check for other headers, all optional.
132 AC_CHECK_HEADERS([selinux/selinux.h sys/prctl.h])
134 dnl Check support for setsockcreatecon_raw (part of SELinux).
135 AC_CHECK_LIB([selinux], [setsockcreatecon_raw], [], [:])
137 dnl Check for GnuTLS (optional, for TLS support).
138 PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0], [
139 AC_SUBST([GNUTLS_CFLAGS])
140 AC_SUBST([GNUTLS_LIBS])
141 AC_DEFINE([HAVE_GNUTLS],[1],[gnutls found at compile time.])
143 AC_MSG_WARN([gnutls not found or < 3.3.0, TLS support will be disabled.])
146 AS_IF([test "$GNUTLS_LIBS" != ""],[
147 AC_MSG_CHECKING([for default TLS session priority string])
148 AC_ARG_WITH([tls-priority],[
149 AS_HELP_STRING([--with-tls-priority],
150 [default TLS session priority string @<:@default=NORMAL@:>@])],
151 [tls_priority=$withval],
152 [tls_priority=NORMAL])
153 AC_MSG_RESULT([$tls_priority])
154 AC_DEFINE_UNQUOTED([TLS_PRIORITY],["$tls_priority"],
155 [Default TLS session priority string])
157 # Check for APIs which may not be present.
159 LIBS="$GNUTLS_LIBS $LIBS"
161 gnutls_certificate_set_known_dh_params \
162 gnutls_session_set_verify_cert])
166 dnl Check for valgrind.
167 AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[no])
169 dnl If valgrind headers are available (optional).
170 dnl Since this is only useful for developers, you have to enable
171 dnl it explicitly using --enable-valgrind.
172 AC_ARG_ENABLE([valgrind],
173 AS_HELP_STRING([--enable-valgrind], [enable Valgrind extensions, for developers]),
174 [enable_valgrind=yes],
175 [enable_valgrind=no])
176 AS_IF([test "x$enable_valgrind" = "xyes"],[
177 PKG_CHECK_MODULES([VALGRIND], [valgrind], [
178 AC_SUBST([VALGRIND_CFLAGS])
179 AC_SUBST([VALGRIND_LIBS])
180 AC_DEFINE([HAVE_VALGRIND],[1],[Valgrind headers found at compile time])
182 AC_MSG_ERROR([--enable-valgrind given, but Valgrind headers are not available])
187 PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], [
189 AC_MSG_CHECKING([for bash-completions directory])
190 m4_ifdef([PKG_CHECK_VAR],[
191 PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir])
193 AS_IF([test -z "$bashcompdir"], [
194 bashcompdir="${sysconfdir}/bash_completion.d"
196 AC_MSG_RESULT([$bashcompdir])
197 AC_SUBST([bashcompdir])
200 AC_MSG_WARN([bash-completion not installed])
202 AM_CONDITIONAL([HAVE_BASH_COMPLETION],[test "x$bash_completion" = "xyes"])
204 dnl Check we have enough to run podwrapper.
205 AC_CHECK_PROG([PERL],[perl],[perl],[no])
206 AS_IF([test "x$PERL" != "xno"],[
207 AC_MSG_CHECKING([if we have perl Pod::Man and Pod::Simple])
208 AS_IF([$PERL -MPod::Man -MPod::Simple -e 1 >&AS_MESSAGE_LOG_FD 2>&1],[
213 AC_MSG_RESULT([$enable_pod])
215 AM_CONDITIONAL([HAVE_POD],
216 [test "x$PERL" != "xno" && test "x$enable_pod" = "xyes"])
218 dnl Define the path to the podwrapper program.
219 PODWRAPPER="$PERL $(pwd)/podwrapper.pl"
220 AC_SUBST([PODWRAPPER])
222 dnl Allow all plugins and filters to be disabled.
223 AC_ARG_ENABLE([plugins],
224 [AS_HELP_STRING([--disable-plugins], [disable all bundled plugins and filters])])
225 AM_CONDITIONAL([HAVE_PLUGINS], [test "x$enable_plugins" != "xno"])
227 dnl Check for Perl, for embedding in the perl plugin.
228 dnl Note that the perl binary is checked above.
229 AC_ARG_ENABLE([perl],
230 AS_HELP_STRING([--disable-perl], [disable Perl embed plugin]),
233 AS_IF([test "x$PERL" != "xno" && test "x$enable_perl" != "xno"],[
234 dnl Check for Perl archlib.
235 AC_MSG_CHECKING([for Perl embed archlib])
236 PERL_ARCHLIB="$($PERL -MConfig -e 'print $Config{archlib}')"
237 AS_IF([ test -n "$PERL_ARCHLIB" ],[
238 AC_MSG_RESULT([$PERL_ARCHLIB])
240 AC_MSG_NOTICE([Perl embed module disabled])
244 dnl Check for Perl CFLAGS.
245 AC_MSG_CHECKING([for Perl embed CFLAGS])
246 PERL_CFLAGS="$($PERL -MExtUtils::Embed -e 'ccflags')"
247 AS_IF([ test -n "$PERL_CFLAGS" ],[
248 AC_MSG_RESULT([$PERL_CFLAGS])
250 AC_MSG_NOTICE([Perl embed module disabled])
254 dnl Check for Perl LDOPTS.
255 AC_MSG_CHECKING([for Perl embed LDOPTS])
256 PERL_LDOPTS="$($PERL -MExtUtils::Embed -e 'ldopts')"
257 AC_MSG_RESULT([$PERL_LDOPTS])
259 dnl XXX Could check these actually work.
261 AM_CONDITIONAL([HAVE_PERL],[test "x$enable_perl" != "xno" && test "x$PERL" != "xno"])
262 AC_SUBST([PERL_ARCHLIB])
263 AC_SUBST([PERL_CFLAGS])
264 AC_SUBST([PERL_LDOPTS])
266 dnl Check for Python, for embedding in the python plugin.
267 AC_CHECK_PROG([PYTHON],[python],[python],[no])
268 AC_ARG_ENABLE([python],
269 AS_HELP_STRING([--disable-python], [disable Python embed plugin]),
272 AS_IF([test "x$PYTHON" != "xno" && test "x$enable_python" != "xno"],[
273 AC_MSG_CHECKING([version of $PYTHON])
274 PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info@<:@0@:>@)"`
275 PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info@<:@1@:>@)"`
276 PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
277 AS_IF([test -n "$PYTHON_VERSION"],[
278 AC_MSG_RESULT([$PYTHON_VERSION])
280 AC_MSG_NOTICE([Python embed module disabled])
284 dnl Check for Python CFLAGS, libraries.
285 dnl On Debian: python-X.Y.pc
286 PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"], [
287 AC_SUBST([PYTHON_CFLAGS])
288 AC_SUBST([PYTHON_LIBS])
289 AC_SUBST([PYTHON_VERSION])
290 AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
292 dnl On Fedora: python.pc
293 PKG_CHECK_MODULES([PYTHON], [python], [
294 AC_SUBST([PYTHON_CFLAGS])
295 AC_SUBST([PYTHON_LIBS])
296 AC_SUBST([PYTHON_VERSION])
297 AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
299 AC_MSG_WARN([python $PYTHON_VERSION not found])
304 dnl Check for various functions needed by the bindings.
307 PYTHON_BLDLIBRARY=`$PYTHON -c "import distutils.sysconfig; \
308 print (distutils.sysconfig.get_config_var('BLDLIBRARY'))"`
309 AC_CHECK_LIB([c],[PyString_FromString],
310 [AC_DEFINE([HAVE_PYSTRING_FROMSTRING],1,
311 [Found PyString_FromString in libpython.])],
312 [],[$PYTHON_BLDLIBRARY])
313 AC_CHECK_LIB([c],[PyString_AsString],
314 [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1,
315 [Found PyString_AsString in libpython.])],
316 [],[$PYTHON_BLDLIBRARY])
317 AC_CHECK_LIB([c],[PyUnicode_AsUTF8],
318 [AC_DEFINE([HAVE_PYUNICODE_ASUTF8],1,
319 [Found PyUnicode_AsUTF8 in libpython.])],
320 [],[$PYTHON_BLDLIBRARY])
325 AM_CONDITIONAL([HAVE_PYTHON],[test "x$enable_python" != "xno" && test "x$PYTHON" != "xno"])
326 AC_SUBST([PYTHON_CFLAGS])
327 AC_SUBST([PYTHON_LIBS])
328 AC_SUBST([PYTHON_LDFLAGS])
330 dnl For the OCaml plugin, you can set OCAMLOPTFLAGS before running
331 dnl ./configure to specify any extra flags you want to pass to
333 AC_SUBST([OCAMLOPTFLAGS])
335 dnl Check for OCaml, for embedding in the ocaml plugin.
337 AC_ARG_ENABLE([ocaml],
338 AS_HELP_STRING([--disable-ocaml], [disable OCaml embed plugin]),
341 AS_IF([test "x$OCAMLOPT" != "xno" && test "x$enable_ocaml" != "xno"],[
342 dnl Check OCaml can create a shared library (see README for details).
343 AC_MSG_CHECKING([if $OCAMLOPT can create a shared library])
344 echo 'print_endline "test"' > conftest.ml
345 AS_IF([$OCAMLOPT $OCAMLOPTFLAGS -output-obj -runtime-variant _pic -o conftest.so conftest.ml >&AS_MESSAGE_LOG_FD 2>&1],[
347 ocaml_link_shared=yes
351 rm -f conftest.ml conftest.cmi conftest.cmx conftest.so conftest.o
353 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLOPT" != "xno" &&
354 test "x$ocaml_link_shared" = "xyes"])
356 dnl Check for Ruby, for embedding in the Ruby plugin.
357 AC_CHECK_PROG([RUBY],[ruby],[ruby],[no])
358 AC_ARG_ENABLE([ruby],
359 AS_HELP_STRING([--disable-ruby], [disable Ruby plugin]),
362 AS_IF([test "x$RUBY" != "xno" && test "x$enable_ruby" != "xno"],[
363 PKG_CHECK_MODULES([RUBY], [ruby], [
364 AC_SUBST([RUBY_CFLAGS])
365 AC_SUBST([RUBY_LIBS])
367 AC_MSG_WARN([ruby not found])
371 AM_CONDITIONAL([HAVE_RUBY],[test "x$RUBY" != "xno" &&
372 test "x$enable_ruby" = "xyes"])
374 dnl Check for Tcl, for embedding in the Tcl plugin.
376 AS_HELP_STRING([--disable-tcl], [disable Tcl plugin]),
379 AS_IF([test "x$enable_tcl" != "xno"],[
380 PKG_CHECK_MODULES([TCL], [tcl], [
381 AC_SUBST([TCL_CFLAGS])
384 AC_MSG_WARN([Tcl not found])
388 AM_CONDITIONAL([HAVE_TCL],[test "x$enable_tcl" = "xyes"])
390 dnl Check for Lua, for embedding in the Lua plugin.
392 AS_HELP_STRING([--disable-lua], [disable Lua plugin]),
395 AS_IF([test "x$enable_lua" != "xno"],[
396 PKG_CHECK_MODULES([LUA], [lua], [
397 AC_SUBST([LUA_CFLAGS])
400 AC_MSG_WARN([Lua not found])
404 AM_CONDITIONAL([HAVE_LUA],[test "x$enable_lua" = "xyes"])
406 dnl Check for curl (only if you want to compile the curl plugin).
408 AS_HELP_STRING([--without-curl],
409 [disable curl plugin @<:@default=check@:>@])],
412 AS_IF([test "$with_curl" != "no"],[
413 PKG_CHECK_MODULES([CURL], [libcurl],[
414 AC_SUBST([CURL_CFLAGS])
415 AC_SUBST([CURL_LIBS])
416 AC_DEFINE([HAVE_CURL],[1],[curl found at compile time.])
418 [AC_MSG_WARN([curl not found, curl plugin will be disabled])])
420 AM_CONDITIONAL([HAVE_CURL],[test "x$CURL_LIBS" != "x"])
422 dnl Check for libvirt (only if you want to compile the libvirt plugin).
423 AC_ARG_WITH([libvirt],[
424 AS_HELP_STRING([--without-libvirt],
425 [disable libvirt plugin @<:@default=check@:>@])],
427 [with_libvirt=check])
428 AS_IF([test "$with_libvirt" != "no"],[
429 PKG_CHECK_MODULES([LIBVIRT], [libvirt],[
430 AC_SUBST([LIBVIRT_CFLAGS])
431 AC_SUBST([LIBVIRT_LIBS])
432 AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.])
434 [AC_MSG_WARN([libvirt not found, libvirt plugin will be disabled])])
436 AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
438 dnl Check for zlib (only if you want to compile the gzip plugin).
440 AS_HELP_STRING([--without-zlib],
441 [disable gzip plugin @<:@default=check@:>@])],
444 AS_IF([test "$with_zlib" != "no"],[
445 PKG_CHECK_MODULES([ZLIB], [zlib],[
446 AC_SUBST([ZLIB_CFLAGS])
447 AC_SUBST([ZLIB_LIBS])
448 AC_DEFINE([HAVE_ZLIB],[1],[zlib found at compile time.])
450 [AC_MSG_WARN([zlib not found, gzip plugin will be disabled])])
452 AM_CONDITIONAL([HAVE_ZLIB],[test "x$ZLIB_LIBS" != "x"])
454 dnl Check for liblzma (only if you want to compile the xz plugin).
455 AC_ARG_WITH([liblzma],[
456 AS_HELP_STRING([--without-liblzma],
457 [disable xz plugin @<:@default=check@:>@])],
459 [with_liblzma=check])
460 AS_IF([test "$with_liblzma" != "no"],[
461 PKG_CHECK_MODULES([LIBLZMA], [liblzma],[
462 AC_SUBST([LIBLZMA_CFLAGS])
463 AC_SUBST([LIBLZMA_LIBS])
464 AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma found at compile time.])
466 [AC_MSG_WARN([liblzma not found, xz plugin will be disabled])])
468 AM_CONDITIONAL([HAVE_LIBLZMA],[test "x$LIBLZMA_LIBS" != "x"])
470 dnl Check for libguestfs (only for the guestfs plugin and the test suite).
471 AC_ARG_WITH([libguestfs],[
472 AS_HELP_STRING([--without-libguestfs],
473 [disable guestfs plugin and tests @<:@default=check@:>@])],
475 [with_libguestfs=check])
476 AS_IF([test "$with_libguestfs" != "no"],[
477 PKG_CHECK_MODULES([LIBGUESTFS], [libguestfs],[
478 # Although the library was found, we want to make sure it supports nbd
479 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
482 #ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
486 AC_SUBST([LIBGUESTFS_CFLAGS])
487 AC_SUBST([LIBGUESTFS_LIBS])
488 AC_DEFINE([HAVE_LIBGUESTFS],[1],[libguestfs found at compile time.])
491 AC_MSG_WARN([libguestfs too old, guestfs plugin and tests will be disabled])])
493 [AC_MSG_WARN([libguestfs not found, guestfs plugin and tests will be disabled])])
495 AM_CONDITIONAL([HAVE_LIBGUESTFS],[test "x$LIBGUESTFS_LIBS" != "x"])
497 dnl Check for guestfish (only needed for some of the tests).
498 AC_CHECK_PROG([GUESTFISH], [guestfish], [guestfish], [no])
499 AM_CONDITIONAL([HAVE_GUESTFISH], [test "x$GUESTFISH" != "xno"])
501 dnl Check for ext2fs and com_err, for the ext2 plugin.
503 AS_HELP_STRING([--without-ext2],
504 [disable ext2 plugin @<:@default=check@:>@])],
507 AS_IF([test "$with_ext2" != "no"], [
508 PKG_CHECK_MODULES([EXT2FS], [ext2fs], [
509 AC_SUBST([EXT2FS_CFLAGS])
510 AC_SUBST([EXT2FS_LIBS])
511 AC_DEFINE([HAVE_EXT2FS],[1],[ext2fs found at compile time.])
513 [AC_MSG_WARN([ext2fs not found, ext2 plugin will be disabled])])
514 PKG_CHECK_MODULES([COM_ERR], [com_err], [
515 AC_SUBST([COM_ERR_CFLAGS])
516 AC_SUBST([COM_ERR_LIBS])
517 AC_DEFINE([HAVE_COM_ERR],[1],[com_err found at compile time.])
519 [AC_MSG_WARN([com_err not found, ext2 plugin will be disabled])])
521 AM_CONDITIONAL([HAVE_EXT2],
522 [test "x$EXT2FS_LIBS" != "x" && test "x$COM_ERR_LIBS" != "x"])
524 dnl Check if the user wants to disable VDDK support.
525 dnl See plugins/vddk/README.VDDK.
526 AC_ARG_ENABLE([vddk],[
527 AS_HELP_STRING([--disable-vddk],
528 [disable VMware VDDK plugin])],
531 AM_CONDITIONAL([HAVE_VDDK], [test "x$enable_vddk" = "xyes"])
533 dnl Produce output files.
534 AC_CONFIG_HEADERS([config.h])
535 AC_CONFIG_FILES([nbdkit],
536 [chmod +x,-w nbdkit])
537 AC_CONFIG_FILES([podwrapper.pl],
538 [chmod +x,-w podwrapper.pl])
539 AC_CONFIG_FILES([Makefile
544 plugins/curl/Makefile
545 plugins/example1/Makefile
546 plugins/example2/Makefile
547 plugins/example3/Makefile
548 plugins/example4/Makefile
549 plugins/ext2/Makefile
550 plugins/file/Makefile
551 plugins/guestfs/Makefile
552 plugins/gzip/Makefile
553 plugins/libvirt/Makefile
555 plugins/memory/Makefile
557 plugins/null/Makefile
558 plugins/ocaml/Makefile
559 plugins/pattern/Makefile
560 plugins/perl/Makefile
561 plugins/python/Makefile
562 plugins/random/Makefile
563 plugins/ruby/Makefile
564 plugins/split/Makefile
565 plugins/streaming/Makefile
568 plugins/vddk/Makefile
570 plugins/zero/Makefile
572 filters/blocksize/Makefile
573 filters/cache/Makefile
575 filters/delay/Makefile
578 filters/nozero/Makefile
579 filters/offset/Makefile
580 filters/partition/Makefile