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.51])
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 Check for febootstrap etc.
106 AC_CHECK_PROG([FEBOOTSTRAP],
107 [febootstrap],[febootstrap],[no])
108 if test "x$FEBOOTSTRAP" != "xno"; then
109 AC_CHECK_PROG([FEBOOTSTRAP_RUN],
110 [febootstrap-run],[febootstrap-run],[no])
111 test "x$FEBOOTSTRAP_RUN" = "xno" && \
112 AC_MSG_ERROR([febootstrap-run must be installed])
113 AC_CHECK_PROG([FEBOOTSTRAP_INSTALL],
114 [febootstrap-install],[febootstrap-install],[no])
115 test "x$FEBOOTSTRAP_INSTALL" = "xno" && \
116 AC_MSG_ERROR([febootstrap-install must be installed])
117 AC_CHECK_PROG([FEBOOTSTRAP_MINIMIZE],
118 [febootstrap-minimize],[febootstrap-minimize],[no])
119 test "x$FEBOOTSTRAP_MINIMIZE" = "xno" && \
120 AC_MSG_ERROR([febootstrap-minimize must be installed])
121 AC_CHECK_PROG([FEBOOTSTRAP_TO_INITRAMFS],
122 [febootstrap-to-initramfs],[febootstrap-to-initramfs],[no])
123 test "x$FEBOOTSTRAP_TO_INITRAMFS" = "xno" && \
124 AC_MSG_ERROR([febootstrap-to-initramfs must be installed])
126 dnl Check we have fakechroot >= 2.9 (it's an indirect requirement
127 dnl of febootstrap, but old versions will fail with yum).
128 AC_CHECK_PROG([FAKECHROOT],
129 [fakechroot],[fakechroot],[no])
130 test "x$FAKECHROOT" = "xno" && \
131 AC_MSG_ERROR([fakechroot must be installed])
133 AC_MSG_CHECKING([fakechroot version])
134 fakechroot_version=`$FAKECHROOT --version | awk '{print $3}'`
135 if test -z "$fakechroot_version"; then
136 AC_MSG_RESULT([failed])
137 AC_MSG_WARN([fakechroot --version command failed, proceeding anyway])
139 AC_MSG_RESULT([$fakechroot_version])
140 fakechroot_major=`echo $fakechroot_version | awk -F. '{print $1}'`
141 fakechroot_minor=`echo $fakechroot_version | awk -F. '{print $2}'`
142 if test "$fakechroot_major" -lt 2 -o \
143 \( "$fakechroot_major" -eq 2 -a "$fakechroot_minor" -lt 9 \); then
144 AC_MSG_ERROR([fakechroot version must be >= 2.9])
148 # check for debootstrap and debirf
149 AC_CHECK_PROG([DEBOOTSTRAP],
150 [debootstrap],[debootstrap],[no])
151 test "x$DEBOOTSTRAP" = "xno" && \
152 AC_MSG_ERROR([Either febootstrap or debootstrap must be installed])
153 AC_CHECK_PROG([DEBIRF],[debirf],[debirf],[no])
154 test "x$DEBIRF" = "xno" &&
155 AC_MSG_ERROR([debirf must be installed])
159 dnl --with-repo to specify a Fedora repository.
161 [AS_HELP_STRING([--with-repo],
162 [set name of Fedora repository @<:@default=fedora-11@:>@])],
164 [with_repo=fedora-11])
167 AC_DEFINE_UNQUOTED([REPO],["$REPO"],[Name of Fedora repository.])
169 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
171 dnl --with-updates to specify a Fedora updates repository.
172 AC_ARG_WITH([updates],
173 [AS_HELP_STRING([--with-updates],
174 [set name of Fedora updates repository @<:@default=updates-released-f11@:>@])],
176 [with_updates=updates-released-f11])
177 UPDATES="$with_updates"
179 AC_DEFINE_UNQUOTED([UPDATES],["$UPDATES"],[Name of Fedora updates repository.])
181 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
183 dnl --with-mirror to specify a local Fedora mirror.
184 AC_ARG_WITH([mirror],
185 [AS_HELP_STRING([--with-mirror],
186 [set URI of a local Fedora mirror])],
189 MIRROR="$with_mirror"
192 dnl Build the supermin appliance? Please see README file before
193 dnl enabling this option.
194 AC_ARG_ENABLE([supermin],
195 [AS_HELP_STRING([--enable-supermin],
196 [enable supermin appliance (see README) @<:@default=no@:>@])],
198 [enable_supermin=no])
199 AM_CONDITIONAL([SUPERMIN],[test "x$enable_supermin" = "xyes"])
201 if test "x$enable_supermin" = "xyes"; then
202 dnl Check febootstrap-to-initramfs accepts the --files option
203 dnl (febootstrap >= 2.2).
204 AC_MSG_CHECKING([for --files support in $FEBOOTSTRAP_TO_INITRAMFS])
205 out=`$FEBOOTSTRAP_TO_INITRAMFS 2>&1 ||:`
206 echo "febootstrap_to_initramfs test command output: $out" >&AS_MESSAGE_LOG_FD
207 if ! echo $out | grep -sq -- "--files" ; then
210 [febootstrap-to-initramfs does not support the --files option.
212 To build the supermin appliance, you need to upgrade to the latest
213 version of febootstrap.
218 dnl Check febootstrap-to-initramfs accepts the --nocompress option
219 dnl (febootstrap >= 2.3).
220 AC_MSG_CHECKING([for --nocompress support in $FEBOOTSTRAP_TO_INITRAMFS])
221 out=`$FEBOOTSTRAP_TO_INITRAMFS 2>&1 ||:`
222 echo "febootstrap_to_initramfs test command output: $out" >&AS_MESSAGE_LOG_FD
223 if ! echo $out | grep -sq -- "--nocompress" ; then
226 [febootstrap-to-initramfs does not support the --nocompress option.
228 To build the supermin appliance, you need to upgrade to the latest
229 version of febootstrap.
236 AC_ARG_WITH([readline],
237 [AS_HELP_STRING([--with-readline],
238 [support fancy command line editing @<:@default=check@:>@])],
240 [with_readline=check])
243 AS_IF([test "x$with_readline" != xno],
244 [AC_CHECK_LIB([readline], [main],
245 [AC_SUBST([LIBREADLINE], ["-lreadline -lncurses"])
246 AC_DEFINE([HAVE_LIBREADLINE], [1],
247 [Define if you have libreadline])
249 [if test "x$with_readline" != xcheck; then
251 [--with-readline was given, but test for readline failed])
256 AM_GNU_GETTEXT([external])
257 AM_GNU_GETTEXT_VERSION([0.14])
259 dnl Check for OCaml (optional, for OCaml bindings).
262 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLC" != "xno" -a "x$OCAMLFIND" != "xno"])
264 dnl Check for Perl (optional, for Perl bindings).
265 dnl XXX This isn't quite right, we should check for Perl devel library.
266 AC_CHECK_PROG([PERL],[perl],[perl],[no])
268 dnl Check for Perl modules that must be present to compile and
269 dnl test the Perl bindings.
270 missing_perl_modules=no
271 for pm in Test::More Test::Pod Test::Pod::Coverage ExtUtils::MakeMaker; do
272 AC_MSG_CHECKING([for $pm])
273 if ! perl -M$pm -e1 >/dev/null 2>&1; then
275 missing_perl_modules=yes
280 if test "x$missing_perl_modules" = "xyes"; then
281 AC_MSG_WARN([some Perl modules required to compile or test the Perl bindings are missing])
284 AM_CONDITIONAL([HAVE_PERL],
285 [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
287 dnl Check for Python (optional, for Python bindings).
288 AC_CHECK_PROG([PYTHON],[python],[python],[no])
293 PYTHON_SITE_PACKAGES=
295 if test "x$PYTHON" != "xno"; then
296 PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"`
297 PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
299 $PYTHON_PREFIX/include/python$PYTHON_VERSION \
300 /usr/include/python$PYTHON_VERSION \
301 /usr/local/include/python$PYTHON_VERSION
303 AC_MSG_CHECKING([Python.h in $d])
304 if test -r "$d/Python.h"; then
305 AC_MSG_RESULT([found])
309 AC_MSG_RESULT([not found])
312 $PYTHON_PREFIX/lib64/python$PYTHON_VERSION/site-packages \
313 $PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages \
314 /usr/lib64/python$PYTHON_VERSION/site-packages \
315 /usr/lib/python$PYTHON_VERSION/site-packages \
316 /usr/local/lib/python$PYTHON_VERSION/site-packages
318 AC_MSG_CHECKING([for $d])
319 if test -d "$d"; then
320 AC_MSG_RESULT([found])
321 PYTHON_SITE_PACKAGES=$d
324 AC_MSG_RESULT([not found])
328 AC_SUBST(PYTHON_PREFIX)
329 AC_SUBST(PYTHON_VERSION)
330 AC_SUBST(PYTHON_INCLUDEDIR)
331 AC_SUBST(PYTHON_SITE_PACKAGES)
333 AM_CONDITIONAL([HAVE_PYTHON],
334 [test "x$PYTHON_INCLUDEDIR" != "x" -a "x$PYTHON_SITE_PACKAGES" != "x"])
336 dnl Check for Ruby and rake (optional, for Ruby bindings).
337 AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=0])
338 AC_CHECK_PROG([RAKE],[rake],[rake],[no])
340 AM_CONDITIONAL([HAVE_RUBY],
341 [test "x$RAKE" != "xno" -a -n "$HAVE_LIBRUBY"])
344 AC_ARG_WITH(java_home,
345 [AS_HELP_STRING([--with-java-home],
346 [specify path to JDK directory @<:@default=check@:>@])],
348 [with_java_home=check])
350 if test "x$with_java_home" != "xno"; then
351 if test "x$with_java_home" != "xyes" -a "x$with_java_home" != "xcheck"
353 if test -d "$with_java_home"; then
354 JAVA_HOME="$with_java_home"
356 AC_MSG_FAILURE([$with_java_home is not a directory (use --with-java-home=no to disable Java support)])
360 if test "x$JAVA_HOME" = "x"; then
361 # Look for Java in some likely locations.
364 /usr/lib/jvm/java-6-openjdk
366 if test -d $d -a -f $d/bin/java; then
373 if test "x$JAVA_HOME" != "x"; then
374 AC_MSG_CHECKING(for JDK in $JAVA_HOME)
375 if test ! -x "$JAVA_HOME/bin/java"; then
376 AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary (use --with-java-home=no to disable Java support)])
378 JAVA="$JAVA_HOME/bin/java"
380 if test ! -x "$JAVA_HOME/bin/javac"; then
381 AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
383 JAVAC="$JAVA_HOME/bin/javac"
385 if test ! -x "$JAVA_HOME/bin/javah"; then
386 AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
388 JAVAH="$JAVA_HOME/bin/javah"
390 if test ! -x "$JAVA_HOME/bin/javadoc"; then
391 AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary])
393 JAVADOC="$JAVA_HOME/bin/javadoc"
395 if test ! -x "$JAVA_HOME/bin/jar"; then
396 AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary])
398 JAR="$JAVA_HOME/bin/jar"
400 java_version=`$JAVA -version 2>&1 | grep "java version"`
401 AC_MSG_RESULT(found $java_version in $JAVA_HOME)
404 AC_MSG_CHECKING([for jni.h])
405 if test -f "$JAVA_HOME/include/jni.h"; then
406 JNI_CFLAGS="-I$JAVA_HOME/include"
408 if test "`find $JAVA_HOME -name jni.h`" != ""; then
409 head=`find $JAVA_HOME -name jni.h | tail -1`
413 AC_MSG_FAILURE([missing jni.h header file])
416 AC_MSG_RESULT([$JNI_CFLAGS])
419 AC_MSG_CHECKING([for jni_md.h])
421 *linux*) system="linux" ;;
422 *SunOS*) system="solaris" ;;
423 *cygwin*) system="win32" ;;
424 *) system="$build_os" ;;
426 if test -f "$JAVA_HOME/include/$system/jni_md.h"; then
427 JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system"
429 if test "`find $JAVA_HOME -name jni_md.h`" != ""; then
430 head=`find $JAVA_HOME -name jni_md.h | tail -1`
432 JNI_CFLAGS="$JNI_CFLAGS -I$dir"
434 AC_MSG_FAILURE([missing jni_md.h header file])
437 AC_MSG_RESULT([$JNI_CFLAGS])
439 dnl Need extra version flag?
440 AC_MSG_CHECKING([extra javac flags])
442 javac_version=`$JAVAC -version 2>&1`
443 case "$javac_version" in
445 JAVAC_FLAGS="-source 1.5" ;;
447 AC_MSG_RESULT([$JAVAC_FLAGS])
449 dnl Where to install jarfiles.
450 dnl XXX How to make it configurable?
451 JAR_INSTALL_DIR=\${prefix}/share/java
452 JNI_INSTALL_DIR=\${libdir}
455 jni_major_version=`echo $VERSION | awk -F. '{print $1}'`
456 jni_minor_version=`echo $VERSION | awk -F. '{print $2}'`
457 jni_micro_version=`echo $VERSION | awk -F. '{print $3}'`
458 JNI_VERSION_INFO=`expr $jni_major_version + $jni_minor_version`:$jni_micro_version:$jni_minor_version
469 AC_SUBST(JAVAC_FLAGS)
470 AC_SUBST(JAR_INSTALL_DIR)
471 AC_SUBST(JNI_INSTALL_DIR)
472 AC_SUBST(JNI_VERSION_INFO)
474 AM_CONDITIONAL([HAVE_JAVA],[test -n "$JAVAC"])
476 dnl Check for Haskell (GHC).
477 AC_CHECK_PROG([GHC],[ghc],[ghc],[no])
479 AM_CONDITIONAL([HAVE_HASKELL],
480 [test "x$GHC" != "xno"])
482 dnl Check for Perl modules needed by the inspector.
483 missing_perl_modules=no
484 for pm in Pod::Usage Getopt::Long Sys::Virt Data::Dumper; do
485 AC_MSG_CHECKING([for $pm])
486 if ! perl -M$pm -e1 >/dev/null 2>&1; then
488 missing_perl_modules=yes
493 if test "x$missing_perl_modules" = "xyes"; then
494 AC_MSG_WARN([some Perl modules required to compile virt-inspector are missing])
497 AM_CONDITIONAL([HAVE_INSPECTOR],
498 [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
501 AC_CONFIG_SUBDIRS([daemon])
503 dnl Produce output files.
504 AC_CONFIG_HEADERS([config.h])
505 AC_CONFIG_FILES([Makefile
506 src/Makefile fish/Makefile po/Makefile.in examples/Makefile
508 appliance/make.sh appliance/update.sh
509 appliance/supermin-split.sh appliance/supermin-make.sh
510 appliance/libguestfs-supermin-helper
514 ocaml/Makefile ocaml/examples/Makefile
517 ruby/Makefile ruby/Rakefile
522 ocaml/META perl/Makefile.PL])
526 chmod +x appliance/*.sh appliance/libguestfs-supermin-helper
531 echo "------------------------------------------------------------"
532 echo "Thank you for downloading $PACKAGE_STRING"
534 echo "This is how we have configured the optional components for you today:"
536 echo "QEMU ................................ $QEMU"
537 echo -n "OCaml bindings ...................... "
538 if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi
539 echo -n "Perl bindings ....................... "
540 if test "x$HAVE_PERL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
541 echo -n "Python bindings ..................... "
542 if test "x$HAVE_PYTHON_TRUE" = "x"; then echo "yes"; else echo "no"; fi
543 echo -n "Ruby bindings ....................... "
544 if test "x$HAVE_RUBY_TRUE" = "x"; then echo "yes"; else echo "no"; fi
545 echo -n "Java bindings ....................... "
546 if test "x$HAVE_JAVA_TRUE" = "x"; then echo "yes"; else echo "no"; fi
547 echo -n "Haskell bindings .................... "
548 if test "x$HAVE_HASKELL" = "x"; then echo "yes"; else echo "no"; fi
549 echo -n "virt-inspector ...................... "
550 if test "x$HAVE_INSPECTOR" = "x"; then echo "yes"; else echo "no"; fi
551 echo "supermin appliance .................. $enable_supermin"
553 echo "If any optional component is configured 'no' when you expected 'yes'"
554 echo "then you should check the preceeding messages."
556 echo "Please report bugs back to the fedora-virt mailing list:"
557 echo "http://www.redhat.com/mailman/listinfo/fedora-virt"
559 echo "Next you should type 'make' to build the package,"
560 echo "then 'make check' to run the tests."
561 echo "------------------------------------------------------------"