nbd: More debug details
[nbdkit/ericb.git] / configure.ac
blob33ed4d5b5271dde21c3c52e137305791648ea0c4
1 # nbdkit
2 # Copyright (C) 2013-2018 Red Hat Inc.
3 # All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
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
31 # SUCH DAMAGE.
33 AC_INIT([nbdkit], [1.9.4])
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
38 AC_SYS_LARGEFILE
40 dnl NB: Do not [quote] this parameter.
41 AM_INIT_AUTOMAKE(foreign)
42 AC_PROG_LIBTOOL
43 LT_INIT
45 AC_CANONICAL_HOST
47 AC_PROG_SED
49 dnl OpenBSD doesn't have seq.  However if you install coreutils
50 dnl you can get gseq.
51 AC_CHECK_PROGS([SEQ], [seq gseq], [no])
52 AS_IF([test "x$SEQ" = "xno" ], [
53     AC_MSG_ERROR([No ‘seq’ or ‘gseq’ program.  Install coreutils.])
56 dnl Check for basic C environment.
57 AC_PROG_CC_STDC
58 AC_PROG_INSTALL
59 AC_PROG_CPP
60 AC_CANONICAL_HOST
62 AC_C_PROTOTYPES
63 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
65 AM_PROG_CC_C_O
67 dnl Check for C++ (optional, we just use this to test the header
68 dnl can be included from C++ code).
69 AC_PROG_CXX
71 dnl The C++ compiler test is pretty useless because even if it fails
72 dnl it sets CXX=g++.  So test the compiler actually works.
73 AC_MSG_CHECKING([if the C++ compiler really really works])
74 AS_IF([$CXX --version >&AS_MESSAGE_LOG_FD 2>&1],[have_cxx=yes],[have_cxx=no])
75 AC_MSG_RESULT([$have_cxx])
76 AM_CONDITIONAL([HAVE_CXX], [test "$have_cxx" = "yes"])
78 AC_ARG_ENABLE([gcc-warnings],
79     [AS_HELP_STRING([--enable-gcc-warnings],
80                     [turn on lots of GCC warnings (for developers)])],
81      [case $enableval in
82       yes|no) ;;
83       *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
84       esac
85       gcc_warnings=$enableval],
86       [gcc_warnings=no]
88 if test "x$gcc_warnings" = "xyes"; then
89     WARNINGS_CFLAGS="-Wall -Werror"
90     AC_SUBST([WARNINGS_CFLAGS])
93 dnl on Haiku we must use BSD-compatibility headers to get the endian macros we use
94 AC_MSG_CHECKING(whether OS-dependent include paths are required)
95 AS_CASE([$host_os],
96   [haiku*], [CFLAGS="$CFLAGS -I`findpaths -p /system B_FIND_PATH_HEADERS_DIRECTORY`/bsd"; AC_MSG_RESULT(yes)],
97   [AC_MSG_RESULT(no)]
100 dnl On Linux /tmp is often tmpfs which is not large enough, so use /var/tmp.
101 dnl But Haiku only has /tmp.
102 AC_MSG_CHECKING([for temporary directory for large files])
103 AS_CASE([$host_os],
104   [haiku*], [LARGE_TMPDIR=/tmp],
105   [LARGE_TMPDIR=/var/tmp]
107 AC_MSG_RESULT([$LARGE_TMPDIR])
108 AC_DEFINE_UNQUOTED([LARGE_TMPDIR],["$LARGE_TMPDIR"],
109                    [Temporary directory for large files])
111 dnl Check if libc has program_invocation_short_name.
112 AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
114 AX_PTHREAD
116 dnl Check if __attribute__((cleanup(...))) works.
117 dnl Set -Werror, otherwise gcc will only emit a warning for attributes
118 dnl that it doesn't understand.
119 acx_nbdkit_save_CFLAGS="${CFLAGS}"
120 CFLAGS="${CFLAGS} -Werror"
121 AC_MSG_CHECKING([if __attribute__((cleanup(...))) works with this compiler])
122 AC_COMPILE_IFELSE([
123 AC_LANG_SOURCE([[
124 #include <stdio.h>
125 #include <stdlib.h>
127 void
128 freep (void *ptr)
130   exit (EXIT_SUCCESS);
133 void
134 test (void)
136   __attribute__((cleanup(freep))) char *ptr = malloc (100);
140 main (int argc, char *argv[])
142   test ();
143   exit (EXIT_FAILURE);
146     ],[
147     AC_MSG_RESULT([yes])
148     ],[
149     AC_MSG_RESULT([no])
150     AC_MSG_ERROR(
151 ['__attribute__((cleanup(...)))' does not work.
153 You may not be using a sufficiently recent version of GCC or CLANG, or
154 you may be using a C compiler which does not support this attribute,
155 or the configure test may be wrong.
157 This code requires the attribute to work for proper locking between threads.])])
158 dnl restore CFLAGS
159 CFLAGS="${acx_nbdkit_save_CFLAGS}"
161 dnl Check for other headers, all optional.
162 AC_CHECK_HEADERS([\
163         alloca.h \
164         byteswap.h \
165         endian.h \
166         selinux/selinux.h \
167         sys/endian.h \
168         sys/prctl.h \
169         sys/procctl.h])
171 dnl Check for functions in libc, all optional.
172 AC_CHECK_FUNCS([\
173         fdatasync \
174         get_current_dir_name \
175         mkostemp])
177 dnl Check whether printf("%m") works
178 AC_CACHE_CHECK([whether the printf family supports %m],
179   [nbdkit_cv_func_printf_percent_m],
180   [AC_RUN_IFELSE(
181     [AC_LANG_PROGRAM([[
182 #include <stdio.h>
183 #include <string.h>
184 #include <errno.h>
185     ]], [[
186     char buf[200] = "";
187     errno = EINVAL;
188     snprintf(buf, sizeof buf, "%m");
189     return !!strcmp (buf, strerror (EINVAL));
190     ]])],
191     [nbdkit_cv_func_printf_percent_m=yes],
192     [nbdkit_cv_func_printf_percent_m=no],
193     [[
194     case "$host_os" in
195       *-gnu* | gnu*) nbdkit_cv_func_printf_percent_m=yes;;
196       *) nbdkit_cv_func_printf_percent_m="guessing no";;
197     esac
198     ]])])
199 AS_IF([test "x$nbdkit_cv_func_printf_percent_m" = xyes],
200   [AC_DEFINE([HAVE_VFPRINTF_PERCENT_M],[1],
201     [Define to 1 if vfprintf supports %m.])])
203 old_LIBS="$LIBS"
204 AC_SEARCH_LIBS([dlopen], [dl dld], [
205         AS_IF([test "x$ac_cv_search_dlopen" != "xnone required"],
206             [DL_LIBS="$ac_cv_search_dlopen"], [DL_LIBS=])
207         AC_SUBST([DL_LIBS])
208     ], [AC_MSG_ERROR([unable to find the dlopen() function])
210 LIBS="$old_LIBS"
212 dnl Test if <iconv.h> header can build working binaries.
214 dnl On FreeBSD: iconv and libiconv both exist, both can be installed
215 dnl simultaneously, <iconv.h> can exist in two separate places, and
216 dnl if you get the wrong header/library mix everything breaks.
218 dnl On Haiku: libiconv is required to link to iconv_* functions.
219 AC_ARG_WITH([iconv],
220     [AS_HELP_STRING([--without-iconv],
221                     [don't try to link against iconv @<:@default=check@:>@])],
222     [],
223     [with_iconv=check])
224 AS_IF([test "x$with_iconv" != "xno"],[
225     AC_CHECK_HEADER([iconv.h],[
226         AC_MSG_CHECKING([if <iconv.h> can be used to link a program])
227         AC_LINK_IFELSE([
228 AC_LANG_SOURCE([[
229 #include <stdio.h>
230 #include <stdlib.h>
231 #include <iconv.h>
233 main (int argc, char *argv[])
235   iconv_t ic = iconv_open ("", "");
236   iconv_close (ic);
237   exit (0);
240             ],[
241             AC_MSG_RESULT([yes])
242             iconv_working=yes
243             ],[
244             AC_MSG_RESULT([no])
245             ])
246         ])
247     ])
248 AM_CONDITIONAL([HAVE_ICONV], [test "x$iconv_working" = "xyes"])
250 dnl Check if -rdynamic linker flag works.
251 acx_nbdkit_save_LDFLAGS="${LDFLAGS}"
252 LDFLAGS="${LDFLAGS} -rdynamic"
253 AC_MSG_CHECKING([if linker supports -rdynamic])
254 AC_LINK_IFELSE([
255 AC_LANG_SOURCE([[
256 #include <stdlib.h>
258 main (int argc, char *argv[])
260   exit (EXIT_SUCCESS);
263     ],[
264     AC_MSG_RESULT([yes])
265     DL_LDFLAGS=-rdynamic
266     ],[
267     AC_MSG_RESULT([no])
269 dnl restore CFLAGS
270 LDFLAGS="${acx_nbdkit_save_LDFLAGS}"
271 AC_SUBST([DL_LDFLAGS])
273 dnl Check for dladdr in -ldl, optional.  This is a glibc extension.
274 old_LIBS="$LIBS"
275 LIBS="$DL_LIBS $LIBS"
276 AC_CHECK_FUNCS([dladdr])
277 LIBS="$old_LIBS"
279 AC_SEARCH_LIBS([getaddrinfo], [network socket])
281 dnl Check support for setsockcreatecon_raw (part of SELinux).
282 AC_CHECK_LIB([selinux], [setsockcreatecon_raw], [], [:])
284 dnl Check for GnuTLS (optional, for TLS support).
285 PKG_CHECK_MODULES([GNUTLS], [gnutls >= 3.3.0], [
286     AC_SUBST([GNUTLS_CFLAGS])
287     AC_SUBST([GNUTLS_LIBS])
288     AC_DEFINE([HAVE_GNUTLS],[1],[gnutls found at compile time.])
289 ], [
290     AC_MSG_WARN([gnutls not found or < 3.3.0, TLS support will be disabled.])
293 AS_IF([test "$GNUTLS_LIBS" != ""],[
294     AC_MSG_CHECKING([for default TLS session priority string])
295     AC_ARG_WITH([tls-priority],
296         [AS_HELP_STRING([--with-tls-priority],
297                         [default TLS session priority string @<:@default=NORMAL@:>@])],
298         [tls_priority=$withval],
299         [tls_priority=NORMAL])
300     AC_MSG_RESULT([$tls_priority])
301     AC_DEFINE_UNQUOTED([TLS_PRIORITY],["$tls_priority"],
302                        [Default TLS session priority string])
304     # Check for APIs which may not be present.
305     old_LIBS="$LIBS"
306     LIBS="$GNUTLS_LIBS $LIBS"
307     AC_CHECK_FUNCS([\
308         gnutls_base64_decode2 \
309         gnutls_certificate_set_known_dh_params \
310         gnutls_session_set_verify_cert])
311     LIBS="$old_LIBS"
314 dnl Check for valgrind.
315 AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind],[no])
317 dnl If valgrind headers are available (optional).
318 dnl Since this is only useful for developers, you have to enable
319 dnl it explicitly using --enable-valgrind.
320 AC_ARG_ENABLE([valgrind],
321     [AS_HELP_STRING([--enable-valgrind],
322                     [enable Valgrind extensions (for developers)])],
323     [enable_valgrind=yes],
324     [enable_valgrind=no])
325 AS_IF([test "x$enable_valgrind" = "xyes"],[
326     PKG_CHECK_MODULES([VALGRIND], [valgrind], [
327         AC_SUBST([VALGRIND_CFLAGS])
328         AC_SUBST([VALGRIND_LIBS])
329         AC_DEFINE([HAVE_VALGRIND],[1],[Valgrind headers found at compile time])
330     ],[
331         AC_MSG_ERROR([--enable-valgrind given, but Valgrind headers are not available])
332     ])
335 dnl Bash completion.
336 PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0], [
337     bash_completion=yes
338     AC_MSG_CHECKING([for bash-completions directory])
339     m4_ifdef([PKG_CHECK_VAR],[
340         PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir])
341     ])
342     AS_IF([test -z "$bashcompdir"], [
343         bashcompdir="${sysconfdir}/bash_completion.d"
344     ])
345     AC_MSG_RESULT([$bashcompdir])
346     AC_SUBST([bashcompdir])
348     bash_completion=no
349     AC_MSG_WARN([bash-completion not installed])
351 AM_CONDITIONAL([HAVE_BASH_COMPLETION],[test "x$bash_completion" = "xyes"])
353 dnl Check we have enough to run podwrapper.
354 AC_CHECK_PROG([PERL],[perl],[perl],[no])
355 AS_IF([test "x$PERL" != "xno"],[
356     AC_MSG_CHECKING([if we have perl Pod::Man and Pod::Simple])
357     AS_IF([$PERL -MPod::Man -MPod::Simple -e 1 >&AS_MESSAGE_LOG_FD 2>&1],[
358         enable_pod=yes
359     ],[
360         enable_pod=no
361     ])
362     AC_MSG_RESULT([$enable_pod])
364 AM_CONDITIONAL([HAVE_POD],
365                [test "x$PERL" != "xno" && test "x$enable_pod" = "xyes"])
367 dnl Define the path to the podwrapper program.
368 PODWRAPPER="$PERL $(pwd)/podwrapper.pl"
369 AC_SUBST([PODWRAPPER])
371 dnl Allow all plugins and filters to be disabled.
372 AC_ARG_ENABLE([plugins],
373     [AS_HELP_STRING([--disable-plugins],
374                     [disable all bundled plugins and filters])])
375 AM_CONDITIONAL([HAVE_PLUGINS], [test "x$enable_plugins" != "xno"])
377 dnl Check for Perl, for embedding in the perl plugin.
378 dnl Note that the perl binary is checked above.
379 AC_ARG_ENABLE([perl],
380     [AS_HELP_STRING([--disable-perl], [disable Perl embed plugin])],
381     [],
382     [enable_perl=yes])
383 AS_IF([test "x$PERL" != "xno" && test "x$enable_perl" != "xno"],[
384     dnl Check for Perl archlib.
385     AC_MSG_CHECKING([for Perl embed archlib])
386     PERL_ARCHLIB="$($PERL -MConfig -e 'print $Config{archlib}')"
387     AS_IF([ test -n "$PERL_ARCHLIB" ],[
388         AC_MSG_RESULT([$PERL_ARCHLIB])
389     ],[
390         AC_MSG_NOTICE([Perl embed module disabled])
391         enable_perl=no
392     ])
394     dnl Check for Perl CFLAGS.
395     AC_MSG_CHECKING([for Perl embed CFLAGS])
396     PERL_CFLAGS="$($PERL -MExtUtils::Embed -e 'ccflags')"
397     AS_IF([ test -n "$PERL_CFLAGS" ],[
398         AC_MSG_RESULT([$PERL_CFLAGS])
399     ],[
400         AC_MSG_NOTICE([Perl embed module disabled])
401         enable_perl=no
402     ])
404     dnl Check for Perl LDOPTS.
405     AC_MSG_CHECKING([for Perl embed LDOPTS])
406     PERL_LDOPTS="$($PERL -MExtUtils::Embed -e 'ldopts')"
407     AC_MSG_RESULT([$PERL_LDOPTS])
409     dnl XXX Could check these actually work.
411 AM_CONDITIONAL([HAVE_PERL],[test "x$enable_perl" != "xno" && test "x$PERL" != "xno"])
412 AC_SUBST([PERL_ARCHLIB])
413 AC_SUBST([PERL_CFLAGS])
414 AC_SUBST([PERL_LDOPTS])
416 dnl Check for Python, for embedding in the python plugin.
417 AC_CHECK_PROG([PYTHON],[python],[python],[no])
418 AC_ARG_ENABLE([python],
419     [AS_HELP_STRING([--disable-python], [disable Python embed plugin])],
420     [],
421     [enable_python=yes])
422 AS_IF([test "x$PYTHON" != "xno" && test "x$enable_python" != "xno"],[
423     AC_MSG_CHECKING([version of $PYTHON])
424     PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info@<:@0@:>@)"`
425     PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info@<:@1@:>@)"`
426     PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
427     AS_IF([test -n "$PYTHON_VERSION"],[
428         AC_MSG_RESULT([$PYTHON_VERSION])
429     ],[
430         AC_MSG_NOTICE([Python embed module disabled])
431         enable_python=no
432     ])
434     dnl Check for Python CFLAGS, libraries.
435     dnl On Debian: python-X.Y.pc
436     PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"], [
437         AC_SUBST([PYTHON_CFLAGS])
438         AC_SUBST([PYTHON_LIBS])
439         AC_SUBST([PYTHON_VERSION])
440         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
441     ],[
442         dnl On Fedora: python.pc
443         PKG_CHECK_MODULES([PYTHON], [python], [
444             AC_SUBST([PYTHON_CFLAGS])
445             AC_SUBST([PYTHON_LIBS])
446             AC_SUBST([PYTHON_VERSION])
447             AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
448         ],[
449             AC_MSG_WARN([python $PYTHON_VERSION not found])
450             enable_python=no
451         ])
452     ])
454     dnl Check for various functions needed by the bindings.
455     old_LIBS="$LIBS"
457     PYTHON_BLDLIBRARY=`$PYTHON -c "import distutils.sysconfig; \
458         print (distutils.sysconfig.get_config_var('BLDLIBRARY'))"`
459     AC_CHECK_LIB([c],[PyString_FromString],
460                  [AC_DEFINE([HAVE_PYSTRING_FROMSTRING],1,
461                             [Found PyString_FromString in libpython.])],
462                  [],[$PYTHON_BLDLIBRARY])
463     AC_CHECK_LIB([c],[PyString_AsString],
464                  [AC_DEFINE([HAVE_PYSTRING_ASSTRING],1,
465                             [Found PyString_AsString in libpython.])],
466                  [],[$PYTHON_BLDLIBRARY])
467     AC_CHECK_LIB([c],[PyUnicode_AsUTF8],
468                  [AC_DEFINE([HAVE_PYUNICODE_ASUTF8],1,
469                             [Found PyUnicode_AsUTF8 in libpython.])],
470                  [],[$PYTHON_BLDLIBRARY])
472     LIBS="$old_LIBS"
475 AM_CONDITIONAL([HAVE_PYTHON],[test "x$enable_python" != "xno" && test "x$PYTHON" != "xno"])
476 AC_SUBST([PYTHON_CFLAGS])
477 AC_SUBST([PYTHON_LIBS])
478 AC_SUBST([PYTHON_LDFLAGS])
480 dnl For the OCaml plugin, you can set OCAMLOPTFLAGS before running
481 dnl ./configure to specify any extra flags you want to pass to
482 dnl ocamlopt.
483 AC_SUBST([OCAMLOPTFLAGS])
485 dnl Check for OCaml, for embedding in the ocaml plugin.
486 AC_PROG_OCAML
487 AC_ARG_ENABLE([ocaml],
488     [AS_HELP_STRING([--disable-ocaml], [disable OCaml embed plugin])],
489     [],
490     [enable_ocaml=yes])
491 AS_IF([test "x$OCAMLOPT" != "xno" && test "x$enable_ocaml" != "xno"],[
492     dnl Check OCaml can create a shared library (see README for details).
493     AC_MSG_CHECKING([if $OCAMLOPT can create a shared library])
494     echo 'print_endline "test"' > conftest.ml
495     AS_IF([$OCAMLOPT $OCAMLOPTFLAGS -output-obj -runtime-variant _pic -o conftest.so conftest.ml >&AS_MESSAGE_LOG_FD 2>&1],[
496         AC_MSG_RESULT([yes])
497         ocaml_link_shared=yes
498     ],[
499         AC_MSG_RESULT([no])
500     ])
501     rm -f conftest.ml conftest.cmi conftest.cmx conftest.so conftest.o
503 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLOPT" != "xno" &&
504                              test "x$ocaml_link_shared" = "xyes"])
506 dnl Check for Ruby, for embedding in the Ruby plugin.
507 AC_CHECK_PROG([RUBY],[ruby],[ruby],[no])
508 AC_ARG_ENABLE([ruby],
509     [AS_HELP_STRING([--disable-ruby], [disable Ruby plugin])],
510     [],
511     [enable_ruby=yes])
512 AS_IF([test "x$RUBY" != "xno" && test "x$enable_ruby" != "xno"],[
513     PKG_CHECK_MODULES([RUBY], [ruby], [
514         AC_SUBST([RUBY_CFLAGS])
515         AC_SUBST([RUBY_LIBS])
516     ],[
517         AC_MSG_WARN([ruby not found])
518         enable_ruby=no
519     ])
521 AM_CONDITIONAL([HAVE_RUBY],[test "x$RUBY" != "xno" &&
522                             test "x$enable_ruby" = "xyes"])
524 dnl Check for Tcl, for embedding in the Tcl plugin.
525 AC_ARG_ENABLE([tcl],
526     [AS_HELP_STRING([--disable-tcl], [disable Tcl plugin])],
527     [],
528     [enable_tcl=yes])
529 AS_IF([test "x$enable_tcl" != "xno"],[
530     PKG_CHECK_MODULES([TCL], [tcl], [
531         AC_SUBST([TCL_CFLAGS])
532         AC_SUBST([TCL_LIBS])
533     ],[
534         AC_MSG_WARN([Tcl not found])
535         enable_tcl=no
536     ])
538 AM_CONDITIONAL([HAVE_TCL],[test "x$enable_tcl" = "xyes"])
540 dnl Check for Lua, for embedding in the Lua plugin.
541 AC_ARG_ENABLE([lua],
542     [AS_HELP_STRING([--disable-lua], [disable Lua plugin])],
543     [],
544     [enable_lua=yes])
545 AS_IF([test "x$enable_lua" != "xno"],[
546     PKG_CHECK_MODULES([LUA], [lua], [
547         AC_SUBST([LUA_CFLAGS])
548         AC_SUBST([LUA_LIBS])
550         dnl Lua 5.1 used by RHEL 7 does not have lua_isinteger.
551         old_LIBS="$LIBS"
552         LIBS="$LUA_LIBS $LIBS"
553         AC_CHECK_FUNCS([lua_isinteger])
554         LIBS="$old_LIBS"
555     ],[
556         AC_MSG_WARN([Lua not found])
557         enable_lua=no
558     ])
560 AM_CONDITIONAL([HAVE_LUA],[test "x$enable_lua" = "xyes"])
562 dnl Check for curl (only if you want to compile the curl plugin).
563 AC_ARG_WITH([curl],
564     [AS_HELP_STRING([--without-curl],
565                     [disable curl plugin @<:@default=check@:>@])],
566     [],
567     [with_curl=check])
568 AS_IF([test "$with_curl" != "no"],[
569     PKG_CHECK_MODULES([CURL], [libcurl],[
570         AC_SUBST([CURL_CFLAGS])
571         AC_SUBST([CURL_LIBS])
572         AC_DEFINE([HAVE_CURL],[1],[curl found at compile time.])
573         AC_CHECK_DECL([CURLOPT_UNIX_SOCKET_PATH], [
574             AC_DEFINE([HAVE_CURLOPT_UNIX_SOCKET_PATH],[1],
575                       [CURLOPT_UNIX_SOCKET_PATH found at compile time.])
576             ], [], [#include <curl/curl.h>])
577     ],
578     [AC_MSG_WARN([curl not found, curl plugin will be disabled])])
580 AM_CONDITIONAL([HAVE_CURL],[test "x$CURL_LIBS" != "x"])
582 dnl Check for genisoimage or mkisofs
583 dnl (only if you want to compile the iso plugin).
584 ISOPROG="no"
585 AC_ARG_WITH([iso],
586     [AS_HELP_STRING([--without-iso],
587                     [disable iso plugin @<:@default=check@:>@])],
588     [],
589     [with_iso=check])
590 AS_IF([test "$with_iso" != "no"],[
591     AC_CHECK_PROG([GENISOIMAGE],[genisoimage],[genisoimage],[no])
592     AC_CHECK_PROG([MKISOFS],[mkisofs],[mkisofs],[no])
593     AS_IF([test "x$GENISOIMAGE" != "xno"],[
594         ISOPROG="$GENISOIMAGE"
595     ],[
596         AS_IF([test "x$MKISOFS" != "xno"],[
597             ISOPROG="$MKISOFS"
598         ])
599     ])
600     AS_IF([test "x$ISOPROG" != "xno"],[
601         AC_DEFINE_UNQUOTED([ISOPROG],["$ISOPROG"],
602                            [Program used by iso plugin to make ISOs.])
603     ])
605 AC_SUBST([ISOPROG])
606 AM_CONDITIONAL([HAVE_ISO],[test "x$ISOPROG" != "xno"])
608 dnl Check for libvirt (only if you want to compile the libvirt plugin).
609 AC_ARG_WITH([libvirt],
610     [AS_HELP_STRING([--without-libvirt],
611                     [disable libvirt plugin @<:@default=check@:>@])],
612     [],
613     [with_libvirt=check])
614 AS_IF([test "$with_libvirt" != "no"],[
615     PKG_CHECK_MODULES([LIBVIRT], [libvirt],[
616         AC_SUBST([LIBVIRT_CFLAGS])
617         AC_SUBST([LIBVIRT_LIBS])
618         AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.])
619     ],
620     [AC_MSG_WARN([libvirt not found, libvirt plugin will be disabled])])
622 AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
624 dnl Check for zlib (only if you want to compile the gzip plugin).
625 AC_ARG_WITH([zlib],
626     [AS_HELP_STRING([--without-zlib],
627                     [disable gzip plugin @<:@default=check@:>@])],
628     [],
629     [with_zlib=check])
630 AS_IF([test "$with_zlib" != "no"],[
631     PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.3.5],[
632         AC_SUBST([ZLIB_CFLAGS])
633         AC_SUBST([ZLIB_LIBS])
634         AC_DEFINE([HAVE_ZLIB],[1],[zlib found at compile time.])
635     ],
636     [AC_MSG_WARN([zlib >= 1.2.3.5 not found, gzip plugin will be disabled])])
638 AM_CONDITIONAL([HAVE_ZLIB],[test "x$ZLIB_LIBS" != "x"])
640 dnl Check for liblzma (only if you want to compile the xz filter).
641 AC_ARG_WITH([liblzma],
642     [AS_HELP_STRING([--without-liblzma],
643                     [disable xz filter @<:@default=check@:>@])],
644     [],
645     [with_liblzma=check])
646 AS_IF([test "$with_liblzma" != "no"],[
647     PKG_CHECK_MODULES([LIBLZMA], [liblzma],[
648         AC_SUBST([LIBLZMA_CFLAGS])
649         AC_SUBST([LIBLZMA_LIBS])
650         AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma found at compile time.])
651     ],
652     [AC_MSG_WARN([liblzma not found, xz filter will be disabled])])
654 AM_CONDITIONAL([HAVE_LIBLZMA],[test "x$LIBLZMA_LIBS" != "x"])
656 dnl Check for libguestfs (only for the guestfs plugin and the test suite).
657 AC_ARG_WITH([libguestfs],
658     [AS_HELP_STRING([--without-libguestfs],
659                     [disable guestfs plugin and tests @<:@default=check@:>@])],
660     [],
661     [with_libguestfs=check])
662 AS_IF([test "$with_libguestfs" != "no"],[
663     PKG_CHECK_MODULES([LIBGUESTFS], [libguestfs],[
664         # Although the library was found, we want to make sure it supports nbd
665         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
666 #include <guestfs.h>
667         ]], [[
668 #ifndef GUESTFS_ADD_DRIVE_OPTS_PROTOCOL
669 #error unsupported
670 #endif
671         ]])], [
672         AC_SUBST([LIBGUESTFS_CFLAGS])
673         AC_SUBST([LIBGUESTFS_LIBS])
674         AC_DEFINE([HAVE_LIBGUESTFS],[1],[libguestfs found at compile time.])
675         ],[
676         LIBGUESTFS_LIBS=
677         AC_MSG_WARN([libguestfs too old, guestfs plugin and tests will be disabled])])
678     ],
679     [AC_MSG_WARN([libguestfs not found, guestfs plugin and tests will be disabled])])
681 AM_CONDITIONAL([HAVE_LIBGUESTFS],[test "x$LIBGUESTFS_LIBS" != "x"])
683 dnl Check for guestfish (only needed for some of the tests).
684 AC_CHECK_PROG([GUESTFISH], [guestfish], [guestfish], [no])
685 AM_CONDITIONAL([HAVE_GUESTFISH], [test "x$GUESTFISH" != "xno"])
687 dnl Check for ext2fs and com_err, for the ext2 plugin.
688 AC_ARG_WITH([ext2],
689     [AS_HELP_STRING([--without-ext2],
690                     [disable ext2 plugin @<:@default=check@:>@])],
691     [],
692     [with_ext2=check])
693 AS_IF([test "$with_ext2" != "no"], [
694     PKG_CHECK_MODULES([EXT2FS], [ext2fs], [
695         AC_SUBST([EXT2FS_CFLAGS])
696         AC_SUBST([EXT2FS_LIBS])
697         AC_DEFINE([HAVE_EXT2FS],[1],[ext2fs found at compile time.])
698     ],
699     [AC_MSG_WARN([ext2fs not found, ext2 plugin will be disabled])])
700     PKG_CHECK_MODULES([COM_ERR], [com_err], [
701         AC_SUBST([COM_ERR_CFLAGS])
702         AC_SUBST([COM_ERR_LIBS])
703         AC_DEFINE([HAVE_COM_ERR],[1],[com_err found at compile time.])
704     ],
705     [AC_MSG_WARN([com_err not found, ext2 plugin will be disabled])])
707 AM_CONDITIONAL([HAVE_EXT2],
708                [test "x$EXT2FS_LIBS" != "x" && test "x$COM_ERR_LIBS" != "x"])
710 dnl Check if the user wants to disable VDDK support.
711 dnl See plugins/vddk/README.VDDK.
712 AC_ARG_ENABLE([vddk],
713     [AS_HELP_STRING([--disable-vddk],
714                     [disable VMware VDDK plugin])],
715     [],
716     [enable_vddk=yes])
717 AM_CONDITIONAL([HAVE_VDDK], [test "x$enable_vddk" = "xyes"])
719 dnl List of plugins and filters.
720 lang_plugins="\
721         lua \
722         ocaml \
723         perl \
724         python \
725         ruby \
726         sh \
727         tcl \
728         "
729 non_lang_plugins="\
730         curl \
731         data \
732         example1 \
733         example2 \
734         example3 \
735         example4 \
736         ext2 \
737         file \
738         floppy \
739         guestfs \
740         gzip \
741         iso \
742         libvirt \
743         memory \
744         nbd \
745         null \
746         partitioning \
747         pattern \
748         random \
749         split \
750         streaming \
751         tar \
752         vddk \
753         xz \
754         zero \
755         "
756 plugins="$(echo $(printf %s\\n $lang_plugins $non_lang_plugins | sort -u))"
757 filters="\
758         blocksize \
759         cache \
760         cow \
761         delay \
762         error \
763         fua \
764         log \
765         nozero \
766         offset \
767         partition \
768         truncate \
769         xz \
770         "
771 AC_SUBST([plugins])
772 AC_SUBST([lang_plugins])
773 AC_SUBST([non_lang_plugins])
774 AC_SUBST([filters])
776 dnl Produce output files.
777 AC_CONFIG_HEADERS([config.h])
778 AC_CONFIG_FILES([podwrapper.pl],
779                 [chmod +x,-w podwrapper.pl])
780 AC_CONFIG_FILES([Makefile
781                  bash/Makefile
782                  common/bitmap/Makefile
783                  common/include/Makefile
784                  common/regions/Makefile
785                  common/sparse/Makefile
786                  docs/Makefile
787                  include/Makefile
788                  plugins/Makefile
789                  plugins/curl/Makefile
790                  plugins/data/Makefile
791                  plugins/example1/Makefile
792                  plugins/example2/Makefile
793                  plugins/example3/Makefile
794                  plugins/example4/Makefile
795                  plugins/ext2/Makefile
796                  plugins/file/Makefile
797                  plugins/floppy/Makefile
798                  plugins/guestfs/Makefile
799                  plugins/gzip/Makefile
800                  plugins/iso/Makefile
801                  plugins/libvirt/Makefile
802                  plugins/lua/Makefile
803                  plugins/memory/Makefile
804                  plugins/nbd/Makefile
805                  plugins/null/Makefile
806                  plugins/ocaml/Makefile
807                  plugins/partitioning/Makefile
808                  plugins/pattern/Makefile
809                  plugins/perl/Makefile
810                  plugins/python/Makefile
811                  plugins/random/Makefile
812                  plugins/ruby/Makefile
813                  plugins/sh/Makefile
814                  plugins/split/Makefile
815                  plugins/streaming/Makefile
816                  plugins/tar/Makefile
817                  plugins/tcl/Makefile
818                  plugins/vddk/Makefile
819                  plugins/xz/Makefile
820                  plugins/zero/Makefile
821                  filters/Makefile
822                  filters/blocksize/Makefile
823                  filters/cache/Makefile
824                  filters/cow/Makefile
825                  filters/delay/Makefile
826                  filters/error/Makefile
827                  filters/fua/Makefile
828                  filters/log/Makefile
829                  filters/nozero/Makefile
830                  filters/offset/Makefile
831                  filters/partition/Makefile
832                  filters/truncate/Makefile
833                  filters/xz/Makefile
834                  src/Makefile
835                  src/nbdkit.pc
836                  tests/functions.sh
837                  tests/Makefile
838                  valgrind/Makefile])
840 AC_OUTPUT