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], [0.1.0])
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"])
132 dnl Produce output files.
133 AC_CONFIG_HEADERS([config.h])
134 AC_CONFIG_FILES([Makefile
138 plugins/example1/Makefile
139 plugins/example2/Makefile
140 plugins/example3/Makefile
141 plugins/libvirt/Makefile