TEMP disable %check
[libvirt/apevec.git] / configure.ac
blob6b30d908d41a598c3fed1bd7a46aa9a61e33b54b
1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT([libvirt], [0.8.5], [libvir-list@redhat.com], [], [http://libvirt.org])
4 AC_CONFIG_SRCDIR([src/libvirt.c])
5 AC_CONFIG_AUX_DIR([build-aux])
6 AC_CONFIG_HEADERS([config.h])
7 AC_CONFIG_MACRO_DIR([m4])
8 dnl Make automake keep quiet about wildcards & other GNUmake-isms
9 AM_INIT_AUTOMAKE([-Wno-portability])
11 # Use the silent-rules feature when possible.
12 m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
13 AM_SILENT_RULES([yes])
15 AC_CANONICAL_HOST
17 LIBVIRT_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
18 LIBVIRT_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'`
19 LIBVIRT_MICRO_VERSION=`echo $VERSION | awk -F. '{print $3}'`
20 LIBVIRT_VERSION=$LIBVIRT_MAJOR_VERSION.$LIBVIRT_MINOR_VERSION.$LIBVIRT_MICRO_VERSION$LIBVIRT_MICRO_VERSION_SUFFIX
21 LIBVIRT_VERSION_INFO=`expr $LIBVIRT_MAJOR_VERSION + $LIBVIRT_MINOR_VERSION`:$LIBVIRT_MICRO_VERSION:$LIBVIRT_MINOR_VERSION
22 LIBVIRT_VERSION_NUMBER=`expr $LIBVIRT_MAJOR_VERSION \* 1000000 + $LIBVIRT_MINOR_VERSION \* 1000 + $LIBVIRT_MICRO_VERSION`
24 AC_SUBST([LIBVIRT_MAJOR_VERSION])
25 AC_SUBST([LIBVIRT_MINOR_VERSION])
26 AC_SUBST([LIBVIRT_MICRO_VERSION])
27 AC_SUBST([LIBVIRT_VERSION])
28 AC_SUBST([LIBVIRT_VERSION_INFO])
29 AC_SUBST([LIBVIRT_VERSION_NUMBER])
31 dnl Required minimum versions of all libs we depend on
32 LIBXML_REQUIRED="2.6.0"
33 GNUTLS_REQUIRED="1.0.25"
34 AVAHI_REQUIRED="0.6.0"
35 POLKIT_REQUIRED="0.6"
36 PARTED_REQUIRED="1.8.0"
37 NETCF_REQUIRED="0.1.4"
38 UDEV_REQUIRED=145
39 PCIACCESS_REQUIRED=0.10.0
40 XMLRPC_REQUIRED=1.14.0
41 HAL_REQUIRED=0.5.0
42 DEVMAPPER_REQUIRED=1.0.0
43 LIBCURL_REQUIRED="7.18.0"
44 LIBPCAP_REQUIRED="1.0.0"
45 LIBNL_REQUIRED="1.1"
47 dnl Checks for C compiler.
48 AC_PROG_CC
49 AC_PROG_INSTALL
50 AC_PROG_CPP
52 gl_EARLY
53 gl_INIT
55 AM_PROG_CC_STDC
56 AC_TYPE_UID_T
58 dnl Make sure we have an ANSI compiler
59 AM_C_PROTOTYPES
60 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
62 dnl Support building Win32 DLLs (must appear *before* AM_PROG_LIBTOOL)
63 AC_LIBTOOL_WIN32_DLL
65 AM_PROG_LIBTOOL
66 AM_PROG_CC_C_O
67 AM_PROG_LD
69 VERSION_SCRIPT_FLAGS=-Wl,--version-script=
70 `$LD --help 2>&1 | grep -- --version-script >/dev/null` || \
71     VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
73 LIBVIRT_COMPILE_WARNINGS([maximum])
75 AC_MSG_CHECKING([for CPUID instruction])
76 AC_COMPILE_IFELSE(AC_LANG_PROGRAM(
77   [[
78     #include <stdint.h>
79   ]],
80   [[
81     uint32_t eax, ebx, ecx, edx;
82     asm volatile (
83         "cpuid"
84         : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
85         : "a" (eax));
86   ]]),
87   [have_cpuid=yes],
88   [have_cpuid=no])
89 if test "x$have_cpuid" = xyes; then
90   AC_DEFINE_UNQUOTED([HAVE_CPUID], 1, [whether CPUID instruction is supported])
92 AC_MSG_RESULT([$have_cpuid])
95 dnl Availability of various common functions (non-fatal if missing).
96 AC_CHECK_FUNCS_ONCE([cfmakeraw regexec sched_getaffinity getuid getgid \
97  posix_fallocate mmap])
99 dnl Availability of various not common threadsafe functions
100 AC_CHECK_FUNCS_ONCE([strerror_r getmntent_r getgrnam_r getpwuid_r])
102 dnl Availability of pthread functions (if missing, win32 threading is
103 dnl assumed).  Because of $LIB_PTHREAD, we cannot use AC_CHECK_FUNCS_ONCE.
104 dnl LIB_PTHREAD was set during gl_INIT by gnulib.
105 old_LIBS=$LIBS
106 LIBS="$LIBS $LIB_PTHREAD"
107 AC_CHECK_FUNCS([pthread_sigmask pthread_mutexattr_init])
108 LIBS=$old_libs
110 dnl Availability of various common headers (non-fatal if missing).
111 AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/syslimits.h sys/un.h \
112   sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h])
114 AC_CHECK_LIB([intl],[gettext],[])
116 dnl Do we have rpcgen?
117 AC_PATH_PROG([RPCGEN], [rpcgen], [no])
118 AM_CONDITIONAL([HAVE_RPCGEN], [test "x$ac_cv_path_RPCGEN" != "xno"])
119 dnl Is this GLIBC's buggy rpcgen?
120 AM_CONDITIONAL([HAVE_GLIBC_RPCGEN],
121                [test "x$ac_cv_path_RPCGEN" != "xno" &&
122                 $ac_cv_path_RPCGEN -t </dev/null >/dev/null 2>&1])
124 dnl Miscellaneous external programs.
125 AC_PATH_PROG([XMLLINT], [xmllint], [/usr/bin/xmllint])
126 AC_PATH_PROG([XMLCATALOG], [xmlcatalog], [/usr/bin/xmlcatalog])
127 AC_PATH_PROG([XSLTPROC], [xsltproc], [/usr/bin/xsltproc])
128 AC_PATH_PROG([AUGPARSE], [augparse], [/usr/bin/augparse])
129 AC_PROG_MKDIR_P
131 dnl External programs that we can use if they are available.
132 dnl We will hard-code paths to these programs unless we cannot
133 dnl detect them, in which case we'll search for the program
134 dnl along the $PATH at runtime and fail if it's not there.
135 AC_PATH_PROG([DNSMASQ], [dnsmasq], [dnsmasq],
136         [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
137 AC_PATH_PROG([BRCTL], [brctl], [brctl],
138         [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
139 AC_PATH_PROG([UDEVADM], [udevadm], [],
140         [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
141 AC_PATH_PROG([UDEVSETTLE], [udevsettle], [],
142         [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
143 AC_PATH_PROG([MODPROBE], [modprobe], [],
144         [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
146 AC_DEFINE_UNQUOTED([DNSMASQ],["$DNSMASQ"],
147         [Location or name of the dnsmasq program])
148 AC_DEFINE_UNQUOTED([BRCTL],["$BRCTL"],
149         [Location or name of the brctl program (see bridge-utils)])
150 if test -n "$UDEVADM"; then
151   AC_DEFINE_UNQUOTED([UDEVADM],["$UDEVADM"],
152         [Location or name of the udevadm program])
154 if test -n "$UDEVSETTLE"; then
155   AC_DEFINE_UNQUOTED([UDEVSETTLE],["$UDEVSETTLE"],
156         [Location or name of the udevsettle program])
158 if test -n "$MODPROBE"; then
159   AC_DEFINE_UNQUOTED([MODPROBE],["$MODPROBE"],
160         [Location or name of the modprobe program])
163 dnl Specific dir for HTML output ?
164 AC_ARG_WITH([html-dir], [AC_HELP_STRING([--with-html-dir=path],
165             [path to base html directory, default $datadir/doc/html])],
166             [HTML_DIR=$withval], [HTML_DIR='$(datadir)/doc'])
168 AC_ARG_WITH([html-subdir], [AC_HELP_STRING([--with-html-subdir=path],
169             [directory used under html-dir, default $PACKAGE-$VERSION/html])],
170             [test "x$withval" != "x" && HTML_DIR="$HTML_DIR/$withval"],
171             [HTML_DIR="$HTML_DIR/\$(PACKAGE)-\$(VERSION)/html"])
172 AC_SUBST([HTML_DIR])
174 dnl Specific XML catalog file for validation of generated html
175 AC_ARG_WITH([xml-catalog-file],
176             [AC_HELP_STRING([--with-xml-catalog-file=path],
177                 [path to XML catalog file for validating
178                  generated html, default /etc/xml/catalog])],
179             [XML_CATALOG_FILE=$withval],
180             [XML_CATALOG_FILE='/etc/xml/catalog'])
181 AC_SUBST([XML_CATALOG_FILE])
183 dnl if --prefix is /usr, don't use /usr/var for localstatedir
184 dnl or /usr/etc for sysconfdir
185 dnl as this makes a lot of things break in testing situations
187 if test "$prefix" = "/usr" && test "$localstatedir" = '${prefix}/var' ; then
188     localstatedir='/var'
190 if test "$prefix" = "/usr" && test "$sysconfdir" = '${prefix}/etc' ; then
191     sysconfdir='/etc'
194 dnl Make some notes about which OS we're compiling for, as the lxc and qemu
195 dnl drivers require linux headers, while storage_mpath and nwfilter are also
196 dnl linux specific.  The "network" and storage_fs drivers are known to not
197 dnl work on MacOS X presently, so we also make a note if compiling for that
199 with_linux=no with_osx=no
200 case $host in
201   *-*-linux*) with_linux=yes ;;
202   *-*-darwin*) with_osx=yes ;;
203 esac
205 if test $with_linux = no; then
206     if test "x$with_lxc" != xyes
207     then
208         with_lxc=no
209     fi
210     if test "x$with_qemu" != xyes
211     then
212         with_qemu=no
213     fi
216 AM_CONDITIONAL([WITH_LINUX], [test "$with_linux" = "yes"])
218 dnl Allow to build without Xen, QEMU/KVM, test or remote driver
219 AC_ARG_WITH([xen],
220   AC_HELP_STRING([--with-xen], [add XEN support @<:@default=check@:>@]),[],[with_xen=check])
221 AC_ARG_WITH([xen-inotify],
222   AC_HELP_STRING([--with-xen-inotify], [add XEN inotify support @<:@default=check@:>@]),[],[with_xen_inotify=check])
223 AC_ARG_WITH([qemu],
224   AC_HELP_STRING([--with-qemu], [add QEMU/KVM support @<:@default=yes@:>@]),[],[with_qemu=yes])
225 AC_ARG_WITH([uml],
226   AC_HELP_STRING([--with-uml], [add UML support @<:@default=check@:>@]),[],[with_uml=check])
227 AC_ARG_WITH([openvz],
228   AC_HELP_STRING([--with-openvz], [add OpenVZ support @<:@default=yes@:>@]),[],[with_openvz=yes])
229 AC_ARG_WITH([libssh2],
230   AC_HELP_STRING([--with-libssh2=@<:@PFX@:>@], [libssh2 location @<:@default=/usr/local/lib@:>@]),[],[with_libssh2=yes])
231 AC_ARG_WITH([phyp],
232   AC_HELP_STRING([--with-phyp], [add PHYP support @<:@default=check@:>@]),[],[with_phyp=check])
233 AC_ARG_WITH([xenapi],
234   AC_HELP_STRING([--with-xenapi], [add XenAPI support @<:@default=check@:>@]),[],[with_xenapi=check])
235 AC_ARG_WITH([vbox],
236   AC_HELP_STRING([--with-vbox=@<:@PFX@:>@],
237                  [VirtualBox XPCOMC location @<:@default=yes@:>@]),[],
238                  [with_vbox=yes])
239 AC_ARG_WITH([lxc],
240   AC_HELP_STRING([--with-lxc], [add Linux Container support @<:@default=check@:>@]),[],[with_lxc=check])
241 AC_ARG_WITH([one],
242   AC_HELP_STRING([--with-one], [add ONE support @<:@default=check@:>@]),[],[with_one=check])
243 AC_ARG_WITH([esx],
244   AC_HELP_STRING([--with-esx], [add ESX support @<:@default=check@:>@]),[],[with_esx=check])
245 AC_ARG_WITH([test],
246   AC_HELP_STRING([--with-test], [add test driver support @<:@default=yes@:>@]),[],[with_test=yes])
247 AC_ARG_WITH([remote],
248   AC_HELP_STRING([--with-remote], [add remote driver support @<:@default=yes@:>@]),[],[with_remote=yes])
249 AC_ARG_WITH([libvirtd],
250   AC_HELP_STRING([--with-libvirtd], [add libvirtd support @<:@default=yes@:>@]),[],[with_libvirtd=yes])
253 dnl in case someone want to build static binaries
254 dnl STATIC_BINARIES="-static"
256 STATIC_BINARIES=
257 AC_SUBST([STATIC_BINARIES])
259 dnl --enable-debug=(yes|no)
260 AC_ARG_ENABLE([debug],
261               [AC_HELP_STRING([--enable-debug=@<:@no|yes@:>@],
262                              [enable debugging output @<:@default=yes@:>@])],[],[enable_debug=yes])
263 AM_CONDITIONAL([ENABLE_DEBUG], test x"$enable_debug" = x"yes")
264 if test x"$enable_debug" = x"yes"; then
265    AC_DEFINE([ENABLE_DEBUG], [], [whether debugging is enabled])
269 AC_MSG_CHECKING([where to write libvirtd PID file])
270 AC_ARG_WITH([remote-pid-file], [AC_HELP_STRING([--with-remote-pid-file=@<:@pidfile|none@:>@], [PID file for libvirtd])])
271 if test "x$with_remote_pid_file" == "x" ; then
272    REMOTE_PID_FILE="$localstatedir/run/libvirtd.pid"
273 elif test "x$with_remote_pid_file" == "xnone" ; then
274    REMOTE_PID_FILE=""
275 else
276    REMOTE_PID_FILE="$with_remote_pid_file"
278 AC_SUBST([REMOTE_PID_FILE])
279 AC_MSG_RESULT($REMOTE_PID_FILE)
282 dnl init script flavor
284 AC_MSG_CHECKING([for init script flavor])
285 AC_ARG_WITH([init-script],
286             [AC_HELP_STRING([--with-init-script=@<:@redhat|auto|none@:>@],
287                      [Style of init script to install @<:@default=auto@:>@])])
288 if test "x$with_init_script" = "x" || test "x$with_init_script" = "xauto"; then
289     if test "$cross_compiling" = yes || test ! -f /etc/redhat-release; then
290         with_init_script=none
291     else
292         with_init_script=redhat
293     fi
295 AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_RED_HAT], test x$with_init_script = xredhat)
296 AC_MSG_RESULT($with_init_script)
298 dnl RHEL-5 has a peculiar version of Xen, which requires some special casing
299 AC_ARG_WITH([rhel5-api],
300         [AC_HELP_STRING([--with-rhel5-api=@<:@ARG@:>@],
301                 [build for the RHEL-5 API @<:@default=no@:>@])])
302 if test x"$with_rhel5_api" = x"yes"; then
303    AC_DEFINE([WITH_RHEL5_API], [1], [whether building for the RHEL-5 API])
306 AC_PATH_PROG([IPTABLES_PATH], [iptables], /sbin/iptables, [/usr/sbin:$PATH])
307 AC_DEFINE_UNQUOTED([IPTABLES_PATH], "$IPTABLES_PATH", [path to iptables binary])
309 AC_PATH_PROG([EBTABLES_PATH], [ebtables], /sbin/ebtables, [/usr/sbin:$PATH])
310 AC_DEFINE_UNQUOTED([EBTABLES_PATH], "$EBTABLES_PATH", [path to ebtables binary])
313 if test "$with_openvz" = "yes"; then
314     AC_DEFINE_UNQUOTED([WITH_OPENVZ], 1, [whether OpenVZ driver is enabled])
316 AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"])
320 dnl check for XDR
323 if test x"$with_remote" = x"yes" || test x"$with_libvirtd" = x"yes"; then
324     dnl Where are the XDR functions?
325     dnl If portablexdr is installed, prefer that.
326     dnl Otherwise try -lrpc (Cygwin) -lxdr (some MinGW), -lnsl (Solaris)
327     dnl or none (most Unix)
328     AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
329         AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl],[],
330             [AC_MSG_ERROR([Cannot find a XDR library])])
331         ])
333     dnl check for cygwin's variation in xdr function names
334     AC_CHECK_FUNCS([xdr_u_int64_t],[],[],[#include <rpc/xdr.h>])
339 dnl check for VirtualBox XPCOMC location
342 vbox_xpcomc_dir=
344 if test "x$with_vbox" != "xyes" && test "x$with_vbox" != "xno"; then
345     # intentionally don't do any further checks here on the provided path
346     vbox_xpcomc_dir=$with_vbox
347     with_vbox=yes
350 AC_DEFINE_UNQUOTED([VBOX_XPCOMC_DIR], ["$vbox_xpcomc_dir"],
351                    [Location of directory containing VirtualBox XPCOMC library])
353 if test "x$with_vbox" = "xyes"; then
354     AC_SEARCH_LIBS([dlopen], [dl], [], [AC_MSG_ERROR([Unable to find dlopen()])])
355     case $ac_cv_search_dlopen in
356       no*) DLOPEN_LIBS= ;;
357       *) DLOPEN_LIBS=$ac_cv_search_dlopen ;;
358     esac
359     AC_SUBST([DLOPEN_LIBS])
360     AC_DEFINE_UNQUOTED([WITH_VBOX], 1, [whether VirtualBox driver is enabled])
362 AM_CONDITIONAL([WITH_VBOX], [test "$with_vbox" = "yes"])
364 if test "$with_libvirtd" = "no" ; then
365   with_qemu=no
367 if test "$with_qemu" = "yes" ; then
368     AC_DEFINE_UNQUOTED([WITH_QEMU], 1, [whether QEMU driver is enabled])
370 AM_CONDITIONAL([WITH_QEMU], [test "$with_qemu" = "yes"])
372 if test "$with_one" = "yes" ; then
373     AC_DEFINE_UNQUOTED([WITH_ONE],1,[whether ONE driver is enabled])
375 AM_CONDITIONAL([WITH_ONE],[test "$with_one" = "yes"])
377 if test "$with_test" = "yes" ; then
378     AC_DEFINE_UNQUOTED([WITH_TEST], 1, [whether Test driver is enabled])
380 AM_CONDITIONAL([WITH_TEST], [test "$with_test" = "yes"])
382 if test "$with_remote" = "yes" ; then
383     AC_DEFINE_UNQUOTED([WITH_REMOTE], 1, [whether Remote driver is enabled])
385 AM_CONDITIONAL([WITH_REMOTE], [test "$with_remote" = "yes"])
387 if test "$with_libvirtd" = "yes" ; then
388     AC_DEFINE_UNQUOTED([WITH_LIBVIRTD], 1, [whether libvirtd daemon is enabled])
390 AM_CONDITIONAL([WITH_LIBVIRTD], [test "$with_libvirtd" = "yes"])
393 old_LIBS="$LIBS"
394 old_CFLAGS="$CFLAGS"
395 LIBXENSERVER_LIBS=""
396 LIBXENSERVER_CFLAGS=""
397 dnl search for the XenServer library
398 if test "$with_xenapi" != "no" ; then
399     if test "$with_xenapi" != "yes" && test "$with_xenapi" != "check" ; then
400         LIBXENSERVER_CFLAGS="-I$with_xenapi/include"
401         LIBXENSERVER_LIBS="-L$with_xenapi"
402     fi
403     fail=0
404     CFLAGS="$CFLAGS $LIBXENSERVER_CFLAGS"
405     LIBS="$LIBS $LIBXENSERVER_LIBS"
406     AC_CHECK_LIB([xenserver], [xen_vm_start], [
407         with_xenapi=yes
408         LIBXENSERVER_LIBS="$LIBXENSERVER_LIBS -lxenserver"
409     ],[
410         if test "$with_xenapi" = "yes"; then
411             fail=1
412         fi
413             with_xenapi=no
414     ])
417 LIBS="$old_LIBS"
418 CFLAGS="$old_CFLAGS"
420 if test $fail = 1; then
421     AC_MSG_ERROR([You must install the XenServer Library to compile XenAPI driver with -lxenserver])
424 if test "$with_xenapi" = "yes"; then
425     AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled])
428 AC_SUBST([LIBXENSERVER_CFLAGS])
429 AC_SUBST([LIBXENSERVER_LIBS])
432 old_LIBS="$LIBS"
433 old_CFLAGS="$CFLAGS"
434 XEN_LIBS=""
435 XEN_CFLAGS=""
436 dnl search for the Xen store library
437 if test "$with_xen" != "no" ; then
438     if test "$with_xen" != "yes" && test "$with_xen" != "check" ; then
439         XEN_CFLAGS="-I$with_xen/include"
440         XEN_LIBS="-L$with_xen/lib64 -L$with_xen/lib"
441     fi
442     fail=0
443     CFLAGS="$CFLAGS $XEN_CFLAGS"
444     LIBS="$LIBS $XEN_LIBS"
445     AC_CHECK_LIB([xenstore], [xs_read], [
446            with_xen=yes
447            XEN_LIBS="$XEN_LIBS -lxenstore"
448        ],[
449            if test "$with_xen" = "yes"; then
450                fail=1
451            fi
452            with_xen=no
453        ])
456 if test "$with_xen" != "no" ; then
457     AC_CHECK_HEADERS([xen/xen.h xen/version.h xen/dom0_ops.h],,[
458        if test "$with_xen" = "yes"; then
459            fail=1
460        fi
461        with_xen=no
462     ],
463 [#include <stdio.h>
464 #include <stdint.h>
468 if test "$with_xen" != "no" ; then
469     dnl Search for the location of <xen/{linux,sys}/privcmd.h>.
470     found=
471     AC_CHECK_HEADERS([xen/sys/privcmd.h xen/linux/privcmd.h], [found=yes; break;], [],
472        [#include <stdio.h>
473         #include <stdint.h>
474         #include <xen/xen.h>
475        ])
476     if test "x$found" != "xyes"; then
477         if test "$with_xen" = "yes"; then
478             fail=1
479         fi
480         with_xen=no
481     fi
484 LIBS="$old_LIBS"
485 CFLAGS="$old_CFLAGS"
487 if test $fail = 1; then
488     AC_MSG_ERROR([You must install the Xen development package to compile Xen driver with -lxenstore])
491 if test "$with_xen" = "yes"; then
492     AC_DEFINE_UNQUOTED([WITH_XEN], 1, [whether Xen driver is enabled])
495 AM_CONDITIONAL([WITH_XEN], [test "$with_xen" = "yes"])
496 AC_SUBST([XEN_CFLAGS])
497 AC_SUBST([XEN_LIBS])
500 dnl check for kernel headers required by xen_inotify
502 if test "$with_xen" != "yes"; then
503     with_xen_inotify=no
505 if test "$with_xen_inotify" != "no"; then
506     AC_CHECK_HEADER([sys/inotify.h], [
507         with_xen_inotify=yes
508     ], [
509         if test "$with_xen_inotify" = "check"; then
510             with_xen_inotify=no
511             AC_MSG_NOTICE([Header file <sys/inotify.h> is required for Xen Inotify support, disabling it])
512         else
513             AC_MSG_ERROR([Header file <sys/inotify.h> is required for Xen Inotify support!])
514         fi
515     0])
517 if test "$with_xen_inotify" = "yes"; then
518     AC_DEFINE_UNQUOTED([WITH_XEN_INOTIFY], 1,[whether Xen inotify sub-driver is enabled])
520 AM_CONDITIONAL([WITH_XEN_INOTIFY], [test "$with_xen_inotify" = "yes"])
523 dnl check for kvm headers
525 AC_CHECK_HEADERS([linux/kvm.h])
528 dnl check for sufficient headers for LXC
530 if test "$with_libvirtd" = "no" ; then
531   with_lxc=no
533 if test "$with_lxc" = "yes" || test "$with_lxc" = "check"; then
534     AC_TRY_LINK([#define _GNU_SOURCE
535         #include <sched.h>
536     ], [
537         unshare (1);
538     ], [
539         with_lxc=yes
540     ], [
541         if test "$with_lxc" = "check"; then
542             with_lxc=no
543             AC_MSG_NOTICE([Function unshare() not present in <sched.h> header but required for LXC driver, disabling it])
544         else
545             AC_MSG_ERROR([Function unshare() not present in <sched.h> header, but required for LXC driver])
546         fi
547     ])
549 if test "$with_lxc" = "yes" ; then
550     AC_DEFINE_UNQUOTED([WITH_LXC], 1, [whether LXC driver is enabled])
552 AM_CONDITIONAL([WITH_LXC], [test "$with_lxc" = "yes"])
555 dnl check for shell that understands <> redirection without truncation,
556 dnl needed by src/qemu/qemu_monitor_{text,json}.c.
558 if test "$with_qemu" = yes; then
559   lv_wrapper_shell=
560   AC_CACHE_CHECK([for shell that supports <> redirection],
561     [lv_cv_wrapper_shell],
562     [
563     # If cross-compiling, guess that /bin/sh is good enough except for
564     # Linux, where it might be dash 0.5.5 which is known broken; and on
565     # Linux, we have a good chance that /bin/bash will exist.
566     # If we guess wrong, a user can override the cache variable.
567     # Going through /bin/bash is a slight slowdown if /bin/sh works.
568     if test "$cross_compiling" = yes; then
569       case $host_os in
570         linux*) lv_cv_wrapper_shell=/bin/bash ;;
571         *) lv_cv_wrapper_shell=/bin/sh ;;
572       esac
573     else
574       for lv_cv_wrapper_shell in /bin/sh bash ksh zsh none; do
575         test $lv_cv_wrapper_shell = none &&
576           AC_MSG_ERROR([could not find decent shell])
577         echo a > conftest.a
578         ($lv_cv_wrapper_shell -c ': 1<>conftest.a') 2>/dev/null &&
579         case `cat conftest.a`.$lv_cv_wrapper_shell in
580           a./*) break;; dnl /bin/sh is good enough
581           a.*) dnl bash, ksh, and zsh all understand 'command', use that
582                dnl to determine the absolute path of the shell
583             lv_cv_wrapper_shell=`$lv_cv_wrapper_shell -c \
584               "command -v $lv_cv_wrapper_shell"`
585             case $lv_cv_wrapper_shell in
586               /*) break;;
587             esac
588             ;;
589         esac
590       done
591       rm -f conftest.a
592     fi
593   ])
594   if test "x$lv_cv_wrapper_shell" != x/bin/sh; then
595     lv_wrapper_shell=$lv_cv_wrapper_shell
596   fi
597   if test "x$lv_wrapper_shell" != x; then
598     AC_DEFINE_UNQUOTED([VIR_WRAPPER_SHELL], ["$lv_wrapper_shell"],
599       [Define to the absolute path of a shell that does not truncate on
600        <> redirection, if /bin/sh does not fit the bill])
601   fi
606 dnl check for kernel headers required by src/bridge.c
608 if test "$with_qemu" = "yes" || test "$with_lxc" = "yes" ; then
609   AC_CHECK_HEADERS([linux/param.h linux/sockios.h linux/if_bridge.h linux/if_tun.h],,
610                    AC_MSG_ERROR([You must install kernel-headers in order to compile libvirt with QEMU or LXC support]))
614 dnl Need to test if pkg-config exists
615 PKG_PROG_PKG_CONFIG
617 dnl OpenNebula driver Compilation setting
620 if test "$with_libvirtd" = "no" ; then
621   with_one=no
623 XMLRPC_CFLAGS=
624 XMLRPC_LIBS=
625 if test "x$with_one" = "xyes" || test "x$with_one" = "xcheck"; then
626     PKG_CHECK_MODULES(XMLRPC, xmlrpc_client >= $XMLRPC_REQUIRED,
627       [with_one=yes], [
628       if test "x$with_one" = "xcheck" ; then
629           with_one=no
630       else
631           AC_MSG_ERROR(
632             [You must install XMLRPC-C >= $XMLRPC_REQUIRED to compile libvirt ONE driver])
633       fi
634     ])
635     if test "x$with_one" = "xyes" ; then
636         AC_DEFINE_UNQUOTED([HAVE_XMLRPC], 1,
637           [whether One is used to broadcast server presence])
638     fi
640 AM_CONDITIONAL([HAVE_XMLRPC], [test "x$with_one" = "xyes"])
641 AM_CONDITIONAL([WITH_ONE], [test "x$with_one" = "xyes"])
642 AC_SUBST([XMLRPC_CFLAGS])
643 AC_SUBST([XMLRPC_LIBS])
646 dnl ==========================================================================
647 dnl find libxml2 library, borrowed from xmlsec
648 dnl ==========================================================================
649 LIBXML_CONFIG="xml2-config"
650 LIBXML_CFLAGS=""
651 LIBXML_LIBS=""
652 LIBXML_FOUND="no"
654 AC_ARG_WITH([libxml], AC_HELP_STRING([--with-libxml=@<:@PFX@:>@], [libxml2 location]))
655 if test "x$with_libxml" = "xno" ; then
656     AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_REQUIRED)
657     AC_MSG_ERROR([libxml2 >= $LIBXML_REQUIRED is required for libvirt])
658 elif test "x$with_libxml" = "x" && test "x$PKG_CONFIG" != "x" ; then
659     PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_REQUIRED, [LIBXML_FOUND=yes], [LIBXML_FOUND=no])
661 if test "$LIBXML_FOUND" = "no" ; then
662     if test "x$with_libxml" != "x" ; then
663         LIBXML_CONFIG=$with_libxml/bin/$LIBXML_CONFIG
664     fi
665     AC_MSG_CHECKING(libxml2 $LIBXML_CONFIG >= $LIBXML_REQUIRED )
666     if ! $LIBXML_CONFIG --version > /dev/null 2>&1 ; then
667         AC_MSG_ERROR([Could not find libxml2 anywhere (see config.log for details).])
668     fi
669     vers=`$LIBXML_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
670     minvers=`echo $LIBXML_REQUIRED | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
671     if test "$vers" -ge "$minvers" ; then
672         LIBXML_LIBS="`$LIBXML_CONFIG --libs`"
673         LIBXML_CFLAGS="`$LIBXML_CONFIG --cflags`"
674         LIBXML_FOUND="yes"
675         AC_MSG_RESULT(yes)
676     else
677         AC_MSG_ERROR(
678           [You need at least libxml2 $LIBXML_REQUIRED for this version of libvirt])
679     fi
682 AC_SUBST([LIBXML_CFLAGS])
683 AC_SUBST([LIBXML_LIBS])
685 dnl xmlURI structure has query_raw?
686 old_cflags="$CFLAGS"
687 old_libs="$LIBS"
688 CFLAGS="$CFLAGS $LIBXML_CFLAGS"
689 LIBS="$LIBS $LIBXML_LIBS"
690 AC_CHECK_MEMBER([struct _xmlURI.query_raw],
691                 [AC_DEFINE([HAVE_XMLURI_QUERY_RAW], [], [Have query_raw field in libxml2 xmlURI structure])],,
692                 [#include <libxml/uri.h>])
693 CFLAGS="$old_cflags"
694 LIBS="$old_libs"
696 dnl GnuTLS library
697 GNUTLS_CFLAGS=
698 GNUTLS_LIBS=
699 GNUTLS_FOUND=no
700 if test -x "$PKG_CONFIG" ; then
701   PKG_CHECK_MODULES(GNUTLS, gnutls >= $GNUTLS_REQUIRED,
702      [GNUTLS_FOUND=yes], [GNUTLS_FOUND=no])
704 if test "$GNUTLS_FOUND" = "no"; then
705   fail=0
706   old_libs="$LIBS"
707   AC_CHECK_HEADER([gnutls/gnutls.h], [], [fail=1])
708   AC_CHECK_LIB([gnutls], [gnutls_handshake],[], [fail=1], [-lgcrypt])
710   test $fail = 1 &&
711     AC_MSG_ERROR([You must install the GnuTLS library in order to compile and run libvirt])
713   dnl Not all versions of gnutls include -lgcrypt, and so we add
714   dnl it explicitly for the calls to gcry_control/check_version
715   GNUTLS_LIBS="$LIBS -lgcrypt"
716   LIBS="$old_libs"
717 else
718   GNUTLS_LIBS="$GNUTLS_LIBS -lgcrypt"
721 AC_SUBST([GNUTLS_CFLAGS])
722 AC_SUBST([GNUTLS_LIBS])
724 dnl Old versions of GnuTLS uses types like 'gnutls_session' instead
725 dnl of 'gnutls_session_t'.  Try to detect this type if defined so
726 dnl that we can offer backwards compatibility.
727 old_cflags="$CFLAGS"
728 old_libs="$LIBS"
729 CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
730 LIBS="$LIBS $GNUTLS_LIBS"
731 AC_CHECK_TYPE([gnutls_session],
732         AC_DEFINE([GNUTLS_1_0_COMPAT],[],
733                 [enable GnuTLS 1.0 compatibility macros]),,
734         [#include <gnutls/gnutls.h>])
735 CFLAGS="$old_cflags"
736 LIBS="$old_libs"
739 dnl Cyrus SASL
740 AC_ARG_WITH([sasl],
741   AC_HELP_STRING([--with-sasl], [use cyrus SASL for authentication @<:@default=check@:>@]),
742   [],
743   [with_sasl=check])
745 SASL_CFLAGS=
746 SASL_LIBS=
747 if test "x$with_sasl" != "xno"; then
748   if test "x$with_sasl" != "xyes" && test "x$with_sasl" != "xcheck"; then
749     SASL_CFLAGS="-I$with_sasl"
750     SASL_LIBS="-L$with_sasl"
751   fi
752   fail=0
753   old_cflags="$CFLAGS"
754   old_libs="$LIBS"
755   CFLAGS="$CFLAGS $SASL_CFLAGS"
756   LIBS="$LIBS $SASL_LIBS"
757   AC_CHECK_HEADER([sasl/sasl.h],[],[
758     if test "x$with_sasl" = "xcheck" ; then
759         with_sasl=no
760     else
761         fail=1
762     fi])
763   if test "x$with_sasl" != "xno" ; then
764     AC_CHECK_LIB([sasl2], [sasl_client_init],[
765       SASL_LIBS="$SASL_LIBS -lsasl2"
766       with_sasl=yes
767     ],[
768       AC_CHECK_LIB([sasl], [sasl_client_init],[
769         SASL_LIBS="$SASL_LIBS -lsasl"
770         with_sasl=yes
771       ],[
772         if test "x$with_sasl" = "xcheck" ; then
773           with_sasl=no
774         else
775           fail=1
776         fi
777       ])
778     ])
779   fi
780   test $fail = 1 &&
781     AC_MSG_ERROR([You must install the Cyrus SASL development package in order to compile libvirt])
782   CFLAGS="$old_cflags"
783   LIBS="$old_libs"
784   if test "x$with_sasl" = "xyes" ; then
785     AC_DEFINE_UNQUOTED([HAVE_SASL], 1,
786       [whether Cyrus SASL is available for authentication])
787   fi
789 AM_CONDITIONAL([HAVE_SASL], [test "x$with_sasl" = "xyes"])
790 AC_SUBST([SASL_CFLAGS])
791 AC_SUBST([SASL_LIBS])
794 dnl YAJL JSON library http://lloyd.github.com/yajl/
795 AC_ARG_WITH([yajl],
796   AC_HELP_STRING([--with-yajl], [use YAJL for JSON parsing/formatting @<:@default=check@:>@]),
797   [],
798   [with_yajl=check])
800 YAJL_CFLAGS=
801 YAJL_LIBS=
802 if test "x$with_yajl" != "xno"; then
803   if test "x$with_yajl" != "xyes" && test "x$with_yajl" != "xcheck"; then
804     YAJL_CFLAGS="-I$with_yajl/include"
805     YAJL_LIBS="-L$with_yajl/lib"
806   fi
807   fail=0
808   old_cppflags="$CPPFLAGS"
809   old_libs="$LIBS"
810   CPPFLAGS="$CPPFLAGS $YAJL_CFLAGS"
811   LIBS="$LIBS $YAJL_LIBS"
812   AC_CHECK_HEADER([yajl/yajl_common.h],[],[
813     if test "x$with_yajl" = "xcheck" ; then
814         with_yajl=no
815     else
816         fail=1
817     fi])
818   if test "x$with_yajl" != "xno" ; then
819     AC_CHECK_LIB([yajl], [yajl_parse],[
820       YAJL_LIBS="$YAJL_LIBS -lyajl"
821       with_yajl=yes
822     ],[
823       if test "x$with_yajl" = "xcheck" ; then
824         with_yajl=no
825       else
826         fail=1
827       fi
828     ])
829   fi
830   test $fail = 1 &&
831     AC_MSG_ERROR([You must install the YAJL development package in order to compile libvirt])
832   CPPFLAGS="$old_cppflags"
833   LIBS="$old_libs"
834   if test "x$with_yajl" = "xyes" ; then
835     AC_DEFINE_UNQUOTED([HAVE_YAJL], 1,
836       [whether YAJL is available for JSON parsing/formatting])
837   fi
839 AM_CONDITIONAL([HAVE_YAJL], [test "x$with_yajl" = "xyes"])
840 AC_SUBST([YAJL_CFLAGS])
841 AC_SUBST([YAJL_LIBS])
844 dnl PolicyKit library
845 POLKIT_CFLAGS=
846 POLKIT_LIBS=
847 PKCHECK_PATH=
848 AC_ARG_WITH([polkit],
849   AC_HELP_STRING([--with-polkit], [use PolicyKit for UNIX socket access checks @<:@default=check@:>@]),
850   [],
851   [with_polkit=check])
853 with_polkit0=no
854 with_polkit1=no
855 if test "x$with_polkit" = "xyes" || test "x$with_polkit" = "xcheck"; then
856   dnl Check for new polkit first - just a binary
857   AC_PATH_PROG([PKCHECK_PATH],[pkcheck], [], [/usr/sbin:$PATH])
858   if test "x$PKCHECK_PATH" != "x" ; then
859     AC_DEFINE_UNQUOTED([PKCHECK_PATH],["$PKCHECK_PATH"],[Location of pkcheck program])
860     AC_DEFINE_UNQUOTED([HAVE_POLKIT], 1,
861         [use PolicyKit for UNIX socket access checks])
862     AC_DEFINE_UNQUOTED([HAVE_POLKIT1], 1,
863         [use PolicyKit for UNIX socket access checks])
864     with_polkit="yes"
865     with_polkit1="yes"
866   else
867     dnl Check for old polkit second - library + binary
868     PKG_CHECK_MODULES(POLKIT, polkit-dbus >= $POLKIT_REQUIRED,
869       [with_polkit=yes], [
870       if test "x$with_polkit" = "xcheck" ; then
871          with_polkit=no
872       else
873          AC_MSG_ERROR(
874            [You must install PolicyKit >= $POLKIT_REQUIRED to compile libvirt])
875       fi
876     ])
877     if test "x$with_polkit" = "xyes" ; then
878       AC_DEFINE_UNQUOTED([HAVE_POLKIT], 1,
879         [use PolicyKit for UNIX socket access checks])
880       AC_DEFINE_UNQUOTED([HAVE_POLKIT0], 1,
881         [use PolicyKit for UNIX socket access checks])
883       old_CFLAGS=$CFLAGS
884       old_LIBS=$LIBS
885       CFLAGS="$CFLAGS $POLKIT_CFLAGS"
886       LIBS="$LIBS $POLKIT_LIBS"
887       AC_CHECK_FUNCS([polkit_context_is_caller_authorized])
888       CFLAGS="$old_CFLAGS"
889       LIBS="$old_LIBS"
891       AC_PATH_PROG([POLKIT_AUTH], [polkit-auth])
892       if test "x$POLKIT_AUTH" != "x"; then
893         AC_DEFINE_UNQUOTED([POLKIT_AUTH],["$POLKIT_AUTH"],[Location of polkit-auth program])
894       fi
895       with_polkit0="yes"
896     fi
897   fi
899 AM_CONDITIONAL([HAVE_POLKIT], [test "x$with_polkit" = "xyes"])
900 AM_CONDITIONAL([HAVE_POLKIT0], [test "x$with_polkit0" = "xyes"])
901 AM_CONDITIONAL([HAVE_POLKIT1], [test "x$with_polkit1" = "xyes"])
902 AC_SUBST([POLKIT_CFLAGS])
903 AC_SUBST([POLKIT_LIBS])
905 dnl Avahi library
906 AC_ARG_WITH([avahi],
907   AC_HELP_STRING([--with-avahi], [use avahi to advertise remote daemon @<:@default=check@:>@]),
908   [],
909   [with_avahi=check])
911 AVAHI_CFLAGS=
912 AVAHI_LIBS=
913 if test "x$with_avahi" = "xyes" || test "x$with_avahi" = "xcheck"; then
914   PKG_CHECK_MODULES(AVAHI, avahi-client >= $AVAHI_REQUIRED,
915     [with_avahi=yes], [
916     if test "x$with_avahi" = "xcheck" ; then
917        with_avahi=no
918     else
919        AC_MSG_ERROR(
920          [You must install Avahi >= $AVAHI_REQUIRED to compile libvirt])
921     fi
922   ])
923   if test "x$with_avahi" = "xyes" ; then
924     AC_DEFINE_UNQUOTED([HAVE_AVAHI], 1,
925       [whether Avahi is used to broadcast server presense])
926   fi
928 AM_CONDITIONAL([HAVE_AVAHI], [test "x$with_avahi" = "xyes"])
929 AC_SUBST([AVAHI_CFLAGS])
930 AC_SUBST([AVAHI_LIBS])
932 dnl Audit library
933 AC_ARG_WITH([audit],
934   AC_HELP_STRING([--with-audit], [use audit library @<:@default=check@:>@]),
935   [],
936   [with_audit=check])
938 AUDIT_CFLAGS=
939 AUDIT_LIBS=
940 if test "$with_audit" != "no" ; then
941   old_cflags="$CFLAGS"
942   old_libs="$LIBS"
943   if test "$with_audit" != "check" && "$with_audit" != "yes" ; then
944     AUDIT_CFLAGS="-I$with_audit/include"
945     AUDIT_LIBS="-L$with_audit/lib"
946   fi
947   CFLAGS="$CFLAGS $AUDIT_CFLAGS"
948   LIBS="$LIBS $AUDIT_LIBS"
949   fail=0
950   AC_CHECK_HEADER([libaudit.h], [], [fail=1])
951   AC_CHECK_LIB([audit], [audit_is_enabled], [], [fail=1])
953   if test $fail = 1 ; then
954     if test "$with_audit" = "yes" ; then
955       AC_MSG_ERROR([You must install the Audit library in order to compile and run libvirt])
956     else
957       with_audit=no
958       AUDIT_CFLAGS=
959       AUDIT_LIBS=
960     fi
961   else
962     with_audit=yes
963   fi
965   if test "$with_audit" = "yes" ; then
966     AUDIT_LIBS="$AUDIT_LIBS -laudit"
967     AC_DEFINE_UNQUOTED([HAVE_AUDIT], 1, [whether libaudit is available])
968   fi
970   CFLAGS="$old_cflags"
971   LIBS="$old_libs"
973 AM_CONDITIONAL([HAVE_AUDIT], [test "$with_audit" = "yes"])
974 AC_SUBST([AUDIT_CFLAGS])
975 AC_SUBST([AUDIT_LIBS])
978 dnl SELinux
979 AC_ARG_WITH([selinux],
980   AC_HELP_STRING([--with-selinux], [use SELinux to manage security @<:@default=check@:>@]),
981   [],
982   [with_selinux=check])
984 SELINUX_CFLAGS=
985 SELINUX_LIBS=
986 if test "$with_selinux" != "no"; then
987   old_cflags="$CFLAGS"
988   old_libs="$LIBS"
989   if test "$with_selinux" = "check"; then
990     AC_CHECK_HEADER([selinux/selinux.h],[],[with_selinux=no])
991     AC_CHECK_LIB([selinux], [fgetfilecon],[],[with_selinux=no])
992     if test "$with_selinux" != "no"; then
993       with_selinux="yes"
994     fi
995   else
996     fail=0
997     AC_CHECK_HEADER([selinux/selinux.h],[],[fail=1])
998     AC_CHECK_LIB([selinux], [fgetfilecon],[],[fail=1])
999     test $fail = 1 &&
1000       AC_MSG_ERROR([You must install the libselinux development package in order to compile libvirt with basic SELinux support])
1001   fi
1002   CFLAGS="$old_cflags"
1003   LIBS="$old_libs"
1005 if test "$with_selinux" = "yes"; then
1006   SELINUX_LIBS="-lselinux"
1007   AC_DEFINE_UNQUOTED([HAVE_SELINUX], 1, [whether basic SELinux functionality is available])
1009 AM_CONDITIONAL([HAVE_SELINUX], [test "$with_selinux" != "no"])
1010 AC_SUBST([SELINUX_CFLAGS])
1011 AC_SUBST([SELINUX_LIBS])
1014 AC_ARG_WITH([secdriver-selinux],
1015   AC_HELP_STRING([--with-secdriver-selinux], [use SELinux security driver @<:@default=check@:>@]),
1016   [],
1017   [with_secdriver_selinux=check])
1019 if test "$with_selinux" != "yes" ; then
1020   if test "$with_secdriver_selinux" = "check" ; then
1021     with_secdriver_selinux=no
1022   elif test "$with_secdriver_selinux" = "yes"; then
1023         AC_MSG_ERROR([You must install the libselinux development package and enable SELinux with the --with-selinux=yes in order to compile libvirt --with-secdriver-selinux=yes])
1024   fi
1025 else
1026   old_cflags="$CFLAGS"
1027   old_libs="$LIBS"
1028   CFLAGS="$CFLAGS $SELINUX_CFLAGS"
1029   LIBS="$CFLAGS $SELINUX_LIBS"
1031   fail=0
1032   AC_CHECK_FUNC([selinux_virtual_domain_context_path], [], [fail=1])
1033   AC_CHECK_FUNC([selinux_virtual_image_context_path], [], [fail=1])
1034   CFLAGS="$old_cflags"
1035   LIBS="$old_libs"
1037   if test "$fail" = "1" ; then
1038     if test "$with_secdriver_selinux" = "check" ; then
1039       with_secdriver_selinux=no
1040     else
1041       AC_MSG_ERROR([You must install libselinux development package >= 2.0.82 in order to compile libvirt --with-secdriver-selinux=yes])
1042     fi
1043   else
1044     with_secdriver_selinux=yes
1045     AC_DEFINE_UNQUOTED([WITH_SECDRIVER_SELINUX], 1, [whether SELinux security driver is available])
1046   fi
1048 AM_CONDITIONAL([WITH_SECDRIVER_SELINUX], [test "$with_secdriver_selinux" != "no"])
1051 dnl AppArmor
1052 AC_ARG_WITH([apparmor],
1053   AC_HELP_STRING([--with-apparmor], [use AppArmor to manage security @<:@default=check@:>@]),
1054   [],
1055   [with_apparmor=check])
1057 APPARMOR_CFLAGS=
1058 APPARMOR_LIBS=
1059 if test "$with_apparmor" != "no"; then
1060   old_cflags="$CFLAGS"
1061   old_libs="$LIBS"
1062   if test "$with_apparmor" = "check"; then
1063     AC_CHECK_HEADER([sys/apparmor.h],[],[with_apparmor=no])
1064     AC_CHECK_LIB([apparmor], [aa_change_profile],[],[with_apparmor=no])
1065     AC_CHECK_LIB([apparmor], [aa_change_hat],[],[with_apparmor=no])
1066     if test "$with_apparmor" != "no"; then
1067       with_apparmor="yes"
1068     fi
1069   else
1070     fail=0
1071     AC_CHECK_HEADER([sys/apparmor.h],[],[fail=1])
1072     AC_CHECK_LIB([apparmor], [aa_change_profile],[],[fail=1])
1073     AC_CHECK_LIB([apparmor], [aa_change_hat],[],[fail=1])
1074     test $fail = 1 &&
1075       AC_MSG_ERROR([You must install the AppArmor development package in order to compile libvirt])
1076   fi
1077   CFLAGS="$old_cflags"
1078   LIBS="$old_libs"
1080 if test "$with_apparmor" = "yes"; then
1081   APPARMOR_LIBS="-lapparmor"
1082   AC_DEFINE_UNQUOTED([HAVE_APPARMOR], 1, [whether AppArmor is available for security])
1083   AC_DEFINE_UNQUOTED([APPARMOR_DIR], "/etc/apparmor.d", [path to apparmor directory])
1084   AC_DEFINE_UNQUOTED([APPARMOR_PROFILES_PATH], "/sys/kernel/security/apparmor/profiles", [path to kernel profiles])
1086 AM_CONDITIONAL([HAVE_APPARMOR], [test "$with_apparmor" != "no"])
1087 AC_SUBST([APPARMOR_CFLAGS])
1088 AC_SUBST([APPARMOR_LIBS])
1091 AC_ARG_WITH([secdriver-apparmor],
1092   AC_HELP_STRING([--with-secdriver-apparmor], [use AppArmor security driver @<:@default=check@:>@]),
1093   [],
1094   [with_secdriver_apparmor=check])
1096 if test "$with_apparmor" != "yes" ; then
1097   if test "$with_secdriver_apparmor" = "check" ; then
1098     with_secdriver_apparmor=no
1099   else
1100     AC_MSG_ERROR([You must install the AppArmor development package in order to compile libvirt])
1101   fi
1102 else
1103   old_cflags="$CFLAGS"
1104   old_libs="$LIBS"
1105   CFLAGS="$CFLAGS $APPARMOR_CFLAGS"
1106   LIBS="$CFLAGS $APPARMOR_LIBS"
1108   fail=0
1109   AC_CHECK_FUNC([change_hat], [], [fail=1])
1110   AC_CHECK_FUNC([aa_change_profile], [], [fail=1])
1111   CFLAGS="$old_cflags"
1112   LIBS="$old_libs"
1114   if test "$fail" = "1" ; then
1115     if test "$with_secdriver_apparmor" = "check" ; then
1116       with_secdriver_apparmor=no
1117     else
1118       AC_MSG_ERROR([You must install the AppArmor development package in order to compile libvirt])
1119     fi
1120   else
1121     with_secdriver_apparmor=yes
1122     AC_DEFINE_UNQUOTED([WITH_SECDRIVER_APPARMOR], 1, [whether AppArmor security driver is available])
1123   fi
1125 AM_CONDITIONAL([WITH_SECDRIVER_APPARMOR], [test "$with_secdriver_apparmor" != "no"])
1128 dnl DTrace static probes
1129 AC_ARG_WITH([dtrace],
1130   AC_HELP_STRING([--with-dtrace], [use dtrace for static probing @<:@default=check@:>@]),
1131   [],
1132   [with_dtrace=check])
1134 if test "$with_dtrace" != "no" ; then
1135   AC_PATH_PROG([DTRACE], [dtrace], [], [/bin:/usr/bin])
1136   if test -z "$DTRACE" ; then
1137     if test "$with_dtrace" = "check"; then
1138       with_dtrace=no
1139     else
1140       AC_MSG_ERROR([You must install the 'dtrace' binary to enable libvirt static probes])
1141     fi
1142   else
1143     with_dtrace=yes
1144   fi
1145   if test "$with_dtrace" = "yes"; then
1146     AC_DEFINE_UNQUOTED([WITH_DTRACE], 1, [whether DTrace static probes are available])
1147   fi
1149 AM_CONDITIONAL([WITH_DTRACE], [test "$with_dtrace" != "no"])
1152 dnl NUMA lib
1153 AC_ARG_WITH([numactl],
1154   AC_HELP_STRING([--with-numactl], [use numactl for host topology info @<:@default=check@:>@]),
1155   [],
1156   [with_numactl=check])
1158 NUMACTL_CFLAGS=
1159 NUMACTL_LIBS=
1160 if test "$with_qemu" = "yes" && test "$with_numactl" != "no"; then
1161   old_cflags="$CFLAGS"
1162   old_libs="$LIBS"
1163   if test "$with_numactl" = "check"; then
1164     AC_CHECK_HEADER([numa.h],[],[with_numactl=no])
1165     AC_CHECK_LIB([numa], [numa_available],[],[with_numactl=no])
1166     if test "$with_numactl" != "no"; then
1167       with_numactl="yes"
1168     fi
1169   else
1170     fail=0
1171     AC_CHECK_HEADER([numa.h],[],[fail=1])
1172     AC_CHECK_LIB([numa], [numa_available],[],[fail=1])
1173     test $fail = 1 &&
1174       AC_MSG_ERROR([You must install the numactl development package in order to compile and run libvirt])
1175   fi
1176   CFLAGS="$old_cflags"
1177   LIBS="$old_libs"
1179 if test "$with_numactl" = "yes"; then
1180   NUMACTL_LIBS="-lnuma"
1181   AC_DEFINE_UNQUOTED([HAVE_NUMACTL], 1, [whether numactl is available for topology info])
1183 AM_CONDITIONAL([HAVE_NUMACTL], [test "$with_numactl" != "no"])
1184 AC_SUBST([NUMACTL_CFLAGS])
1185 AC_SUBST([NUMACTL_LIBS])
1188 dnl pcap lib
1189 LIBPCAP_CONFIG="pcap-config"
1190 LIBPCAP_CFLAGS=""
1191 LIBPCAP_LIBS=""
1192 LIBPCAP_FOUND="no"
1194 AC_ARG_WITH([libpcap], AC_HELP_STRING([--with-libpcap=@<:@PFX@:>@], [libpcap location]))
1195 if test "$with_qemu" = "yes"; then
1196     if test "x$with_libpcap" != "xno" ; then
1197         if test "x$with_libpcap" != "x" ; then
1198             LIBPCAP_CONFIG=$with_libpcap/bin/$LIBPCAP_CONFIG
1199         fi
1200         AC_MSG_CHECKING(libpcap $LIBPCAP_CONFIG >= $LIBPCAP_REQUIRED )
1201         if ! $LIBPCAP_CONFIG --libs > /dev/null 2>&1 ; then
1202             AC_MSG_RESULT(no)
1203         else
1204             LIBPCAP_LIBS="`$LIBPCAP_CONFIG --libs`"
1205             LIBPCAP_CFLAGS="`$LIBPCAP_CONFIG --cflags`"
1206             LIBPCAP_FOUND="yes"
1207             AC_MSG_RESULT(yes)
1208         fi
1209     fi
1212 if test "x$LIBPCAP_FOUND" = "xyes"; then
1213   AC_DEFINE_UNQUOTED([HAVE_LIBPCAP], 1, [whether libpcap can be used])
1216 AC_SUBST([LIBPCAP_CFLAGS])
1217 AC_SUBST([LIBPCAP_LIBS])
1222 dnl Checks for the UML driver
1225 if test "$with_libvirtd" = "no" ; then
1226   with_uml=no
1228 if test "$with_uml" = "yes" || test "$with_uml" = "check"; then
1229     AC_CHECK_HEADER([sys/inotify.h], [
1230         with_uml=yes
1231     ], [
1232         if test "$with_uml" = "check"; then
1233             with_uml=no
1234             AC_MSG_NOTICE([<sys/inotify.h> is required for the UML driver, disabling it])
1235         else
1236             AC_MSG_ERROR([The <sys/inotify.h> is required for the UML driver. Upgrade your libc6.])
1237         fi
1238     ])
1240 if test "$with_uml" = "yes" ; then
1241     AC_DEFINE_UNQUOTED([WITH_UML], 1, [whether UML driver is enabled])
1243 AM_CONDITIONAL([WITH_UML], [test "$with_uml" = "yes"])
1248 dnl libssh checks
1251 if test "$with_libssh2" != "yes" && test "$with_libssh2" != "no"; then
1252                 libssh2_path="$with_libssh2"
1253 elif test "$with_libssh2" = "yes"; then
1254                 libssh2_path="/usr/local/lib/"
1255 elif test "$with_libssh2" = "no"; then
1256                 with_phyp="no";
1259 if test "$with_phyp" = "check"; then
1260     AC_CHECK_LIB([ssh2],[libssh2_session_startup],[
1261         LIBSSH2_LIBS="$LIBSSH2_LIBS -lssh2 -L$libssh2_path"
1262         AC_SUBST([LIBSSH2_LIBS])
1263     ],[
1264         with_phyp="no"
1265         with_libssh2="no";
1266     ],[])
1268     if test "$with_phyp" != "no"; then
1269         AC_CHECK_HEADERS([libssh2.h],[
1270             with_phyp="yes"
1271             LIBSSH2_CFLAGS="-I/usr/local/include"
1272             AC_SUBST([LIBSSH2_CFLAGS])
1273         ],[
1274             with_phyp="no"
1275             with_libssh2="no";
1276         ],[
1277         ])
1278     fi
1280     if test "$with_phyp" != "no"; then
1281         saved_libs="$LIBS"
1282         LIBS="$LIBS -L$libssh2_path -lssh2"
1283         AC_TRY_LINK([#include <libssh2.h>], [
1284             (void) libssh2_session_block_directions(NULL);
1285         ], [
1286             AC_DEFINE_UNQUOTED([WITH_PHYP], 1, [whether IBM HMC / IVM driver is enabled])
1287         ], [
1288             with_phyp=no
1289             AC_MSG_NOTICE([Function libssh2_session_block_directions() not present in  your version of libssh2 but required for Phyp driver, disabling it])
1290         ])
1291         LIBS="$saved_libs"
1292     fi
1293 elif test "$with_phyp" = "yes"; then
1294   AC_CHECK_LIB([ssh2],[libssh2_session_startup],[
1295         LIBSSH2_LIBS="$LIBSSH2_LIBS -lssh2 -L$libssh2_path"
1296         AC_SUBST([LIBSSH2_LIBS])],[
1297         AC_MSG_ERROR([You must install the libssh2 to compile Phyp driver.])
1298                                 ])
1300   AC_CHECK_HEADERS([libssh2.h],[
1301         LIBSSH2_CFLAGS="-I/usr/local/include"
1302         AC_SUBST([LIBSSH2_CFLAGS])],[
1303         AC_MSG_ERROR([Cannot find libssh2 headers. Is libssh2 installed ?])
1304                                 ],[])
1306   saved_libs="$LIBS"
1307   LIBS="$LIBS -lssh2"
1308   AC_TRY_LINK([#include <libssh2.h>], [
1309   (void) libssh2_session_block_directions(NULL);
1310   ], [], [
1311   AC_MSG_ERROR([Function libssh2_session_block_directions() not present in your version of libssh2. Need >= 1.0])
1312   ])
1313   LIBS="$saved_libs"
1315   AC_DEFINE_UNQUOTED([WITH_PHYP], 1,
1316         [whether IBM HMC / IVM driver is enabled])
1318 AM_CONDITIONAL([WITH_PHYP],[test "$with_phyp" = "yes"])
1320 dnl libcap-ng
1321 AC_ARG_WITH([capng],
1322   AC_HELP_STRING([--with-capng], [use libcap-ng to reduce libvirtd privileges @<:@default=check@:>@]),
1323   [],
1324   [with_capng=check])
1327 dnl This check looks for 'capng_updatev' since that was
1328 dnl introduced in 0.4.0 release which need as minimum
1330 CAPNG_CFLAGS=
1331 CAPNG_LIBS=
1332 if test "$with_qemu" = "yes" && test "$with_capng" != "no"; then
1333   old_cflags="$CFLAGS"
1334   old_libs="$LIBS"
1335   if test "$with_capng" = "check"; then
1336     AC_CHECK_HEADER([cap-ng.h],[],[with_capng=no])
1337     AC_CHECK_LIB([cap-ng], [capng_updatev],[],[with_capng=no])
1338     if test "$with_capng" != "no"; then
1339       with_capng="yes"
1340     fi
1341   else
1342     fail=0
1343     AC_CHECK_HEADER([cap-ng.h],[],[fail=1])
1344     AC_CHECK_LIB([cap-ng], [capng_updatev],[],[fail=1])
1345     test $fail = 1 &&
1346       AC_MSG_ERROR([You must install the capng >= 0.4.0 development package in order to compile and run libvirt])
1347   fi
1348   CFLAGS="$old_cflags"
1349   LIBS="$old_libs"
1351 if test "$with_capng" = "yes"; then
1352   CAPNG_LIBS="-lcap-ng"
1353   AC_DEFINE_UNQUOTED([HAVE_CAPNG], 1, [whether capng is available for privilege reduction])
1355 AM_CONDITIONAL([HAVE_CAPNG], [test "$with_capng" != "no"])
1356 AC_SUBST([CAPNG_CFLAGS])
1357 AC_SUBST([CAPNG_LIBS])
1361 dnl virsh libraries
1362 AC_CHECK_HEADERS([readline/readline.h])
1364 # Check for readline.
1365 AC_CHECK_LIB([readline], [readline],
1366         [lv_use_readline=yes; VIRSH_LIBS="$VIRSH_LIBS -lreadline"],
1367         [lv_use_readline=no])
1369 # If the above test failed, it may simply be that -lreadline requires
1370 # some termcap-related code, e.g., from one of the following libraries.
1371 # See if adding one of them to LIBS helps.
1372 if test $lv_use_readline = no; then
1373     lv_saved_libs=$LIBS
1374     LIBS=
1375     AC_SEARCH_LIBS([tgetent], [ncurses curses termcap termlib])
1376     case $LIBS in
1377       no*) ;;  # handle "no" and "none required"
1378       *) # anything else is a -lLIBRARY
1379         # Now, check for -lreadline again, also using $LIBS.
1380         # Note: this time we use a different function, so that
1381         # we don't get a cached "no" result.
1382         AC_CHECK_LIB([readline], [rl_initialize],
1383                 [lv_use_readline=yes
1384                  VIRSH_LIBS="$VIRSH_LIBS -lreadline $LIBS"],,
1385                 [$LIBS])
1386         ;;
1387     esac
1388     test $lv_use_readline = no &&
1389         AC_MSG_WARN([readline library not found])
1390     LIBS=$lv_saved_libs
1393 if test $lv_use_readline = yes; then
1394     AC_DEFINE_UNQUOTED([USE_READLINE], 1,
1395                        [whether virsh can use readline])
1396     READLINE_CFLAGS=-DUSE_READLINE
1397 else
1398     READLINE_CFLAGS=
1400 AC_SUBST([READLINE_CFLAGS])
1401 AC_SUBST([VIRSH_LIBS])
1403 dnl check if the network driver should be compiled
1405 AC_ARG_WITH([network],
1406   AC_HELP_STRING([--with-network], [with virtual network driver @<:@default=yes@:>@]),[],[with_network=yes])
1408 dnl there's no use compiling the network driver without the libvirt
1409 dnl daemon, nor compiling it for MacOS X, where it breaks the compile
1411 if test "$with_libvirtd" = "no" || test "$with_osx" = "yes"; then
1412   with_network=no
1415 if test "$with_network" = "yes" ; then
1416   AC_DEFINE_UNQUOTED([WITH_NETWORK], 1, [whether network driver is enabled])
1418 AM_CONDITIONAL([WITH_NETWORK], [test "$with_network" = "yes"])
1420 with_bridge=no
1421 if test "$with_qemu:$with_lxc:$with_network" != "no:no:no"; then
1422     with_bridge=yes
1423     AC_DEFINE_UNQUOTED([WITH_BRIDGE], 1, [whether bridge code is needed])
1425 AM_CONDITIONAL([WITH_BRIDGE], [test "$with_bridge" = "yes"])
1427 dnl netcf library
1428 AC_ARG_WITH([netcf],
1429   AC_HELP_STRING([--with-netcf], [libnetcf support to configure physical host network interfaces @<:@default=check@:>@]),
1430 [], [with_netcf=check])
1432 NETCF_CFLAGS=
1433 NETCF_LIBS=
1434 if test "$with_netcf" = "yes" || test "$with_netcf" = "check"; then
1435   PKG_CHECK_MODULES(NETCF, netcf >= $NETCF_REQUIRED,
1436     [with_netcf=yes], [
1437     if test "$with_netcf" = "check" ; then
1438        with_netcf=no
1439     else
1440        AC_MSG_ERROR(
1441          [You must install libnetcf >= $NETCF_REQUIRED to compile libvirt])
1442     fi
1443   ])
1444   if test "$with_netcf" = "yes" ; then
1445     AC_DEFINE_UNQUOTED([WITH_NETCF], 1,
1446       [whether libnetcf is available to configure physical host network interfaces])
1447   fi
1449 AM_CONDITIONAL([WITH_NETCF], [test "$with_netcf" = "yes"])
1450 AC_SUBST([NETCF_CFLAGS])
1451 AC_SUBST([NETCF_LIBS])
1454 with_secrets=yes
1455 if test "$with_libvirtd" = "no"; then
1456   with_secrets=no
1458 if test "$with_secrets" = "yes" ; then
1459   AC_DEFINE_UNQUOTED([WITH_SECRETS], 1, [whether local secrets management driver is available])
1461 AM_CONDITIONAL([WITH_SECRETS], [test "$with_secrets" = "yes"])
1464 AC_ARG_WITH([storage-fs],
1465   AC_HELP_STRING([--with-storage-fs], [with FileSystem backend for the storage driver @<:@default=check@:>@]),[],[with_storage_fs=check])
1466 AC_ARG_WITH([storage-lvm],
1467   AC_HELP_STRING([--with-storage-lvm], [with LVM backend for the storage driver @<:@default=check@:>@]),[],[with_storage_lvm=check])
1468 AC_ARG_WITH([storage-iscsi],
1469   AC_HELP_STRING([--with-storage-iscsi], [with iSCSI backend for the storage driver @<:@default=check@:>@]),[],[with_storage_iscsi=check])
1470 AC_ARG_WITH([storage-scsi],
1471   AC_HELP_STRING([--with-storage-scsi], [with SCSI backend for the storage driver @<:@default=check@:>@]),[],[with_storage_scsi=check])
1472 AC_ARG_WITH([storage-mpath],
1473   AC_HELP_STRING([--with-storage-mpath], [with mpath backend for the storage driver @<:@default=check@:>@]),[],[with_storage_mpath=check])
1474 AC_ARG_WITH([storage-disk],
1475   AC_HELP_STRING([--with-storage-disk], [with GPartd Disk backend for the storage driver @<:@default=check@:>@]),[],[with_storage_disk=check])
1477 with_storage_dir=yes
1478 if test "$with_libvirtd" = "no"; then
1479   with_storage_dir=no
1480   with_storage_fs=no
1481   with_storage_lvm=no
1482   with_storage_iscsi=no
1483   with_storage_scsi=no
1484   with_storage_mpath=no
1485   with_storage_disk=no
1487 if test "$with_storage_dir" = "yes" ; then
1488   AC_DEFINE_UNQUOTED([WITH_STORAGE_DIR], 1, [whether directory backend for storage driver is enabled])
1490 AM_CONDITIONAL([WITH_STORAGE_DIR], [test "$with_storage_dir" = "yes"])
1492 dnl storage-fs does not work on MacOS X
1494 if test "$with_osx" = "yes"; then
1495   with_storage_fs=no
1498 if test "$with_storage_fs" = "yes" || test "$with_storage_fs" = "check"; then
1499   AC_PATH_PROG([MOUNT], [mount], [], [$PATH:/sbin:/usr/sbin])
1500   AC_PATH_PROG([UMOUNT], [umount], [], [$PATH:/sbin:/usr/sbin])
1501   if test "$with_storage_fs" = "yes" ; then
1502     if test -z "$MOUNT" ; then AC_MSG_ERROR([We need mount for FS storage driver]) ; fi
1503     if test -z "$UMOUNT" ; then AC_MSG_ERROR([We need umount for FS storage driver]) ; fi
1504   else
1505     if test -z "$MOUNT" ; then with_storage_fs=no ; fi
1506     if test -z "$UMOUNT" ; then with_storage_fs=no ; fi
1508     if test "$with_storage_fs" = "check" ; then with_storage_fs=yes ; fi
1509   fi
1511   if test "$with_storage_fs" = "yes" ; then
1512     AC_DEFINE_UNQUOTED([WITH_STORAGE_FS], 1, [whether FS backend for storage driver is enabled])
1513     AC_DEFINE_UNQUOTED([MOUNT],["$MOUNT"],
1514         [Location or name of the mount program])
1515     AC_DEFINE_UNQUOTED([UMOUNT],["$UMOUNT"],
1516         [Location or name of the mount program])
1517   fi
1519 AM_CONDITIONAL([WITH_STORAGE_FS], [test "$with_storage_fs" = "yes"])
1520 if test "$with_storage_fs" = "yes"; then
1521   AC_PATH_PROG([SHOWMOUNT], [showmount], [], [$PATH:/sbin:/usr/sbin])
1522   AC_DEFINE_UNQUOTED([SHOWMOUNT], ["$SHOWMOUNT"],
1523     [Location or name of the showmount program])
1526 if test "$with_storage_lvm" = "yes" || test "$with_storage_lvm" = "check"; then
1527   AC_PATH_PROG([PVCREATE], [pvcreate], [], [$PATH:/sbin:/usr/sbin])
1528   AC_PATH_PROG([VGCREATE], [vgcreate], [], [$PATH:/sbin:/usr/sbin])
1529   AC_PATH_PROG([LVCREATE], [lvcreate], [], [$PATH:/sbin:/usr/sbin])
1530   AC_PATH_PROG([PVREMOVE], [pvremove], [], [$PATH:/sbin:/usr/sbin])
1531   AC_PATH_PROG([VGREMOVE], [vgremove], [], [$PATH:/sbin:/usr/sbin])
1532   AC_PATH_PROG([LVREMOVE], [lvremove], [], [$PATH:/sbin:/usr/sbin])
1533   AC_PATH_PROG([VGCHANGE], [vgchange], [], [$PATH:/sbin:/usr/sbin])
1534   AC_PATH_PROG([VGSCAN], [vgscan], [], [$PATH:/sbin:/usr/sbin])
1535   AC_PATH_PROG([PVS], [pvs], [], [$PATH:/sbin:/usr/sbin])
1536   AC_PATH_PROG([VGS], [vgs], [], [$PATH:/sbin:/usr/sbin])
1537   AC_PATH_PROG([LVS], [lvs], [], [$PATH:/sbin:/usr/sbin])
1539   if test "$with_storage_lvm" = "yes" ; then
1540     if test -z "$PVCREATE" ; then AC_MSG_ERROR([We need pvcreate for LVM storage driver]) ; fi
1541     if test -z "$VGCREATE" ; then AC_MSG_ERROR([We need vgcreate for LVM storage driver]) ; fi
1542     if test -z "$LVCREATE" ; then AC_MSG_ERROR([We need lvcreate for LVM storage driver]) ; fi
1543     if test -z "$PVREMOVE" ; then AC_MSG_ERROR([We need pvremove for LVM storage driver]) ; fi
1544     if test -z "$VGREMOVE" ; then AC_MSG_ERROR([We need vgremove for LVM storage driver]) ; fi
1545     if test -z "$LVREMOVE" ; then AC_MSG_ERROR([We need lvremove for LVM storage driver]) ; fi
1546     if test -z "$VGCHANGE" ; then AC_MSG_ERROR([We need vgchange for LVM storage driver]) ; fi
1547     if test -z "$VGSCAN" ; then AC_MSG_ERROR([We need vgscan for LVM storage driver]) ; fi
1548     if test -z "$PVS" ; then AC_MSG_ERROR([We need pvs for LVM storage driver]) ; fi
1549     if test -z "$VGS" ; then AC_MSG_ERROR([We need vgs for LVM storage driver]) ; fi
1550     if test -z "$LVS" ; then AC_MSG_ERROR([We need lvs for LVM storage driver]) ; fi
1551   else
1552     if test -z "$PVCREATE" ; then with_storage_lvm=no ; fi
1553     if test -z "$VGCREATE" ; then with_storage_lvm=no ; fi
1554     if test -z "$LVCREATE" ; then with_storage_lvm=no ; fi
1555     if test -z "$PVREMOVE" ; then with_storage_lvm=no ; fi
1556     if test -z "$VGREMOVE" ; then with_storage_lvm=no ; fi
1557     if test -z "$LVREMOVE" ; then with_storage_lvm=no ; fi
1558     if test -z "$VGCHANGE" ; then with_storage_lvm=no ; fi
1559     if test -z "$VGSCAN" ; then with_storage_lvm=no ; fi
1560     if test -z "$PVS" ; then with_storage_lvm=no ; fi
1561     if test -z "$VGS" ; then with_storage_lvm=no ; fi
1562     if test -z "$LVS" ; then with_storage_lvm=no ; fi
1564     if test "$with_storage_lvm" = "check" ; then with_storage_lvm=yes ; fi
1565   fi
1567   if test "$with_storage_lvm" = "yes" ; then
1568     AC_DEFINE_UNQUOTED([WITH_STORAGE_LVM], 1, [whether LVM backend for storage driver is enabled])
1569     AC_DEFINE_UNQUOTED([PVCREATE],["$PVCREATE"],[Location of pvcreate program])
1570     AC_DEFINE_UNQUOTED([VGCREATE],["$VGCREATE"],[Location of vgcreate program])
1571     AC_DEFINE_UNQUOTED([LVCREATE],["$LVCREATE"],[Location of lvcreate program])
1572     AC_DEFINE_UNQUOTED([PVREMOVE],["$PVREMOVE"],[Location of pvcreate program])
1573     AC_DEFINE_UNQUOTED([VGREMOVE],["$VGREMOVE"],[Location of vgcreate program])
1574     AC_DEFINE_UNQUOTED([LVREMOVE],["$LVREMOVE"],[Location of lvcreate program])
1575     AC_DEFINE_UNQUOTED([VGCHANGE],["$VGCHANGE"],[Location of vgchange program])
1576     AC_DEFINE_UNQUOTED([VGSCAN],["$VGSCAN"],[Location of vgscan program])
1577     AC_DEFINE_UNQUOTED([PVS],["$PVS"],[Location of pvs program])
1578     AC_DEFINE_UNQUOTED([VGS],["$VGS"],[Location of vgs program])
1579     AC_DEFINE_UNQUOTED([LVS],["$LVS"],[Location of lvs program])
1580   fi
1582 AM_CONDITIONAL([WITH_STORAGE_LVM], [test "$with_storage_lvm" = "yes"])
1586 if test "$with_storage_iscsi" = "yes" || test "$with_storage_iscsi" = "check"; then
1587   AC_PATH_PROG([ISCSIADM], [iscsiadm], [], [$PATH:/sbin:/usr/sbin])
1588   if test "$with_storage_iscsi" = "yes" ; then
1589     if test -z "$ISCSIADM" ; then AC_MSG_ERROR([We need iscsiadm for iSCSI storage driver]) ; fi
1590   else
1591     if test -z "$ISCSIADM" ; then with_storage_iscsi=no ; fi
1593     if test "$with_storage_iscsi" = "check" ; then with_storage_iscsi=yes ; fi
1594   fi
1596   if test "$with_storage_iscsi" = "yes" ; then
1597     AC_DEFINE_UNQUOTED([WITH_STORAGE_ISCSI], 1, [whether iSCSI backend for storage driver is enabled])
1598     AC_DEFINE_UNQUOTED([ISCSIADM],["$ISCSIADM"],[Location of iscsiadm program])
1599   fi
1601 AM_CONDITIONAL([WITH_STORAGE_ISCSI], [test "$with_storage_iscsi" = "yes"])
1603 if test "$with_storage_scsi" = "check"; then
1604    with_storage_scsi=yes
1606    AC_DEFINE_UNQUOTED([WITH_STORAGE_SCSI], 1,
1607      [whether SCSI backend for storage driver is enabled])
1609 AM_CONDITIONAL([WITH_STORAGE_SCSI], [test "$with_storage_scsi" = "yes"])
1611 if test "$with_storage_mpath" = "check" && test "$with_linux" = "yes"; then
1612    with_storage_mpath=yes
1614    AC_DEFINE_UNQUOTED([WITH_STORAGE_MPATH], 1,
1615      [whether mpath backend for storage driver is enabled])
1617 AM_CONDITIONAL([WITH_STORAGE_MPATH], [test "$with_storage_mpath" = "yes"])
1619 if test "$with_storage_mpath" = "yes"; then
1620    DEVMAPPER_CFLAGS=
1621    DEVMAPPER_LIBS=
1622    PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= $DEVMAPPER_REQUIRED], [], [DEVMAPPER_FOUND=no])
1623    if test "$DEVMAPPER_FOUND" = "no"; then
1624      # devmapper is missing pkg-config files in ubuntu, suse, etc
1625      save_LIBS="$LIBS"
1626      save_CFLAGS="$CFLAGS"
1627      DEVMAPPER_FOUND=yes
1628      AC_CHECK_HEADER([libdevmapper.h],,[DEVMAPPER_FOUND=no])
1629      AC_CHECK_LIB([devmapper], [dm_task_run],,[DEVMAPPER_FOUND=no])
1630      DEVMAPPER_LIBS="-ldevmapper"
1631      LIBS="$save_LIBS"
1632      CFLAGS="$save_CFLAGS"
1633    fi
1634    if test "$DEVMAPPER_FOUND" = "no" ; then
1635      AC_MSG_ERROR([You must install device-mapper-devel/libdevmapper >= $DEVMAPPER_REQUIRED to compile libvirt])
1636    fi
1639 AC_SUBST([DEVMAPPER_CFLAGS])
1640 AC_SUBST([DEVMAPPER_LIBS])
1642 LIBPARTED_CFLAGS=
1643 LIBPARTED_LIBS=
1644 if test "$with_storage_disk" = "yes" || test "$with_storage_disk" = "check"; then
1645   AC_PATH_PROG([PARTED], [parted], [], [$PATH:/sbin:/usr/sbin])
1646   if test -z "$PARTED" ; then
1647     with_storage_disk=no
1648     PARTED_FOUND=no
1649   else
1650     PARTED_FOUND=yes
1651   fi
1653   if test "$with_storage_disk" != "no" && test "x$PKG_CONFIG" != "x" ; then
1654     PKG_CHECK_MODULES(LIBPARTED, libparted >= $PARTED_REQUIRED, [], [PARTED_FOUND=no])
1655   fi
1656   if test "$PARTED_FOUND" = "no"; then
1657     # RHEL-5 vintage parted is missing pkg-config files
1658     save_LIBS="$LIBS"
1659     save_CFLAGS="$CFLAGS"
1660     PARTED_FOUND=yes
1661     AC_CHECK_HEADER([parted/parted.h],,[PARTED_FOUND=no])
1662     AC_CHECK_LIB([uuid], [uuid_generate],,[PARTED_FOUND=no])
1663     AC_CHECK_LIB([parted], [ped_device_read],,[PARTED_FOUND=no])
1664     LIBPARTED_LIBS="-luuid -lparted"
1665     LIBS="$save_LIBS"
1666     CFLAGS="$save_CFLAGS"
1667   fi
1669   if test "$PARTED_FOUND" = "no" ; then
1670     if test "$with_storage_disk" = "yes" ; then
1671       AC_MSG_ERROR([We need parted for disk storage driver])
1672     else
1673       with_storage_disk=no
1674     fi
1675   else
1676     with_storage_disk=yes
1677   fi
1679   if test "$with_storage_disk" = "yes"; then
1680     AC_DEFINE_UNQUOTED([WITH_STORAGE_DISK], 1, [whether Disk backend for storage driver is enabled])
1681     AC_DEFINE_UNQUOTED([PARTED],["$PARTED"], [Location or name of the parted program])
1682   fi
1684 AM_CONDITIONAL([WITH_STORAGE_DISK], [test "$with_storage_disk" = "yes"])
1685 AC_SUBST([LIBPARTED_CFLAGS])
1686 AC_SUBST([LIBPARTED_LIBS])
1689 dnl check for libcurl (ESX/XenAPI)
1692 LIBCURL_CFLAGS=""
1693 LIBCURL_LIBS=""
1695 if test "$with_esx" = "yes" || test "$with_esx" = "check" || test "$with_xenapi" = "yes" || test "$with_xenapi" = "check"; then
1696     PKG_CHECK_MODULES(LIBCURL, libcurl >= $LIBCURL_REQUIRED, [
1697         if test "$with_esx" = "check"; then
1698             with_esx=yes
1699         fi
1701         if test "$with_xenapi" = "check"; then
1702             with_xenapi=yes
1703         fi
1704     ], [
1705         if test "$with_esx" = "check"; then
1706             with_esx=no
1707             AC_MSG_NOTICE([libcurl is required for the ESX driver, disabling it])
1708         elif test "$with_esx" = "yes"; then
1709             AC_MSG_ERROR([libcurl >= $LIBCURL_REQUIRED is required for the ESX driver])
1710         fi
1712         if test "$with_xenapi" = "check"; then
1713             with_xenapi=no
1714             AC_MSG_NOTICE([libcurl is required for the XenAPI driver, disabling it])
1715         elif test "$with_xenapi" = "yes"; then
1716             AC_MSG_ERROR([libcurl >= $LIBCURL_REQUIRED is required for the XenAPI driver])
1717         fi
1718     ])
1722 if test "$with_esx" = "yes" ; then
1723     AC_DEFINE_UNQUOTED([WITH_ESX], 1, [whether ESX driver is enabled])
1725 AM_CONDITIONAL([WITH_ESX], [test "$with_esx" = "yes"])
1727 if test "$with_xenapi" = "yes" ; then
1728     AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled])
1730 AM_CONDITIONAL([WITH_XENAPI], [test "$with_xenapi" = "yes"])
1732 # XXX as of libcurl-devel-7.20.1-3.fc13.x86_64, curl ships a version
1733 # of <curl/curl.h> that #defines several wrapper macros around underlying
1734 # functions to add type safety for gcc only.  However, these macros
1735 # spuriously trip gcc's -Wlogical-op warning.  Avoid the warning by
1736 # disabling the wrappers; even if it removes some type-check safety.
1737 LIBCURL_CFLAGS="-DCURL_DISABLE_TYPECHECK $LIBCURL_CFLAGS"
1739 AC_SUBST([LIBCURL_CFLAGS])
1740 AC_SUBST([LIBCURL_LIBS])
1743 dnl check for python
1746 AC_ARG_WITH([python],
1747   AC_HELP_STRING([--with-python], [Build python bindings @<:@default=yes@:>@]),[],[with_python=yes])
1749 if test "$enable_shared:$with_python" = no:yes; then
1750   AC_MSG_WARN([Disabling shared libraries is incompatible with building Python extensions.])
1751   AC_MSG_WARN([Ignoring --with-python.])
1752   with_python=no
1755 PYTHON_VERSION=
1756 PYTHON_INCLUDES=
1757 if test "$with_python" != "no" ; then
1758     if test -x "$with_python/bin/python"
1759     then
1760         AC_MSG_NOTICE(Found python in $with_python/bin/python)
1761         PYTHON="$with_python/bin/python"
1762         with_python=yes
1763     else
1764         if test -x "$with_python"
1765         then
1766             AC_MSG_NOTICE(Found python in $with_python)
1767             PYTHON="$with_python"
1768             with_python=yes
1769         else
1770             if test -x "$PYTHON"
1771             then
1772                 AC_MSG_NOTICE(Found python in environment PYTHON=$PYTHON)
1773                 with_python=yes
1774             fi
1775         fi
1776     fi
1778     if test "$with_python" == "yes" ; then
1779         AM_PATH_PYTHON(,, [:])
1781         if test "$PYTHON" != : ; then
1782             PYTHON_CONFIG="$PYTHON-config"
1784             if test -x "$PYTHON_CONFIG"
1785             then
1786                 PYTHON_INCLUDES=`$PYTHON_CONFIG --includes`
1787             else
1788                 if test -r $PYTHON_EXEC_PREFIX/include/python$PYTHON_VERSION/Python.h
1789                 then
1790                     PYTHON_INCLUDES=-I$PYTHON_EXEC_PREFIX/include/python$PYTHON_VERSION
1791                 else
1792                     if test -r $prefix/include/python$PYTHON_VERSION/Python.h
1793                     then
1794                         PYTHON_INCLUDES=-I$prefix/include/python$PYTHON_VERSION
1795                     else
1796                         if test -r /usr/include/python$PYTHON_VERSION/Python.h
1797                         then
1798                             PYTHON_INCLUDES=-I/usr/include/python$PYTHON_VERSION
1799                         else
1800                             AC_MSG_NOTICE([Could not find python$PYTHON_VERSION/Python.h, disabling bindings])
1801                             with_python=no
1802                         fi
1803                     fi
1804                 fi
1805             fi
1806         else
1807             AC_MSG_NOTICE([Could not find python interpreter, disabling bindings])
1808             with_python=no
1809         fi
1810     else
1811         AC_MSG_NOTICE([Could not find python in $with_python, disabling bindings])
1812         with_python=no
1813     fi
1815 AM_CONDITIONAL([WITH_PYTHON], [test "$with_python" = "yes"])
1816 AC_SUBST([PYTHON_VERSION])
1817 AC_SUBST([PYTHON_INCLUDES])
1821 AC_MSG_CHECKING([whether this host is running a Xen kernel])
1822 RUNNING_XEN=
1823 if test -d /proc/sys/xen
1824 then
1825     RUNNING_XEN=yes
1826 else
1827     RUNNING_XEN=no
1829 AC_MSG_RESULT($RUNNING_XEN)
1831 AC_MSG_CHECKING([If XenD UNIX socket /var/run/xend/xmlrpc.sock is accessible])
1832 RUNNING_XEND=
1833 if test -S /var/run/xend/xmlrpc.sock
1834 then
1835     RUNNING_XEND=yes
1836 else
1837     RUNNING_XEND=no
1839 AC_MSG_RESULT($RUNNING_XEND)
1841 AM_CONDITIONAL([ENABLE_XEN_TESTS], [test "$RUNNING_XEN" != "no" && test "$RUNNING_XEND" != "no"])
1843 AC_ARG_ENABLE([test-coverage],
1844   AC_HELP_STRING([--enable-test-coverage], [turn on code coverage instrumentation @<:@default=no@:>@]),
1845 [case "${enableval}" in
1846    yes|no) ;;
1847    *)      AC_MSG_ERROR([bad value ${enableval} for test-coverage option]) ;;
1848  esac],
1849               [enableval=no])
1850 enable_coverage=$enableval
1852 if test "${enable_coverage}" = yes; then
1853   COMPILER_FLAGS=
1854   gl_COMPILER_FLAGS(-fprofile-arcs)
1855   gl_COMPILER_FLAGS(-ftest-coverage)
1856   AC_SUBST([COVERAGE_CFLAGS], [$COMPILER_FLAGS])
1857   AC_SUBST([COVERAGE_LDFLAGS], [$COMPILER_FLAGS])
1858   COMPILER_FLAGS=
1861 AC_ARG_ENABLE([test-oom],
1862   AC_HELP_STRING([--enable-test-oom], [memory allocation failure checking @<:@default=no@:>@]),
1863 [case "${enableval}" in
1864    yes|no) ;;
1865    *)      AC_MSG_ERROR([bad value ${enableval} for test-oom option]) ;;
1866  esac],
1867               [enableval=no])
1868 enable_oom=$enableval
1870 if test "${enable_oom}" = yes; then
1871   have_trace=yes
1872   AC_CHECK_HEADER([execinfo.h],[],[have_trace=no])
1873   AC_CHECK_FUNC([backtrace],[],[have_trace=no])
1874   if test "$have_trace" = "yes"; then
1875     AC_DEFINE([TEST_OOM_TRACE], 1, [Whether backtrace() is available])
1876   fi
1877   AC_DEFINE([TEST_OOM], 1, [Whether malloc OOM checking is enabled])
1881 AC_ARG_ENABLE([test-locking],
1882   AC_HELP_STRING([--enable-test-locking], [thread locking tests using CIL @<:@default=no@:>@]),
1883 [case "${enableval}" in
1884    yes|no) ;;
1885    *)      AC_MSG_ERROR([bad value ${enableval} for test-locking option]) ;;
1886  esac],
1887               [enableval=no])
1888 enable_locking=$enableval
1890 if test "$enable_locking" = "yes"; then
1891   LOCK_CHECKING_CFLAGS="-Dbool=char -D_Bool=char -save-temps"
1892   AC_SUBST([LOCK_CHECKING_CFLAGS])
1894 AM_CONDITIONAL([WITH_CIL],[test "$enable_locking" = "yes"])
1896 dnl Enable building the proxy?
1898 AC_ARG_WITH([xen-proxy],
1899   AC_HELP_STRING([--with-xen-proxy], [add XEN setuid proxy support @<:@default=auto@:>@]),[],[with_xen_proxy=auto])
1901 AC_MSG_CHECKING([if Xen setuid proxy is needed])
1902 if test "$with_xen_proxy" = "auto"; then
1903   if test "$with_polkit" = "yes"; then
1904     with_xen_proxy="no"
1905   else
1906     with_xen_proxy="yes"
1907   fi
1909 if test "$with_xen" != "yes"; then
1910   with_xen_proxy="no"
1912 AC_MSG_RESULT([$with_xen_proxy])
1914 AM_CONDITIONAL([WITH_PROXY],[test "$with_xen_proxy" = "yes"])
1915 if test "$with_xen_proxy" = "yes"; then
1916   AC_DEFINE([WITH_PROXY], 1, [Whether Xen proxy is enabled])
1919 dnl Enable building libvirtd?
1920 AM_CONDITIONAL([WITH_LIBVIRTD],[test "x$with_libvirtd" = "xyes"])
1922 dnl Check for gettext
1923 AM_GNU_GETTEXT_VERSION([0.14.1])
1924 AM_GNU_GETTEXT([external])
1925 dnl Since we're using such an old version of gettext, we must also define
1926 dnl this symbol, in order to make the autopoint-supplied Makefile.in.in
1927 dnl work properly.
1928 AC_SUBST([MKINSTALLDIRS], ["\$(top_builddir)/$ac_aux_dir/mkinstalldirs"])
1930 ALL_LINGUAS=`cd "$srcdir/po" > /dev/null && ls *.po | sed 's+\.po$++'`
1932 dnl Extra link-time flags for Cygwin.
1933 dnl Copied from libxml2 configure.in, but I removed mingw changes
1934 dnl for now since I'm not supporting mingw at present.  - RWMJ
1935 CYGWIN_EXTRA_LDFLAGS=
1936 CYGWIN_EXTRA_LIBADD=
1937 CYGWIN_EXTRA_PYTHON_LIBADD=
1938 MINGW_EXTRA_LDFLAGS=
1939 WIN32_EXTRA_CFLAGS=
1940 LIBVIRT_SYMBOL_FILE=libvirt.syms
1941 LIBVIRT_QEMU_SYMBOL_FILE='$(srcdir)/libvirt_qemu.syms'
1942 case "$host" in
1943   *-*-cygwin*)
1944     CYGWIN_EXTRA_LDFLAGS="-no-undefined"
1945     CYGWIN_EXTRA_LIBADD="${INTLLIBS}"
1946     if test "x$PYTHON_VERSION" != "x"; then
1947       CYGWIN_EXTRA_PYTHON_LIBADD="-L/usr/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
1948     fi
1949     ;;
1950   *-*-mingw*)
1951     MINGW_EXTRA_LDFLAGS="-no-undefined"
1952     ;;
1953 esac
1954 case "$host" in
1955   *-*-mingw* | *-*-cygwin* | *-*-msvc* )
1956     # If the host is Windows, and shared libraries are disabled, we
1957     # need to add -DLIBVIRT_STATIC to the CFLAGS for proper linking
1958     if test "x$enable_shared" = "xno"; then
1959       WIN32_EXTRA_CFLAGS="-DLIBVIRT_STATIC"
1960     fi
1961 esac
1962 case "$host" in
1963   *-*-mingw* | *-*-msvc* )
1964     # Also set the symbol file to .def, so src/Makefile generates libvirt.def
1965     # from libvirt.syms and passes libvirt.def instead of libvirt.syms to the linker
1966     LIBVIRT_SYMBOL_FILE=libvirt.def
1967     LIBVIRT_QEMU_SYMBOL_FILE=libvirt_qemu.def
1968     # mingw's ld has the --version-script parameter, but it requires a .def file
1969     # instead to work properly, therefore clear --version-script here and use
1970     # -Wl, to pass the .def file to the linker
1971     # cygwin's ld has the --version-script parameter too, but for some reason
1972     # it's working there as expected
1973     VERSION_SCRIPT_FLAGS="-Wl,"
1974     ;;
1975 esac
1976 AC_SUBST([CYGWIN_EXTRA_LDFLAGS])
1977 AC_SUBST([CYGWIN_EXTRA_LIBADD])
1978 AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
1979 AC_SUBST([MINGW_EXTRA_LDFLAGS])
1980 AC_SUBST([WIN32_EXTRA_CFLAGS])
1981 AC_SUBST([LIBVIRT_SYMBOL_FILE])
1982 AC_SUBST([LIBVIRT_QEMU_SYMBOL_FILE])
1983 AC_SUBST([VERSION_SCRIPT_FLAGS])
1986 dnl Look for windres to build a Windows icon resource.
1987 case "$host" in
1988   *-*-mingw* | *-*-cygwin* | *-*-msvc* )
1989     AC_CHECK_TOOL([WINDRES], [windres], [])
1990     ;;
1991 esac
1992 AM_CONDITIONAL([WITH_WIN_ICON], [test "$WINDRES" != ""])
1995 dnl Driver-Modules library
1996 AC_ARG_WITH([driver-modules],
1997   AC_HELP_STRING([--with-driver-modules], [build drivers as loadable modules @<:@default=no@:>@]),
1998   [],
1999   [with_driver_modules=no])
2001 DRIVER_MODULE_CFLAGS=
2002 DRIVER_MODULE_LIBS=
2003 if test "x$with_driver_modules" = "xyes" ; then
2004   old_cflags="$CFLAGS"
2005   old_libs="$LIBS"
2006   fail=0
2007   AC_CHECK_HEADER([dlfcn.h],[],[fail=1])
2008   AC_SEARCH_LIBS([dlopen], [dl], [], [fail=1])
2009   test $fail = 1 &&
2010       AC_MSG_ERROR([You must have dlfcn.h / dlopen() support to build driver modules])
2012   CFLAGS="$old_cflags"
2013   LIBS="$old_libs"
2015 if test "$with_driver_modules" = "yes"; then
2016   DRIVER_MODULE_CFLAGS="-export-dynamic"
2017   case $ac_cv_search_dlopen in
2018     no*) DRIVER_MODULE_LIBS= ;;
2019     *) DRIVER_MODULE_LIBS=$ac_cv_search_dlopen ;;
2020   esac
2021   AC_DEFINE_UNQUOTED([WITH_DRIVER_MODULES], 1, [whether to build drivers as modules])
2023 AM_CONDITIONAL([WITH_DRIVER_MODULES], [test "$with_driver_modules" != "no"])
2024 AC_SUBST([DRIVER_MODULE_CFLAGS])
2025 AC_SUBST([DRIVER_MODULE_LIBS])
2028 # Set LV_LIBTOOL_OBJDIR to "." or $lt_cv_objdir, depending on whether
2029 # we're building shared libraries.  This is the name of the directory
2030 # in which .o files will be created.
2031 test "$enable_shared" = no && lt_cv_objdir=.
2032 LV_LIBTOOL_OBJDIR=${lt_cv_objdir-.}
2033 AC_SUBST([LV_LIBTOOL_OBJDIR])
2035 dnl HAL library check for host device enumeration
2036 HAL_CFLAGS=
2037 HAL_LIBS=
2038 AC_ARG_WITH([hal],
2039   AC_HELP_STRING([--with-hal], [use HAL for host device enumeration @<:@default=check@:>@]),
2040   [],
2041   [with_hal=check])
2043 if test "$with_libvirtd" = "no" ; then
2044   with_hal=no
2046 if test "x$with_hal" = "xyes" || test "x$with_hal" = "xcheck"; then
2047   PKG_CHECK_MODULES(HAL, hal >= $HAL_REQUIRED,
2048     [with_hal=yes], [
2049     if test "x$with_hal" = "xcheck" ; then
2050        with_hal=no
2051     else
2052        AC_MSG_ERROR(
2053          [You must install hal-devel >= $HAL_REQUIRED to compile libvirt])
2054     fi
2055   ])
2056   if test "x$with_hal" = "xyes" ; then
2057     old_CFLAGS=$CFLAGS
2058     old_LIBS=$LIBS
2059     CFLAGS="$CFLAGS $HAL_CFLAGS"
2060     LIBS="$LIBS $HAL_LIBS"
2061     AC_CHECK_FUNCS([libhal_get_all_devices],,[with_hal=no])
2062     AC_CHECK_FUNCS([dbus_watch_get_unix_fd])
2063     CFLAGS="$old_CFLAGS"
2064     LIBS="$old_LIBS"
2065   fi
2066   if test "x$with_hal" = "xyes" ; then
2067     AC_DEFINE_UNQUOTED([HAVE_HAL], 1,
2068       [use HAL for host device enumeration])
2069   fi
2071 AM_CONDITIONAL([HAVE_HAL], [test "x$with_hal" = "xyes"])
2072 AC_SUBST([HAL_CFLAGS])
2073 AC_SUBST([HAL_LIBS])
2076 dnl udev/libpciaccess library check for alternate host device enumeration
2077 UDEV_CFLAGS=
2078 UDEV_LIBS=
2079 PCIACCESS_CFLAGS=
2080 PCIACCESS_LIBS=
2081 AC_ARG_WITH([udev],
2082   AC_HELP_STRING([--with-udev], [use libudev for host device enumeration @<:@default=check@:>@]),
2083   [],
2084   [with_udev=check])
2086 if test "$with_libvirtd" = "no" ; then
2087   with_udev=no
2089 if test "x$with_udev" = "xyes" || test "x$with_udev" = "xcheck"; then
2090   PKG_CHECK_MODULES(UDEV, libudev >= $UDEV_REQUIRED,
2091     [], [
2092     if test "x$with_udev" = "xcheck" ; then
2093        with_udev=no
2094     else
2095        AC_MSG_ERROR(
2096          [You must install libudev-devel >= $UDEV_REQUIRED to compile libvirt])
2097     fi
2098   ])
2099   if test "x$with_udev" != "xno"; then
2100     PKG_CHECK_MODULES(PCIACCESS, pciaccess >= $PCIACCESS_REQUIRED,
2101       [with_udev=yes],
2102       [
2103         if test "x$with_udev" = "xcheck" ; then
2104           with_udev=no
2105         else
2106           AC_MSG_ERROR(
2107            [You must install libpciaccess-devel >= $PCIACCESS_REQUIRED to compile libvirt])
2108         fi
2109       ])
2110   fi
2111   if test "x$with_udev" = "xyes" ; then
2112     AC_DEFINE_UNQUOTED([HAVE_UDEV], 1,
2113       [use UDEV for host device enumeration])
2114   fi
2116 AM_CONDITIONAL([HAVE_UDEV], [test "x$with_udev" = "xyes"])
2117 AC_SUBST([UDEV_CFLAGS])
2118 AC_SUBST([UDEV_LIBS])
2119 AC_SUBST([PCIACCESS_CFLAGS])
2120 AC_SUBST([PCIACCESS_LIBS])
2122 with_nodedev=no;
2123 if test "$with_hal" = "yes" || test "$with_udev" = "yes";
2124 then
2125   with_nodedev=yes
2126   AC_DEFINE_UNQUOTED([WITH_NODE_DEVICES], 1, [with node device driver])
2128 AM_CONDITIONAL([WITH_NODE_DEVICES], [test "$with_nodedev" = "yes"])
2130 dnl nwfilter should only be compiled for linux, and only if the
2131 dnl libvirt daemon is also being compiled
2133 with_nwfilter=yes
2134 if test "$with_libvirtd" = "no" || test "$with_linux" != "yes"; then
2135   with_nwfilter=no
2137 if test "$with_nwfilter" = "yes" ; then
2138   AC_DEFINE([WITH_NWFILTER], 1, [whether local network filter management driver is available])
2140 AM_CONDITIONAL([WITH_NWFILTER], [test "$with_nwfilter" = "yes"])
2142 AC_ARG_WITH([qemu-user],
2143   AC_HELP_STRING([--with-qemu-user], [username to run QEMU system instance as @<:@default=root@:>@]),
2144   [QEMU_USER=${withval}],
2145   [QEMU_USER=root])
2146 AC_ARG_WITH([qemu-group],
2147   AC_HELP_STRING([--with-qemu-group], [groupname to run QEMU system instance as @<:@default=root@:>@]),
2148   [QEMU_GROUP=${withval}],
2149   [QEMU_GROUP=root])
2150 AC_DEFINE_UNQUOTED([QEMU_USER], ["$QEMU_USER"], [QEMU user account])
2151 AC_DEFINE_UNQUOTED([QEMU_GROUP], ["$QEMU_GROUP"], [QEMU group account])
2154 AC_ARG_WITH([macvtap],
2155   AC_HELP_STRING([--with-macvtap],[enable macvtap device @<:@default=check@:>@]),
2156   [with_macvtap=${withval}],
2157   [with_macvtap=check])
2159 AC_MSG_CHECKING([whether to compile with macvtap support])
2160 if test "$with_macvtap" != "no" ; then
2161     AC_TRY_COMPILE([ #include <sys/socket.h>
2162                      #include <linux/rtnetlink.h> ],
2163                    [ int x = MACVLAN_MODE_BRIDGE; ],
2164                    [ with_macvtap=yes ],
2165                    [ if test "$with_macvtap" = "yes" ; then
2166                          AC_MSG_ERROR([Installed linux headers don't show support for macvtap device.])
2167                      fi
2168                      with_macvtap=no ])
2169     if test "$with_macvtap" = "yes" ; then
2170         val=1
2171     else
2172         val=0
2173     fi
2174     AC_DEFINE_UNQUOTED([WITH_MACVTAP], $val, [whether macvtap support is enabled])
2176 AM_CONDITIONAL([WITH_MACVTAP], [test "$with_macvtap" = "yes"])
2177 AC_MSG_RESULT([$with_macvtap])
2179 AC_ARG_WITH([virtualport],
2180   AC_HELP_STRING([--with-virtualport],[enable virtual port support @<:@default=check@:>@]),
2181   [with_virtualport=${withval}],
2182   [with_virtualport=check])
2184 dnl Warn the user and error out if they requested virtualport support with configure
2185 dnl options, but the required macvtap support isn't available
2187 if test "$with_virtualport" = "yes"; then
2188     if test "$with_macvtap" = "no"; then
2189         AC_MSG_ERROR([--with-virtualport requires --with-macvtap])
2190     fi
2193 dnl virtualport checks
2195 if test "$with_macvtap" != "yes"; then
2196     with_virtualport=no
2198 if test "$with_virtualport" != "no"; then
2199     AC_MSG_CHECKING([whether to compile with virtual port support])
2200     AC_TRY_COMPILE([ #include <sys/socket.h>
2201                      #include <linux/rtnetlink.h> ],
2202                      [ int x = IFLA_PORT_MAX; ],
2203                      [ with_virtualport=yes ],
2204                      [ if test "$with_virtualport" = "yes" ; then
2205                          AC_MSG_ERROR([Installed linux headers don't show support for virtual port support.])
2206                        fi
2207                        with_virtualport=no ])
2208     if test "$with_virtualport" = "yes"; then
2209         val=1
2210     else
2211         val=0
2212     fi
2213     AC_DEFINE_UNQUOTED([WITH_VIRTUALPORT], $val,
2214                        [whether vsi vepa support is enabled])
2215     AC_MSG_RESULT([$with_virtualport])
2217 AM_CONDITIONAL([WITH_VIRTUALPORT], [test "$with_virtualport" = "yes"])
2220 dnl netlink library
2222 LIBNL_CFLAGS=""
2223 LIBNL_LIBS=""
2225 if test "$with_macvtap" = "yes"; then
2226     PKG_CHECK_MODULES([LIBNL], [libnl-1 >= $LIBNL_REQUIRED], [
2227     ], [
2228         AC_MSG_ERROR([libnl >= $LIBNL_REQUIRED is required for macvtap support])
2229     ])
2232 AC_SUBST([LIBNL_CFLAGS])
2233 AC_SUBST([LIBNL_LIBS])
2238 # Only COPYING.LIB is under version control, yet COPYING
2239 # is included as part of the distribution tarball.
2240 # Copy one to the other, but only if this is a srcdir-build.
2241 # You are unlikely to be doing distribution-related things in a non-srcdir build
2242 test "x$srcdir" = x. && ! test -f COPYING &&
2243 cp -f COPYING.LIB COPYING
2245 # Detect when running under the clang static analyzer's scan-build driver
2246 # or Coverity-prevent's cov-build.  Define STATIC_ANALYSIS accordingly.
2247 test -n "$CCC_ANALYZER_ANALYSIS$COVERITY_BUILD_COMMAND" && t=1 || t=0
2248 AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t],
2249   [Define to 1 when performing static analysis.])
2251 AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
2252           docs/schemas/Makefile \
2253           gnulib/lib/Makefile \
2254           gnulib/tests/Makefile \
2255           libvirt.pc libvirt.spec mingw32-libvirt.spec \
2256           po/Makefile.in \
2257           include/libvirt/Makefile include/libvirt/libvirt.h \
2258           python/Makefile python/tests/Makefile \
2259           daemon/Makefile \
2260           tools/Makefile \
2261           tests/Makefile proxy/Makefile \
2262           tests/xml2sexprdata/Makefile \
2263           tests/sexpr2xmldata/Makefile \
2264           tests/xmconfigdata/Makefile \
2265           tests/xencapsdata/Makefile \
2266           tests/confdata/Makefile \
2267           examples/apparmor/Makefile \
2268           examples/domain-events/events-c/Makefile \
2269           examples/domsuspend/Makefile \
2270           examples/dominfo/Makefile \
2271           examples/openauth/Makefile \
2272           examples/python/Makefile \
2273           examples/hellolibvirt/Makefile \
2274           examples/systemtap/Makefile \
2275           examples/xml/nwfilter/Makefile)
2277 AC_MSG_NOTICE([])
2278 AC_MSG_NOTICE([Configuration summary])
2279 AC_MSG_NOTICE([=====================])
2280 AC_MSG_NOTICE([])
2281 AC_MSG_NOTICE([Drivers])
2282 AC_MSG_NOTICE([])
2283 AC_MSG_NOTICE([     Xen: $with_xen])
2284 AC_MSG_NOTICE([   Proxy: $with_xen_proxy])
2285 AC_MSG_NOTICE([    QEMU: $with_qemu])
2286 AC_MSG_NOTICE([     UML: $with_uml])
2287 AC_MSG_NOTICE([  OpenVZ: $with_openvz])
2288 AC_MSG_NOTICE([    VBox: $with_vbox])
2289 AC_MSG_NOTICE([  XenAPI: $with_xenapi])
2290 AC_MSG_NOTICE([     LXC: $with_lxc])
2291 AC_MSG_NOTICE([    PHYP: $with_phyp])
2292 AC_MSG_NOTICE([     ONE: $with_one])
2293 AC_MSG_NOTICE([     ESX: $with_esx])
2294 AC_MSG_NOTICE([    Test: $with_test])
2295 AC_MSG_NOTICE([  Remote: $with_remote])
2296 AC_MSG_NOTICE([ Network: $with_network])
2297 AC_MSG_NOTICE([Libvirtd: $with_libvirtd])
2298 AC_MSG_NOTICE([   netcf: $with_netcf])
2299 AC_MSG_NOTICE([ macvtap: $with_macvtap])
2300 AC_MSG_NOTICE([virtport: $with_virtualport])
2301 AC_MSG_NOTICE([])
2302 AC_MSG_NOTICE([Storage Drivers])
2303 AC_MSG_NOTICE([])
2304 AC_MSG_NOTICE([     Dir: $with_storage_dir])
2305 AC_MSG_NOTICE([      FS: $with_storage_fs])
2306 AC_MSG_NOTICE([   NetFS: $with_storage_fs])
2307 AC_MSG_NOTICE([     LVM: $with_storage_lvm])
2308 AC_MSG_NOTICE([   iSCSI: $with_storage_iscsi])
2309 AC_MSG_NOTICE([    SCSI: $with_storage_scsi])
2310 AC_MSG_NOTICE([   mpath: $with_storage_mpath])
2311 AC_MSG_NOTICE([    Disk: $with_storage_disk])
2312 AC_MSG_NOTICE([])
2313 AC_MSG_NOTICE([Security Drivers])
2314 AC_MSG_NOTICE([])
2315 AC_MSG_NOTICE([ SELinux: $with_secdriver_selinux])
2316 AC_MSG_NOTICE([AppArmor: $with_secdriver_apparmor])
2317 AC_MSG_NOTICE([])
2318 AC_MSG_NOTICE([Driver Loadable Modules])
2319 AC_MSG_NOTICE([])
2320 if test "$with_driver_modules" != "no" ; then
2321 AC_MSG_NOTICE([  dlopen: $DRIVER_MODULE_CFLAGS $DRIVER_MODULE_LIBS])
2322 else
2323 AC_MSG_NOTICE([  dlopen: no])
2325 AC_MSG_NOTICE([])
2326 AC_MSG_NOTICE([Libraries])
2327 AC_MSG_NOTICE([])
2328 AC_MSG_NOTICE([  libxml: $LIBXML_CFLAGS $LIBXML_LIBS])
2329 if test "$with_esx" = "yes" ; then
2330 AC_MSG_NOTICE([ libcurl: $LIBCURL_CFLAGS $LIBCURL_LIBS])
2331 else
2332 AC_MSG_NOTICE([ libcurl: no])
2334 if test "$with_libssh2" != "no" ; then
2335 AC_MSG_NOTICE([ libssh2: $LIBSSH2_CFLAGS $LIBSSH2_LIBS])
2336 else
2337 AC_MSG_NOTICE([ libssh2: no])
2339 AC_MSG_NOTICE([  gnutls: $GNUTLS_CFLAGS $GNUTLS_LIBS])
2340 if test "$with_sasl" != "no" ; then
2341 AC_MSG_NOTICE([    sasl: $SASL_CFLAGS $SASL_LIBS])
2342 else
2343 AC_MSG_NOTICE([    sasl: no])
2345 if test "$with_yajl" != "no" ; then
2346 AC_MSG_NOTICE([    yajl: $YAJL_CFLAGS $YAJL_LIBS])
2347 else
2348 AC_MSG_NOTICE([    yajl: no])
2350 if test "$with_avahi" = "yes" ; then
2351 AC_MSG_NOTICE([   avahi: $AVAHI_CFLAGS $AVAHI_LIBS])
2352 else
2353 AC_MSG_NOTICE([   avahi: no])
2355 if test "$with_polkit" = "yes" ; then
2356 if test "$with_polkit0" = "yes" ; then
2357 AC_MSG_NOTICE([  polkit: $POLKIT_CFLAGS $POLKIT_LIBS (version 0)])
2358 else
2359 AC_MSG_NOTICE([  polkit: $PKCHECK_PATH (version 1)])
2361 else
2362 AC_MSG_NOTICE([  polkit: no])
2364 if test "$with_audit" = "yes" ; then
2365 AC_MSG_NOTICE([   audit: $AUDIT_CFLAGS $AUDIT_LIBS])
2366 else
2367 AC_MSG_NOTICE([   audit: no])
2369 if test "$with_selinux" = "yes" ; then
2370 AC_MSG_NOTICE([ selinux: $SELINUX_CFLAGS $SELINUX_LIBS])
2371 else
2372 AC_MSG_NOTICE([ selinux: no])
2374 if test "$with_apparmor" = "yes" ; then
2375 AC_MSG_NOTICE([apparmor: $APPARMOR_CFLAGS $APPARMOR_LIBS])
2376 else
2377 AC_MSG_NOTICE([apparmor: no])
2379 if test "$with_numactl" = "yes" ; then
2380 AC_MSG_NOTICE([ numactl: $NUMACTL_CFLAGS $NUMACTL_LIBS])
2381 else
2382 AC_MSG_NOTICE([ numactl: no])
2384 if test "$with_capng" = "yes" ; then
2385 AC_MSG_NOTICE([   capng: $CAPNG_CFLAGS $CAPNG_LIBS])
2386 else
2387 AC_MSG_NOTICE([   capng: no])
2389 if test "$with_xen" = "yes" ; then
2390 AC_MSG_NOTICE([     xen: $XEN_CFLAGS $XEN_LIBS])
2391 else
2392 AC_MSG_NOTICE([     xen: no])
2394 if test "$with_xenapi" = "yes" ; then
2395 AC_MSG_NOTICE([  xenapi: $LIBXENSERVER_CFLAGS $LIBXENSERVER_LIBS])
2396 else
2397 AC_MSG_NOTICE([  xenapi: no])
2399 if test "$with_hal" = "yes" ; then
2400 AC_MSG_NOTICE([     hal: $HAL_CFLAGS $HAL_LIBS])
2401 else
2402 AC_MSG_NOTICE([     hal: no])
2404 if test "$with_udev" = "yes" ; then
2405 AC_MSG_NOTICE([    udev: $UDEV_CFLAGS $UDEV_LIBS $PCIACCESS_CFLAGS $PCIACCESS_LIBS])
2406 else
2407 AC_MSG_NOTICE([    udev: no])
2409 if test "$with_netcf" = "yes" ; then
2410 AC_MSG_NOTICE([   netcf: $NETCF_CFLAGS $NETCF_LIBS])
2411 else
2412 AC_MSG_NOTICE([   netcf: no])
2414 if test "$with_one" = "yes" ; then
2415 AC_MSG_NOTICE([  xmlrpc: $XMLRPC_CFLAGS $XMLRPC_LIBS])
2416 else
2417 AC_MSG_NOTICE([  xmlrpc: no])
2419 if test "$with_qemu" = "yes" ; then
2420 AC_MSG_NOTICE([    pcap: $LIBPCAP_CFLAGS $LIBPCAP_LIBS])
2421 else
2422 AC_MSG_NOTICE([    pcap: no])
2424 if test "$with_macvtap" = "yes" ; then
2425 AC_MSG_NOTICE([      nl: $LIBNL_CFLAGS $LIBNL_LIBS])
2426 else
2427 AC_MSG_NOTICE([      nl: no])
2429 AC_MSG_NOTICE([])
2430 AC_MSG_NOTICE([Test suite])
2431 AC_MSG_NOTICE([])
2432 AC_MSG_NOTICE([   Coverage: $enable_coverage])
2433 AC_MSG_NOTICE([  Alloc OOM: $enable_oom])
2434 AC_MSG_NOTICE([])
2435 AC_MSG_NOTICE([Miscellaneous])
2436 AC_MSG_NOTICE([])
2437 AC_MSG_NOTICE([        Debug: $enable_debug])
2438 AC_MSG_NOTICE([     Warnings: $enable_compile_warnings])
2439 AC_MSG_NOTICE([     Readline: $lv_use_readline])
2440 AC_MSG_NOTICE([       Python: $with_python])
2441 AC_MSG_NOTICE([       DTrace: $with_dtrace])
2442 AC_MSG_NOTICE([  XML Catalog: $XML_CATALOG_FILE])
2443 AC_MSG_NOTICE([])
2444 AC_MSG_NOTICE([Privileges])
2445 AC_MSG_NOTICE([])
2446 AC_MSG_NOTICE([      QEMU: $QEMU_USER:$QEMU_GROUP])
2447 AC_MSG_NOTICE([])