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.8])
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.
39 AC_CHECK_HEADERS([errno.h sys/types.h sys/un.h sys/wait.h sys/socket.h])
41 dnl Check for rpcgen and XDR library. rpcgen is optional.
42 AC_CHECK_PROG([RPCGEN],[rpcgen],[rpcgen],[no])
43 AM_CONDITIONAL([HAVE_RPCGEN],[test "x$RPCGEN" != "xno"])
44 AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[
45 AC_SEARCH_LIBS([xdrmem_create],[rpc xdr nsl])
48 dnl Check for pod2man and pod2text.
49 AC_CHECK_PROG([POD2MAN],[pod2man],[pod2man],[no])
50 test "x$POD2MAN" = "xno" &&
51 AC_MSG_ERROR([pod2man must be installed])
52 AC_CHECK_PROG([POD2TEXT],[pod2text],[pod2text],[no])
53 test "x$POD2TEXT" = "xno" &&
54 AC_MSG_ERROR([pod2text must be installed])
56 dnl Check for QEMU for running binaries on this $host_cpu, fall
57 dnl back to basic 'qemu'. Allow the user to override it.
58 default_qemu="qemu-system-$host_cpu qemu"
59 # On x86-64, try using KVM first.
60 if test "x$host_cpu" = "xx86_64"; then
61 default_qemu="qemu-kvm $default_qemu"
64 [AS_HELP_STRING([--with-qemu],
65 [set default QEMU binary @<:@default=[qemu-kvm] qemu-system-<host> qemu@:>@])],
67 [with_qemu="$default_qemu"])
68 AC_PATH_PROGS([QEMU],[$with_qemu],[no],
69 [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
70 test "x$QEMU" = "xno" && AC_MSG_ERROR([qemu must be installed])
71 AC_DEFINE_UNQUOTED([QEMU],["$QEMU"],[Location of qemu binary.])
73 dnl Check for febootstrap etc.
74 AC_CHECK_PROG([FEBOOTSTRAP],
75 [febootstrap],[febootstrap],[no])
76 test "x$FEBOOTSTRAP" = "xno" && \
77 AC_MSG_ERROR([febootstrap must be installed])
78 AC_CHECK_PROG([FEBOOTSTRAP_RUN],
79 [febootstrap-run],[febootstrap-run],[no])
80 test "x$FEBOOTSTRAP_RUN" = "xno" && \
81 AC_MSG_ERROR([febootstrap-run must be installed])
82 AC_CHECK_PROG([FEBOOTSTRAP_MINIMIZE],
83 [febootstrap-minimize],[febootstrap-minimize],[no])
84 test "x$FEBOOTSTRAP_MINIMIZE" = "xno" && \
85 AC_MSG_ERROR([febootstrap-minimize must be installed])
86 AC_CHECK_PROG([FEBOOTSTRAP_TO_INITRAMFS],
87 [febootstrap-to-initramfs],[febootstrap-to-initramfs],[no])
88 test "x$FEBOOTSTRAP_TO_INITRAMFS" = "xno" && \
89 AC_MSG_ERROR([febootstrap-to-initramfs must be installed])
91 dnl --with-repo to specify a Fedora repository.
93 [AS_HELP_STRING([--with-repo],
94 [set name of Fedora repository @<:@default=fedora-10@:>@])],
96 [with_repo=fedora-10])
99 AC_DEFINE_UNQUOTED([REPO],["$REPO"],[Name of Fedora repository.])
101 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
103 dnl --with-updates to specify a Fedora updates repository.
104 AC_ARG_WITH([updates],
105 [AS_HELP_STRING([--with-updates],
106 [set name of Fedora updates repository @<:@default=updates-released-f10@:>@])],
108 [with_updates=updates-released-f10])
109 UPDATES="$with_updates"
111 AC_DEFINE_UNQUOTED([UPDATES],["$UPDATES"],[Name of Fedora updates repository.])
113 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
115 dnl --with-mirror to specify a local Fedora mirror.
116 AC_ARG_WITH([mirror],
117 [AS_HELP_STRING([--with-mirror],
118 [set URI of a local Fedora mirror])],
121 MIRROR="$with_mirror"
125 AC_ARG_WITH([readline],
126 [AS_HELP_STRING([--with-readline],
127 [support fancy command line editing @<:@default=check@:>@])],
129 [with_readline=check])
132 AS_IF([test "x$with_readline" != xno],
133 [AC_CHECK_LIB([readline], [main],
134 [AC_SUBST([LIBREADLINE], ["-lreadline -lncurses"])
135 AC_DEFINE([HAVE_LIBREADLINE], [1],
136 [Define if you have libreadline])
138 [if test "x$with_readline" != xcheck; then
140 [--with-readline was given, but test for readline failed])
144 dnl Check for OCaml (optional, for OCaml bindings).
147 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLC" != "xno" -a "x$OCAMLFIND" != "xno"])
149 dnl Check for Perl (optional, for Perl bindings).
150 dnl XXX This isn't quite right, we should check for devel libraries.
151 AC_CHECK_PROG([PERL],[perl],[perl],[no])
152 AM_CONDITIONAL([HAVE_PERL],[test "x$PERL" != "xno"])
154 dnl Check for Python (optional, for Python bindings).
155 AC_CHECK_PROG([PYTHON],[python],[python],[no])
160 PYTHON_SITE_PACKAGES=
162 if test "x$PYTHON" != "xno"; then
163 PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"`
164 PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
166 $PYTHON_PREFIX/include/python$PYTHON_VERSION \
167 /usr/include/python$PYTHON_VERSION \
168 /usr/local/include/python$PYTHON_VERSION
170 AC_MSG_CHECKING([Python.h in $d])
171 if test -r "$d/Python.h"; then
172 AC_MSG_RESULT([found])
176 AC_MSG_RESULT([not found])
179 $PYTHON_PREFIX/lib64/python$PYTHON_VERSION/site-packages \
180 $PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages \
181 /usr/lib64/python$PYTHON_VERSION/site-packages \
182 /usr/lib/python$PYTHON_VERSION/site-packages \
183 /usr/local/lib/python$PYTHON_VERSION/site-packages
185 AC_MSG_CHECKING([for $d])
186 if test -d "$d"; then
187 AC_MSG_RESULT([found])
188 PYTHON_SITE_PACKAGES=$d
191 AC_MSG_RESULT([not found])
195 AC_SUBST(PYTHON_PREFIX)
196 AC_SUBST(PYTHON_VERSION)
197 AC_SUBST(PYTHON_INCLUDEDIR)
198 AC_SUBST(PYTHON_SITE_PACKAGES)
200 AM_CONDITIONAL([HAVE_PYTHON],
201 [test "x$PYTHON_INCLUDEDIR" != "x" -a "x$PYTHON_SITE_PACKAGES" != "x"])
203 dnl Check for Ruby and rake (optional, for Ruby bindings).
204 AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=0])
205 AC_CHECK_PROG([RAKE],[rake],[rake],[no])
207 AM_CONDITIONAL([HAVE_RUBY],
208 [test "x$RAKE" != "xno" -a -n "$HAVE_LIBRUBY"])
211 AC_ARG_WITH(java_home,
212 [AS_HELP_STRING([--with-java-home],
213 [specify path to JDK directory @<:@default=check@:>@])],
215 [with_java_home=check])
217 if test "x$with_java_home" != "xno"; then
218 if test "x$with_java_home" != "xyes" -a "x$with_java_home" != "xcheck"
220 if test -d "$with_java_home"; then
221 JAVA_HOME="$with_java_home"
223 AC_MSG_FAILURE([$with_java_home is not a directory (use --with-java-home=no to disable Java support)])
226 if test "x$JAVA_HOME" = "x"; then
227 JAVA_HOME=/usr/lib/jvm/java
229 AC_MSG_CHECKING(for JDK in $JAVA_HOME)
230 if test ! -x "$JAVA_HOME/bin/java"; then
231 AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary (use --with-java-home=no to disable Java support)])
233 JAVA="$JAVA_HOME/bin/java"
235 if test ! -x "$JAVA_HOME/bin/javac"; then
236 AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
238 JAVAC="$JAVA_HOME/bin/javac"
240 if test ! -x "$JAVA_HOME/bin/javah"; then
241 AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
243 JAVAH="$JAVA_HOME/bin/javah"
245 if test ! -x "$JAVA_HOME/bin/javadoc"; then
246 AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary])
248 JAVADOC="$JAVA_HOME/bin/javadoc"
250 if test ! -x "$JAVA_HOME/bin/jar"; then
251 AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary])
253 JAR="$JAVA_HOME/bin/jar"
255 java_version=`$JAVA -version 2>&1 | grep "java version"`
256 AC_MSG_RESULT(found $java_version in $JAVA_HOME)
259 AC_MSG_CHECKING([for jni.h])
260 if test -f "$JAVA_HOME/include/jni.h"; then
261 JNI_CFLAGS="-I$JAVA_HOME/include"
263 if test "`find $JAVA_HOME -name jni.h`" != ""; then
264 head=`find $JAVA_HOME -name jni.h | tail -1`
268 AC_MSG_FAILURE([missing jni.h header file])
271 AC_MSG_RESULT([$JNI_CFLAGS])
274 AC_MSG_CHECKING([for jni_md.h])
276 *linux*) system="linux" ;;
277 *SunOS*) system="solaris" ;;
278 *cygwin*) system="win32" ;;
279 *) system="$build_os" ;;
281 if test -f "$JAVA_HOME/include/$system/jni_md.h"; then
282 JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system"
284 if test "`find $JAVA_HOME -name jni_md.h`" != ""; then
285 head=`find $JAVA_HOME -name jni_md.h | tail -1`
287 JNI_CFLAGS="$JNI_CFLAGS -I$dir"
289 AC_MSG_FAILURE([missing jni_md.h header file])
292 AC_MSG_RESULT([$JNI_CFLAGS])
294 dnl Need extra version flag?
295 AC_MSG_CHECKING([extra javac flags])
297 javac_version=`$JAVAC -version 2>&1`
298 case "$javac_version" in
300 JAVAC_FLAGS="-source 1.5" ;;
302 AC_MSG_RESULT([$JAVAC_FLAGS])
304 dnl Where to install jarfiles.
305 dnl XXX How to make it configurable?
306 JAR_INSTALL_DIR=\${prefix}/share/java
307 JNI_INSTALL_DIR=\${libdir}
310 jni_major_version=`echo $VERSION | awk -F. '{print $1}'`
311 jni_minor_version=`echo $VERSION | awk -F. '{print $2}'`
312 jni_micro_version=`echo $VERSION | awk -F. '{print $3}'`
313 JNI_VERSION_INFO=`expr $jni_major_version + $jni_minor_version`:$jni_micro_version:$jni_minor_version
323 AC_SUBST(JAVAC_FLAGS)
324 AC_SUBST(JAR_INSTALL_DIR)
325 AC_SUBST(JNI_INSTALL_DIR)
326 AC_SUBST(JNI_VERSION_INFO)
328 AM_CONDITIONAL([HAVE_JAVA],[test -n "$JAVAC"])
331 AC_CONFIG_SUBDIRS([daemon])
333 dnl Produce output files.
334 AC_CONFIG_HEADERS([config.h])
335 AC_CONFIG_FILES([Makefile src/Makefile fish/Makefile examples/Makefile
337 ocaml/Makefile ocaml/examples/Makefile
340 ruby/Makefile ruby/Rakefile
342 make-initramfs.sh update-initramfs.sh
343 libguestfs.spec libguestfs.pc
344 ocaml/META perl/Makefile.PL])
348 chmod +x make-initramfs.sh update-initramfs.sh
353 echo "------------------------------------------------------------"
354 echo "Thank you for downloading $PACKAGE_STRING"
356 echo "This is how we have configured the optional components for you today:"
358 echo "QEMU ................................ $QEMU"
359 echo -n "OCaml bindings ...................... "
360 if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi
361 echo -n "Perl bindings ....................... "
362 if test "x$HAVE_PERL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
363 echo -n "Python bindings ..................... "
364 if test "x$HAVE_PYTHON_TRUE" = "x"; then echo "yes"; else echo "no"; fi
365 echo -n "Ruby bindings ....................... "
366 if test "x$HAVE_RUBY_TRUE" = "x"; then echo "yes"; else echo "no"; fi
367 echo -n "Java bindings ....................... "
368 if test "x$HAVE_JAVA_TRUE" = "x"; then echo "yes"; else echo "no"; fi
370 echo "If any optional component is configured 'no' when you expected 'yes'"
371 echo "then you should check the preceeding messages."
373 echo "Please report bugs back to the fedora-virt mailing list:"
374 echo "http://www.redhat.com/mailman/listinfo/fedora-virt"
376 echo "Next you should type 'make' to build the package,"
377 echo "then 'make check' to run the tests."
378 echo "------------------------------------------------------------"