New API: pread-device, partial read for devices.
[libguestfs.git] / daemon / configure.ac
1 # libguestfs-daemon
2 # Copyright (C) 2009-2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 AC_INIT([libguestfs-daemon],[1.0.0])
19 AC_CONFIG_AUX_DIR([build-aux])
20 AM_INIT_AUTOMAKE([foreign])
21
22 m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
23 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
24
25 AC_CONFIG_MACRO_DIR([m4])
26
27 dnl If the user specified --enable-32bit, then force the C compiler
28 dnl to build 32 bit binaries (gcc -m32).
29 AC_ARG_ENABLE([32bit],
30   [AS_HELP_STRING([--enable-32bit], [build 32 bit binaries (gcc -m32)])],
31   [export CC="gcc -m32"],
32   [enable_32bit=no])
33
34 dnl Enable packet dumps when in verbose mode.  This generates lots
35 dnl of debug info, only useful for people debugging the RPC mechanism.
36 AC_ARG_ENABLE([packet-dump],
37         [AS_HELP_STRING([--enable-packet-dump],
38           [enable packet dumps in verbose mode @<:@default=no@:>@])],
39         [AC_DEFINE([ENABLE_PACKET_DUMP],[1],[Enable packet dumps in verbose mode.])],
40         [])
41
42 dnl For strchrnul(3), asprintf(3), futimens(2) and getline(3).
43 AC_GNU_SOURCE
44
45 dnl Check for basic C environment.
46 AC_PROG_CC
47 AC_PROG_INSTALL
48 AC_PROG_CPP
49
50 gl_EARLY
51 gl_INIT
52
53 AC_ARG_ENABLE([gcc-warnings],
54   [AS_HELP_STRING([--enable-gcc-warnings],
55                   [turn on lots of GCC warnings (for developers)])],
56   [case $enableval in
57      yes|no) ;;
58      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
59    esac
60    gl_gcc_warnings=$enableval],
61   [gl_gcc_warnings=no]
62 )
63
64 if test "$gl_gcc_warnings" = yes; then
65   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
66   AC_SUBST([WERROR_CFLAGS])
67
68   nw=
69   # This, $nw, is the list of warnings we disable.
70   nw="$nw -Wdeclaration-after-statement" # too useful to forbid
71   nw="$nw -Waggregate-return"       # anachronistic
72   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
73   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
74   nw="$nw -Wtraditional"            # Warns on #elif which we use often
75   nw="$nw -Wcast-qual"              # Too many warnings for now
76   nw="$nw -Wconversion"             # Too many warnings for now
77   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
78   nw="$nw -Wsign-conversion"        # Too many warnings for now
79   nw="$nw -Wtraditional-conversion" # Too many warnings for now
80   nw="$nw -Wunreachable-code"       # Too many warnings for now
81   nw="$nw -Wpadded"                 # Our structs are not padded
82   nw="$nw -Wredundant-decls"        # openat.h declares e.g., mkdirat
83   nw="$nw -Wlogical-op"             # any use of fwrite provokes this
84   nw="$nw -Wvla"                    # two warnings in mount.c
85   # things I might fix soon:
86   nw="$nw -Wmissing-format-attribute" # daemon.h's asprintf_nowarn
87   nw="$nw -Winline"                 # daemon.h's asprintf_nowarn
88   nw="$nw -Wshadow"                 # numerous, plus we're not unanimous
89   # ?? -Wstrict-overflow
90   nw="$nw -Wunsafe-loop-optimizations" # just a warning that an optimization
91                                     # was not possible, safe to ignore
92   nw="$nw -Wlong-long"              # Allow long long since it's required
93                                     # by Python, Ruby and xstrtoll.
94
95   gl_MANYWARN_ALL_GCC([ws])
96   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
97   for w in $ws; do
98     gl_WARN_ADD([$w])
99   done
100   gl_WARN_ADD([-Wno-unused-parameter]) # stubs.c
101   gl_WARN_ADD([-Wno-jump-misses-init]) # stubs.c
102   gl_WARN_ADD([-Wno-unused-variable]) # FIXME: only temporary, for guestfs_protocol.c, etc
103
104   # In spite of excluding -Wlogical-op above, it is enabled, as of
105   # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
106   gl_WARN_ADD([-Wno-logical-op])
107
108   gl_WARN_ADD([-fdiagnostics-show-option])
109
110   AC_SUBST([WARN_CFLAGS])
111
112   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
113   AC_DEFINE([_FORTIFY_SOURCE], [2],
114     [enable compile-time and run-time bounds-checking, and some warnings])
115   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
116 fi
117
118 AC_C_PROTOTYPES
119 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
120
121 AM_PROG_CC_C_O
122
123 dnl If the host is Windows, define _WIN32_WINNT to a suitable value.
124 AC_CANONICAL_HOST
125 case $host in
126      *mingw*|*cygwin*|*win32*) CFLAGS="$CFLAGS -D_WIN32_WINNT=0x0500" ;;
127 esac
128
129 dnl Check support for 64 bit file offsets.
130 AC_SYS_LARGEFILE
131
132 dnl Check if dirent (readdir) supports d_type member.
133 AC_STRUCT_DIRENT_D_TYPE
134
135 dnl Check if stat has the required fields.
136 AC_STRUCT_ST_BLOCKS
137 AC_CHECK_MEMBER([struct stat.st_blksize],[
138         AC_DEFINE([HAVE_STRUCT_STAT_ST_BLKSIZE],[1],[Define to 1 if 'st_blksize' is a member of 'struct stat'])])
139
140 dnl Check for Augeas (now optional).
141 AC_CHECK_LIB([augeas],[aug_match],[
142         LIBS="-laugeas $LIBS"
143         have_augeas=yes
144         dnl Check for functions not available in earlier versions of Augeas.
145         AC_CHECK_FUNCS([aug_load aug_defvar aug_defnode])
146         ],[have_augeas=no])
147 if test "x$have_augeas" = "xyes"; then
148         AC_DEFINE([HAVE_AUGEAS],[1],[Define to 1 if you have Augeas])
149 fi
150
151 dnl Check for libselinux (optional).
152 AC_CHECK_HEADERS([selinux/selinux.h])
153 AC_CHECK_LIB([selinux],[setexeccon],[
154         LIBS="-lselinux $LIBS"
155         have_libselinux="$ac_cv_header_selinux_selinux_h"
156         AC_CHECK_FUNCS([setcon getcon])
157         ],[have_libselinux=no])
158 if test "x$have_libselinux" = "xyes"; then
159         AC_DEFINE([HAVE_LIBSELINUX],[1],[Define to 1 if you have libselinux])
160 fi
161
162 dnl Check for XDR library.
163 AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
164         AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
165         ])
166
167 dnl Functions which may not be available in older distributions.
168 AC_CHECK_FUNCS([\
169         getxattr \
170         htonl \
171         htons \
172         inotify_init1 \
173         lgetxattr \
174         listxattr \
175         llistxattr \
176         lsetxattr \
177         lremovexattr \
178         mknod \
179         ntohl \
180         ntohs \
181         posix_fallocate \
182         realpath \
183         removexattr \
184         setxattr \
185         statvfs \
186         sync])
187
188 dnl Headers.
189 AC_CHECK_HEADERS([\
190         attr/xattr.h \
191         printf.h \
192         sys/inotify.h \
193         sys/statvfs.h \
194         sys/xattr.h \
195         windows.h])
196
197 dnl For modified printf, we need glibc either (old-style)
198 dnl register_printf_function or (new-style) register_printf_specifier.
199 AC_CHECK_FUNC([register_printf_specifier],[
200         AC_DEFINE([HAVE_REGISTER_PRINTF_SPECIFIER],[1],
201                 [Define to 1 if you have new-style register_printf_specifier])
202         ],[
203         AC_CHECK_FUNC([register_printf_function],[
204                 AC_DEFINE([HAVE_REGISTER_PRINTF_FUNCTION],[1],
205                         [Define to 1 if you have old-style register_printf_function])
206                 ],[
207                 AC_MSG_FAILURE(
208 [No support for glibc-style extended printf formatters.
209
210 This means you either have a very old glibc (pre-2.0) or you
211 are using some other libc where this is not supported.])])])
212
213 dnl Produce output files.
214 AC_CONFIG_HEADERS([config.h])
215 AC_CONFIG_FILES([Makefile lib/Makefile tests/Makefile])
216 AC_OUTPUT