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