From: Richard Jones Date: Tue, 21 Apr 2009 13:25:16 +0000 (+0100) Subject: Basic Java build environment. X-Git-Tag: 1.0.5~8 X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=commitdiff_plain;h=b9014d6a0da8b2b3a76c4ab51fab2773fe7480b2 Basic Java build environment. --- diff --git a/Makefile.am b/Makefile.am index 710e39d..b642bdd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,6 +31,9 @@ endif if HAVE_RUBY SUBDIRS += ruby endif +if HAVE_JAVA +SUBDIRS += java +endif EXTRA_DIST = \ make-initramfs.sh update-initramfs.sh \ diff --git a/README b/README index 50d2145..5b22da9 100644 --- a/README +++ b/README @@ -52,6 +52,9 @@ also to build the OCaml bindings - (Optional) Ruby, rake if you want to build the ruby bindings +- (Optional) Java, JNI, jpackage-utils if you want to build the java +bindings + Running ./configure will check you have all the requirements installed on your machine. diff --git a/configure.ac b/configure.ac index 5be2587..68b716b 100644 --- a/configure.ac +++ b/configure.ac @@ -197,7 +197,113 @@ LIBS="$old_libs" AC_CHECK_PROG([RAKE],[rake],[rake],[no]) AM_CONDITIONAL([HAVE_RUBY], - [test "x$RAKE" != "xno" -a -n "x$HAVE_LIBRUBY"]) + [test "x$RAKE" != "xno" -a -n "$HAVE_LIBRUBY"]) + +dnl Check for Java. +AC_ARG_WITH(java_home, + [AS_HELP_STRING([--with-java-home], + [specify path to JDK directory @<:@default=check@:>@])], + [], + [with_java_home=check]) + +if test "x$with_java_home" != "xno"; then + if test "x$with_java_home" != "xyes" -a "x$with_java_home" != "xcheck" + then + if test -d "$with_java_home"; then + JAVA_HOME="$with_java_home" + else + AC_MSG_FAILURE([$with_java_home is not a directory]) + fi + fi + if test "x$JAVA_HOME" = "x"; then + JAVA_HOME=/usr/lib/jvm/java + fi + AC_MSG_CHECKING(for JDK in $JAVA_HOME) + if test ! -x "$JAVA_HOME/bin/java"; then + AC_MSG_ERROR([missing $JAVA_HOME/bin/java binary]) + else + JAVA="$JAVA_HOME/bin/java" + fi + if test ! -x "$JAVA_HOME/bin/javac"; then + AC_MSG_ERROR([missing $JAVA_HOME/bin/javac binary]) + else + JAVAC="$JAVA_HOME/bin/javac" + fi + if test ! -x "$JAVA_HOME/bin/javah"; then + AC_MSG_ERROR([missing $JAVA_HOME/bin/javah binary]) + else + JAVAH="$JAVA_HOME/bin/javah" + fi + if test ! -x "$JAVA_HOME/bin/javadoc"; then + AC_MSG_ERROR([missing $JAVA_HOME/bin/javadoc binary]) + else + JAVADOC="$JAVA_HOME/bin/javadoc" + fi + if test ! -x "$JAVA_HOME/bin/jar"; then + AC_MSG_ERROR([missing $JAVA_HOME/bin/jar binary]) + else + JAR="$JAVA_HOME/bin/jar" + fi + java_version=`$JAVA -version 2>&1 | grep "java version"` + AC_MSG_RESULT(found $java_version in $JAVA_HOME) + + dnl Find jni.h. + AC_MSG_CHECKING([for jni.h]) + if test -f "$JAVA_HOME/include/jni.h"; then + JNI_CFLAGS="-I$JAVA_HOME/include" + else + if test "`find $JAVA_HOME -name jni.h`" != ""; then + head=`find $JAVA_HOME -name jni.h | tail -1` + dir=`dirname $head` + JNI_CFLAGS="-I$dir" + else + AC_MSG_FAILURE([missing jni.h header file]) + fi + fi + AC_MSG_RESULT([$JNI_CFLAGS]) + + dnl Find jni_md.h. + AC_MSG_CHECKING([for jni_md.h]) + case "$build_os" in + *linux*) system="linux" ;; + *SunOS*) system="solaris" ;; + *cygwin*) system="win32" ;; + *) system="$build_os" ;; + esac + if test -f "$JAVA_HOME/include/$system/jni_md.h"; then + JNI_CFLAGS="$JNI_CFLAGS -I$JAVA_HOME/include/$system" + else + if test "`find $JAVA_HOME -name jni_md.h`" != ""; then + head=`find $JAVA_HOME -name jni_md.h | tail -1` + dir=`dirname $head` + JNI_CFLAGS="$JNI_CFLAGS -I$dir" + else + AC_MSG_FAILURE([missing jni_md.h header file]) + fi + fi + AC_MSG_RESULT([$JNI_CFLAGS]) + + dnl Need extra version flag? + AC_MSG_CHECKING([extra javac flags]) + JAVAC_FLAGS= + javac_version=`$JAVAC -version 2>&1` + case "$javac_version" in + *Eclipse*) + JAVAC_FLAGS="-source 1.5" ;; + esac + AC_MSG_RESULT([$JAVAC_FLAGS]) +fi + +AC_SUBST(JAVA_HOME) +AC_SUBST(JAVA) +AC_SUBST(JAVAC) +AC_SUBST(JAVAH) +AC_SUBST(JAVADOC) +AC_SUBST(JAR) +AC_SUBST(JNI_CFLAGS) +AC_SUBST(JAVAC_FLAGS) + +AM_CONDITIONAL([HAVE_JAVA],[test -n "$JAVAC"]) dnl Run in subdirs. AC_CONFIG_SUBDIRS([daemon]) @@ -210,6 +316,7 @@ AC_CONFIG_FILES([Makefile src/Makefile fish/Makefile examples/Makefile perl/Makefile python/Makefile ruby/Makefile ruby/Rakefile + java/Makefile make-initramfs.sh update-initramfs.sh libguestfs.spec ocaml/META perl/Makefile.PL]) diff --git a/java/Makefile.am b/java/Makefile.am new file mode 100644 index 0000000..7e8786d --- /dev/null +++ b/java/Makefile.am @@ -0,0 +1,25 @@ +# libguestfs Java bindings +# Copyright (C) 2009 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +EXTRA_DIST = + +CLEANFILES = *~ + +if HAVE_JAVA + + +endif \ No newline at end of file diff --git a/libguestfs.spec.in b/libguestfs.spec.in index ef07ea8..9cc9266 100644 --- a/libguestfs.spec.in +++ b/libguestfs.spec.in @@ -44,6 +44,9 @@ BuildRequires: perl-ExtUtils-MakeMaker BuildRequires: python-devel BuildRequires: ruby-devel BuildRequires: rubygem-rake +BuildRequires: java >= 1.5.0 +BuildRequires: jpackage-utils +BuildRequires: java-devel # Runtime requires: Requires: qemu >= 0.10-7 @@ -81,6 +84,8 @@ For Python bindings, see 'python-libguestfs'. For Ruby bindings, see 'ruby-libguestfs'. +For Java bindings, see 'libguestfs-java-devel'. + %package devel Summary: Development tools and libraries for %{name} @@ -168,6 +173,44 @@ Provides: ruby(guestfs) = %{version} ruby-%{name} contains Ruby bindings for %{name}. +%package java +Summary: Java bindings for %{name} +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: java >= 1.5.0 +Requires: jpackage-utils + +%description java +%{name}-java contains Java bindings for %{name}. + +If you want to develop software in Java which uses %{name}, then +you will also need %{name}-java-devel. + + +%package java-devel +Summary: Java development package for %{name} +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: %{name}-java = %{version}-%{release} + +%description java-devel +%{name}-java-devel contains the tools for developing Java software +using %{name}. + +See also %{name}-javadoc. + + +%package javadoc +Summary: Java documentation for %{name} +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} +Requires: %{name}-java = %{version}-%{release} +Requires: jpackage-utils + +%description javadoc +%{name}-javadoc contains the Java documentation for %{name}. + + %prep %setup -q @@ -184,10 +227,14 @@ popd %define extra %nil %endif -./configure --prefix=%{_prefix} --libdir=%{_libdir} %{extra} +./configure \ + --prefix=%{_prefix} --libdir=%{_libdir} \ + --with-java-home=%{java_home} \ + %{extra} # 'INSTALLDIRS' ensures that perl libs are installed in the vendor dir # not the site dir. +# Uses javac which is incompatible with parallel make. make INSTALLDIRS=vendor @@ -321,6 +368,25 @@ rm -rf $RPM_BUILD_ROOT %{ruby_sitearch}/_guestfs.so +%files java +%defattr(-,root,root,-) +%doc README +%{_libdir}/libguestfs_jni*.so.* +%{_datadir}/java/*.jar + + +%files java-devel +%defattr(-,root,root,-) +%doc java/ +%{_libdir}/libguestfs_jni*.so + + +%files java +%defattr(-,root,root,-) +%doc README +/usr/share/javadoc/%{name}-java-%{version} + + %changelog * Mon Apr 20 2009 Richard Jones - @VERSION@-1 - New upstream version @VERSION@.