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