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