gitignore: Ignore gdb history file.
[nbdkit/ericb.git] / configure.ac
blobdbc4764b98bd1a877e444e326e4b64e8cd970118
1 # nbdkit
2 # Copyright (C) 2013 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], [0.1.0])
34 AC_CONFIG_MACRO_DIR([m4])
35 AC_USE_SYSTEM_EXTENSIONS
36 AC_SYS_LARGEFILE
38 AM_INIT_AUTOMAKE(foreign) dnl NB: Do not [quote] this parameter.
39 LT_INIT
41 dnl Check for basic C environment.
42 AC_PROG_CC_STDC
43 AC_PROG_INSTALL
44 AC_PROG_CPP
46 AC_C_PROTOTYPES
47 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
49 AM_PROG_CC_C_O
51 AC_ARG_ENABLE([gcc-warnings],
52     [AS_HELP_STRING([--enable-gcc-warnings],
53                     [turn on lots of GCC warnings (for developers)])],
54      [case $enableval in
55       yes|no) ;;
56       *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
57       esac
58       gcc_warnings=$enableval],
59       [gcc_warnings=no]
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])
73 AC_RUN_IFELSE([
74 AC_LANG_SOURCE([[
75 #include <stdio.h>
76 #include <stdlib.h>
78 void
79 freep (void *ptr)
81   exit (EXIT_SUCCESS);
84 void
85 test (void)
87   __attribute__((cleanup(freep))) char *ptr = malloc (100);
90 int
91 main (int argc, char *argv[])
93   test ();
94   exit (EXIT_FAILURE);
96 ]])
97     ],[
98     AC_MSG_RESULT([yes])
99     AC_DEFINE([HAVE_ATTRIBUTE_CLEANUP],[1],[Define to 1 if '__attribute__((cleanup(...)))' works with this compiler.])
100     ],[
101     AC_MSG_WARN(
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@:>@])],
119     [],
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.])
126     ],
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
135                  docs/Makefile
136                  include/Makefile
137                  plugins/Makefile
138                  plugins/example1/Makefile
139                  plugins/example2/Makefile
140                  plugins/example3/Makefile
141                  plugins/libvirt/Makefile
142                  src/Makefile])
144 AC_OUTPUT