virt-bmap: Examine whole devices.
[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.28])
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.10 which has `guestfs_blockdev_setra'])
89 ])
90 AC_CHECK_LIB([guestfs], [guestfs_bmap], [], [
91     AC_MSG_ERROR([you need libguestfs >= 1.29.10 which has `guestfs_bmap'])
92 ])
93
94 dnl Check nbdkit is installed.
95 AC_CHECK_PROG([NBDKIT], [nbdkit], [nbdkit], [no])
96 if test "$NBDKIT" = "xno"; then
97     AC_MSG_ERROR([nbdkit was not found])
98 fi
99 AC_CHECK_HEADER([nbdkit-plugin.h],[],[
100     AC_MSG_ERROR([you need to install the nbdkit development package])
101 ])
102
103 dnl Check for C++ boost library with interval_map.hpp
104 AC_LANG_PUSH([C++])
105 AC_CHECK_HEADERS([boost/icl/interval_map.hpp], [],
106     [AC_MSG_ERROR(You need the Boost libraries.)])
107 AC_LANG_POP([C++])
108
109 dnl Check for pod2man (from Perl, for the manual).
110 AC_CHECK_PROG([POD2MAN], [pod2man], [pod2man], [no])
111 if test "x$POD2MAN" = "xno"; then
112     AC_MSG_ERROR([pod2man was not found.  This is needed to build man pages.])
113 fi
114
115 dnl Produce output files.
116 AC_CONFIG_HEADERS([config.h])
117 AC_CONFIG_FILES([Makefile])
118 AC_CONFIG_FILES([run], [chmod +x,-w run])
119 AC_CONFIG_FILES([virt-bmap], [chmod +x,-w virt-bmap])
120
121 AC_OUTPUT