Index: /main/trunk/greenstone3/build.properties.in
===================================================================
--- /main/trunk/greenstone3/build.properties.in	(revision 22183)
+++ /main/trunk/greenstone3/build.properties.in	(revision 22184)
@@ -47,6 +47,18 @@
 compile.optimize=true
 
-## should compilation be static?? - used for distributions
+# Control whether or not JNI bindings are used
+#   e.g. MG, MG++ and GDBM and the like
+# Setting this false means these components are not available to the install
+# The expectation is that collections will be build from 100% Java components:
+#   e.g Lucene and JDBM
+# 
+# Ant 1.7.1 and before only test for *existence* so this needs to be commented
+# in or out to control whether jni is used or not
+with.jni=true
+
+## Control if compilation of gs2 is static or not. Used, for example, for distributions
+# Same issue as 'with.jni' for how this gets used in ant 1.7.1 and before
 #compile.static=true
+
 
 ## windows c++ compilation
Index: /main/trunk/greenstone3/build.xml
===================================================================
--- /main/trunk/greenstone3/build.xml	(revision 22183)
+++ /main/trunk/greenstone3/build.xml	(revision 22184)
@@ -218,4 +218,17 @@
   <condition property="static.arg" value="LDFLAGS=-static" else=" ">
     <isset property="compile.static"/>
+  </condition>
+
+  <condition property="gs2.opt.args" value= " " else="--disable-mg --disable-mgpp --disable-accentfold --disable-gdbm --disable-sqlite">
+    <istrue value="${with.jni}"/>
+  </condition>
+  <condition property="gs2.compile.target" value="with-jni" else="without-jni">
+    <istrue value="${with.jni}"/>
+  </condition>
+  <condition property="gs2.install.target" value="install-with-jni" else="install-without-jni">
+    <istrue value="${with.jni}"/>
+  </condition>
+  <condition property="gs2.windows.enablejni" value="1" else="0">
+    <istrue value="${with.jni}"/>
   </condition>
   
@@ -315,4 +328,5 @@
     <!-- mg and mgpp get installed into lib/jni but they may not be there yet
     so we add them in by name -->
+    <!-- *** is there any way to make this optional, based on ${with.jni}? -->
     <pathelement location="${lib.jni}/mg.jar"/>
     <pathelement location="${lib.jni}/mgpp.jar"/>
@@ -810,5 +824,5 @@
       <env key="CLASSPATH" path="${tomcat.classpath}"/>
       <env key="LD_LIBRARY_PATH" path="${env.LD_LIBRARY_PATH}:${lib.jni}"/>
-      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here??-->
+      <env key="DYLD_LIBRARY_PATH" path="${env.DYLD_LIBRARY_PATH}:${lib.jni}:${gdbm.home}/lib"/> <!-- for mac os --> <!-- need gdbm here these days ??-->
       <env key="WNHOME" path="${wn.home}"/>
     </exec>
@@ -1197,5 +1211,5 @@
     description="Configure only the packages."/>
   
-  <target name="configure-javagdbm">
+  <target name="configure-javagdbm" if="with.jni">
     <echo>
       Configuring JavaGDBM
@@ -1228,4 +1242,11 @@
   
   <target name="compile-packages" description="Compile only the source packages">
+    <!-- javagdbm -->
+    <antcall target="compile-javagdbm"/>
+    <!-- Search4j -->
+    <antcall target="compile-search4j"/>
+  </target>
+
+  <target name="compile-javagdbm" description="Compile JavaGDBM" if="with.jni">
     
     <!-- unix: -->
@@ -1246,8 +1267,4 @@
     <echo>Install the javagdbm jar file</echo>
     <copy file="${javagdbm.home}/javagdbm.jar" todir="${lib.jni}"/>
-
-
-    <!-- Search4j -->
-    <antcall target="compile-search4j"/>
   </target>
 
@@ -1288,10 +1305,19 @@
 
   <target name="install-auxiliary-jar-files" depends="init">
-    <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
-    <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
+
+    <if>
+      <bool><available file="${mg.home}/mg.jar"/></bool>
+      <copy file="${mg.home}/mg.jar" todir="${lib.jni}"/>
+    </if>
+
+    <if>
+      <bool><available file="${mgpp.home}/mg.jar"/></bool>
+      <copy file="${mgpp.home}/mgpp.jar" todir="${lib.jni}"/>
+    </if>
+
     <copy file="${lucene.home}/LuceneWrapper.jar" todir="${web.lib}"/>    
   </target>
   
-  <target name="install-jni-files" depends="init,install-jni-files-linux,install-jni-files-windows,install-jni-files-macos"/>
+  <target name="install-jni-files" depends="init,install-jni-files-linux,install-jni-files-windows,install-jni-files-macos" if="with.jni"/>
 
   <target name="install-jni-files-linux" depends="init" if="current.os.isunixnotmac">
@@ -1355,5 +1381,5 @@
       <arg value="--prefix=${gs2build.home}"/> <!-- what value to use?? -->
       <arg value="--bindir=${gs2build.home}/bin/${os.bin.dir}"/> <!-- what value to use?? -->
-      <arg value="--enable-jni"/>
+      <arg line="${gs2.opt.args}"/>
       <arg line="${static.arg}"/>
     </exec>
@@ -1389,5 +1415,5 @@
     <!-- unix: -->
     <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
-      <arg value="with-jni"/>
+      <arg value="${gs2.compile.target}"/>
     </exec>
     <!-- windows: -->
@@ -1396,6 +1422,6 @@
       <arg value="win32.mak"/>
       <arg value="GSDLHOME=${gs2build.home}"/>
-      <arg value="ENABLE_JNI=1"/>
-      <arg value="USE_SQLITE=0"/>
+      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
+      <arg value="USE_SQLITE=0"/> <!-- Why is this not on by default? -->
     </exec>
   </target>
@@ -1431,5 +1457,5 @@
     <!-- unix: -->
     <exec executable="make" os="${os.unix}" dir="${common.src.home}" failonerror="true">
-      <arg value="install-with-jni"/>
+      <arg value="${gs2.install.target}"/>
     </exec>
       
@@ -1439,6 +1465,6 @@
       <arg value="win32.mak"/>
       <arg value="install"/>
-      <arg value="ENABLE_JNI=1"/>
-      <arg value="USE_SQLITE=0"/>
+      <arg value="ENABLE_JNI=${gs2.windows.enablejni}"/>
+      <arg value="USE_SQLITE=0"/> <!-- why is this not on by default? -->
     </exec>
 
@@ -1672,4 +1698,5 @@
       dir="${build.src.home}" failonerror="true">
       <arg value="--prefix=${gs2build.home}"/>
+      <arg line="${gs2.opt.args}"/>
       <arg line="${static.arg}"/>
     </exec>
@@ -1882,2 +1909,3 @@
     
 </project>
+
