2 # Copyright (C) 2014 Red Hat Inc.
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.
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.
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.
18 AC_INIT([virt-bmap],[0.1])
19 AM_INIT_AUTOMAKE([foreign])
21 dnl Check for basic C environment.
27 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
35 dnl Define GNU_SOURCE etc.
36 AC_USE_SYSTEM_EXTENSIONS
38 dnl Need libtool for creating the shared library.
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])
59 __attribute__((cleanup(freep))) char *ptr = malloc (100);
63 main (int argc, char *argv[])
71 AC_DEFINE([HAVE_ATTRIBUTE_CLEANUP],[1],[Define to 1 if '__attribute__((cleanup(...)))' works with this compiler.])
74 ['__attribute__((cleanup(...)))' does not work.
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.
80 The code will still compile, but is likely to leak memory and other
81 resources when it runs.])])
83 dnl Check new enough libguestfs.
84 PKG_CHECK_MODULES([GUESTFS], [libguestfs >= 1.29.11])
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])
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])
96 AC_CHECK_HEADER([nbdkit-plugin.h],[],[
97 AC_MSG_ERROR([you need to install the nbdkit development package])
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])
106 nbdkitplugindir="$plugindir"
107 AC_SUBST([nbdkitplugindir])
108 AC_MSG_RESULT([$nbdkitplugindir])
110 dnl Check for C++ boost library with interval_map.hpp
112 AC_CHECK_HEADERS([boost/icl/interval_map.hpp], [],
113 [AC_MSG_ERROR(You need the Boost libraries.)])
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.])
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])