<?xml version="1.0" encoding="iso-8859-1"?>
<!--
Indus, a program analysis and transformation toolkit for Java.
Copyright (c) 2001, 2007  Venkatesh Prasad Ranganath

All rights reserved.  This program and the accompanying materials are made 
available under the terms of the Eclipse Public License v1.0 which accompanies 
the distribution containing this program, and is available at 
http://www.opensource.org/licenses/eclipse-1.0.php.

For questions about the license, copyright, and software, contact 
	Venkatesh Prasad Ranganath at venkateshprasad.ranganath@gmail.com
                                
This software was developed by Venkatesh Prasad Ranganath in SAnToS Laboratory 
at Kansas State University.
-->
<!-- $Revision$ -->
<project name="indus.indus" default="build" basedir=".">

	<!-- define all local properties in localbuild.properties -->
	
	<import file="prelocalbuild.xml" />
	
	<condition property="doxygen.present">
		<isset property="doxygen.jar"/>
	</condition>
	
	<condition property="docbook.present">
		<isset property="docbook.base"/>
	</condition>
	
	<condition property="compilerToUse" value="org.eclipse.jdt.core.JDTCompilerAdapter">
		<not>
			<isset property="compilerToUse"/>
		</not>
	</condition>
	
	<condition property="custom.javadoc.links" value="">
			<not>
				<isset property="custom.javadoc.links"/>
			</not>
	</condition>
	
	<target name="init">
		<tstamp />
	</target>

	<target name="localbuild" depends="init">
		<mkdir dir="${build.dir}" />
		<javac source="1.5" target="1.5" destdir="${build.dir}" debug="on" 
			debuglevel="${debuglevel}" includes="**/*.java" compiler="${compilerToUse}">
			<src refid="${ant.project.name}.srcpath" />
			<classpath refid="${classpath}" />
		</javac>
		<copy todir="${build.dir}">
			<fileset dir=".">
				<include name="src*/**/*.properties" />
				<include name="src*/**/*.xsd" />				
				<include name="src*/**/*.xml" />		
			</fileset>
			<mapper type="regexp" from="^(src[^/]*/)(.+)(properties|xsd|xml)" to="\2\3" />
		</copy>
	</target>

	<target name="build" depends="init">
		<mkdir dir="${build.dir}" />
		<antcall target="localbuild">
			<param name="srcpath" value="${ant.project.name}.docsrcpath" />
			<param name="classpath" value="${ant.project.name}.classpath" />
			<param name="debuglevel" value="lines" />
		</antcall>
		<antcall target="executeCustomBuild" />
	</target>

	<target name="debugBuild" depends="init">
		<mkdir dir="${build.dir}" />
		<antcall target="localbuild">
			<param name="srcpath" value="${ant.project.name}.srcpath" />
			<param name="classpath" value="${ant.project.name}.classpath" />
			<param name="debuglevel" value="lines,vars,source" />
		</antcall>
		<antcall target="executeCustomBuild" />
	</target>

	<target name="executeCustomBuild" if="custombuild.exists">
		<antcall target="custombuild" />
	</target>


	<target name="jar" depends="init">
		<jar destfile="${jarfile}">
            <fileset dir="${build.dir}">
                <exclude name="**/.*"/>
                <exclude name="**/*Test.class"/>
                <exclude name="**/*TestSetup.class"/>
                <exclude name="**/*TestSuite.class"/>
                <exclude name="**/*TestCase.class"/>
                <exclude name="**/*Test$*.class"/>            	
            	<exclude name="**/*Test?.class"/>
            </fileset>
			<fileset file="LICENSE.TXT"/>
        </jar>
	</target>

	<target name="buildAndJar" depends="build">
        <antcall target="jar"/>
	</target>

	<target name="docs" depends="init">
		<antcall target="javadocs">
			<param name="access" value="protected" />
			<param name="sootlink" value="${remote.soot.link}" />
			<param name="jdklink" value="${remote.jdk.link}" />
			<param name="srcpath" value="${ant.project.name}.docsrcpath" />
			<param name="exclude" value="yes" />
		</antcall>
		<antcall target="doxydocs">
			<param name="configFile" value="Doxyfile" />
		</antcall>
	<!--	<antcall target="docbook-doc" /> -->
	</target>

	<target name="privatedocs" depends="init">
		<antcall target="javadocs">
			<param name="access" value="private" />
			<param name="sootlink" value="${local.soot.link}" />
			<param name="jdklink" value="${local.jdk.link}" />
			<param name="srcpath" value="${ant.project.name}.srcpath" />
			<param name="exclude" value="no" />
		</antcall>
		<antcall target="doxydocs">
			<param name="configFile" value="privateDoxyfile" />
		</antcall>
		<antcall target="docbook-doc" />
	</target>

	<target name="doxydocs" if="doxygen.present" >
		<taskdef name="doxygen" classname="net.drishti.util.ant.Doxygen" classpath="${doxygen.jar}" />
		<delete dir="${docs}/doxydocs" />
		<mkdir dir="${docs}/doxydocs" />
		<doxygen configfile="${configFile}" />
	</target>

	<target name="javadocs">
		<delete dir="${docs}/javadocs" />
		<mkdir dir="${docs}/javadocs" />
		<javadoc packagenames="${doc.packages}"
		         destdir="${docs}/javadocs"
		         access="${access}"
		         use="true"
		         author="true"
		         additionalparam="-breakiterator"
		         defaultexcludes="${exclude}"
		         header="&lt;b> &lt;a href='http://indus.projects.cis.ksu.edu'>Indus &lt;/a>, a &lt;a href='http://www.cis.ksu.edu/santos'>SAnToS laboratory &lt;/a> project.&lt;/b>"
		         doctitle="&lt;b>Indus, a toolkit to customize and adapt Java programs.&lt;/b>"
		         overview="src/overview.html"
				 source="1.5">
			<classpath refid="${ant.project.name}.classpath" />
			<sourcepath refid="${srcpath}" />
			<link href="${sootlink}" />
			<link href="${jdklink}" />
			<tag name="pre" description="Precondition:" scope="constructors,methods" />
			<tag name="post" description="Postcondition:" scope="constructors,methods" />
			<tag name="invariant" description="Invariant" scope="methods,types,fields" />
			<arg line="${custom.javadoc.links}"/>
		</javadoc>
	</target>

	<target name="docbook-doc" if="docbook.present">
		<ant dir="docs/ug/" antfile="${docbook.base}/build.xml" target="pdf" />
		<ant dir="docs/ug/" antfile="${docbook.base}/build.xml" target="html-single" />
	</target>

	<target name="dist" depends="build, docs">
		<antcall target="src-dist" />
	</target>

	<target name="privatebuild" depends="build, privatedocs" />

	<target name="src-dist" depends="init">
		<mkdir dir="${dist}" />
		<property name="filename" value="${dist}/${ant.project.name}-src-${DSTAMP}" />
		<property name="bin.filename" value="${dist}/${ant.project.name}-${DSTAMP}" />
		<jar jarfile="${bin.filename}.jar" basedir="${build.dir}" excludes="*.jar, *.tar, *.tgz" />
		<zip destfile="${filename}.zip" level="9">
			<zipfileset dir="." prefix="${ant.project.name}">
				<patternset refid="dist.srcpath"/>
				<include name="${filename}.jar"/>
				<include name="auxiliary/*"/>
				<include name="${docs}/**"/>
				<include name="build.xml"/>
				<include name="prelocalbuild.xml"/>
				<include name="antbuild.properties"/>
				<include name="guidelines.txt"/>
				<include name="LICENSE.TXT"/>
				<exclude name="dist"/>
			</zipfileset>
		</zip>
		<delete file="${filename}.tar" />
	</target>

	<target name="clean" depends="init">
		<delete includeEmptyDirs="true" quiet="true">
			<fileset dir="${build.dir}" includes="**/*" />
		</delete>
		<delete dir="${docs}/javadocs" quiet="true" />
		<delete dir="${docs}/doxydocs" quiet="true" />
	</target>

</project>

<!--
Local Variables:
mode: sgml
End:
-->

