Todo: ntfsclone.
[libguestfs.git] / daemon / configure.ac
1 # libguestfs-daemon
2 # Copyright (C) 2009 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 'debug' command.
35 AC_ARG_ENABLE([debug-command],
36   [AS_HELP_STRING([--enable-debug-command], [enable the 'debug' command])],
37   [AC_DEFINE_UNQUOTED([ENABLE_DEBUG_COMMAND],[1],[Enable the 'debug' command])],
38   [])
39
40 dnl For strchrnul(3), asprintf(3), futimens(2) and getline(3).
41 AC_GNU_SOURCE
42
43 dnl Check for basic C environment.
44 AC_PROG_CC
45 AC_PROG_INSTALL
46 AC_PROG_CPP
47
48 gl_EARLY
49 gl_INIT
50
51 AC_ARG_ENABLE([gcc-warnings],
52   [AS_HELP_STRING([--enable-gcc-warnings],
53                   [turn on lots of GCC warnings (for developers)])],
54   [case $enableval in
55      yes|no) ;;
56      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
57    esac
58    gl_gcc_warnings=$enableval],
59   [gl_gcc_warnings=no]
60 )
61
62 if test "$gl_gcc_warnings" = yes; then
63   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
64   AC_SUBST([WERROR_CFLAGS])
65
66   nw=
67   # This, $nw, is the list of warnings we disable.
68   nw="$nw -Wdeclaration-after-statement" # too useful to forbid
69   nw="$nw -Waggregate-return"       # anachronistic
70   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
71   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
72   nw="$nw -Wtraditional"            # Warns on #elif which we use often
73   nw="$nw -Wcast-qual"              # Too many warnings for now
74   nw="$nw -Wconversion"             # Too many warnings for now
75   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
76   nw="$nw -Wsign-conversion"        # Too many warnings for now
77   nw="$nw -Wtraditional-conversion" # Too many warnings for now
78   nw="$nw -Wunreachable-code"       # Too many warnings for now
79   nw="$nw -Wpadded"                 # Our structs are not padded
80   nw="$nw -Wredundant-decls"        # openat.h declares e.g., mkdirat
81   nw="$nw -Wlogical-op"             # any use of fwrite provokes this
82   nw="$nw -Wvla"                    # two warnings in mount.c
83   # things I might fix soon:
84   nw="$nw -Wmissing-format-attribute" # daemon.h's asprintf_nowarn
85   nw="$nw -Winline"                 # daemon.h's asprintf_nowarn
86   nw="$nw -Wshadow"                 # numerous, plus we're not unanimous
87   # ?? -Wstrict-overflow
88
89   gl_MANYWARN_ALL_GCC([ws])
90   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
91   for w in $ws; do
92     gl_WARN_ADD([$w])
93   done
94   gl_WARN_ADD([-Wno-unused-parameter]) # stubs.c
95   gl_WARN_ADD([-Wno-jump-misses-init]) # stubs.c
96   gl_WARN_ADD([-Wno-unused-variable]) # FIXME: only temporary, for guestfs_protocol.c, etc
97
98   # In spite of excluding -Wlogical-op above, it is enabled, as of
99   # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
100   gl_WARN_ADD([-Wno-logical-op])
101
102   gl_WARN_ADD([-fdiagnostics-show-option])
103
104   AC_SUBST([WARN_CFLAGS])
105
106   AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
107   AC_DEFINE([_FORTIFY_SOURCE], [2],
108     [enable compile-time and run-time bounds-checking, and some warnings])
109   AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
110 fi
111
112 AC_C_PROTOTYPES
113 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
114
115 AM_PROG_CC_C_O
116
117 dnl Check for Augeas (now optional).
118 AC_CHECK_LIB([augeas],[aug_match],[
119         LIBS="-laugeas $LIBS"
120         have_augeas=yes
121         dnl Check for functions not available in earlier versions of Augeas.
122         AC_CHECK_FUNCS([aug_load aug_defvar aug_defnode])
123         ],[have_augeas=no])
124 if test "x$have_augeas" = "xyes"; then
125         AC_DEFINE([HAVE_AUGEAS],[1],[Define to 1 if you have Augeas])
126 fi
127
128 dnl Check for libselinux (optional).
129 AC_CHECK_HEADERS([selinux/selinux.h])
130 AC_CHECK_LIB([selinux],[setexeccon],[
131         LIBS="-lselinux $LIBS"
132         have_libselinux="$ac_cv_header_selinux_selinux_h"
133         AC_CHECK_FUNCS([setcon getcon])
134         ],[have_libselinux=no])
135 if test "x$have_libselinux" = "xyes"; then
136         AC_DEFINE([HAVE_LIBSELINUX],[1],[Define to 1 if you have libselinux])
137 fi
138
139 dnl Check for XDR library.
140 AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
141         AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
142         ])
143
144 dnl Functions which may not be available in older distributions.
145 AC_CHECK_FUNCS([futimens listxattr llistxattr getxattr lgetxattr setxattr lsetxattr removexattr lremovexattr inotify_init1])
146
147 dnl For modified printf, we need glibc either (old-style)
148 dnl register_printf_function or (new-style) register_printf_specifier.
149 AC_CHECK_FUNC([register_printf_specifier],[
150         AC_DEFINE([HAVE_REGISTER_PRINTF_SPECIFIER],[1],
151                 [Define to 1 if you have new-style register_printf_specifier])
152         ],[
153         AC_CHECK_FUNC([register_printf_function],[
154                 AC_DEFINE([HAVE_REGISTER_PRINTF_FUNCTION],[1],
155                         [Define to 1 if you have old-style register_printf_function])
156                 ],[
157                 AC_MSG_FAILURE(
158 [No support for glibc-style extended printf formatters.
159
160 This means you either have a very old glibc (pre-2.0) or you
161 are using some other libc where this is not supported.])])])
162
163 dnl Headers.
164 AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h])
165
166 dnl Produce output files.
167 AC_CONFIG_HEADERS([config.h])
168 AC_CONFIG_FILES([Makefile lib/Makefile tests/Makefile])
169 AC_OUTPUT