Index: greenstone3/trunk/build.xml
===================================================================
--- greenstone3/trunk/build.xml	(revision 20083)
+++ greenstone3/trunk/build.xml	(revision 20085)
@@ -96,4 +96,5 @@
   <!-- jar files needed by applets go here -->
   <property name="web.applet" value="${web.home}/applet"/>
+
   <!-- jar files needed by the servlet (and extra ones) go here -->
   <property name="web.lib" value="${web.home}/WEB-INF/lib"/>
@@ -126,5 +127,5 @@
   <!-- catalina home is set to tomcat basedir if already installed, otherwise
   use greenstone's tomcat -->
-  <condition property="catalina.home" value="${tomcat.installed.path}"> 
+  <condition property="catalina.home" value="${tomcat.installed.path}" else="${packages.home}/tomcat"> 
     <and>
       <isset property="tomcat.installed.path"/>
@@ -135,6 +136,4 @@
   </condition>
   
-  <property name="catalina.home" value="${packages.home}/tomcat"/>
-
   <property name="os.linux" value="Linux"/> 
   <property name="os.mac" value="Mac OS X"/>
@@ -206,18 +205,12 @@
   </condition>
   
-  <condition property="static.arg" value="LDFLAGS=-static">
+  <condition property="static.arg" value="LDFLAGS=-static" else=" ">
     <isset property="compile.static"/>
   </condition>
-  <condition property="static.arg" value=" ">
-    <not>
-      <isset property="compile.static"/>
-    </not>
-  </condition>
   
   <!-- where is search4j tool -->
-  <condition property="search4j.exec" value="bin/search4j.exe"> 
+  <condition property="search4j.exec" value="bin/search4j.exe" else="bin/search4j"> 
     <isset property="current.os.iswindows"/>
   </condition>
-  <property name="search4j.exec" value="bin/search4j"/>
 
   
@@ -227,12 +220,6 @@
   <property name="gli.home" value="${basedir}/gli"/>
   <property name="javagdbm.home" value="${src.packages.home}/javagdbm"/>
-  
-  <condition property="common.src.home" value="${gs2build.home}/common-src">
-    <not>
-      <isset property="disable.collection.building"/>
-    </not>
-  </condition>
-
-  <condition property="common.src.home" value="${basedir}/common-src">
+
+  <condition property="common.src.home" value="${basedir}/common-src" else="${gs2build.home}/common-src">
     <isset property="disable.collection.building"/>
   </condition>
@@ -276,23 +263,23 @@
   <!-- All elements that Tomcat 5 exposes to applications -->
   <path id="tomcat5">
-	<pathelement location="${catalina.home}/common/classes"/>
-	<fileset dir="${catalina.home}/common/endorsed">
-	  <include name="*.jar"/>
-	</fileset>
-	<fileset dir="${catalina.home}/common/lib">
-	  <include name="*.jar"/>
-	</fileset>
-	<!-- seems to be empty, but will leave in just in case some people make use of this to customise their install: -->
-	<pathelement location="${catalina.home}/shared/classes"/>
-	<fileset dir="${catalina.home}/shared/lib">
-	  <include name="*.jar"/>
-	</fileset>
+    <pathelement location="${catalina.home}/common/classes"/>
+    <fileset dir="${catalina.home}/common/endorsed">
+      <include name="*.jar"/>
+    </fileset>
+    <fileset dir="${catalina.home}/common/lib">
+      <include name="*.jar"/>
+    </fileset>
+    <!-- seems to be empty, but will leave in just in case some people make use of this to customise their install: -->
+    <pathelement location="${catalina.home}/shared/classes"/>
+    <fileset dir="${catalina.home}/shared/lib">
+      <include name="*.jar"/>
+    </fileset>
   </path>
   
   <!-- All elements that Tomcat 6 exposes to applications -->
   <path id="tomcat6">
-	<fileset dir="${catalina.home}/lib">
-	  <include name="*.jar"/>
-	</fileset>
+    <fileset dir="${catalina.home}/lib">
+      <include name="*.jar"/>
+    </fileset>
   </path>
   
@@ -320,7 +307,7 @@
     <pathelement location="${lib.jni}/mgpp.jar"/>
     
-	<!-- Include all elements that Tomcat exposes to applications -->
-	<path refid="tomcat${tomcat.version.major}"/>
-
+    <!-- Include all elements that Tomcat exposes to applications -->
+    <path refid="tomcat${tomcat.version.major}"/>
+    
   </path>
 
@@ -350,6 +337,5 @@
     <echo>os.unix: ${os.unix}</echo>
   </target>
-
-
+  
   <!-- ==================== Primary and Global Targets ============================= -->
 
@@ -454,9 +440,17 @@
     <fail if="do.abort">Build aborted by user. Please change your properties settings and re-run the target</fail>
   </target>
-
-
+  
   <!-- this sets up some initial properties -->
   <target name="init">
 
+    <!-- has the gs3-setup script been run?? -->
+    <condition property="gs3-setup-not-done">
+      <not>
+	<isset property="env.GSDL3HOME"/>
+      </not>
+    </condition>
+
+    <fail if="gs3-setup-not-done" message="please run 'gs3-setup' (Windows) or 'source gs3-setup.sh' (Linux/Mac) before running this target."/>
+    
     <condition property="java.too.old">
       <or>
@@ -548,17 +542,14 @@
     <echo>activating xalan.jar</echo>
     <copy file="${web.lib}/xalan.jar.tmp" tofile="${web.lib}/xalan.jar"/>
-	<if>
-	  <bool>
-		<and>
-		  <isset property="current.os.ismac"/>
-		  <available file="${catalina.home}/common/endorsed" type="dir"/>
-		</and>
-	  </bool>
-	  <copy file="${web.lib}/xalan.jar.tmp" tofile="${catalina.home}/common/endorsed/xalan.jar"/> 
+    <if>
+      <bool>
+	<and>
+	  <isset property="current.os.ismac"/>
+	  <available file="${catalina.home}/common/endorsed" type="dir"/>
+	</and>
+      </bool>
+      <copy file="${web.lib}/xalan.jar.tmp" tofile="${catalina.home}/common/endorsed/xalan.jar"/> 
     </if>
   </target>
-
-  <!-- to delete -->
-  <target name="copy-xalan-for-mac"></target>
 
   <target name="deactivate-xalan-jar">
@@ -671,16 +662,16 @@
       <unzip src="${packages.home}/${tomcat.version}.zip" 
         dest="${packages.home}"/>
-	
-		<!-- If we are using Java 1.4, we'd be using tomcat 5.5 in which case 
-		we would need to have the tomcat compat package to work with Java 1.4-->
-	  <if>
-		<bool><equals arg1="1.4" arg2="${ant.java.version}"/></bool>
-		  <get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
-			dest="${packages.home}/${tomcat.version}-compat.zip"
-			usetimestamp="true"/>
-		<unzip src="${packages.home}/${tomcat.version}-compat.zip" 
-			dest="${packages.home}"/>
-	  </if>
-	
+      
+      <!-- If we are using Java 1.4, we'd be using tomcat 5.5 in which case 
+      we would need to have the tomcat compat package to work with Java 1.4-->
+      <if>
+	<bool><equals arg1="1.4" arg2="${ant.java.version}"/></bool>
+	<get src="http://www.greenstone.org/gs3files/${tomcat.version}-compat.zip"
+	  dest="${packages.home}/${tomcat.version}-compat.zip"
+	  usetimestamp="true"/>
+	<unzip src="${packages.home}/${tomcat.version}-compat.zip" 
+	  dest="${packages.home}"/>
+      </if>
+      
       <!-- delete any existing tomcat -->
       <delete dir="${packages.home}/tomcat"/>
@@ -1018,11 +1009,11 @@
   <target name="compile-core" depends="init" 
     description="Compile only the Greenstone core">
-	<if>
-	  <!-- Rather than test for tomcat 6, testing here for NOT tomcat 5 
-		(so that it may hopefully still serve when it becomes tomcat 7) -->
-	  <bool><not><equals arg1="5" arg2="${tomcat.version.major}"/></not></bool>
-	    <copy file="${web.lib}/xercesImpl.jar" todir="${catalina.home}/lib"/>
-        <copy file="${web.lib}/xml-apis.jar" todir="${catalina.home}/lib"/>
-	</if>
+    <if>
+      <!-- Rather than test for tomcat 6, testing here for NOT tomcat 5 
+      (so that it may hopefully still serve when it becomes tomcat 7) -->
+      <bool><not><equals arg1="5" arg2="${tomcat.version.major}"/></not></bool>
+      <copy file="${web.lib}/xercesImpl.jar" todir="${catalina.home}/lib"/>
+      <copy file="${web.lib}/xml-apis.jar" todir="${catalina.home}/lib"/>
+    </if>
     <mkdir dir="${build.home}"/>
     <javac srcdir="${src.home}"
@@ -1073,6 +1064,6 @@
     <if>
       <bool><istrue value="${tomcat.islocal}"/></bool>
-		<copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
-		<copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
+      <copy file="${web.lib}/xercesImpl.jar" todir="${web.applet}"/>
+      <copy file="${web.lib}/xml-apis.jar" todir="${web.applet}"/>
     </if>
 
