From 6f188e15fe11b22830c6d984fae0302b5394121d Mon Sep 17 00:00:00 2001
From: Brian Carrier <carrier@sleuthkit.org>
Date: Tue, 19 Nov 2013 18:07:43 -0500
Subject: [PATCH] Cleaned up java code a bit in build / make system

---
 Makefile.am               |  3 ++-
 bindings/java/Makefile.am |  3 +++
 configure.ac              | 17 ++++++++++++-----
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 33390d34b..6c9be1d2e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -62,8 +62,9 @@ if CPPUNIT
   UNIT_TESTS=unit_tests
 endif
 
+# Compile java bindings if all of the dependencies existed
 if X_JNI
-  JAVA_BINDINGS=bindings/java/jni bindings/java
+  JAVA_BINDINGS=bindings/java
 else   
   JAVA_BINDINGS=
 endif
diff --git a/bindings/java/Makefile.am b/bindings/java/Makefile.am
index fa70d5ca8..1007a3e60 100644
--- a/bindings/java/Makefile.am
+++ b/bindings/java/Makefile.am
@@ -2,6 +2,9 @@ Z_PATH=@Z_PATH@
 EWF_PATH=@EWF_PATH@
 ANT_PROPS=
 
+# Compile the sub directories
+SUBDIRS = jni
+
 if X_ZLIB
   ANT_PROPS+=-Dlib.z.path=$(Z_PATH)
 endif
diff --git a/configure.ac b/configure.ac
index f1d6d10d2..ba65c1650 100644
--- a/configure.ac
+++ b/configure.ac
@@ -225,8 +225,9 @@ dnl sqlite requires pthread libraries - this was copied from its configure.ac
 dnl AC_SEARCH_LIBS(pthread_create, pthread)
 AC_SEARCH_LIBS(dlopen, dl)
 
-dnl Test for java/jni so that we can compile the java bindings
+dnl Test for the various java things that we need for bindings
 AS_IF([test "x$enable_java" != "xno"], [
+    dnl javac is needed to compile the JAR file
     AC_PROG_JAVAC
     if test "x$JAVAC" != x; then
         AX_JNI_INCLUDE_DIR
@@ -237,14 +238,20 @@ AS_IF([test "x$enable_java" != "xno"], [
         dnl Export the paths so that the makefile gets them
         AC_SUBST(JNI_CPPFLAGS, $JNI_CPPFLAGS)
     fi
+
+    dnl java is needed by ant
+    dnl we had one report of a system with javac and not java
     AC_PROG_JAVA
-]) dnl test enable_java
 
-dnl Test is ant is available
-AC_PATH_PROG([ANT_FOUND], [ant], [])
-AM_CONDITIONAL([X_JNI],[test "x$JNI_CPPFLAGS" != x && test "x$ANT_FOUND" != x && test "x$JAVA" != x])
+    dnl Test is ant is available
+    AC_PATH_PROG([ANT_FOUND], [ant], [])
+
+]) dnl test enable_java
 
+dnl if we found everything we need, set ax_java_support for the
+dnl status message and set X_JNI for use in Makefile
 AS_IF([test "x$JNI_CPPFLAGS" != x && test "x$ANT_FOUND" != x && test "x$JAVA" != x], [ax_java_support=yes], [ax_java_support=no])
+AM_CONDITIONAL([X_JNI],[test "x$ax_java_support" == "xyes"])
 
 AC_CONFIG_COMMANDS([tsk/tsk_incs.h],
     [echo "#ifndef _TSK_INCS_H" > tsk/tsk_incs.h
-- 
GitLab