automake: setup autotools to build cephfs-java

Adds --enable-cephfs-java and --with-jdk to build
the libcephfs Java bindings and specify the default
JDK directory, respectively.

Also adds default JDK paths to avoid --with-jdk in
the common case. Currently setup for the default
provided by Debian's default-jdk package, but other
default search paths can easily be added.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
This commit is contained in:
Noah Watkins 2012-09-01 10:26:41 -07:00
parent 350433530f
commit 68e01649ff
5 changed files with 135 additions and 41 deletions

View File

@ -244,7 +244,80 @@ AS_IF([test "x$with_tcmalloc" != xno],
[no tcmalloc found (use --without-tcmalloc to disable)])])])
AM_CONDITIONAL(WITH_TCMALLOC, [test "$HAVE_LIBTCMALLOC" = "1"])
#
# Java is painful
# - adapted from OMPI wrappers package
# - this might become bigger. maybe should be own m4 file
#
AC_ARG_ENABLE(cephfs-java,
AC_HELP_STRING([--enable-cephfs-java], [build libcephfs Java bindings]),
[], [enable_cephfs_java=no])
AM_CONDITIONAL(ENABLE_CEPHFS_JAVA, test "x$enable_cephfs_java" = "xyes")
AC_ARG_WITH(jdk-dir,
AC_HELP_STRING([--with-jdk-dir(=DIR)], [Path to JDK directory]))
AC_DEFUN([JAVA_DNE],
AC_MSG_ERROR([Cannot find $1 '$2'. Try setting --with-jdk-dir]))
AS_IF([test "x$enable_cephfs_java" = "xyes"], [
# setup bin/include dirs from --with-jdk-dir (search for jni.h, javac)
AS_IF([test -n "$with_jdk_dir"], [
javac_prog=`find $with_jdk_dir/ -name javac | head -n 1`
AS_IF([test -x "$javac_prog"], [
EXTRA_JDK_BIN_DIR=`dirname $javac_prog`])
jnih=`find $with_jdk_dir/ -name jni.h | head -n 1`
AS_IF([test -r "$jnih"], [
EXTRA_JDK_INC_DIR=`dirname $jnih`])])
# setup defaults for Debian default-jdk package (without --with-jdk-dir)
AS_IF([test -z "$with_jdk_dir"], [
# This works with Debian's default-jdk package
dir='/usr/lib/jvm/default-java/'
javac_prog=`find $dir -name javac | head -n 1`
AS_IF([test -x "$javac_prog"], [
EXTRA_JDK_BIN_DIR=`dirname $javac_prog`])
jnih=`find $dir -name jni.h | head -n 1`
AS_IF([test -r "$jnih"], [
EXTRA_JDK_INC_DIR=`dirname $jnih`])])
# Check for Java programs: javac, javah, jar
PATH_save=$PATH
PATH="$PATH:$EXTRA_JDK_BIN_DIR"
AC_PATH_PROG(JAVAC, javac)
AC_PATH_PROG(JAVAH, javah)
AC_PATH_PROG(JAR, jar)
PATH=$PATH_save
# Ensure we have them...
AS_IF([test -z "$JAVAC"], JAVA_DNE(program, javac))
AS_IF([test -z "$JAVAH"], JAVA_DNE(program, javah))
AS_IF([test -z "$JAR"], JAVA_DNE(program, jar))
# Check for jni.h
CPPFLAGS_save=$CPPFLAGS
AS_IF([test -n "$EXTRA_JDK_INC_DIR"],
[JDK_CPPFLAGS="-I$EXTRA_JDK_INC_DIR"
AS_IF([test -d "$EXTRA_JDK_INC_DIR/linux"],
[JDK_CPPFLAGS="$JDK_CPPFLAGS -I$EXTRA_JDK_INC_DIR/linux"])
CPPFLAGS="$CPPFLAGS $JDK_CPPFLAGS"])
AC_CHECK_HEADER([jni.h], [], JAVA_DNE(header, jni.h))
CPPFLAGS=$CPPFLAGS_save
# Setup output var
AC_SUBST(JDK_CPPFLAGS)
])
# jni?
# clear cache (from java above) -- this whole thing will get
# folded into the bigger java package later -- for now maintain
# backward compat
AS_UNSET(ac_cv_header_jni_h)
AC_ARG_WITH([hadoop],
[AS_HELP_STRING([--with-hadoop], [build hadoop client])],
[],
@ -443,6 +516,7 @@ AC_CONFIG_FILES([Makefile
src/ocf/Makefile
src/ocf/ceph
src/ocf/rbd
src/java/Makefile
man/Makefile
ceph.spec])
AC_OUTPUT

View File

@ -1,5 +1,5 @@
AUTOMAKE_OPTIONS = gnu
SUBDIRS = ocf
SUBDIRS = ocf java
DIST_SUBDIRS = gtest ocf leveldb libs3
EXTRA_DIST = \
@ -506,6 +506,19 @@ libhadoopcephfs_la_CFLAGS = ${AM_CFLAGS}
libhadoopcephfs_la_CXXFLAGS = ${AM_CXXFLAGS}
libhadoopcephfs_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0 -export-symbols-regex 'hadoopcephfs_.*'
lib_LTLIBRARIES += libhadoopcephfs.la
endif
## CephFS Java Wrappers
## - The JNI library is here
## - The Java source Makefile.am is in src/java
if ENABLE_CEPHFS_JAVA
libcephfs_jni_la_SOURCES = java/native/libcephfs_jni.cc
libcephfs_jni_la_LIBADD = libcephfs.la
libcephfs_jni_la_CFLAGS = $(JDK_CPPFLAGS) ${AM_CFLAGS}
libcephfs_jni_la_CXXFLAGS = $(JDK_CPPFLAGS) ${AM_CXXFLAGS}
libcephfs_jni_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0
lib_LTLIBRARIES += libcephfs_jni.la
endif
## key_value_store classes

4
src/java/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.class
libcephfs.jar
native/com_ceph_fs_CephMount.h
TEST-*.txt

43
src/java/Makefile.am Normal file
View File

@ -0,0 +1,43 @@
# automake technique adapted from OpenMPI Java
JAVA_SRC = \
java/com/ceph/fs/CephMount.java \
java/com/ceph/fs/CephStat.java \
java/com/ceph/fs/CephStatVFS.java \
java/com/ceph/fs/CephNativeLoader.java \
java/com/ceph/fs/CephNotMountedException.java
EXTRA_DIST = $(JAVA_SRC)
if ENABLE_CEPHFS_JAVA
JAVA_CLASSES = $(JAVA_SRC:java/%.java=%.class)
# This is dumb -- It might be better to split some work
# between Make and Ant or Maven
#ESCAPED_JAVA_CLASSES = \
# com/ceph/fs/CephMount\$$State.class
JAVA_H = native/com_ceph_fs_CephMount.h
# target to make automake happy
CEPH_PROXY=java/com/ceph/fs/CephMount.class
$(CEPH_PROXY): $(JAVA_SRC)
export CLASSPATH=java/ ;
$(JAVAC) java/com/ceph/fs/*.java
$(JAVA_H): $(CEPH_PROXY)
export CLASSPATH=java/ ; \
$(JAVAH) -jni -o $@ com.ceph.fs.CephMount
libcephfs.jar: $(CEPH_PROXY)
$(JAR) cf $@ $(JAVA_CLASSES:%=-C java %) # $(ESCAPED_JAVA_CLASSES:%=-C java %)
javadir = $(libdir)
java_DATA = libcephfs.jar
BUILT_SOURCES = $(JAVA_H)
CLEANFILES = -rf java/com/ceph/fs/*.class $(JAVA_H) libcephfs.jar
endif

View File

@ -1,40 +0,0 @@
/*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package com.ceph.fs;
/**
* Class that represents generic Ceph exception.
*/
public class CephException extends Exception {
/**
* Create basic CephException.
*/
public CephException() {
super();
}
/**
* Create CephException with message.
*/
public CephException(String s) {
super(s);
}
}