Add section "Notes on disk format" to the manual.
[virt-bmap.git] / configure.ac
1 # virt-bmap
2 # Copyright (C) 2014 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 AC_INIT([virt-bmap],[0.1])
19 AM_INIT_AUTOMAKE([foreign])
20
21 dnl Check for basic C environment.
22 AC_PROG_CC_STDC
23 AM_PROG_CC_C_O
24 AC_PROG_CPP
25
26 AC_C_PROTOTYPES
27 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
28
29 dnl C++ environment.
30 AC_PROG_CXX
31 AC_PROG_CXX_C_O
32
33 AC_PROG_INSTALL
34
35 dnl Define GNU_SOURCE etc.
36 AC_USE_SYSTEM_EXTENSIONS
37
38 dnl Need libtool for creating the shared library.
39 AC_PROG_LIBTOOL
40
41 dnl Check if __attribute__((cleanup(...))) works.
42 dnl XXX It would be nice to use AC_COMPILE_IFELSE here, but gcc just
43 dnl emits a warning for attributes that it doesn't understand.
44 AC_MSG_CHECKING([if __attribute__((cleanup(...))) works with this compiler])
45 AC_RUN_IFELSE([
46 AC_LANG_SOURCE([[
47 #include <stdio.h>
48 #include <stdlib.h>
49
50 void
51 freep (void *ptr)
52 {
53   exit (EXIT_SUCCESS);
54 }
55
56 void
57 test (void)
58 {
59   __attribute__((cleanup(freep))) char *ptr = malloc (100);
60 }
61
62 int
63 main (int argc, char *argv[])
64 {
65   test ();
66   exit (EXIT_FAILURE);
67 }
68 ]])
69     ],[
70     AC_MSG_RESULT([yes])
71     AC_DEFINE([HAVE_ATTRIBUTE_CLEANUP],[1],[Define to 1 if '__attribute__((cleanup(...)))' works with this compiler.])
72     ],[
73     AC_MSG_WARN(
74 ['__attribute__((cleanup(...)))' does not work.
75
76 You may not be using a sufficiently recent version of GCC or CLANG, or
77 you may be using a C compiler which does not support this attribute,
78 or the configure test may be wrong.
79
80 The code will still compile, but is likely to leak memory and other
81 resources when it runs.])])
82
83 dnl Check new enough libguestfs.
84 PKG_CHECK_MODULES([GUESTFS], [libguestfs >= 1.29.11])
85
86 dnl We need some new APIs which were added specifically for virt-bmap:
87 AC_CHECK_LIB([guestfs], [guestfs_blockdev_setra], [], [
88     AC_MSG_ERROR([you need libguestfs >= 1.29.11 which has new APIs for virt-bmap])
89 ])
90
91 dnl Check nbdkit is installed.
92 AC_CHECK_PROG([NBDKIT], [nbdkit], [nbdkit], [no])
93 if test "$NBDKIT" = "xno"; then
94     AC_MSG_ERROR([nbdkit was not found])
95 fi
96 AC_CHECK_HEADER([nbdkit-plugin.h],[],[
97     AC_MSG_ERROR([you need to install the nbdkit development package])
98 ])
99
100 dnl Get nbdkit plugin directory.
101 AC_MSG_CHECKING([for nbdkit plugin directory])
102 eval `$NBDKIT --dump-config`
103 if test "x$plugindir" = "x"; then
104     AC_MSG_ERROR([something went wrong getting nbdkit plugin directory])
105 fi
106 nbdkitplugindir="$plugindir"
107 AC_SUBST([nbdkitplugindir])
108 AC_MSG_RESULT([$nbdkitplugindir])
109
110 dnl Check for C++ boost library with interval_map.hpp
111 AC_LANG_PUSH([C++])
112 AC_CHECK_HEADERS([boost/icl/interval_map.hpp], [],
113     [AC_MSG_ERROR(You need the Boost libraries.)])
114 AC_LANG_POP([C++])
115
116 dnl Check for pod2man (from Perl, for the manual).
117 AC_CHECK_PROG([POD2MAN], [pod2man], [pod2man], [no])
118 if test "x$POD2MAN" = "xno"; then
119     AC_MSG_ERROR([pod2man was not found.  This is needed to build man pages.])
120 fi
121
122 dnl Produce output files.
123 AC_CONFIG_HEADERS([config.h])
124 AC_CONFIG_FILES([Makefile])
125 AC_CONFIG_FILES([run], [chmod +x,-w run])
126 AC_CONFIG_FILES([virt-bmap], [chmod +x,-w virt-bmap])
127
128 AC_OUTPUT