Version 1.1.5.
[nbdkit/ericb.git] / configure.ac
blob373fc5acb128f0a1e1a5253126a5a709a0d95c35
1 # nbdkit
2 # Copyright (C) 2013-2014 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.1.5])
34 AC_CONFIG_MACRO_DIR([m4])
35 AC_USE_SYSTEM_EXTENSIONS
36 AC_SYS_LARGEFILE
38 dnl NB: Do not [quote] this parameter.
39 AM_INIT_AUTOMAKE(foreign)
40 LT_INIT
42 dnl Check for basic C environment.
43 AC_PROG_CC_STDC
44 AC_PROG_INSTALL
45 AC_PROG_CPP
47 AC_C_PROTOTYPES
48 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
50 AM_PROG_CC_C_O
52 AC_ARG_ENABLE([gcc-warnings],
53     [AS_HELP_STRING([--enable-gcc-warnings],
54                     [turn on lots of GCC warnings (for developers)])],
55      [case $enableval in
56       yes|no) ;;
57       *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
58       esac
59       gcc_warnings=$enableval],
60       [gcc_warnings=no]
62 if test "x$gcc_warnings" = "xyes"; then
63     WARNINGS_CFLAGS="-Wall -Werror"
64     AC_SUBST([WARNINGS_CFLAGS])
67 dnl Check if libc has program_invocation_short_name.
68 AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
70 dnl Check if __attribute__((cleanup(...))) works.
71 dnl XXX It would be nice to use AC_COMPILE_IFELSE here, but gcc just
72 dnl emits a warning for attributes that it doesn't understand.
73 AC_MSG_CHECKING([if __attribute__((cleanup(...))) works with this compiler])
74 AC_RUN_IFELSE([
75 AC_LANG_SOURCE([[
76 #include <stdio.h>
77 #include <stdlib.h>
79 void
80 freep (void *ptr)
82   exit (EXIT_SUCCESS);
85 void
86 test (void)
88   __attribute__((cleanup(freep))) char *ptr = malloc (100);
91 int
92 main (int argc, char *argv[])
94   test ();
95   exit (EXIT_FAILURE);
97 ]])
98     ],[
99     AC_MSG_RESULT([yes])
100     AC_DEFINE([HAVE_ATTRIBUTE_CLEANUP],[1],[Define to 1 if '__attribute__((cleanup(...)))' works with this compiler.])
101     ],[
102     AC_MSG_WARN(
103 ['__attribute__((cleanup(...)))' does not work.
105 You may not be using a sufficiently recent version of GCC or CLANG, or
106 you may be using a C compiler which does not support this attribute,
107 or the configure test may be wrong.
109 The code will still compile, but is likely to leak memory and other
110 resources when it runs.])])
112 dnl Check for Perl POD.
113 AC_CHECK_PROG([POD2MAN], [pod2man], [pod2man], [no])
114 AM_CONDITIONAL([HAVE_POD2MAN], [test "x$POD2MAN" != "xno"])
116 dnl Check for Perl, for embedding in the perl plugin.
117 AC_CHECK_PROG([PERL],[perl],[perl],[no])
118 AC_ARG_ENABLE([perl],
119     AS_HELP_STRING([--disable-perl], [disable Perl embed plugin]),
120     [],
121     [enable_perl=yes])
122 AS_IF([test "x$PERL" != "xno" && test "x$enable_perl" != "xno"],[
123     dnl Check for Perl archlib.
124     AC_MSG_CHECKING([for Perl embed archlib])
125     PERL_ARCHLIB="$($PERL -MConfig -e 'print $Config{archlib}')"
126     AS_IF([ test -n "$PERL_ARCHLIB" ],[
127         AC_MSG_RESULT([$PERL_ARCHLIB])
128     ],[
129         AC_MSG_NOTICE([Perl embed module disabled])
130         enable_perl=no
131     ])
133     dnl Check for Perl CFLAGS.
134     AC_MSG_CHECKING([for Perl embed CFLAGS])
135     PERL_CFLAGS="$($PERL -MExtUtils::Embed -e 'ccflags')"
136     AS_IF([ test -n "$PERL_CFLAGS" ],[
137         AC_MSG_RESULT([$PERL_CFLAGS])
138     ],[
139         AC_MSG_NOTICE([Perl embed module disabled])
140         enable_perl=no
141     ])
143     dnl Check for Perl LDOPTS.
144     AC_MSG_CHECKING([for Perl embed LDOPTS])
145     PERL_LDOPTS="$($PERL -MExtUtils::Embed -e 'ldopts')"
147     dnl XXX Could check these actually work.
149 AM_CONDITIONAL([HAVE_PERL],[test "x$enable_perl" != "xno" && test "x$PERL" != "xno"])
150 AC_SUBST([PERL_ARCHLIB])
151 AC_SUBST([PERL_CFLAGS])
152 AC_SUBST([PERL_LDOPTS])
154 dnl Check for Python, for embedding in the python plugin.
155 AC_CHECK_PROG([PYTHON],[python],[python],[no])
156 AC_ARG_ENABLE([python],
157     AS_HELP_STRING([--disable-python], [disable Python embed plugin]),
158     [],
159     [enable_python=yes])
160 AS_IF([test "x$PYTHON" != "xno" && test "x$enable_python" != "xno"],[
161     AC_MSG_CHECKING([version of $PYTHON])
162     PYTHON_VERSION_MAJOR=`$PYTHON -c "import sys; print (sys.version_info@<:@0@:>@)"`
163     PYTHON_VERSION_MINOR=`$PYTHON -c "import sys; print (sys.version_info@<:@1@:>@)"`
164     PYTHON_VERSION="$PYTHON_VERSION_MAJOR.$PYTHON_VERSION_MINOR"
165     AS_IF([test -n "$PYTHON_VERSION"],[
166         AC_MSG_RESULT([$PYTHON_VERSION])
167     ],[
168         AC_MSG_NOTICE([Python embed module disabled])
169         enable_python=no
170     ])
172     dnl Check for Python CFLAGS, libraries.
173     dnl On Debian: python-X.Y.pc
174     PKG_CHECK_MODULES([PYTHON], [python-"$PYTHON_VERSION"], [
175         AC_SUBST([PYTHON_CFLAGS])
176         AC_SUBST([PYTHON_LIBS])
177         AC_SUBST([PYTHON_VERSION])
178         AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
179     ],[
180         dnl On Fedora: python.pc
181         PKG_CHECK_MODULES([PYTHON], [python], [
182             AC_SUBST([PYTHON_CFLAGS])
183             AC_SUBST([PYTHON_LIBS])
184             AC_SUBST([PYTHON_VERSION])
185             AC_DEFINE([HAVE_PYTHON],[1],[Python library found at compile time])
186         ],[
187             AC_MSG_WARN([python $PYTHON_VERSION not found])
188             enable_python=no
189         ])
190     ])
192     dnl XXX Could check these actually work.
194 AM_CONDITIONAL([HAVE_PYTHON],[test "x$enable_python" != "xno" && test "x$PYTHON" != "xno"])
195 AC_SUBST([PYTHON_CFLAGS])
196 AC_SUBST([PYTHON_LIBS])
197 AC_SUBST([PYTHON_LDFLAGS])
199 dnl Check for libvirt (only if you want to compile the libvirt plugin).
200 AC_ARG_WITH([libvirt],[
201     AS_HELP_STRING([--without-libvirt],
202                    [disable libvirt plugin @<:@default=check@:>@])],
203     [],
204     [with_libvirt=check])
205 AS_IF([test "$with_libvirt" != "no"],[
206     PKG_CHECK_MODULES([LIBVIRT], [libvirt],[
207         AC_SUBST([LIBVIRT_CFLAGS])
208         AC_SUBST([LIBVIRT_LIBS])
209         AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.])
210     ],
211     [AC_MSG_WARN([libvirt not found, libvirt plugin will be disabled])])
213 AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
215 dnl Check for zlib (only if you want to compile the gzip plugin).
216 AC_ARG_WITH([zlib],[
217     AS_HELP_STRING([--without-zlib],
218                    [disable gzip plugin @<:@default=check@:>@])],
219     [],
220     [with_zlib=check])
221 AS_IF([test "$with_zlib" != "no"],[
222     PKG_CHECK_MODULES([ZLIB], [zlib],[
223         AC_SUBST([ZLIB_CFLAGS])
224         AC_SUBST([ZLIB_LIBS])
225         AC_DEFINE([HAVE_ZLIB],[1],[zlib found at compile time.])
226     ],
227     [AC_MSG_WARN([zlib not found, gzip plugin will be disabled])])
229 AM_CONDITIONAL([HAVE_ZLIB],[test "x$ZLIB_LIBS" != "x"])
231 dnl Check for liblzma (only if you want to compile the xz plugin).
232 AC_ARG_WITH([liblzma],[
233     AS_HELP_STRING([--without-liblzma],
234                    [disable xz plugin @<:@default=check@:>@])],
235     [],
236     [with_liblzma=check])
237 AS_IF([test "$with_liblzma" != "no"],[
238     PKG_CHECK_MODULES([LIBLZMA], [liblzma],[
239         AC_SUBST([LIBLZMA_CFLAGS])
240         AC_SUBST([LIBLZMA_LIBS])
241         AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma found at compile time.])
242     ],
243     [AC_MSG_WARN([liblzma not found, xz plugin will be disabled])])
245 AM_CONDITIONAL([HAVE_LIBLZMA],[test "x$LIBLZMA_LIBS" != "x"])
247 dnl Check for libguestfs (only for the guestfs plugin and the test suite).
248 AC_ARG_WITH([libguestfs],[
249     AS_HELP_STRING([--without-libguestfs],
250                    [disable guestfs plugin and tests @<:@default=check@:>@])],
251     [],
252     [with_libguestfs=check])
253 AS_IF([test "$with_libguestfs" != "no"],[
254     PKG_CHECK_MODULES([LIBGUESTFS], [libguestfs],[
255         AC_SUBST([LIBGUESTFS_CFLAGS])
256         AC_SUBST([LIBGUESTFS_LIBS])
257         AC_DEFINE([HAVE_LIBGUESTFS],[1],[libguestfs found at compile time.])
258     ],
259     [AC_MSG_WARN([libguestfs not found, guestfs plugin and tests will be disabled])])
261 AM_CONDITIONAL([HAVE_LIBGUESTFS],[test "x$LIBGUESTFS_LIBS" != "x"])
263 dnl Check for guestfish (only needed for some of the tests).
264 AC_CHECK_PROG([GUESTFISH], [guestfish], [guestfish], [no])
265 AM_CONDITIONAL([HAVE_GUESTFISH], [test "x$GUESTFISH" != "xno"])
267 dnl See plugins/vddk/README.VDDK.
268 AC_CHECK_SIZEOF([size_t])
269 AS_IF([test "x$ac_cv_sizeof_size_t" = "x4"],[bits=32],[bits=64])
270 AC_ARG_WITH([vddk],[
271     AS_HELP_STRING([--with-vddk],
272                    [enable VMware VDDK plugin @<:@default=no@:>@])],
273     [],
274     [with_vddk=no])
275 AS_IF([test "$with_vddk" = "yes"],[
276     VDDK_CFLAGS=
277     VDDK_LIBS="-lvixDiskLib"
278     # XXX Warning: stupid VMware API.
279     VDDK_LIBDIR="$libdir/vmware-vix-disklib"
280     ],[
281     AS_IF([test "$with_vddk" != "no"], [
282         VDDK_CFLAGS="-I$with_vddk/include"
283         VDDK_LIBS="-L$with_vddk/lib$bits -lvixDiskLib"
284         VDDK_LIBDIR="$with_vddk"
285         ],
286         [AC_MSG_NOTICE([VDDK plugin disabled])
287     ])
289 AC_SUBST([VDDK_CFLAGS])
290 AC_SUBST([VDDK_LIBS])
291 AC_DEFINE_UNQUOTED([VDDK_LIBDIR],["$VDDK_LIBDIR"],[VDDK 'libDir'.])
292 AM_CONDITIONAL([HAVE_VDDK],[test "x$VDDK_LIBS" != "x"])
294 dnl Produce output files.
295 AC_CONFIG_HEADERS([config.h])
296 AC_CONFIG_FILES([Makefile
297                  docs/Makefile
298                  include/Makefile
299                  plugins/Makefile
300                  plugins/example1/Makefile
301                  plugins/example2/Makefile
302                  plugins/example3/Makefile
303                  plugins/file/Makefile
304                  plugins/guestfs/Makefile
305                  plugins/gzip/Makefile
306                  plugins/libvirt/Makefile
307                  plugins/perl/Makefile
308                  plugins/python/Makefile
309                  plugins/vddk/Makefile
310                  plugins/xz/Makefile
311                  src/Makefile
312                  tests/Makefile])
314 AC_OUTPUT