2 # Copyright (C) 2009 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 AC_INIT([libguestfs],[1.0.54])
21 AC_CONFIG_MACRO_DIR([m4])
25 dnl Check for basic C environment.
31 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
35 dnl Check support for 64 bit file offsets.
38 dnl Check sizeof long.
39 AC_CHECK_SIZEOF([long])
42 AC_CHECK_HEADERS([errno.h sys/types.h sys/un.h sys/wait.h sys/socket.h])
44 dnl Check for rpcgen and XDR library. rpcgen is optional.
45 AC_CHECK_PROG([RPCGEN],[rpcgen],[rpcgen],[no])
46 AM_CONDITIONAL([HAVE_RPCGEN],[test "x$RPCGEN" != "xno"])
47 AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
48 AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
51 dnl Check for pod2man and pod2text.
52 AC_CHECK_PROG([POD2MAN],[pod2man],[pod2man],[no])
53 test "x$POD2MAN" = "xno" &&
54 AC_MSG_ERROR([pod2man must be installed])
55 AC_CHECK_PROG([POD2TEXT],[pod2text],[pod2text],[no])
56 test "x$POD2TEXT" = "xno" &&
57 AC_MSG_ERROR([pod2text must be installed])
59 dnl Check for mksquashfs.
60 AC_PATH_PROGS([MKSQUASHFS],[mksquashfs],[no],
61 [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
62 test "x$MKSQUASHFS" = "xno" && AC_MSG_ERROR([mksquashfs must be installed])
64 dnl Check for QEMU for running binaries on this $host_cpu, fall
65 dnl back to basic 'qemu'. Allow the user to override it.
66 default_qemu="qemu-kvm qemu-system-$host_cpu qemu"
68 [AS_HELP_STRING([--with-qemu],
69 [set default QEMU binary @<:@default=[qemu-kvm] qemu-system-<host> qemu@:>@])],
71 [with_qemu="$default_qemu"])
72 AC_PATH_PROGS([QEMU],[$with_qemu],[no],
73 [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
74 test "x$QEMU" = "xno" && AC_MSG_ERROR([qemu must be installed])
75 AC_DEFINE_UNQUOTED([QEMU],["$QEMU"],[Location of qemu binary.])
77 dnl Check that the chosen qemu has vmchannel support.
78 dnl http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg01042.html
79 if test "x$vmchannel_test" != "xno"; then
80 AC_MSG_CHECKING([for vmchannel support in $QEMU])
81 vmchannelout=`$QEMU -net channel /dev/zero 2>&1 ||:`
82 echo "vmchannel test command output: $vmchannelout" >&AS_MESSAGE_LOG_FD
83 if ! echo $vmchannelout | grep -sq "vmchannel wrong port number" ; then
86 [I did not find vmchannel support in $QEMU.
88 vmchannel support is vital for libguestfs to operate. You need a version
89 of qemu >= 0.10, or the following patch backported to earlier versions:
91 http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg01042.html
93 You can override this test by setting the environment variable
94 vmchannel_test=no However if you don't have vmchannel support
95 in your qemu, then this just delays the pain.
97 If I am using the wrong qemu or you want to compile qemu from source
98 and install it in another location, then you should configure with
99 the --with-qemu option.
105 dnl Set drive interface used by the guestfs_add_drive{,_ro} calls
106 dnl ('-drive ...,if=...' option to qemu).
108 dnl NB. We will change the default in future to virtio, but at the
109 dnl moment this causes a performance problem, RHBZ#509383.
110 AC_ARG_WITH([drive-if],
111 [AS_HELP_STRING([--with-drive-if],
112 [set default driver (ide|scsi|virtio) @<:@default=ide@:>@])],
115 AC_DEFINE_UNQUOTED([DRIVE_IF],["$with_drive_if"],[Default drive interface.])
117 dnl Check for febootstrap etc.
118 AC_CHECK_PROG([FEBOOTSTRAP],
119 [febootstrap],[febootstrap],[no])
120 if test "x$FEBOOTSTRAP" != "xno"; then
121 AC_CHECK_PROG([FEBOOTSTRAP_RUN],
122 [febootstrap-run],[febootstrap-run],[no])
123 test "x$FEBOOTSTRAP_RUN" = "xno" && \
124 AC_MSG_ERROR([febootstrap-run must be installed])
125 AC_CHECK_PROG([FEBOOTSTRAP_INSTALL],
126 [febootstrap-install],[febootstrap-install],[no])
127 test "x$FEBOOTSTRAP_INSTALL" = "xno" && \
128 AC_MSG_ERROR([febootstrap-install must be installed])
129 AC_CHECK_PROG([FEBOOTSTRAP_MINIMIZE],
130 [febootstrap-minimize],[febootstrap-minimize],[no])
131 test "x$FEBOOTSTRAP_MINIMIZE" = "xno" && \
132 AC_MSG_ERROR([febootstrap-minimize must be installed])
133 AC_CHECK_PROG([FEBOOTSTRAP_TO_INITRAMFS],
134 [febootstrap-to-initramfs],[febootstrap-to-initramfs],[no])
135 test "x$FEBOOTSTRAP_TO_INITRAMFS" = "xno" && \
136 AC_MSG_ERROR([febootstrap-to-initramfs must be installed])
138 dnl Check we have fakechroot >= 2.9 (it's an indirect requirement
139 dnl of febootstrap, but old versions will fail with yum).
140 AC_CHECK_PROG([FAKECHROOT],
141 [fakechroot],[fakechroot],[no])
142 test "x$FAKECHROOT" = "xno" && \
143 AC_MSG_ERROR([fakechroot must be installed])
145 AC_MSG_CHECKING([fakechroot version])
146 fakechroot_version=`$FAKECHROOT --version | awk '{print $3}'`
147 if test -z "$fakechroot_version"; then
148 AC_MSG_RESULT([failed])
149 AC_MSG_WARN([fakechroot --version command failed, proceeding anyway])
151 AC_MSG_RESULT([$fakechroot_version])
152 fakechroot_major=`echo $fakechroot_version | awk -F. '{print $1}'`
153 fakechroot_minor=`echo $fakechroot_version | awk -F. '{print $2}'`
154 if test "$fakechroot_major" -lt 2 -o \
155 \( "$fakechroot_major" -eq 2 -a "$fakechroot_minor" -lt 9 \); then
156 AC_MSG_ERROR([fakechroot version must be >= 2.9])
161 # check for debootstrap and debirf
162 AC_CHECK_PROG([DEBOOTSTRAP],
163 [debootstrap],[debootstrap],[no])
164 test "x$DEBOOTSTRAP" = "xno" && \
165 AC_MSG_ERROR([Either febootstrap or debootstrap must be installed])
166 AC_CHECK_PROG([DEBIRF],[debirf],[debirf],[no])
167 test "x$DEBIRF" = "xno" &&
168 AC_MSG_ERROR([debirf must be installed])
174 dnl --with-repo to specify a Fedora repository.
176 [AS_HELP_STRING([--with-repo],
177 [set name of Fedora repository @<:@default=fedora-11@:>@])],
179 [with_repo=fedora-11])
182 AC_DEFINE_UNQUOTED([REPO],["$REPO"],[Name of Fedora repository.])
184 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
186 dnl --with-updates to specify a Fedora updates repository.
187 AC_ARG_WITH([updates],
188 [AS_HELP_STRING([--with-updates],
189 [set name of Fedora updates repository @<:@default=updates-released-f11@:>@])],
191 [with_updates=updates-released-f11])
192 UPDATES="$with_updates"
194 AC_DEFINE_UNQUOTED([UPDATES],["$UPDATES"],[Name of Fedora updates repository.])
196 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
198 dnl --with-mirror to specify a local Fedora mirror.
199 AC_ARG_WITH([mirror],
200 [AS_HELP_STRING([--with-mirror],
201 [set URI of a local Fedora mirror])],
204 MIRROR="$with_mirror"
207 dnl Build the supermin appliance? Please see README file before
208 dnl enabling this option.
209 AC_ARG_ENABLE([supermin],
210 [AS_HELP_STRING([--enable-supermin],
211 [enable supermin appliance (see README) @<:@default=no@:>@])],
213 [enable_supermin=no])
214 AM_CONDITIONAL([SUPERMIN],[test "x$enable_supermin" = "xyes"])
216 if test "x$enable_supermin" = "xyes"; then
217 dnl Check febootstrap-to-initramfs accepts the --files option
218 dnl (febootstrap >= 2.2).
219 AC_MSG_CHECKING([for --files support in $FEBOOTSTRAP_TO_INITRAMFS])
220 out=`$FEBOOTSTRAP_TO_INITRAMFS 2>&1 ||:`
221 echo "febootstrap_to_initramfs test command output: $out" >&AS_MESSAGE_LOG_FD
222 if ! echo $out | grep -sq -- "--files" ; then
225 [febootstrap-to-initramfs does not support the --files option.
227 To build the supermin appliance, you need to upgrade to the latest
228 version of febootstrap.
233 dnl Check febootstrap-to-initramfs accepts the --nocompress option
234 dnl (febootstrap >= 2.3).
235 AC_MSG_CHECKING([for --nocompress support in $FEBOOTSTRAP_TO_INITRAMFS])
236 out=`$FEBOOTSTRAP_TO_INITRAMFS 2>&1 ||:`
237 echo "febootstrap_to_initramfs test command output: $out" >&AS_MESSAGE_LOG_FD
238 if ! echo $out | grep -sq -- "--nocompress" ; then
241 [febootstrap-to-initramfs does not support the --nocompress option.
243 To build the supermin appliance, you need to upgrade to the latest
244 version of febootstrap.
251 AC_ARG_WITH([readline],
252 [AS_HELP_STRING([--with-readline],
253 [support fancy command line editing @<:@default=check@:>@])],
255 [with_readline=check])
258 AS_IF([test "x$with_readline" != xno],
259 [AC_CHECK_LIB([readline], [main],
260 [AC_SUBST([LIBREADLINE], ["-lreadline -lncurses"])
261 AC_DEFINE([HAVE_LIBREADLINE], [1],
262 [Define if you have libreadline])
264 [if test "x$with_readline" != xcheck; then
266 [--with-readline was given, but test for readline failed])
271 AM_GNU_GETTEXT([external])
272 AM_GNU_GETTEXT_VERSION([0.14])
274 dnl Check for OCaml (optional, for OCaml bindings).
277 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLC" != "xno" -a "x$OCAMLFIND" != "xno"])
279 dnl Check for Perl (optional, for Perl bindings).
280 dnl XXX This isn't quite right, we should check for Perl devel library.
281 AC_CHECK_PROG([PERL],[perl],[perl],[no])
283 dnl Check for Perl modules that must be present to compile and
284 dnl test the Perl bindings.
285 missing_perl_modules=no
286 for pm in Test::More Test::Pod Test::Pod::Coverage ExtUtils::MakeMaker; do
287 AC_MSG_CHECKING([for $pm])
288 if ! perl -M$pm -e1 >/dev/null 2>&1; then
290 missing_perl_modules=yes
295 if test "x$missing_perl_modules" = "xyes"; then
296 AC_MSG_WARN([some Perl modules required to compile or test the Perl bindings are missing])
299 AM_CONDITIONAL([HAVE_PERL],
300 [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
302 dnl Check for Python (optional, for Python bindings).
303 AC_CHECK_PROG([PYTHON],[python],[python],[no])
308 PYTHON_SITE_PACKAGES=
310 if test "x$PYTHON" != "xno"; then
311 PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"`
312 PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
314 $PYTHON_PREFIX/include/python$PYTHON_VERSION \
315 /usr/include/python$PYTHON_VERSION \
316 /usr/local/include/python$PYTHON_VERSION
318 AC_MSG_CHECKING([Python.h in $d])
319 if test -r "$d/Python.h"; then
320 AC_MSG_RESULT([found])
324 AC_MSG_RESULT([not found])
327 $PYTHON_PREFIX/lib64/python$PYTHON_VERSION/site-packages \
328 $PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages \
329 /usr/lib64/python$PYTHON_VERSION/site-packages \
330 /usr/lib/python$PYTHON_VERSION/site-packages \
331 /usr/local/lib/python$PYTHON_VERSION/site-packages
333 AC_MSG_CHECKING([for $d])
334 if test -d "$d"; then
335 AC_MSG_RESULT([found])
336 PYTHON_SITE_PACKAGES=$d
339 AC_MSG_RESULT([not found])
343 AC_SUBST(PYTHON_PREFIX)
344 AC_SUBST(PYTHON_VERSION)
345 AC_SUBST(PYTHON_INCLUDEDIR)
346 AC_SUBST(PYTHON_SITE_PACKAGES)
348 AM_CONDITIONAL([HAVE_PYTHON],
349 [test "x$PYTHON_INCLUDEDIR" != "x" -a "x$PYTHON_SITE_PACKAGES" != "x"])
351 dnl Check for Ruby and rake (optional, for Ruby bindings).
352 AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=0])
353 AC_CHECK_PROG([RAKE],[rake],[rake],[no])
355 AM_CONDITIONAL([HAVE_RUBY],
356 [test "x$RAKE" != "xno" -a -n "$HAVE_LIBRUBY"])
359 AC_ARG_WITH(java_home,
360 [AS_HELP_STRING([--with-java-home],
361 [specify path to JDK directory @<:@default=check@:>@])],
363 [with_java_home=check])
365 if test "x$with_java_home" != "xno"; then
366 if test "x$with_java_home" != "xyes" -a "x$with_java_home" != "xcheck"
368 if test -d "$with_java_home"; then
369 JAVA_HOME="$with_java_home"
371 AC_MSG_FAILURE([$with_java_home is not a directory (use --with-java-home=no to disable Java support)])
375 if test "x$JAVA_HOME" = "x"; then
376 # Look for Java in some likely locations.
379 /usr/lib/jvm/java-6-openjdk
381 if test -d $d -a -f $d/bin/java; then
388 if test "x$JAVA_HOME" != "x"; then
389 AC_MSG_CHECKING(for JDK in $JAVA_HOME)
390 if test ! -x "$JAVA_HOME/bin/java"; then
391 AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary (use --with-java-home=no to disable Java support)])
393 JAVA="$JAVA_HOME/bin/java"
395 if test ! -x "$JAVA_HOME/bin/javac"; then
396 AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
398 JAVAC="$JAVA_HOME/bin/javac"
400 if test ! -x "$JAVA_HOME/bin/javah"; then
401 AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
403 JAVAH="$JAVA_HOME/bin/javah"
405 if test ! -x "$JAVA_HOME/bin/javadoc"; then
406 AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary])
408 JAVADOC="$JAVA_HOME/bin/javadoc"
410 if test ! -x "$JAVA_HOME/bin/jar"; then
411 AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary])
413 JAR="$JAVA_HOME/bin/jar"
415 java_version=`$JAVA -version 2>&1 | grep "java version"`
416 AC_MSG_RESULT(found $java_version in $JAVA_HOME)
419 AC_MSG_CHECKING([for jni.h])
420 if test -f "$JAVA_HOME/include/jni.h"; then
421 JNI_CFLAGS="-I$JAVA_HOME/include"
423 if test "`find $JAVA_HOME -name jni.h`" != ""; then
424 head=`find $JAVA_HOME -name jni.h | tail -1`
428 AC_MSG_FAILURE([missing jni.h header file])
431 AC_MSG_RESULT([$JNI_CFLAGS])
434 AC_MSG_CHECKING([for jni_md.h])
436 *linux*) system="linux" ;;
437 *SunOS*) system="solaris" ;;
438 *cygwin*) system="win32" ;;
439 *) system="$build_os" ;;
441 if test -f "$JAVA_HOME/include/$system/jni_md.h"; then
442 JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system"
444 if test "`find $JAVA_HOME -name jni_md.h`" != ""; then
445 head=`find $JAVA_HOME -name jni_md.h | tail -1`
447 JNI_CFLAGS="$JNI_CFLAGS -I$dir"
449 AC_MSG_FAILURE([missing jni_md.h header file])
452 AC_MSG_RESULT([$JNI_CFLAGS])
454 dnl Need extra version flag?
455 AC_MSG_CHECKING([extra javac flags])
457 javac_version=`$JAVAC -version 2>&1`
458 case "$javac_version" in
460 JAVAC_FLAGS="-source 1.5" ;;
462 AC_MSG_RESULT([$JAVAC_FLAGS])
464 dnl Where to install jarfiles.
465 dnl XXX How to make it configurable?
466 JAR_INSTALL_DIR=\${prefix}/share/java
467 JNI_INSTALL_DIR=\${libdir}
470 jni_major_version=`echo $VERSION | awk -F. '{print $1}'`
471 jni_minor_version=`echo $VERSION | awk -F. '{print $2}'`
472 jni_micro_version=`echo $VERSION | awk -F. '{print $3}'`
473 JNI_VERSION_INFO=`expr $jni_major_version + $jni_minor_version`:$jni_micro_version:$jni_minor_version
484 AC_SUBST(JAVAC_FLAGS)
485 AC_SUBST(JAR_INSTALL_DIR)
486 AC_SUBST(JNI_INSTALL_DIR)
487 AC_SUBST(JNI_VERSION_INFO)
489 AM_CONDITIONAL([HAVE_JAVA],[test -n "$JAVAC"])
491 dnl Check for Haskell (GHC).
492 AC_CHECK_PROG([GHC],[ghc],[ghc],[no])
494 AM_CONDITIONAL([HAVE_HASKELL],
495 [test "x$GHC" != "xno"])
497 dnl Check for Perl modules needed by the inspector.
498 missing_perl_modules=no
499 for pm in Pod::Usage Getopt::Long Sys::Virt Data::Dumper XML::Writer; do
500 AC_MSG_CHECKING([for $pm])
501 if ! perl -M$pm -e1 >/dev/null 2>&1; then
503 missing_perl_modules=yes
508 if test "x$missing_perl_modules" = "xyes"; then
509 AC_MSG_WARN([some Perl modules required to compile virt-inspector are missing])
512 AM_CONDITIONAL([HAVE_INSPECTOR],
513 [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
515 dnl Library versioning.
516 MAX_PROC_NR=`cat $srcdir/src/MAX_PROC_NR`
517 AC_SUBST(MAX_PROC_NR)
520 AC_CONFIG_SUBDIRS([daemon])
522 dnl Produce output files.
523 AC_CONFIG_HEADERS([config.h])
524 dnl http://www.mail-archive.com/automake@gnu.org/msg10204.html
525 AC_CONFIG_FILES([appliance/make.sh],
526 [chmod +x appliance/make.sh])
527 AC_CONFIG_FILES([appliance/update.sh],
528 [chmod +x appliance/update.sh])
529 AC_CONFIG_FILES([appliance/supermin-split.sh],
530 [chmod +x appliance/supermin-split.sh])
531 AC_CONFIG_FILES([appliance/supermin-make.sh],
532 [chmod +x appliance/supermin-make.sh])
533 AC_CONFIG_FILES([appliance/libguestfs-supermin-helper],
534 [chmod +x appliance/libguestfs-supermin-helper])
535 AC_CONFIG_FILES([Makefile
536 src/Makefile fish/Makefile po/Makefile.in examples/Makefile
538 appliance/debian/debirf.conf
542 ocaml/Makefile ocaml/examples/Makefile
545 ruby/Makefile ruby/Rakefile
550 ocaml/META perl/Makefile.PL])
556 echo "------------------------------------------------------------"
557 echo "Thank you for downloading $PACKAGE_STRING"
559 echo "This is how we have configured the optional components for you today:"
561 echo "QEMU ................................ $QEMU"
562 echo -n "OCaml bindings ...................... "
563 if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi
564 echo -n "Perl bindings ....................... "
565 if test "x$HAVE_PERL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
566 echo -n "Python bindings ..................... "
567 if test "x$HAVE_PYTHON_TRUE" = "x"; then echo "yes"; else echo "no"; fi
568 echo -n "Ruby bindings ....................... "
569 if test "x$HAVE_RUBY_TRUE" = "x"; then echo "yes"; else echo "no"; fi
570 echo -n "Java bindings ....................... "
571 if test "x$HAVE_JAVA_TRUE" = "x"; then echo "yes"; else echo "no"; fi
572 echo -n "Haskell bindings .................... "
573 if test "x$HAVE_HASKELL" = "x"; then echo "yes"; else echo "no"; fi
574 echo -n "virt-inspector ...................... "
575 if test "x$HAVE_INSPECTOR" = "x"; then echo "yes"; else echo "no"; fi
576 echo "supermin appliance .................. $enable_supermin"
578 echo "If any optional component is configured 'no' when you expected 'yes'"
579 echo "then you should check the preceeding messages."
581 echo "Please report bugs back to the fedora-virt mailing list:"
582 echo "http://www.redhat.com/mailman/listinfo/fedora-virt"
584 echo "Next you should type 'make' to build the package,"
585 echo "then 'make check' to run the tests."
586 echo "------------------------------------------------------------"