Version 1.11.12
[nbdkit/ericb.git] / configure.ac
blob3c753979538f2e96a647d5d21694a86315329729
1 # nbdkit
2 # Copyright (C) 2013-2016 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.12])
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 For the OCaml plugin, you can set OCAMLOPTFLAGS before running
200 dnl ./configure to specify any extra flags you want to pass to
201 dnl ocamlopt.
202 AC_SUBST([OCAMLOPTFLAGS])
204 dnl Check for OCaml, for embedding in the ocaml plugin.
205 AC_PROG_OCAML
206 AC_ARG_ENABLE([ocaml],
207     AS_HELP_STRING([--disable-ocaml], [disable OCaml embed plugin]),
208     [],
209     [enable_ocaml=yes])
210 AS_IF([test "x$OCAMLOPT" != "xno" && test "x$enable_ocaml" != "xno"],[
211     dnl Check OCaml can create a shared library (see README for details).
212     AC_MSG_CHECKING([if $OCAMLOPT can create a shared library])
213     echo 'print_endline "test"' > conftest.ml
214     AS_IF([$OCAMLOPT $OCAMLOPTFLAGS -output-obj -runtime-variant _pic -o conftest.so conftest.ml >&AS_MESSAGE_LOG_FD 2>&1],[
215         AC_MSG_RESULT([yes])
216         ocaml_link_shared=yes
217     ],[
218         AC_MSG_RESULT([no])
219     ])
220     rm -f conftest.ml conftest.cmi conftest.cmx conftest.so conftest.o
222 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLOPT" != "xno" &&
223                              test "x$ocaml_link_shared" = "xyes"])
225 dnl Check for Ruby, for embedding in the Ruby plugin.
226 AC_CHECK_PROG([RUBY],[ruby],[ruby],[no])
227 AC_ARG_ENABLE([ruby],
228     AS_HELP_STRING([--disable-ruby], [disable Ruby plugin]),
229     [],
230     [enable_ruby=yes])
231 AS_IF([test "x$RUBY" != "xno" && test "x$enable_ruby" != "xno"],[
232     PKG_CHECK_MODULES([RUBY], [ruby], [
233         AC_SUBST([RUBY_CFLAGS])
234         AC_SUBST([RUBY_LIBS])
235     ],[
236         AC_MSG_WARN([ruby not found])
237         enable_ruby=no
238     ])
240 AM_CONDITIONAL([HAVE_RUBY],[test "x$RUBY" != "xno" &&
241                             test "x$enable_ruby" = "xyes"])
243 dnl Check for curl (only if you want to compile the curl plugin).
244 AC_ARG_WITH([curl],[
245     AS_HELP_STRING([--without-curl],
246                    [disable curl plugin @<:@default=check@:>@])],
247     [],
248     [with_curl=check])
249 AS_IF([test "$with_curl" != "no"],[
250     PKG_CHECK_MODULES([CURL], [libcurl],[
251         AC_SUBST([CURL_CFLAGS])
252         AC_SUBST([CURL_LIBS])
253         AC_DEFINE([HAVE_CURL],[1],[curl found at compile time.])
254     ],
255     [AC_MSG_WARN([curl not found, curl plugin will be disabled])])
257 AM_CONDITIONAL([HAVE_CURL],[test "x$CURL_LIBS" != "x"])
259 dnl Check for libvirt (only if you want to compile the libvirt plugin).
260 AC_ARG_WITH([libvirt],[
261     AS_HELP_STRING([--without-libvirt],
262                    [disable libvirt plugin @<:@default=check@:>@])],
263     [],
264     [with_libvirt=check])
265 AS_IF([test "$with_libvirt" != "no"],[
266     PKG_CHECK_MODULES([LIBVIRT], [libvirt],[
267         AC_SUBST([LIBVIRT_CFLAGS])
268         AC_SUBST([LIBVIRT_LIBS])
269         AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.])
270     ],
271     [AC_MSG_WARN([libvirt not found, libvirt plugin will be disabled])])
273 AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
275 dnl Check for zlib (only if you want to compile the gzip plugin).
276 AC_ARG_WITH([zlib],[
277     AS_HELP_STRING([--without-zlib],
278                    [disable gzip plugin @<:@default=check@:>@])],
279     [],
280     [with_zlib=check])
281 AS_IF([test "$with_zlib" != "no"],[
282     PKG_CHECK_MODULES([ZLIB], [zlib],[
283         AC_SUBST([ZLIB_CFLAGS])
284         AC_SUBST([ZLIB_LIBS])
285         AC_DEFINE([HAVE_ZLIB],[1],[zlib found at compile time.])
286     ],
287     [AC_MSG_WARN([zlib not found, gzip plugin will be disabled])])
289 AM_CONDITIONAL([HAVE_ZLIB],[test "x$ZLIB_LIBS" != "x"])
291 dnl Check for liblzma (only if you want to compile the xz plugin).
292 AC_ARG_WITH([liblzma],[
293     AS_HELP_STRING([--without-liblzma],
294                    [disable xz plugin @<:@default=check@:>@])],
295     [],
296     [with_liblzma=check])
297 AS_IF([test "$with_liblzma" != "no"],[
298     PKG_CHECK_MODULES([LIBLZMA], [liblzma],[
299         AC_SUBST([LIBLZMA_CFLAGS])
300         AC_SUBST([LIBLZMA_LIBS])
301         AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma found at compile time.])
302     ],
303     [AC_MSG_WARN([liblzma not found, xz plugin will be disabled])])
305 AM_CONDITIONAL([HAVE_LIBLZMA],[test "x$LIBLZMA_LIBS" != "x"])
307 dnl Check for libguestfs (only for the guestfs plugin and the test suite).
308 AC_ARG_WITH([libguestfs],[
309     AS_HELP_STRING([--without-libguestfs],
310                    [disable guestfs plugin and tests @<:@default=check@:>@])],
311     [],
312     [with_libguestfs=check])
313 AS_IF([test "$with_libguestfs" != "no"],[
314     PKG_CHECK_MODULES([LIBGUESTFS], [libguestfs],[
315         AC_SUBST([LIBGUESTFS_CFLAGS])
316         AC_SUBST([LIBGUESTFS_LIBS])
317         AC_DEFINE([HAVE_LIBGUESTFS],[1],[libguestfs found at compile time.])
318     ],
319     [AC_MSG_WARN([libguestfs not found, guestfs plugin and tests will be disabled])])
321 AM_CONDITIONAL([HAVE_LIBGUESTFS],[test "x$LIBGUESTFS_LIBS" != "x"])
323 dnl Check for guestfish (only needed for some of the tests).
324 AC_CHECK_PROG([GUESTFISH], [guestfish], [guestfish], [no])
325 AM_CONDITIONAL([HAVE_GUESTFISH], [test "x$GUESTFISH" != "xno"])
327 dnl See plugins/vddk/README.VDDK.
328 AC_CHECK_SIZEOF([size_t])
329 AS_IF([test "x$ac_cv_sizeof_size_t" = "x4"],[bits=32],[bits=64])
330 AC_ARG_WITH([vddk],[
331     AS_HELP_STRING([--with-vddk],
332                    [enable VMware VDDK plugin @<:@default=no@:>@])],
333     [],
334     [with_vddk=no])
335 AS_IF([test "$with_vddk" = "yes"],[
336     VDDK_CFLAGS=
337     VDDK_LIBS="-lvixDiskLib"
338     # XXX Warning: stupid VMware API.
339     VDDK_LIBDIR="$libdir/vmware-vix-disklib"
340     ],[
341     AS_IF([test "$with_vddk" != "no"], [
342         VDDK_CFLAGS="-I$with_vddk/include"
343         VDDK_LIBS="-L$with_vddk/lib$bits -lvixDiskLib"
344         VDDK_LIBDIR="$with_vddk"
345         ],
346         [AC_MSG_NOTICE([VDDK plugin disabled])
347     ])
349 AC_SUBST([VDDK_CFLAGS])
350 AC_SUBST([VDDK_LIBS])
351 AC_DEFINE_UNQUOTED([VDDK_LIBDIR],["$VDDK_LIBDIR"],[VDDK 'libDir'.])
352 AM_CONDITIONAL([HAVE_VDDK],[test "x$VDDK_LIBS" != "x"])
354 dnl Produce output files.
355 AC_CONFIG_HEADERS([config.h])
356 AC_CONFIG_FILES([Makefile
357                  docs/Makefile
358                  include/Makefile
359                  plugins/Makefile
360                  plugins/curl/Makefile
361                  plugins/example1/Makefile
362                  plugins/example2/Makefile
363                  plugins/example3/Makefile
364                  plugins/file/Makefile
365                  plugins/guestfs/Makefile
366                  plugins/gzip/Makefile
367                  plugins/libvirt/Makefile
368                  plugins/ocaml/Makefile
369                  plugins/perl/Makefile
370                  plugins/python/Makefile
371                  plugins/ruby/Makefile
372                  plugins/streaming/Makefile
373                  plugins/vddk/Makefile
374                  plugins/xz/Makefile
375                  src/Makefile
376                  tests/Makefile])
378 AC_OUTPUT