2 # Copyright (C) 2009-2011 Red Hat Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 # The major, minor, and release fields MUST be numbers. Packagers can
19 # add extra information using --with-extra="..." which may be any
21 m4_define([libguestfs_major], [1])
22 m4_define([libguestfs_minor], [13])
23 m4_define([libguestfs_release], [9])
25 AC_INIT([libguestfs],libguestfs_major.libguestfs_minor.libguestfs_release)
26 AC_CONFIG_AUX_DIR([build-aux])
27 AM_INIT_AUTOMAKE([foreign])
29 m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
30 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
32 AC_CONFIG_MACRO_DIR([m4])
34 dnl Stable or unstable version?
35 AC_MSG_CHECKING([if this is a stable or unstable branch of libguestfs])
36 AS_IF([test "$((libguestfs_minor % 2))" -eq 0 ],[
37 AC_MSG_RESULT([stable])
39 AC_MSG_RESULT([unstable])
42 This is a development version of libguestfs. Some APIs may be unstable
43 until they appear in a stable release of libguestfs (at which point
44 the C API and ABI is guaranteed to remain stable forever). For
45 more information about stable and development branches of libguestfs
46 please see the section "LIBGUESTFS VERSION NUMBERS" in guestfs(3).
50 dnl Extra string, a freeform string defined by packagers.
52 [AS_HELP_STRING([--with-extra],
53 [extra version string (for use by packagers)])],
54 [libguestfs_extra="$withval"],
58 AC_MSG_NOTICE([libguestfs version libguestfs_major.libguestfs_minor.libguestfs_release$libguestfs_extra])
60 dnl Split up the version string.
61 AC_DEFINE([PACKAGE_VERSION_MAJOR],[libguestfs_major],[Major version number])
62 AC_DEFINE([PACKAGE_VERSION_MINOR],[libguestfs_minor],[Minor version number])
63 AC_DEFINE([PACKAGE_VERSION_RELEASE],[libguestfs_release],[Release number])
64 AC_DEFINE_UNQUOTED([PACKAGE_VERSION_EXTRA],["$libguestfs_extra"],[Extra version string])
66 dnl Early gnulib initialization.
72 dnl Check for basic C environment.
77 AC_ARG_ENABLE([gcc-warnings],
78 [AS_HELP_STRING([--enable-gcc-warnings],
79 [turn on lots of GCC warnings (for developers)])],
82 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
84 gl_gcc_warnings=$enableval],
88 if test "$gl_gcc_warnings" = yes; then
89 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
90 AC_SUBST([WERROR_CFLAGS])
93 # This, $nw, is the list of warnings we disable.
94 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
95 nw="$nw -Waggregate-return" # anachronistic
96 nw="$nw -Wc++-compat" # We don't care about C++ compilers
97 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
98 nw="$nw -Wtraditional" # Warns on #elif which we use often
99 nw="$nw -Wcast-qual" # Too many warnings for now
100 nw="$nw -Wconversion" # Too many warnings for now
101 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
102 nw="$nw -Wsign-conversion" # Too many warnings for now
103 nw="$nw -Wtraditional-conversion" # Too many warnings for now
104 nw="$nw -Wunreachable-code" # Too many warnings for now
105 nw="$nw -Wpadded" # Our structs are not padded
106 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
107 nw="$nw -Wlogical-op" # any use of fwrite provokes this
108 nw="$nw -Wvla" # two warnings in mount.c
109 # things I might fix soon:
110 nw="$nw -Wmissing-format-attribute" # daemon.h's asprintf_nowarn
111 nw="$nw -Winline" # daemon.h's asprintf_nowarn
112 nw="$nw -Wshadow" # numerous, plus we're not unanimous
113 nw="$nw -Wunsafe-loop-optimizations" # just a warning that an optimization
114 # was not possible, safe to ignore
115 nw="$nw -Wpacked" # Allow attribute((packed)) on structs
116 nw="$nw -Wlong-long" # Allow long long since it's required
117 # by Python, Ruby and xstrtoll.
118 nw="$nw -Wstack-protector" # Don't warn about stack-protector
119 # failures (seen on Ubuntu).
120 nw="$nw -Wmissing-noreturn" # Don't warn about missed noreturn funcs
123 gl_MANYWARN_ALL_GCC([ws])
124 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
128 gl_WARN_ADD([-Wno-unused-parameter]) # stubs.c
129 gl_WARN_ADD([-Wno-jump-misses-init]) # stubs.c
130 gl_WARN_ADD([-Wno-unused-variable]) # FIXME: only temporary, for guestfs_protocol.c, etc
132 # In spite of excluding -Wlogical-op above, it is enabled, as of
133 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
134 gl_WARN_ADD([-Wno-logical-op])
136 # Work around warning in src/inspect.c. This seems to be a bug in gcc 4.5.1.
137 gl_WARN_ADD([-Wno-strict-overflow])
139 gl_WARN_ADD([-fdiagnostics-show-option])
141 AC_SUBST([WARN_CFLAGS])
143 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
144 AC_DEFINE([_FORTIFY_SOURCE], [2],
145 [enable compile-time and run-time bounds-checking, and some warnings])
146 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
150 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
154 dnl Work out how to specify the linker script to the linker.
155 VERSION_SCRIPT_FLAGS=-Wl,--version-script=
156 `/usr/bin/ld --help 2>&1 | grep -- --version-script >/dev/null` || \
157 VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
158 AC_SUBST(VERSION_SCRIPT_FLAGS)
160 dnl Check support for 64 bit file offsets.
163 dnl Check sizeof long.
164 AC_CHECK_SIZEOF([long])
166 dnl Check if dirent (readdir) supports d_type member.
167 AC_STRUCT_DIRENT_D_TYPE
169 dnl Check if stat has the required fields.
171 AC_CHECK_MEMBER([struct stat.st_blksize],[
172 AC_DEFINE([HAVE_STRUCT_STAT_ST_BLKSIZE],[1],[Define to 1 if 'st_blksize' is a member of 'struct stat'])])
174 dnl Define a C symbol for the host CPU architecture.
175 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
217 dnl For modified printf in the daemon, we need glibc either (old-style)
218 dnl register_printf_function or (new-style) register_printf_specifier.
219 AC_CHECK_FUNC([register_printf_specifier],[
220 AC_DEFINE([HAVE_REGISTER_PRINTF_SPECIFIER],[1],
221 [Define to 1 if you have new-style register_printf_specifier])
223 AC_CHECK_FUNC([register_printf_function],[
224 AC_DEFINE([HAVE_REGISTER_PRINTF_FUNCTION],[1],
225 [Define to 1 if you have old-style register_printf_function])
228 [No support for glibc-style extended printf formatters.
230 This means you either have a very old glibc (pre-2.0) or you
231 are using some other libc where this is not supported.])])])
233 dnl Build the daemon?
234 AC_MSG_CHECKING([if we should build the daemon])
235 AC_ARG_ENABLE([daemon],
236 [AS_HELP_STRING([--enable-daemon],
237 [enable building the daemon @<:@default=yes@:>@])],
240 AM_CONDITIONAL([ENABLE_DAEMON],[test "x$enable_daemon" = "xyes"])
241 AC_MSG_RESULT([$enable_daemon])
243 if test "x$enable_daemon" = "xyes"; then
244 dnl Install the daemon (for libguestfs live service)
245 AC_MSG_CHECKING([if we should install the daemon])
246 AC_ARG_ENABLE([install-daemon],
247 [AS_HELP_STRING([--enable-install-daemon],
248 [enable installing the daemon under $sbindir @<:@default=no@:>@])],
250 [enable_install_daemon=no])
251 AM_CONDITIONAL([INSTALL_DAEMON],[test "x$enable_install_daemon" = "xyes"])
252 AC_MSG_RESULT([$enable_install_daemon])
255 dnl Build the appliance?
256 AC_MSG_CHECKING([if we should build the appliance])
257 AC_ARG_ENABLE([appliance],
258 [AS_HELP_STRING([--enable-appliance],
259 [enable building the appliance @<:@default=yes@:>@])],
261 [enable_appliance=yes])
262 AM_CONDITIONAL([ENABLE_APPLIANCE],[test "x$enable_appliance" = "xyes"])
263 AC_MSG_RESULT([$enable_appliance])
265 if test "x$enable_appliance" = "xyes"; then
266 dnl Check for febootstrap >= 3.0
267 AC_CHECK_PROG([FEBOOTSTRAP],
268 [febootstrap],[febootstrap],[no])
269 test "x$FEBOOTSTRAP" = "xno" &&
270 AC_MSG_ERROR([febootstrap must be installed])
271 dnl febootstrap 2.x did not support the --version parameter
272 $FEBOOTSTRAP --version >&AS_MESSAGE_LOG_FD 2>&1 ||
273 AC_MSG_ERROR([febootstrap >= 3.0 must be installed, your version is too old])
275 dnl Pass a febootstrap --yum-config option.
276 AC_MSG_CHECKING([if user requested febootstrap --yum-config option])
277 AC_ARG_WITH([febootstrap-yum-config],
278 [AS_HELP_STRING([--with-febootstrap-yum-config=FILE],
279 [pass febootstrap --yum-config option @<:@default=no@:>@])],
280 [FEBOOTSTRAP_YUM_CONFIG="$withval"],
281 [FEBOOTSTRAP_YUM_CONFIG=no])
282 AC_MSG_RESULT([$FEBOOTSTRAP_YUM_CONFIG])
283 AC_SUBST([FEBOOTSTRAP_YUM_CONFIG])
287 dnl This used to be Very Important but is now just used to select
288 dnl which packages to install in the appliance, since the package
289 dnl names vary slightly across distros. (See
290 dnl appliance/packagelist.in and appliance/excludelist.in)
291 AC_MSG_CHECKING([which Linux distro for package names])
293 if test -f /etc/debian_version; then
295 if grep -q 'DISTRIB_ID=Ubuntu' /etc/lsb-release 2>&AS_MESSAGE_LOG_FD; then
299 if test -f /etc/arch-release; then
302 AC_MSG_RESULT([$DISTRO])
306 dnl Check for rpcgen and XDR library. rpcgen is optional.
307 AC_CHECK_PROG([RPCGEN],[rpcgen],[rpcgen],[no])
308 AM_CONDITIONAL([HAVE_RPCGEN],[test "x$RPCGEN" != "xno"])
309 AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
310 AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
313 dnl Check for Augeas (now optional).
314 AC_CHECK_LIB([augeas],[aug_match],[
316 AUGEAS_LIB="-laugeas"
319 LIBS="$LIBS $AUGEAS_LIB"
320 dnl Check for functions not available in earlier versions of Augeas.
321 AC_CHECK_FUNCS([aug_load aug_defvar aug_defnode])
325 if test "x$have_augeas" = "xyes"; then
326 AC_DEFINE([HAVE_AUGEAS],[1],[Define to 1 if you have Augeas])
328 AC_SUBST([AUGEAS_LIB])
330 dnl Check for libselinux (optional).
331 AC_CHECK_HEADERS([selinux/selinux.h])
332 AC_CHECK_LIB([selinux],[setexeccon],[
333 have_libselinux="$ac_cv_header_selinux_selinux_h"
334 SELINUX_LIB="-lselinux"
337 LIBS="$LIBS $SELINUX_LIB"
338 AC_CHECK_FUNCS([setcon getcon])
341 ],[have_libselinux=no])
342 if test "x$have_libselinux" = "xyes"; then
343 AC_DEFINE([HAVE_LIBSELINUX],[1],[Define to 1 if you have libselinux])
345 AC_SUBST([SELINUX_LIB])
347 dnl Check for cpio which isn't in the default Pardus install amazingly.
348 AC_CHECK_PROG([CPIO],[cpio],[cpio],[no])
349 test "x$CPIO" = "xno" &&
350 AC_MSG_ERROR([cpio must be installed])
353 AC_CHECK_PROG([GPERF],[gperf],[gperf],[no])
354 test "x$GPERF" = "xno" &&
355 AC_MSG_ERROR([gperf must be installed])
357 dnl Check for pod2man, pod2text, pod2html.
358 AC_CHECK_PROG([POD2MAN],[pod2man],[pod2man],[no])
359 test "x$POD2MAN" = "xno" &&
360 AC_MSG_ERROR([pod2man must be installed])
361 AC_CHECK_PROG([POD2TEXT],[pod2text],[pod2text],[no])
362 test "x$POD2TEXT" = "xno" &&
363 AC_MSG_ERROR([pod2text must be installed])
364 AC_CHECK_PROG([POD2HTML],[pod2html],[pod2html],[no])
365 test "x$POD2HTML" = "xno" &&
366 AC_MSG_ERROR([pod2html must be installed])
368 dnl Check if pod2man, pod2text take --stderr and -u options (not in RHEL 5).
369 AC_MSG_CHECKING([if pod2man takes --stderr option])
370 if "$POD2MAN" --stderr >&AS_MESSAGE_LOG_FD 2>&1; then
372 POD2_STDERR_OPTION="--stderr"
375 POD2_STDERR_OPTION=""
377 AC_SUBST([POD2_STDERR_OPTION])
379 AC_MSG_CHECKING([if pod2man takes -u option])
380 if "$POD2MAN" -u >&AS_MESSAGE_LOG_FD 2>&1; then
382 POD2_UTF8_OPTION="-u"
387 AC_SUBST([POD2_UTF8_OPTION])
389 dnl Check for genisoimage.
390 AC_PATH_PROGS([GENISOIMAGE],[genisoimage],[no],
391 [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
392 test "x$GENISOIMAGE" = "xno" && AC_MSG_ERROR([genisoimage must be installed])
394 dnl Check for optional xmllint.
395 AC_CHECK_PROG([XMLLINT],[xmllint],[xmllint],[no])
396 AM_CONDITIONAL([HAVE_XMLLINT],[test "x$XMLLINT" != "xno"])
398 dnl po4a for translating man pages and POD files (optional).
399 AC_CHECK_PROG([PO4A],[po4a],[po4a],[no])
400 AM_CONDITIONAL([HAVE_PO4A], [test "x$PO4A" != "xno"])
402 dnl Check for db_dump, db_load (optional).
403 AC_CHECK_PROGS([DB_DUMP],
404 [db_dump db4_dump db4.8_dump db4.7_dump db4.6_dump],[no])
405 AC_CHECK_PROGS([DB_LOAD],
406 [db_load db4_load db4.8_load db4.7_load db4.6_load],[no])
407 if test "x$DB_DUMP" != "xno"; then
408 AC_DEFINE_UNQUOTED([DB_DUMP],["$DB_DUMP"],[Name of db_dump program.])
410 if test "x$DB_LOAD" != "xno"; then
411 AC_DEFINE_UNQUOTED([DB_LOAD],["$DB_LOAD"],[Name of db_load program.])
414 dnl Check for QEMU for running binaries on this $host_cpu, fall
415 dnl back to basic 'qemu'. Allow the user to override it.
416 default_qemu="qemu-kvm kvm qemu-system-$host_cpu qemu"
418 [AS_HELP_STRING([--with-qemu],
419 [set default QEMU binary @<:@default=[qemu-kvm] qemu-system-<host> qemu@:>@])],
421 [with_qemu="$default_qemu"])
422 AC_PATH_PROGS([QEMU],[$with_qemu],[no],
423 [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/libexec])
424 test "x$QEMU" = "xno" && AC_MSG_ERROR([qemu must be installed])
425 AC_DEFINE_UNQUOTED([QEMU],["$QEMU"],[Location of qemu binary.])
427 dnl Check that the chosen qemu has virtio-serial support.
428 if test "x$vmchannel_test" != "xno"; then
429 AC_MSG_CHECKING([that $QEMU -help works])
430 if $QEMU -help >&AS_MESSAGE_LOG_FD 2>&1; then
435 [$QEMU -help: command failed.
437 This could be a very old version of qemu, or qemu might not be
442 AC_MSG_CHECKING([for virtio-serial support in $QEMU])
443 if $QEMU -nographic -device \? 2>&1 | grep -sq virtio-serial; then
448 [I did not find virtio-serial support in
451 virtio-serial support in qemu or KVM is essential for libguestfs
454 Usually this means that you have to install a newer version of qemu
455 and/or KVM. Please read the relevant section in the README file for
456 more information about this.
458 You can override this test by setting the environment variable
459 vmchannel_test=no However if you don't have the right support
460 in your qemu, then this just delays the pain.
462 If I am using the wrong qemu or you want to compile qemu from source
463 and install it in another location, then you should configure with
464 the --with-qemu option.
469 dnl Set default drive interface used by the guestfs_add_drive_opts call
470 dnl ('-drive ...,if=...' option to qemu).
472 dnl If you encounter performance problems with virtio (RHBZ#509383)
473 dnl then try '--with-drive-if=ide'.
474 AC_ARG_WITH([drive-if],
475 [AS_HELP_STRING([--with-drive-if],
476 [set default driver (ide|scsi|virtio) @<:@default=virtio@:>@])],
478 [with_drive_if=virtio])
479 AC_DEFINE_UNQUOTED([DRIVE_IF],["$with_drive_if"],[Default drive interface.])
481 dnl Set interface used by the network. Normally you should
482 dnl leave this at the default (virtio-net-pci) but you can use the
483 dnl alternative (ne2k_pci) because of bugs in virtio networking
484 dnl eg. https://bugzilla.redhat.com/show_bug.cgi?id=516022
485 AC_ARG_WITH([net-if],
486 [AS_HELP_STRING([--with-net-if],
487 [set default net driver (virtio-net-pci|ne2k_pci) @<:@default=virtio-net-pci@:>@])],
489 [with_net_if=virtio-net-pci])
490 AC_DEFINE_UNQUOTED([NET_IF],["$with_net_if"],[Default network interface.])
492 dnl Enable packet dumps when in verbose mode. This generates lots
493 dnl of debug info, only useful for people debugging the RPC mechanism.
494 AC_ARG_ENABLE([packet-dump],
495 [AS_HELP_STRING([--enable-packet-dump],
496 [enable packet dumps in verbose mode @<:@default=no@:>@])],
497 [AC_DEFINE([ENABLE_PACKET_DUMP],[1],[Enable packet dumps in verbose mode.])],
501 AC_ARG_WITH([readline],
502 [AS_HELP_STRING([--with-readline],
503 [support fancy command line editing @<:@default=check@:>@])],
505 [with_readline=check])
508 AS_IF([test "x$with_readline" != xno],
509 [AC_CHECK_LIB([readline], [main],
510 [AC_SUBST([LIBREADLINE], ["-lreadline -lncurses"])
511 AC_DEFINE([HAVE_LIBREADLINE], [1],
512 [Define if you have libreadline])
514 [if test "x$with_readline" != xcheck; then
516 [--with-readline was given, but test for readline failed])
520 LIBS="$LIBS $LIBREADLINE"
521 AC_CHECK_FUNCS([append_history completion_matches rl_completion_matches])
526 AM_GNU_GETTEXT([external])
528 dnl Check for PCRE (required)
529 PKG_CHECK_MODULES([PCRE], [libpcre])
531 dnl libmagic (highly recommended)
532 AC_CHECK_LIB([magic],[magic_file],
533 [AC_CHECK_HEADER([magic.h],
534 [AC_SUBST([MAGIC_LIBS], ["-lmagic"])
535 AC_DEFINE([HAVE_LIBMAGIC],[1],[libmagic found at compile time.])
538 [AC_MSG_WARN([libmagic not found, some core features will be disabled])])
540 dnl libvirt (highly recommended)
541 PKG_CHECK_MODULES([LIBVIRT], [libvirt],
542 [AC_SUBST([LIBVIRT_CFLAGS])
543 AC_SUBST([LIBVIRT_LIBS])
544 AC_DEFINE([HAVE_LIBVIRT],[1],[libvirt found at compile time.])
546 [AC_MSG_WARN([libvirt not found, some core features will be disabled])])
547 AM_CONDITIONAL([HAVE_LIBVIRT],[test "x$LIBVIRT_LIBS" != "x"])
549 dnl libxml2 (highly recommended)
550 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0],
551 [AC_SUBST([LIBXML2_CFLAGS])
552 AC_SUBST([LIBXML2_LIBS])
553 AC_DEFINE([HAVE_LIBXML2],[1],[libxml2 found at compile time.])
555 [AC_MSG_WARN([libxml2 not found, some core features will be disabled])])
556 AM_CONDITIONAL([HAVE_LIBXML2],[test "x$LIBXML2_LIBS" != "x"])
558 dnl libconfig (highly recommended)
559 PKG_CHECK_MODULES([LIBCONFIG], [libconfig],
560 [AC_SUBST([LIBCONFIG_CFLAGS])
561 AC_SUBST([LIBCONFIG_LIBS])
562 AC_DEFINE([HAVE_LIBCONFIG],[1],[libconfig found at compile time.])
564 [AC_MSG_WARN([libconfig not found, some features will be disabled])])
565 AM_CONDITIONAL([HAVE_LIBCONFIG],[test "x$LIBCONFIG_LIBS" != "x"])
567 dnl hivex library (highly recommended)
568 dnl This used to be a part of libguestfs, but was spun off into its
569 dnl own separate upstream project in libguestfs 1.0.85.
570 PKG_CHECK_MODULES([HIVEX], [hivex],
571 [AC_SUBST([HIVEX_CFLAGS])
572 AC_SUBST([HIVEX_LIBS])
573 AC_DEFINE([HAVE_HIVEX],[1],[hivex library found at compile time.])
575 [AC_MSG_WARN([hivex not found, some core features will be disabled])])
576 AM_CONDITIONAL([HAVE_HIVEX],[test "x$HIVEX_LIBS" != "x"])
578 dnl FUSE is optional to build the FUSE module.
579 AC_ARG_ENABLE([fuse],
580 AS_HELP_STRING([--disable-fuse], [Disable FUSE (guestmount) support]),
583 AS_IF([test "x$enable_fuse" != "xno"],
584 [PKG_CHECK_MODULES([FUSE],[fuse],,[
586 AC_MSG_WARN([FUSE library and headers are missing, so optional FUSE module won't be built])])])
587 AM_CONDITIONAL([HAVE_FUSE],[test "x$enable_fuse" != "xno"])
589 dnl Check for OCaml (optional, for OCaml bindings).
592 AC_ARG_ENABLE([ocaml],
593 AS_HELP_STRING([--disable-ocaml], [Disable OCaml language bindings]),
596 AS_IF([test "x$enable_ocaml" != "xno"],
597 [dnl OCAMLC and OCAMLFIND have to be unset first, otherwise
598 dnl AC_CHECK_TOOL (inside AC_PROG_OCAML) will not look.
604 AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"],
605 [AC_CHECK_OCAML_PKG([pcre])])
607 AM_CONDITIONAL([HAVE_OCAML],
608 [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"])
609 AM_CONDITIONAL([HAVE_OCAML_PCRE],
610 [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && test "x$OCAML_PKG_pcre" != "xno"])
611 AM_CONDITIONAL([HAVE_OCAMLDOC],
612 [test "x$OCAMLDOC" != "xno"])
614 dnl Check for Perl (optional, for Perl bindings).
616 AC_ARG_ENABLE([perl],
617 AS_HELP_STRING([--disable-perl], [Disable Perl language bindings]),
620 AS_IF([test "x$enable_perl" != "xno"],
623 AC_CHECK_PROG([PERL],[perl],[perl],[no])
625 dnl Check for Perl modules that must be present to compile and
626 dnl test the Perl bindings.
627 missing_perl_modules=no
628 for pm in Test::More ExtUtils::MakeMaker; do
629 AC_MSG_CHECKING([for $pm])
630 if ! perl -M$pm -e1 >&AS_MESSAGE_LOG_FD 2>&1; then
632 missing_perl_modules=yes
637 if test "x$missing_perl_modules" = "xyes"; then
638 AC_MSG_WARN([some Perl modules required to compile or test the Perl bindings are missing])
641 AM_CONDITIONAL([HAVE_PERL],
642 [test "x$PERL" != "xno" && test "x$missing_perl_modules" != "xyes"])
644 dnl Check for Python (optional, for Python bindings).
650 AC_ARG_ENABLE([python],
651 AS_HELP_STRING([--disable-python], [Disable Python language bindings]),
654 AS_IF([test "x$enable_python" != "xno"],
656 AC_CHECK_PROG([PYTHON],[python],[python],[no])
658 if test "x$PYTHON" != "xno"; then
659 AC_MSG_CHECKING([Python prefix])
660 PYTHON_PREFIX=`$PYTHON -c "import sys; print (sys.prefix)"`
661 AC_MSG_RESULT([$PYTHON_PREFIX])
663 AC_MSG_CHECKING([Python version])
664 PYTHON_VERSION=`$PYTHON -c "import sys; print (sys.version[[0:3]])"`
665 AC_MSG_RESULT([$PYTHON_VERSION])
667 AC_MSG_CHECKING([for Python include path])
668 if test -z "$PYTHON_INCLUDEDIR"; then
669 python_path=`$PYTHON -c "import distutils.sysconfig; \
670 print (distutils.sysconfig.get_python_inc ());"`
671 PYTHON_INCLUDEDIR=$python_path
673 AC_MSG_RESULT([$PYTHON_INCLUDEDIR])
675 AC_ARG_WITH([python-installdir],
676 [AS_HELP_STRING([--with-python-installdir],
677 [directory to install python modules @<:@default=check@:>@])],
678 [PYTHON_INSTALLDIR="$withval"
679 AC_MSG_NOTICE([Python install dir $PYTHON_INSTALLDIR])],
680 [PYTHON_INSTALLDIR=check])
682 if test "x$PYTHON_INSTALLDIR" = "xcheck"; then
684 AC_MSG_CHECKING([for Python site-packages path])
685 if test -z "$PYTHON_INSTALLDIR"; then
686 PYTHON_INSTALLDIR=`$PYTHON -c "import distutils.sysconfig; \
687 print (distutils.sysconfig.get_python_lib(1,0));"`
689 AC_MSG_RESULT([$PYTHON_INSTALLDIR])
693 LIBS="$LIBS -lpython$PYTHON_VERSION"
694 AC_CHECK_FUNCS([PyCapsule_New])
698 AC_SUBST(PYTHON_PREFIX)
699 AC_SUBST(PYTHON_VERSION)
700 AC_SUBST(PYTHON_INCLUDEDIR)
701 AC_SUBST(PYTHON_INSTALLDIR)
703 AM_CONDITIONAL([HAVE_PYTHON],
704 [test "x$PYTHON" != "xno" && test "x$PYTHON_INCLUDEDIR" != "x" && test "x$PYTHON_INSTALLDIR" != "x"])
706 dnl Check for Ruby and rake (optional, for Ruby bindings).
707 AC_ARG_ENABLE([ruby],
708 AS_HELP_STRING([--disable-ruby], [Disable Ruby language bindings]),
711 AS_IF([test "x$enable_ruby" != "xno"],
713 AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=0])
714 AC_CHECK_PROG([RAKE],[rake],[rake],[no])
716 AM_CONDITIONAL([HAVE_RUBY],
717 [test "x$RAKE" != "xno" && test -n "$HAVE_LIBRUBY"])
720 AC_ARG_WITH(java_home,
721 [AS_HELP_STRING([--with-java-home],
722 [specify path to JDK directory @<:@default=check@:>@])],
724 [with_java_home=check])
726 if test "x$with_java_home" != "xno"; then
727 if test "x$with_java_home" != "xyes" && test "x$with_java_home" != "xcheck"
729 # Reject unsafe characters in $JAVA_HOME
733 *[\\\"\#\$\&\'\`$jh_lf\ \ ]*)
734 AC_MSG_FAILURE([unsafe \$JAVA_HOME directory (use --with-java-home=no to disable Java support)]);;
736 if test -d "$with_java_home"; then
737 JAVA_HOME="$with_java_home"
739 AC_MSG_FAILURE([$with_java_home is not a directory (use --with-java-home=no to disable Java support)])
743 if test "x$JAVA_HOME" = "x"; then
744 # Look for Java in some likely locations.
747 /usr/lib/jvm/java-6-openjdk
749 if test -d $d && test -f $d/bin/java; then
756 if test "x$JAVA_HOME" != "x"; then
757 AC_MSG_CHECKING(for JDK in $JAVA_HOME)
758 if test ! -x "$JAVA_HOME/bin/java"; then
759 AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary (use --with-java-home=no to disable Java support)])
761 JAVA="$JAVA_HOME/bin/java"
763 if test ! -x "$JAVA_HOME/bin/javac"; then
764 AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
766 JAVAC="$JAVA_HOME/bin/javac"
768 if test ! -x "$JAVA_HOME/bin/javah"; then
769 AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
771 JAVAH="$JAVA_HOME/bin/javah"
773 if test ! -x "$JAVA_HOME/bin/javadoc"; then
774 AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary])
776 JAVADOC="$JAVA_HOME/bin/javadoc"
778 if test ! -x "$JAVA_HOME/bin/jar"; then
779 AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary])
781 JAR="$JAVA_HOME/bin/jar"
783 java_version=`$JAVA -version 2>&1 | grep "java version"`
784 AC_MSG_RESULT(found $java_version in $JAVA_HOME)
787 AC_MSG_CHECKING([for jni.h])
788 if test -f "$JAVA_HOME/include/jni.h"; then
789 JNI_CFLAGS="-I$JAVA_HOME/include"
791 if test "`find $JAVA_HOME -name jni.h`" != ""; then
792 head=`find $JAVA_HOME -name jni.h | tail -1`
793 dir=`dirname "$head"`
796 AC_MSG_FAILURE([missing jni.h header file])
799 AC_MSG_RESULT([$JNI_CFLAGS])
802 AC_MSG_CHECKING([for jni_md.h])
804 *linux*) system="linux" ;;
805 *SunOS*) system="solaris" ;;
806 *cygwin*) system="win32" ;;
807 *) system="$build_os" ;;
809 if test -f "$JAVA_HOME/include/$system/jni_md.h"; then
810 JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system"
812 if test "`find $JAVA_HOME -name jni_md.h`" != ""; then
813 head=`find $JAVA_HOME -name jni_md.h | tail -1`
814 dir=`dirname "$head"`
815 JNI_CFLAGS="$JNI_CFLAGS -I$dir"
817 AC_MSG_FAILURE([missing jni_md.h header file])
820 AC_MSG_RESULT([$JNI_CFLAGS])
822 dnl Need extra version flag?
823 AC_MSG_CHECKING([extra javac flags])
825 javac_version=`$JAVAC -version 2>&1`
826 case "$javac_version" in
828 JAVAC_FLAGS="-source 1.5" ;;
830 AC_MSG_RESULT([$JAVAC_FLAGS])
832 dnl Where to install jarfiles.
833 dnl XXX How to make it configurable?
834 JAR_INSTALL_DIR=\${prefix}/share/java
835 JNI_INSTALL_DIR=\${libdir}
838 jni_major_version=`echo "$VERSION" | awk -F. '{print $1}'`
839 jni_minor_version=`echo "$VERSION" | awk -F. '{print $2}'`
840 jni_micro_version=`echo "$VERSION" | awk -F. '{print $3}'`
841 JNI_VERSION_INFO=`expr "$jni_major_version" + "$jni_minor_version"`":$jni_micro_version:$jni_minor_version"
852 AC_SUBST(JAVAC_FLAGS)
853 AC_SUBST(JAR_INSTALL_DIR)
854 AC_SUBST(JNI_INSTALL_DIR)
855 AC_SUBST(JNI_VERSION_INFO)
857 AM_CONDITIONAL([HAVE_JAVA],[test -n "$JAVAC"])
859 dnl Check for Haskell (GHC).
861 AC_ARG_ENABLE([haskell],
862 AS_HELP_STRING([--disable-haskell], [Disable Haskell language bindings]),
864 [enable_haskell=yes])
865 AS_IF([test "x$enable_haskell" != "xno"],
868 AC_CHECK_PROG([GHC],[ghc],[ghc],[no])
870 AM_CONDITIONAL([HAVE_HASKELL],
871 [test "x$GHC" != "xno"])
876 AS_HELP_STRING([--disable-php], [Disable PHP language bindings]),
879 AS_IF([test "x$enable_php" != "xno"],
882 AC_CHECK_PROG([PHP],[php],[php],[no])
883 AC_CHECK_PROG([PHPIZE],[phpize],[phpize],[no])
885 AM_CONDITIONAL([HAVE_PHP], [test "x$PHP" != "xno" && test "x$PHPIZE" != "xno"])
887 dnl Check for Perl modules needed by Perl virt tools (virt-df, etc.)
888 AS_IF([test "x$PERL" != "xno"],
890 missing_perl_modules=no
891 for pm in Pod::Usage Getopt::Long Sys::Virt Data::Dumper Locale::TextDomain Win::Hivex Win::Hivex::Regedit String::ShellQuote; do
892 AC_MSG_CHECKING([for $pm])
893 if ! $PERL -M$pm -e1 >&AS_MESSAGE_LOG_FD 2>&1; then
895 missing_perl_modules=yes
900 if test "x$missing_perl_modules" = "xyes"; then
901 AC_MSG_WARN([some Perl modules required to compile the Perl virt-* tools are missing])
905 AM_CONDITIONAL([HAVE_TOOLS],
906 [test "x$PERL" != "xno" && test "x$missing_perl_modules" != "xyes"])
908 dnl Library versioning.
909 MAX_PROC_NR=`cat $srcdir/src/MAX_PROC_NR`
910 AC_SUBST(MAX_PROC_NR)
912 dnl Replace libtool with a wrapper that clobbers dependency_libs in *.la files
913 dnl http://lists.fedoraproject.org/pipermail/devel/2010-November/146343.html
914 LIBTOOL='bash $(top_srcdir)/libtool-kill-dependency_libs.sh $(top_builddir)/libtool'
917 dnl Produce output files.
918 AC_CONFIG_HEADERS([config.h])
919 dnl http://www.mail-archive.com/automake@gnu.org/msg10204.html
920 AC_CONFIG_FILES([podwrapper.sh],
921 [chmod +x podwrapper.sh])
922 AC_CONFIG_FILES([run],
924 AC_CONFIG_FILES([Makefile
939 gnulib/tests/Makefile
944 java/examples/Makefile
948 ocaml/examples/Makefile
951 perl/examples/Makefile
958 python/examples/Makefile
964 ruby/examples/Makefile
973 echo "------------------------------------------------------------"
974 echo "Thank you for downloading $PACKAGE_STRING"
976 echo "This is how we have configured the optional components for you today:"
978 echo "Daemon .............................. $enable_daemon"
979 echo "Appliance ........................... $enable_appliance"
980 echo "QEMU ................................ $QEMU"
981 echo -n "OCaml bindings ...................... "
982 if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi
983 echo -n "Perl bindings ....................... "
984 if test "x$HAVE_PERL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
985 echo -n "Python bindings ..................... "
986 if test "x$HAVE_PYTHON_TRUE" = "x"; then echo "yes"; else echo "no"; fi
987 echo -n "Ruby bindings ....................... "
988 if test "x$HAVE_RUBY_TRUE" = "x"; then echo "yes"; else echo "no"; fi
989 echo -n "Java bindings ....................... "
990 if test "x$HAVE_JAVA_TRUE" = "x"; then echo "yes"; else echo "no"; fi
991 echo -n "Haskell bindings .................... "
992 if test "x$HAVE_HASKELL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
993 echo -n "PHP bindings ........................ "
994 if test "x$HAVE_PHP_TRUE" = "x"; then echo "yes"; else echo "no"; fi
995 echo "guestfish and C virt tools .......... yes"
996 echo -n "Perl virt tools ..................... "
997 if test "x$HAVE_TOOLS_TRUE" = "x"; then echo "yes"; else echo "no"; fi
998 echo -n "virt-resize ......................... "
999 if test "x$HAVE_OCAML_TRUE" = "x" && test "x$HAVE_OCAML_PCRE_TRUE" = "x"; then echo "yes"; else echo "no"; fi
1000 echo "FUSE filesystem ..................... $enable_fuse"
1002 echo "If any optional component is configured 'no' when you expected 'yes'"
1003 echo "then you should check the preceeding messages."
1005 echo "Please report bugs back to the mailing list:"
1006 echo "http://www.redhat.com/mailman/listinfo/libguestfs"
1008 echo "Next you should type 'make' to build the package,"
1009 echo "then 'make check' to run the tests."
1010 echo "------------------------------------------------------------"