Version 1.0.32
[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.32])
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_INSTALL],
110         [febootstrap-install],[febootstrap-install],[no])
111 test "x$FEBOOTSTRAP_INSTALL" = "xno" && \
112      AC_MSG_ERROR([febootstrap-install 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-11@:>@])],
148         [],
149         [with_repo=fedora-11])
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-f11@:>@])],
160         [],
161         [with_updates=updates-released-f11])
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 For i18n.
198 AM_GNU_GETTEXT([external])
199 AM_GNU_GETTEXT_VERSION([0.17])
200
201 dnl Check for OCaml (optional, for OCaml bindings).
202 AC_PROG_OCAML
203 AC_PROG_FINDLIB
204 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLC" != "xno" -a "x$OCAMLFIND" != "xno"])
205
206 dnl Check for Perl (optional, for Perl bindings).
207 dnl XXX This isn't quite right, we should check for Perl devel library.
208 AC_CHECK_PROG([PERL],[perl],[perl],[no])
209
210 dnl Check for Perl modules that must be present to compile and
211 dnl test the Perl bindings.
212 missing_perl_modules=no
213 for pm in Test::More Test::Pod Test::Pod::Coverage ExtUtils::MakeMaker; do
214     AC_MSG_CHECKING([for $pm])
215     if ! perl -M$pm -e1 >/dev/null 2>&1; then
216         AC_MSG_RESULT([no])
217         missing_perl_modules=yes
218     else
219         AC_MSG_RESULT([yes])
220     fi
221 done
222 if test "x$missing_perl_modules" = "xyes"; then
223     AC_MSG_WARN([some Perl modules required to compile or test the Perl bindings are missing])
224 fi
225
226 AM_CONDITIONAL([HAVE_PERL],
227     [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
228
229 dnl Check for Python (optional, for Python bindings).
230 AC_CHECK_PROG([PYTHON],[python],[python],[no])
231
232 PYTHON_PREFIX=
233 PYTHON_VERSION=
234 PYTHON_INCLUDEDIR=
235 PYTHON_SITE_PACKAGES=
236
237 if test "x$PYTHON" != "xno"; then
238     PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"`
239     PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
240     for d in \
241         $PYTHON_PREFIX/include/python$PYTHON_VERSION \
242         /usr/include/python$PYTHON_VERSION \
243         /usr/local/include/python$PYTHON_VERSION
244     do
245         AC_MSG_CHECKING([Python.h in $d])
246         if test -r "$d/Python.h"; then
247             AC_MSG_RESULT([found])
248             PYTHON_INCLUDEDIR=$d
249             break
250         fi
251         AC_MSG_RESULT([not found])
252     done
253     for d in \
254         $PYTHON_PREFIX/lib64/python$PYTHON_VERSION/site-packages \
255         $PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages \
256         /usr/lib64/python$PYTHON_VERSION/site-packages \
257         /usr/lib/python$PYTHON_VERSION/site-packages \
258         /usr/local/lib/python$PYTHON_VERSION/site-packages
259     do
260         AC_MSG_CHECKING([for $d])
261         if test -d "$d"; then
262             AC_MSG_RESULT([found])
263             PYTHON_SITE_PACKAGES=$d
264             break
265         fi
266         AC_MSG_RESULT([not found])
267     done
268 fi
269
270 AC_SUBST(PYTHON_PREFIX)
271 AC_SUBST(PYTHON_VERSION)
272 AC_SUBST(PYTHON_INCLUDEDIR)
273 AC_SUBST(PYTHON_SITE_PACKAGES)
274
275 AM_CONDITIONAL([HAVE_PYTHON],
276     [test "x$PYTHON_INCLUDEDIR" != "x" -a "x$PYTHON_SITE_PACKAGES" != "x"])
277
278 dnl Check for Ruby and rake (optional, for Ruby bindings).
279 AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=0])
280 AC_CHECK_PROG([RAKE],[rake],[rake],[no])
281
282 AM_CONDITIONAL([HAVE_RUBY],
283     [test "x$RAKE" != "xno" -a -n "$HAVE_LIBRUBY"])
284
285 dnl Check for Java.
286 AC_ARG_WITH(java_home,
287     [AS_HELP_STRING([--with-java-home],
288         [specify path to JDK directory @<:@default=check@:>@])],
289     [],
290     [with_java_home=check])
291
292 if test "x$with_java_home" != "xno"; then
293     if test "x$with_java_home" != "xyes" -a "x$with_java_home" != "xcheck"
294     then
295         if test -d "$with_java_home"; then
296             JAVA_HOME="$with_java_home"
297         else
298             AC_MSG_FAILURE([$with_java_home is not a directory (use --with-java-home=no to disable Java support)])
299         fi
300     fi
301     if test "x$JAVA_HOME" = "x"; then
302         JAVA_HOME=/usr/lib/jvm/java
303     fi
304     AC_MSG_CHECKING(for JDK in $JAVA_HOME)
305     if test ! -x "$JAVA_HOME/bin/java"; then
306         AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary (use --with-java-home=no to disable Java support)])
307     else
308         JAVA="$JAVA_HOME/bin/java"
309     fi
310     if test ! -x "$JAVA_HOME/bin/javac"; then
311         AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
312     else
313         JAVAC="$JAVA_HOME/bin/javac"
314     fi
315     if test ! -x "$JAVA_HOME/bin/javah"; then
316         AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
317     else
318         JAVAH="$JAVA_HOME/bin/javah"
319     fi
320     if test ! -x "$JAVA_HOME/bin/javadoc"; then
321         AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary])
322     else
323         JAVADOC="$JAVA_HOME/bin/javadoc"
324     fi
325     if test ! -x "$JAVA_HOME/bin/jar"; then
326         AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary])
327     else
328         JAR="$JAVA_HOME/bin/jar"
329     fi
330     java_version=`$JAVA -version 2>&1 | grep "java version"`
331     AC_MSG_RESULT(found $java_version in $JAVA_HOME)
332
333     dnl Find jni.h.
334     AC_MSG_CHECKING([for jni.h])
335     if test -f "$JAVA_HOME/include/jni.h"; then
336         JNI_CFLAGS="-I$JAVA_HOME/include"
337     else
338     if test "`find $JAVA_HOME -name jni.h`" != ""; then
339         head=`find $JAVA_HOME -name jni.h | tail -1`
340         dir=`dirname $head`
341         JNI_CFLAGS="-I$dir"
342     else
343         AC_MSG_FAILURE([missing jni.h header file])
344     fi
345     fi
346     AC_MSG_RESULT([$JNI_CFLAGS])
347
348     dnl Find jni_md.h.
349     AC_MSG_CHECKING([for jni_md.h])
350     case "$build_os" in
351     *linux*) system="linux" ;;
352     *SunOS*) system="solaris" ;;
353     *cygwin*) system="win32" ;;
354     *) system="$build_os" ;;
355     esac
356     if test -f "$JAVA_HOME/include/$system/jni_md.h"; then
357         JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system"
358     else
359     if test "`find $JAVA_HOME -name jni_md.h`" != ""; then
360         head=`find $JAVA_HOME -name jni_md.h | tail -1`
361         dir=`dirname $head`
362         JNI_CFLAGS="$JNI_CFLAGS -I$dir"
363     else
364         AC_MSG_FAILURE([missing jni_md.h header file])
365     fi
366     fi
367     AC_MSG_RESULT([$JNI_CFLAGS])
368
369     dnl Need extra version flag?
370     AC_MSG_CHECKING([extra javac flags])
371     JAVAC_FLAGS=
372     javac_version=`$JAVAC -version 2>&1`
373     case "$javac_version" in
374     *Eclipse*)
375         JAVAC_FLAGS="-source 1.5" ;;
376     esac
377     AC_MSG_RESULT([$JAVAC_FLAGS])
378
379     dnl Where to install jarfiles.
380     dnl XXX How to make it configurable?
381     JAR_INSTALL_DIR=\${prefix}/share/java
382     JNI_INSTALL_DIR=\${libdir}
383
384     dnl JNI version.
385     jni_major_version=`echo $VERSION | awk -F. '{print $1}'`
386     jni_minor_version=`echo $VERSION | awk -F. '{print $2}'`
387     jni_micro_version=`echo $VERSION | awk -F. '{print $3}'`
388     JNI_VERSION_INFO=`expr $jni_major_version + $jni_minor_version`:$jni_micro_version:$jni_minor_version
389 fi
390
391 AC_SUBST(JAVA_HOME)
392 AC_SUBST(JAVA)
393 AC_SUBST(JAVAC)
394 AC_SUBST(JAVAH)
395 AC_SUBST(JAVADOC)
396 AC_SUBST(JAR)
397 AC_SUBST(JNI_CFLAGS)
398 AC_SUBST(JAVAC_FLAGS)
399 AC_SUBST(JAR_INSTALL_DIR)
400 AC_SUBST(JNI_INSTALL_DIR)
401 AC_SUBST(JNI_VERSION_INFO)
402
403 AM_CONDITIONAL([HAVE_JAVA],[test -n "$JAVAC"])
404
405 dnl Check for Haskell (GHC).
406 AC_CHECK_PROG([GHC],[ghc],[ghc],[no])
407
408 AM_CONDITIONAL([HAVE_HASKELL],
409     [test "x$GHC" != "xno"])
410
411 dnl Check for Perl modules needed by the inspector.
412 missing_perl_modules=no
413 for pm in Pod::Usage Getopt::Long Sys::Virt Data::Dumper; do
414     AC_MSG_CHECKING([for $pm])
415     if ! perl -M$pm -e1 >/dev/null 2>&1; then
416         AC_MSG_RESULT([no])
417         missing_perl_modules=yes
418     else
419         AC_MSG_RESULT([yes])
420     fi
421 done
422 if test "x$missing_perl_modules" = "xyes"; then
423     AC_MSG_WARN([some Perl modules required to compile virt-inspector are missing])
424 fi
425
426 AM_CONDITIONAL([HAVE_INSPECTOR],
427     [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
428
429 dnl Run in subdirs.
430 AC_CONFIG_SUBDIRS([daemon])
431
432 dnl Produce output files.
433 AC_CONFIG_HEADERS([config.h])
434 AC_CONFIG_FILES([Makefile
435                  src/Makefile fish/Makefile po/Makefile.in examples/Makefile
436                  images/Makefile
437                  ocaml/Makefile ocaml/examples/Makefile
438                  perl/Makefile
439                  python/Makefile
440                  ruby/Makefile ruby/Rakefile
441                  java/Makefile
442                  haskell/Makefile
443                  inspector/Makefile
444                  make-initramfs.sh update-initramfs.sh
445                  libguestfs.pc
446                  ocaml/META perl/Makefile.PL])
447 AC_OUTPUT
448
449 dnl WTF?
450 chmod +x make-initramfs.sh update-initramfs.sh
451
452 dnl Produce summary.
453 echo
454 echo
455 echo "------------------------------------------------------------"
456 echo "Thank you for downloading $PACKAGE_STRING"
457 echo
458 echo "This is how we have configured the optional components for you today:"
459 echo
460 echo    "QEMU ................................ $QEMU"
461 echo -n "OCaml bindings ...................... "
462 if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi
463 echo -n "Perl bindings ....................... "
464 if test "x$HAVE_PERL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
465 echo -n "Python bindings ..................... "
466 if test "x$HAVE_PYTHON_TRUE" = "x"; then echo "yes"; else echo "no"; fi
467 echo -n "Ruby bindings ....................... "
468 if test "x$HAVE_RUBY_TRUE" = "x"; then echo "yes"; else echo "no"; fi
469 echo -n "Java bindings ....................... "
470 if test "x$HAVE_JAVA_TRUE" = "x"; then echo "yes"; else echo "no"; fi
471 echo -n "Haskell bindings .................... "
472 if test "x$HAVE_HASKELL" = "x"; then echo "yes"; else echo "no"; fi
473 echo -n "virt-inspector ...................... "
474 if test "x$HAVE_INSPECTOR" = "x"; then echo "yes"; else echo "no"; fi
475 echo
476 echo "If any optional component is configured 'no' when you expected 'yes'"
477 echo "then you should check the preceeding messages."
478 echo
479 echo "Please report bugs back to the fedora-virt mailing list:"
480 echo "http://www.redhat.com/mailman/listinfo/fedora-virt"
481 echo
482 echo "Next you should type 'make' to build the package,"
483 echo "then 'make check' to run the tests."
484 echo "------------------------------------------------------------"