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