Check fakechroot >= 2.9
[libguestfs.git] / configure.ac
1 # libguestfs
2 # Copyright (C) 2009 Red Hat Inc.
3 #
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.
8 #
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.
13 #
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.
17
18 AC_INIT([libguestfs],[1.0.17])
19 AM_INIT_AUTOMAKE
20
21 AC_CONFIG_MACRO_DIR([m4])
22
23 AC_PROG_LIBTOOL
24
25 dnl Check for basic C environment.
26 AC_PROG_CC_STDC
27 AC_PROG_INSTALL
28 AC_PROG_CPP
29
30 AC_C_PROTOTYPES
31 test "x$U" != "x" && AC_MSG_ERROR([Compiler not ANSI compliant])
32
33 AM_PROG_CC_C_O
34
35 dnl Check support for 64 bit file offsets.
36 AC_SYS_LARGEFILE
37
38 dnl Check sizeof long.
39 AC_CHECK_SIZEOF([long])
40
41 dnl Headers.
42 AC_CHECK_HEADERS([errno.h sys/types.h sys/un.h sys/wait.h sys/socket.h])
43
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])
49         ])
50
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])
58
59 dnl Check for QEMU for running binaries on this $host_cpu, fall
60 dnl back to basic 'qemu'.  Allow the user to override it.
61 default_qemu="qemu-system-$host_cpu qemu"
62 # On x86-64, try using KVM first.
63 if test "x$host_cpu" = "xx86_64"; then
64     default_qemu="qemu-kvm $default_qemu"
65 fi
66 AC_ARG_WITH([qemu],
67         [AS_HELP_STRING([--with-qemu],
68           [set default QEMU binary @<:@default=[qemu-kvm] qemu-system-<host> qemu@:>@])],
69         [],
70         [with_qemu="$default_qemu"])
71 AC_PATH_PROGS([QEMU],[$with_qemu],[no],
72         [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
73 test "x$QEMU" = "xno" && AC_MSG_ERROR([qemu must be installed])
74 AC_DEFINE_UNQUOTED([QEMU],["$QEMU"],[Location of qemu binary.])
75
76 dnl Check that the chosen qemu has vmchannel support.
77 dnl http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg01042.html
78 if test "x$vmchannel_test" != "xno"; then
79     AC_MSG_CHECKING([for vmchannel support in $QEMU])
80     vmchannelout=`$QEMU -net channel /dev/zero 2>&1 ||:`
81     echo "vmchannel test command output: $vmchannelout" >&AS_MESSAGE_LOG_FD
82     if ! echo $vmchannelout | grep -sq "vmchannel wrong port number" ; then
83         AC_MSG_RESULT([no])
84         AC_MSG_FAILURE(
85 [I did not find vmchannel support in $QEMU.
86
87 vmchannel support is vital for libguestfs to operate.  You need a version
88 of qemu >= 0.10, or the following patch backported to earlier versions:
89
90 http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg01042.html
91
92 You can override this test by setting the environment variable
93 vmchannel_test=no  However if you don't have vmchannel support
94 in your qemu, then this just delays the pain.
95
96 If I am using the wrong qemu or you want to compile qemu from source
97 and install it in another location, then you should configure with
98 the --with-qemu option.
99 ])
100     fi
101     AC_MSG_RESULT([yes])
102 fi
103
104 dnl Check for febootstrap etc.
105 AC_CHECK_PROG([FEBOOTSTRAP],
106         [febootstrap],[febootstrap],[no])
107 test "x$FEBOOTSTRAP" = "xno" && \
108      AC_MSG_ERROR([febootstrap must be installed])
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_MINIMIZE],
114         [febootstrap-minimize],[febootstrap-minimize],[no])
115 test "x$FEBOOTSTRAP_MINIMIZE" = "xno" && \
116      AC_MSG_ERROR([febootstrap-minimize must be installed])
117 AC_CHECK_PROG([FEBOOTSTRAP_TO_INITRAMFS],
118         [febootstrap-to-initramfs],[febootstrap-to-initramfs],[no])
119 test "x$FEBOOTSTRAP_TO_INITRAMFS" = "xno" && \
120      AC_MSG_ERROR([febootstrap-to-initramfs must be installed])
121
122 dnl Check we have fakechroot >= 2.9 (it's an indirect requirement
123 dnl of febootstrap, but old versions will fail with yum).
124 AC_CHECK_PROG([FAKECHROOT],
125         [fakechroot],[fakechroot],[no])
126 test "x$FAKECHROOT" = "xno" && \
127     AC_MSG_ERROR([fakechroot must be installed])
128
129 AC_MSG_CHECKING([fakechroot version])
130 fakechroot_version=`$FAKECHROOT --version | awk '{print $3}'`
131 if test -z "$fakechroot_version"; then
132     AC_MSG_RESULT([failed])
133     AC_MSG_WARN([fakechroot --version command failed, proceeding anyway])
134 else
135     AC_MSG_RESULT([$fakechroot_version])
136     fakechroot_major=`echo $fakechroot_version | awk -F. '{print $1}'`
137     fakechroot_minor=`echo $fakechroot_version | awk -F. '{print $2}'`
138     if test "$fakechroot_major" -lt 2 -o \
139             \( "$fakechroot_major" -eq 2 -a "$fakechroot_minor" -lt 9 \); then
140         AC_MSG_ERROR([fakechroot version must be >= 2.9])
141     fi
142 fi
143
144 dnl --with-repo to specify a Fedora repository.
145 AC_ARG_WITH([repo],
146         [AS_HELP_STRING([--with-repo],
147           [set name of Fedora repository @<:@default=fedora-10@:>@])],
148         [],
149         [with_repo=fedora-10])
150 REPO="$with_repo"
151 AC_SUBST(REPO)
152 AC_DEFINE_UNQUOTED([REPO],["$REPO"],[Name of Fedora repository.])
153
154 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
155
156 dnl --with-updates to specify a Fedora updates repository.
157 AC_ARG_WITH([updates],
158         [AS_HELP_STRING([--with-updates],
159           [set name of Fedora updates repository @<:@default=updates-released-f10@:>@])],
160         [],
161         [with_updates=updates-released-f10])
162 UPDATES="$with_updates"
163 AC_SUBST(UPDATES)
164 AC_DEFINE_UNQUOTED([UPDATES],["$UPDATES"],[Name of Fedora updates repository.])
165
166 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
167
168 dnl --with-mirror to specify a local Fedora mirror.
169 AC_ARG_WITH([mirror],
170         [AS_HELP_STRING([--with-mirror],
171           [set URI of a local Fedora mirror])],
172         [],
173         [with_mirror=])
174 MIRROR="$with_mirror"
175 AC_SUBST(MIRROR)
176
177 dnl Readline.
178 AC_ARG_WITH([readline],
179     [AS_HELP_STRING([--with-readline],
180         [support fancy command line editing @<:@default=check@:>@])],
181     [],
182     [with_readline=check])
183
184 LIBREADLINE=
185 AS_IF([test "x$with_readline" != xno],
186     [AC_CHECK_LIB([readline], [main],
187         [AC_SUBST([LIBREADLINE], ["-lreadline -lncurses"])
188          AC_DEFINE([HAVE_LIBREADLINE], [1],
189                    [Define if you have libreadline])
190         ],
191         [if test "x$with_readline" != xcheck; then
192          AC_MSG_FAILURE(
193              [--with-readline was given, but test for readline failed])
194          fi
195         ], -lncurses)])
196
197 dnl Check for OCaml (optional, for OCaml bindings).
198 AC_PROG_OCAML
199 AC_PROG_FINDLIB
200 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLC" != "xno" -a "x$OCAMLFIND" != "xno"])
201
202 dnl Check for Perl (optional, for Perl bindings).
203 dnl XXX This isn't quite right, we should check for Perl devel library.
204 AC_CHECK_PROG([PERL],[perl],[perl],[no])
205
206 dnl Check for Perl modules that must be present to compile and
207 dnl test the Perl bindings.
208 missing_perl_modules=no
209 for pm in Test::More Test::Pod Test::Pod::Coverage ExtUtils::MakeMaker; do
210     AC_MSG_CHECKING([for $pm])
211     if ! perl -M$pm -e1 >/dev/null 2>&1; then
212         AC_MSG_RESULT([no])
213         missing_perl_modules=yes
214     else
215         AC_MSG_RESULT([yes])
216     fi
217 done
218 if test "x$missing_perl_modules" = "xyes"; then
219     AC_MSG_WARN([some Perl modules required to compile or test the Perl bindings are missing])
220 fi
221
222 AM_CONDITIONAL([HAVE_PERL],
223     [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
224
225 dnl Check for Python (optional, for Python bindings).
226 AC_CHECK_PROG([PYTHON],[python],[python],[no])
227
228 PYTHON_PREFIX=
229 PYTHON_VERSION=
230 PYTHON_INCLUDEDIR=
231 PYTHON_SITE_PACKAGES=
232
233 if test "x$PYTHON" != "xno"; then
234     PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"`
235     PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
236     for d in \
237         $PYTHON_PREFIX/include/python$PYTHON_VERSION \
238         /usr/include/python$PYTHON_VERSION \
239         /usr/local/include/python$PYTHON_VERSION
240     do
241         AC_MSG_CHECKING([Python.h in $d])
242         if test -r "$d/Python.h"; then
243             AC_MSG_RESULT([found])
244             PYTHON_INCLUDEDIR=$d
245             break
246         fi
247         AC_MSG_RESULT([not found])
248     done
249     for d in \
250         $PYTHON_PREFIX/lib64/python$PYTHON_VERSION/site-packages \
251         $PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages \
252         /usr/lib64/python$PYTHON_VERSION/site-packages \
253         /usr/lib/python$PYTHON_VERSION/site-packages \
254         /usr/local/lib/python$PYTHON_VERSION/site-packages
255     do
256         AC_MSG_CHECKING([for $d])
257         if test -d "$d"; then
258             AC_MSG_RESULT([found])
259             PYTHON_SITE_PACKAGES=$d
260             break
261         fi
262         AC_MSG_RESULT([not found])
263     done
264 fi
265
266 AC_SUBST(PYTHON_PREFIX)
267 AC_SUBST(PYTHON_VERSION)
268 AC_SUBST(PYTHON_INCLUDEDIR)
269 AC_SUBST(PYTHON_SITE_PACKAGES)
270
271 AM_CONDITIONAL([HAVE_PYTHON],
272     [test "x$PYTHON_INCLUDEDIR" != "x" -a "x$PYTHON_SITE_PACKAGES" != "x"])
273
274 dnl Check for Ruby and rake (optional, for Ruby bindings).
275 AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=0])
276 AC_CHECK_PROG([RAKE],[rake],[rake],[no])
277
278 AM_CONDITIONAL([HAVE_RUBY],
279     [test "x$RAKE" != "xno" -a -n "$HAVE_LIBRUBY"])
280
281 dnl Check for Java.
282 AC_ARG_WITH(java_home,
283     [AS_HELP_STRING([--with-java-home],
284         [specify path to JDK directory @<:@default=check@:>@])],
285     [],
286     [with_java_home=check])
287
288 if test "x$with_java_home" != "xno"; then
289     if test "x$with_java_home" != "xyes" -a "x$with_java_home" != "xcheck"
290     then
291         if test -d "$with_java_home"; then
292             JAVA_HOME="$with_java_home"
293         else
294             AC_MSG_FAILURE([$with_java_home is not a directory (use --with-java-home=no to disable Java support)])
295         fi
296     fi
297     if test "x$JAVA_HOME" = "x"; then
298         JAVA_HOME=/usr/lib/jvm/java
299     fi
300     AC_MSG_CHECKING(for JDK in $JAVA_HOME)
301     if test ! -x "$JAVA_HOME/bin/java"; then
302         AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary (use --with-java-home=no to disable Java support)])
303     else
304         JAVA="$JAVA_HOME/bin/java"
305     fi
306     if test ! -x "$JAVA_HOME/bin/javac"; then
307         AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
308     else
309         JAVAC="$JAVA_HOME/bin/javac"
310     fi
311     if test ! -x "$JAVA_HOME/bin/javah"; then
312         AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
313     else
314         JAVAH="$JAVA_HOME/bin/javah"
315     fi
316     if test ! -x "$JAVA_HOME/bin/javadoc"; then
317         AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary])
318     else
319         JAVADOC="$JAVA_HOME/bin/javadoc"
320     fi
321     if test ! -x "$JAVA_HOME/bin/jar"; then
322         AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary])
323     else
324         JAR="$JAVA_HOME/bin/jar"
325     fi
326     java_version=`$JAVA -version 2>&1 | grep "java version"`
327     AC_MSG_RESULT(found $java_version in $JAVA_HOME)
328
329     dnl Find jni.h.
330     AC_MSG_CHECKING([for jni.h])
331     if test -f "$JAVA_HOME/include/jni.h"; then
332         JNI_CFLAGS="-I$JAVA_HOME/include"
333     else
334     if test "`find $JAVA_HOME -name jni.h`" != ""; then
335         head=`find $JAVA_HOME -name jni.h | tail -1`
336         dir=`dirname $head`
337         JNI_CFLAGS="-I$dir"
338     else
339         AC_MSG_FAILURE([missing jni.h header file])
340     fi
341     fi
342     AC_MSG_RESULT([$JNI_CFLAGS])
343
344     dnl Find jni_md.h.
345     AC_MSG_CHECKING([for jni_md.h])
346     case "$build_os" in
347     *linux*) system="linux" ;;
348     *SunOS*) system="solaris" ;;
349     *cygwin*) system="win32" ;;
350     *) system="$build_os" ;;
351     esac
352     if test -f "$JAVA_HOME/include/$system/jni_md.h"; then
353         JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system"
354     else
355     if test "`find $JAVA_HOME -name jni_md.h`" != ""; then
356         head=`find $JAVA_HOME -name jni_md.h | tail -1`
357         dir=`dirname $head`
358         JNI_CFLAGS="$JNI_CFLAGS -I$dir"
359     else
360         AC_MSG_FAILURE([missing jni_md.h header file])
361     fi
362     fi
363     AC_MSG_RESULT([$JNI_CFLAGS])
364
365     dnl Need extra version flag?
366     AC_MSG_CHECKING([extra javac flags])
367     JAVAC_FLAGS=
368     javac_version=`$JAVAC -version 2>&1`
369     case "$javac_version" in
370     *Eclipse*)
371         JAVAC_FLAGS="-source 1.5" ;;
372     esac
373     AC_MSG_RESULT([$JAVAC_FLAGS])
374
375     dnl Where to install jarfiles.
376     dnl XXX How to make it configurable?
377     JAR_INSTALL_DIR=\${prefix}/share/java
378     JNI_INSTALL_DIR=\${libdir}
379
380     dnl JNI version.
381     jni_major_version=`echo $VERSION | awk -F. '{print $1}'`
382     jni_minor_version=`echo $VERSION | awk -F. '{print $2}'`
383     jni_micro_version=`echo $VERSION | awk -F. '{print $3}'`
384     JNI_VERSION_INFO=`expr $jni_major_version + $jni_minor_version`:$jni_micro_version:$jni_minor_version
385 fi
386
387 AC_SUBST(JAVA_HOME)
388 AC_SUBST(JAVA)
389 AC_SUBST(JAVAC)
390 AC_SUBST(JAVAH)
391 AC_SUBST(JAVADOC)
392 AC_SUBST(JAR)
393 AC_SUBST(JNI_CFLAGS)
394 AC_SUBST(JAVAC_FLAGS)
395 AC_SUBST(JAR_INSTALL_DIR)
396 AC_SUBST(JNI_INSTALL_DIR)
397 AC_SUBST(JNI_VERSION_INFO)
398
399 AM_CONDITIONAL([HAVE_JAVA],[test -n "$JAVAC"])
400
401 dnl Check for Perl modules needed by the inspector.
402 missing_perl_modules=no
403 for pm in Pod::Usage Getopt::Long Sys::Virt Data::Dumper; do
404     AC_MSG_CHECKING([for $pm])
405     if ! perl -M$pm -e1 >/dev/null 2>&1; then
406         AC_MSG_RESULT([no])
407         missing_perl_modules=yes
408     else
409         AC_MSG_RESULT([yes])
410     fi
411 done
412 if test "x$missing_perl_modules" = "xyes"; then
413     AC_MSG_WARN([some Perl modules required to compile virt-inspector are missing])
414 fi
415
416 AM_CONDITIONAL([HAVE_INSPECTOR],
417     [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
418
419 dnl Run in subdirs.
420 AC_CONFIG_SUBDIRS([daemon])
421
422 dnl Produce output files.
423 AC_CONFIG_HEADERS([config.h])
424 AC_CONFIG_FILES([Makefile src/Makefile fish/Makefile examples/Makefile
425                  images/Makefile
426                  ocaml/Makefile ocaml/examples/Makefile
427                  perl/Makefile
428                  python/Makefile
429                  ruby/Makefile ruby/Rakefile
430                  java/Makefile
431                  inspector/Makefile
432                  make-initramfs.sh update-initramfs.sh
433                  libguestfs.spec libguestfs.pc
434                  ocaml/META perl/Makefile.PL])
435 AC_OUTPUT
436
437 dnl WTF?
438 chmod +x make-initramfs.sh update-initramfs.sh
439
440 dnl Produce summary.
441 echo
442 echo
443 echo "------------------------------------------------------------"
444 echo "Thank you for downloading $PACKAGE_STRING"
445 echo
446 echo "This is how we have configured the optional components for you today:"
447 echo
448 echo    "QEMU ................................ $QEMU"
449 echo -n "OCaml bindings ...................... "
450 if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi
451 echo -n "Perl bindings ....................... "
452 if test "x$HAVE_PERL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
453 echo -n "Python bindings ..................... "
454 if test "x$HAVE_PYTHON_TRUE" = "x"; then echo "yes"; else echo "no"; fi
455 echo -n "Ruby bindings ....................... "
456 if test "x$HAVE_RUBY_TRUE" = "x"; then echo "yes"; else echo "no"; fi
457 echo -n "Java bindings ....................... "
458 if test "x$HAVE_JAVA_TRUE" = "x"; then echo "yes"; else echo "no"; fi
459 echo -n "virt-inspector ...................... "
460 if test "x$HAVE_INSPECTOR" = "x"; then echo "yes"; else echo "no"; fi
461 echo
462 echo "If any optional component is configured 'no' when you expected 'yes'"
463 echo "then you should check the preceeding messages."
464 echo
465 echo "Please report bugs back to the fedora-virt mailing list:"
466 echo "http://www.redhat.com/mailman/listinfo/fedora-virt"
467 echo
468 echo "Next you should type 'make' to build the package,"
469 echo "then 'make check' to run the tests."
470 echo "------------------------------------------------------------"