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.28])
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'])
90 AC_CHECK_LIB([guestfs], [guestfs_bmap], [], [
91 AC_MSG_ERROR([you need libguestfs >= 1.29.10 which has `guestfs_bmap'])
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])
99 AC_CHECK_HEADER([nbdkit-plugin.h],[],[
100 AC_MSG_ERROR([you need to install the nbdkit development package])
103 dnl Check for C++ boost library with interval_map.hpp
105 AC_CHECK_HEADERS([boost/icl/interval_map.hpp], [],
106 [AC_MSG_ERROR(You need the Boost libraries.)])
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.])
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])