2 # Copyright (C) 2013 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.1.2])
34 AC_CONFIG_MACRO_DIR([m4])
35 AC_USE_SYSTEM_EXTENSIONS
38 AM_INIT_AUTOMAKE(foreign) dnl NB: Do not [quote] this parameter.
41 dnl Check for basic C environment.
47 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
51 AC_ARG_ENABLE([gcc-warnings],
52 [AS_HELP_STRING([--enable-gcc-warnings],
53 [turn on lots of GCC warnings (for developers)])],
56 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
58 gcc_warnings=$enableval],
61 if test "x$gcc_warnings" = "xyes"; then
62 WARNINGS_CFLAGS="-Wall -Werror"
63 AC_SUBST([WARNINGS_CFLAGS])
66 dnl Check if libc has program_invocation_short_name.
67 AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
69 dnl Check if __attribute__((cleanup(...))) works.
70 dnl XXX It would be nice to use AC_COMPILE_IFELSE here, but gcc just
71 dnl emits a warning for attributes that it doesn't understand.
72 AC_MSG_CHECKING([if __attribute__((cleanup(...))) works with this compiler])
87 __attribute__((cleanup(freep))) char *ptr = malloc (100);
91 main (int argc, char *argv[])
99 AC_DEFINE([HAVE_ATTRIBUTE_CLEANUP],[1],[Define to 1 if '__attribute__((cleanup(...)))' works with this compiler.])
102 ['__attribute__((cleanup(...)))' does not work.
104 You may not be using a sufficiently recent version of GCC or CLANG, or
105 you may be using a C compiler which does not support this attribute,
106 or the configure test may be wrong.
108 The code will still compile, but is likely to leak memory and other
109 resources when it runs.])])
111 dnl Check for Perl POD.
112 AC_CHECK_PROG([POD2MAN], [pod2man], [pod2man], [no])
113 AM_CONDITIONAL([HAVE_POD2MAN], [test "x$POD2MAN" != "xno"])
115 dnl Check for libvirt (only if you want to compile the libvirt plugin).
116 AC_ARG_WITH([libvirt],[
117 AS_HELP_STRING([--without-libvirt],
118 [disable libvirt plugin @<:@default=check@:>@])],
120 [with_libvirt=check])
121 AS_IF([test "$with_libvirt" != "no"],[
122 PKG_CHECK_MODULES([LIBVIRT], [libvirt],[
123 AC_SUBST([LIBVIRT_CFLAGS])
124 AC_SUBST([LIBVIRT_LIBS])
125 AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.])
127 [AC_MSG_WARN([libvirt not found, libvirt plugin will be disabled])])
129 AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
131 dnl Check for zlib (only if you want to compile the gzip plugin).
133 AS_HELP_STRING([--without-zlib],
134 [disable gzip plugin @<:@default=check@:>@])],
137 AS_IF([test "$with_zlib" != "no"],[
138 PKG_CHECK_MODULES([ZLIB], [zlib],[
139 AC_SUBST([ZLIB_CFLAGS])
140 AC_SUBST([ZLIB_LIBS])
141 AC_DEFINE([HAVE_ZLIB],[1],[zlib found at compile time.])
143 [AC_MSG_WARN([zlib not found, gzip plugin will be disabled])])
145 AM_CONDITIONAL([HAVE_ZLIB],[test "x$ZLIB_LIBS" != "x"])
147 dnl Check for liblzma (only if you want to compile the xz plugin).
148 AC_ARG_WITH([liblzma],[
149 AS_HELP_STRING([--without-liblzma],
150 [disable xz plugin @<:@default=check@:>@])],
152 [with_liblzma=check])
153 AS_IF([test "$with_liblzma" != "no"],[
154 PKG_CHECK_MODULES([LIBLZMA], [liblzma],[
155 AC_SUBST([LIBLZMA_CFLAGS])
156 AC_SUBST([LIBLZMA_LIBS])
157 AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma found at compile time.])
159 [AC_MSG_WARN([liblzma not found, xz plugin will be disabled])])
161 AM_CONDITIONAL([HAVE_LIBLZMA],[test "x$LIBLZMA_LIBS" != "x"])
163 dnl Check for libguestfs (only for the guestfs plugin and the test suite).
164 AC_ARG_WITH([libguestfs],[
165 AS_HELP_STRING([--without-libguestfs],
166 [disable guestfs plugin and tests @<:@default=check@:>@])],
168 [with_libguestfs=check])
169 AS_IF([test "$with_libguestfs" != "no"],[
170 PKG_CHECK_MODULES([LIBGUESTFS], [libguestfs],[
171 AC_SUBST([LIBGUESTFS_CFLAGS])
172 AC_SUBST([LIBGUESTFS_LIBS])
173 AC_DEFINE([HAVE_LIBGUESTFS],[1],[libguestfs found at compile time.])
175 [AC_MSG_WARN([libguestfs not found, guestfs plugin and tests will be disabled])])
177 AM_CONDITIONAL([HAVE_LIBGUESTFS],[test "x$LIBGUESTFS_LIBS" != "x"])
179 dnl Check for guestfish (only needed for some of the tests).
180 AC_CHECK_PROG([GUESTFISH], [guestfish], [guestfish], [no])
181 AM_CONDITIONAL([HAVE_GUESTFISH], [test "x$GUESTFISH" != "xno"])
183 dnl See plugins/vddk/README.VDDK.
184 AC_CHECK_SIZEOF([size_t])
185 AS_IF([test "x$ac_cv_sizeof_size_t" = "x4"],[bits=32],[bits=64])
187 AS_HELP_STRING([--with-vddk],
188 [enable VMware VDDK plugin @<:@default=no@:>@])],
191 AS_IF([test "$with_vddk" = "yes"],[
193 VDDK_LIBS="-lvixDiskLib"
194 # XXX Warning: stupid VMware API.
195 VDDK_LIBDIR="$libdir/vmware-vix-disklib"
197 AS_IF([test "$with_vddk" != "no"], [
198 VDDK_CFLAGS="-I$with_vddk/include"
199 VDDK_LIBS="-L$with_vddk/lib$bits -lvixDiskLib"
200 VDDK_LIBDIR="$with_vddk"
202 [AC_MSG_NOTICE([VDDK plugin disabled])
205 AC_SUBST([VDDK_CFLAGS])
206 AC_SUBST([VDDK_LIBS])
207 AC_DEFINE_UNQUOTED([VDDK_LIBDIR],["$VDDK_LIBDIR"],[VDDK 'libDir'.])
208 AM_CONDITIONAL([HAVE_VDDK],[test "x$VDDK_LIBS" != "x"])
210 dnl Produce output files.
211 AC_CONFIG_HEADERS([config.h])
212 AC_CONFIG_FILES([Makefile
216 plugins/example1/Makefile
217 plugins/example2/Makefile
218 plugins/example3/Makefile
219 plugins/file/Makefile
220 plugins/guestfs/Makefile
221 plugins/gzip/Makefile
222 plugins/libvirt/Makefile
223 plugins/vddk/Makefile