export2tar recipe
[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.12])
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
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 --with-repo to specify a Fedora repository.
123 AC_ARG_WITH([repo],
124         [AS_HELP_STRING([--with-repo],
125           [set name of Fedora repository @<:@default=fedora-10@:>@])],
126         [],
127         [with_repo=fedora-10])
128 REPO="$with_repo"
129 AC_SUBST(REPO)
130 AC_DEFINE_UNQUOTED([REPO],["$REPO"],[Name of Fedora repository.])
131
132 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
133
134 dnl --with-updates to specify a Fedora updates repository.
135 AC_ARG_WITH([updates],
136         [AS_HELP_STRING([--with-updates],
137           [set name of Fedora updates repository @<:@default=updates-released-f10@:>@])],
138         [],
139         [with_updates=updates-released-f10])
140 UPDATES="$with_updates"
141 AC_SUBST(UPDATES)
142 AC_DEFINE_UNQUOTED([UPDATES],["$UPDATES"],[Name of Fedora updates repository.])
143
144 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
145
146 dnl --with-mirror to specify a local Fedora mirror.
147 AC_ARG_WITH([mirror],
148         [AS_HELP_STRING([--with-mirror],
149           [set URI of a local Fedora mirror])],
150         [],
151         [with_mirror=])
152 MIRROR="$with_mirror"
153 AC_SUBST(MIRROR)
154
155 dnl Readline.
156 AC_ARG_WITH([readline],
157     [AS_HELP_STRING([--with-readline],
158         [support fancy command line editing @<:@default=check@:>@])],
159     [],
160     [with_readline=check])
161
162 LIBREADLINE=
163 AS_IF([test "x$with_readline" != xno],
164     [AC_CHECK_LIB([readline], [main],
165         [AC_SUBST([LIBREADLINE], ["-lreadline -lncurses"])
166          AC_DEFINE([HAVE_LIBREADLINE], [1],
167                    [Define if you have libreadline])
168         ],
169         [if test "x$with_readline" != xcheck; then
170          AC_MSG_FAILURE(
171              [--with-readline was given, but test for readline failed])
172          fi
173         ], -lncurses)])
174
175 dnl Check for OCaml (optional, for OCaml bindings).
176 AC_PROG_OCAML
177 AC_PROG_FINDLIB
178 AM_CONDITIONAL([HAVE_OCAML],[test "x$OCAMLC" != "xno" -a "x$OCAMLFIND" != "xno"])
179
180 dnl Check for Perl (optional, for Perl bindings).
181 dnl XXX This isn't quite right, we should check for Perl devel library.
182 AC_CHECK_PROG([PERL],[perl],[perl],[no])
183
184 dnl Check for Perl modules that must be present to compile and
185 dnl test the Perl bindings.
186 missing_perl_modules=no
187 for pm in Test::More Test::Pod Test::Pod::Coverage ExtUtils::MakeMaker; do
188     AC_MSG_CHECKING([for $pm])
189     if ! perl -M$pm >/dev/null 2>&1; then
190         AC_MSG_RESULT([no])
191         missing_perl_modules=yes
192     else
193         AC_MSG_RESULT([yes])
194     fi
195 done
196 if test "x$missing_perl_modules" = "xyes"; then
197     AC_MSG_WARN([some Perl modules required to compile or test the Perl bindings are missing])
198 fi
199
200 AM_CONDITIONAL([HAVE_PERL],
201     [test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
202
203 dnl Check for Python (optional, for Python bindings).
204 AC_CHECK_PROG([PYTHON],[python],[python],[no])
205
206 PYTHON_PREFIX=
207 PYTHON_VERSION=
208 PYTHON_INCLUDEDIR=
209 PYTHON_SITE_PACKAGES=
210
211 if test "x$PYTHON" != "xno"; then
212     PYTHON_PREFIX=`$PYTHON -c "import sys; print sys.prefix"`
213     PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
214     for d in \
215         $PYTHON_PREFIX/include/python$PYTHON_VERSION \
216         /usr/include/python$PYTHON_VERSION \
217         /usr/local/include/python$PYTHON_VERSION
218     do
219         AC_MSG_CHECKING([Python.h in $d])
220         if test -r "$d/Python.h"; then
221             AC_MSG_RESULT([found])
222             PYTHON_INCLUDEDIR=$d
223             break
224         fi
225         AC_MSG_RESULT([not found])
226     done
227     for d in \
228         $PYTHON_PREFIX/lib64/python$PYTHON_VERSION/site-packages \
229         $PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages \
230         /usr/lib64/python$PYTHON_VERSION/site-packages \
231         /usr/lib/python$PYTHON_VERSION/site-packages \
232         /usr/local/lib/python$PYTHON_VERSION/site-packages
233     do
234         AC_MSG_CHECKING([for $d])
235         if test -d "$d"; then
236             AC_MSG_RESULT([found])
237             PYTHON_SITE_PACKAGES=$d
238             break
239         fi
240         AC_MSG_RESULT([not found])
241     done
242 fi
243
244 AC_SUBST(PYTHON_PREFIX)
245 AC_SUBST(PYTHON_VERSION)
246 AC_SUBST(PYTHON_INCLUDEDIR)
247 AC_SUBST(PYTHON_SITE_PACKAGES)
248
249 AM_CONDITIONAL([HAVE_PYTHON],
250     [test "x$PYTHON_INCLUDEDIR" != "x" -a "x$PYTHON_SITE_PACKAGES" != "x"])
251
252 dnl Check for Ruby and rake (optional, for Ruby bindings).
253 AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=0])
254 AC_CHECK_PROG([RAKE],[rake],[rake],[no])
255
256 AM_CONDITIONAL([HAVE_RUBY],
257     [test "x$RAKE" != "xno" -a -n "$HAVE_LIBRUBY"])
258
259 dnl Check for Java.
260 AC_ARG_WITH(java_home,
261     [AS_HELP_STRING([--with-java-home],
262         [specify path to JDK directory @<:@default=check@:>@])],
263     [],
264     [with_java_home=check])
265
266 if test "x$with_java_home" != "xno"; then
267     if test "x$with_java_home" != "xyes" -a "x$with_java_home" != "xcheck"
268     then
269         if test -d "$with_java_home"; then
270             JAVA_HOME="$with_java_home"
271         else
272             AC_MSG_FAILURE([$with_java_home is not a directory (use --with-java-home=no to disable Java support)])
273         fi
274     fi
275     if test "x$JAVA_HOME" = "x"; then
276         JAVA_HOME=/usr/lib/jvm/java
277     fi
278     AC_MSG_CHECKING(for JDK in $JAVA_HOME)
279     if test ! -x "$JAVA_HOME/bin/java"; then
280         AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary (use --with-java-home=no to disable Java support)])
281     else
282         JAVA="$JAVA_HOME/bin/java"
283     fi
284     if test ! -x "$JAVA_HOME/bin/javac"; then
285         AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary])
286     else
287         JAVAC="$JAVA_HOME/bin/javac"
288     fi
289     if test ! -x "$JAVA_HOME/bin/javah"; then
290         AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary])
291     else
292         JAVAH="$JAVA_HOME/bin/javah"
293     fi
294     if test ! -x "$JAVA_HOME/bin/javadoc"; then
295         AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary])
296     else
297         JAVADOC="$JAVA_HOME/bin/javadoc"
298     fi
299     if test ! -x "$JAVA_HOME/bin/jar"; then
300         AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary])
301     else
302         JAR="$JAVA_HOME/bin/jar"
303     fi
304     java_version=`$JAVA -version 2>&1 | grep "java version"`
305     AC_MSG_RESULT(found $java_version in $JAVA_HOME)
306
307     dnl Find jni.h.
308     AC_MSG_CHECKING([for jni.h])
309     if test -f "$JAVA_HOME/include/jni.h"; then
310         JNI_CFLAGS="-I$JAVA_HOME/include"
311     else
312     if test "`find $JAVA_HOME -name jni.h`" != ""; then
313         head=`find $JAVA_HOME -name jni.h | tail -1`
314         dir=`dirname $head`
315         JNI_CFLAGS="-I$dir"
316     else
317         AC_MSG_FAILURE([missing jni.h header file])
318     fi
319     fi
320     AC_MSG_RESULT([$JNI_CFLAGS])
321
322     dnl Find jni_md.h.
323     AC_MSG_CHECKING([for jni_md.h])
324     case "$build_os" in
325     *linux*) system="linux" ;;
326     *SunOS*) system="solaris" ;;
327     *cygwin*) system="win32" ;;
328     *) system="$build_os" ;;
329     esac
330     if test -f "$JAVA_HOME/include/$system/jni_md.h"; then
331         JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system"
332     else
333     if test "`find $JAVA_HOME -name jni_md.h`" != ""; then
334         head=`find $JAVA_HOME -name jni_md.h | tail -1`
335         dir=`dirname $head`
336         JNI_CFLAGS="$JNI_CFLAGS -I$dir"
337     else
338         AC_MSG_FAILURE([missing jni_md.h header file])
339     fi
340     fi
341     AC_MSG_RESULT([$JNI_CFLAGS])
342
343     dnl Need extra version flag?
344     AC_MSG_CHECKING([extra javac flags])
345     JAVAC_FLAGS=
346     javac_version=`$JAVAC -version 2>&1`
347     case "$javac_version" in
348     *Eclipse*)
349         JAVAC_FLAGS="-source 1.5" ;;
350     esac
351     AC_MSG_RESULT([$JAVAC_FLAGS])
352
353     dnl Where to install jarfiles.
354     dnl XXX How to make it configurable?
355     JAR_INSTALL_DIR=\${prefix}/share/java
356     JNI_INSTALL_DIR=\${libdir}
357
358     dnl JNI version.
359     jni_major_version=`echo $VERSION | awk -F. '{print $1}'`
360     jni_minor_version=`echo $VERSION | awk -F. '{print $2}'`
361     jni_micro_version=`echo $VERSION | awk -F. '{print $3}'`
362     JNI_VERSION_INFO=`expr $jni_major_version + $jni_minor_version`:$jni_micro_version:$jni_minor_version
363 fi
364
365 AC_SUBST(JAVA_HOME)
366 AC_SUBST(JAVA)
367 AC_SUBST(JAVAC)
368 AC_SUBST(JAVAH)
369 AC_SUBST(JAVADOC)
370 AC_SUBST(JAR)
371 AC_SUBST(JNI_CFLAGS)
372 AC_SUBST(JAVAC_FLAGS)
373 AC_SUBST(JAR_INSTALL_DIR)
374 AC_SUBST(JNI_INSTALL_DIR)
375 AC_SUBST(JNI_VERSION_INFO)
376
377 AM_CONDITIONAL([HAVE_JAVA],[test -n "$JAVAC"])
378
379 dnl Run in subdirs.
380 AC_CONFIG_SUBDIRS([daemon])
381
382 dnl Produce output files.
383 AC_CONFIG_HEADERS([config.h])
384 AC_CONFIG_FILES([Makefile src/Makefile fish/Makefile examples/Makefile
385                  images/Makefile
386                  ocaml/Makefile ocaml/examples/Makefile
387                  perl/Makefile
388                  python/Makefile
389                  ruby/Makefile ruby/Rakefile
390                  java/Makefile
391                  make-initramfs.sh update-initramfs.sh
392                  libguestfs.spec libguestfs.pc
393                  ocaml/META perl/Makefile.PL])
394 AC_OUTPUT
395
396 dnl WTF?
397 chmod +x make-initramfs.sh update-initramfs.sh
398
399 dnl Produce summary.
400 echo
401 echo
402 echo "------------------------------------------------------------"
403 echo "Thank you for downloading $PACKAGE_STRING"
404 echo
405 echo "This is how we have configured the optional components for you today:"
406 echo
407 echo    "QEMU ................................ $QEMU"
408 echo -n "OCaml bindings ...................... "
409 if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi
410 echo -n "Perl bindings ....................... "
411 if test "x$HAVE_PERL_TRUE" = "x"; then echo "yes"; else echo "no"; fi
412 echo -n "Python bindings ..................... "
413 if test "x$HAVE_PYTHON_TRUE" = "x"; then echo "yes"; else echo "no"; fi
414 echo -n "Ruby bindings ....................... "
415 if test "x$HAVE_RUBY_TRUE" = "x"; then echo "yes"; else echo "no"; fi
416 echo -n "Java bindings ....................... "
417 if test "x$HAVE_JAVA_TRUE" = "x"; then echo "yes"; else echo "no"; fi
418 echo
419 echo "If any optional component is configured 'no' when you expected 'yes'"
420 echo "then you should check the preceeding messages."
421 echo
422 echo "Please report bugs back to the fedora-virt mailing list:"
423 echo "http://www.redhat.com/mailman/listinfo/fedora-virt"
424 echo
425 echo "Next you should type 'make' to build the package,"
426 echo "then 'make check' to run the tests."
427 echo "------------------------------------------------------------"