<!--
/* ============================================================
 * JRobin : Pure java implementation of RRDTool's functionality
 * ============================================================
 *
 * Project Info:  http://www.jrobin.org
 * Project Lead:  Sasa Markovic (saxon@jrobin.org)
 *
 * Developers:    Sasa Markovic (saxon@jrobin.org)
 *                Arne Vandamme (cobralord@jrobin.org)
 *
 * (C) Copyright 2003, by Sasa Markovic.
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 */
-->

<project name="JRobin" default="dist" basedir=".">
	<description>JRobin build file</description>

	<!-- VARIABLES -->
	<property name="version" value="1.4.0" />
	<property name="who" value="Sasa Markovic &lt;saxon@jrobin.org&gt;"/>
	<property name="cwd" location=".."/>

	<property name="classes" value="classes"/>
	<property name="doc" value="doc"/>
	<property name="javadoc" value="${doc}/javadoc"/>
	<property name="dist" value="dist"/>
	<property name="src" value="src"/>
	<property name="libs" value="lib" />
	<property name="ant" value="ant" />
	<property name="lib-snmp" value="snmp-1.3.jar"/>
	<property name="lib-xmlrpc" value="xmlrpc-1.2-b1.jar"/>
	<property name="lib-jrobin" value="jrobin-${version}.jar"/>
	<property name="lib-demo" value="jrobin-demo-${version}.jar"/>
	<property name="lib-mrtg-client" value="mrtg-client-${version}.jar"/>
	<property name="lib-mrtg-server" value="mrtg-server-${version}.jar"/>
	<property name="lib-inspector" value="inspector-${version}.jar"/>
	<property name="lib-convertor" value="convertor-${version}.jar"/>
	<property name="res" value="res"/>
	<property name="res-mrtg" value="${res}/mrtg"/>
	<property name="classpath" value="${cwd}/${libs}/${lib-snmp}:${cwd}/${libs}/${lib-xmlrpc}"/>
	<property name="tarfile" value="jrobin-${version}.tar"/>
	<property name="tgzfile" value="jrobin-${version}.tar.gz"/>

	<!-- TARGETS -->
	<target name="init">
		<tstamp/>
	</target>

	<target name="clean" depends="init">
		<delete includeemptydirs="true">
			<fileset dir="${cwd}" >
				<include name="${classes}/**/*"/>
				<include name="${dist}/jrobin*.tar.gz"/>
				<include name="${javadoc}/**/*"/>
				<include name="${libs}/${lib-jrobin}" />
				<include name="${libs}/${lib-mrtg-client}" />
				<include name="${libs}/${lib-mrtg-server}" />
				<include name="${libs}/${lib-inspector}" />
				<include name="${libs}/${lib-convertor}" />
			</fileset>
		</delete>
	</target>

	<target name="compile" depends="init">
		<mkdir dir="${cwd}/${classes}"/>
		<javac
			srcdir="${cwd}/${src}" destdir="${cwd}/${classes}"
			classpath="${classpath}"
            compiler="modern" source="1.4"
		/>
	</target>

	<target name="core-lib" depends="compile">
		<delete file="${cwd}/${libs}/${lib-jrobin}" />
		<jar jarfile="${cwd}/${libs}/${lib-jrobin}" basedir="${cwd}/${classes}">
			<manifest>
				<attribute name="Main-Class" value="org.jrobin.core.RrdDb"/>
			</manifest>
			<include name="org/jrobin/core/**/*.class"/>
			<include name="org/jrobin/graph/**/*.class"/>
		</jar>
	</target>

	<target name="demo-lib" depends="core-lib">
		<delete file="${cwd}/${libs}/${lib-demo}" />
		<jar jarfile="${cwd}/${libs}/${lib-demo}" basedir="${cwd}/${classes}">
			<manifest>
				<attribute name="Main-Class" value="org.jrobin.demo.Demo"/>
				<attribute name="Class-Path" value="${lib-jrobin}"/>
			</manifest>
			<include name="org/jrobin/demo/**/*.class"/>
		</jar>
	</target>

	<target name="mrtg-server-lib" depends="core-lib">
		<delete file="${cwd}/${libs}/${lib-mrtg-server}" />
		<jar jarfile="${cwd}/${libs}/${lib-mrtg-server}" basedir="${cwd}/${classes}">
			<manifest>
				<attribute name="Main-Class" value="org.jrobin.mrtg.server.Server"/>
				<attribute name="Class-Path" value="${lib-xmlrpc} ${lib-snmp} ${lib-jrobin}"/>
			</manifest>
			<include name="org/jrobin/mrtg/*.class"/>
			<include name="org/jrobin/mrtg/server/*.class"/>
		</jar>
	</target>

	<target name="mrtg-client-lib" depends="mrtg-server-lib">
		<delete file="${cwd}/${libs}/${lib-mrtg-client}" />
		<jar jarfile="${cwd}/${libs}/${lib-mrtg-client}" basedir="${cwd}/${classes}">
			<include name="org/jrobin/mrtg/*.class"/>
			<include name="org/jrobin/mrtg/client/*.class"/>
		</jar>
		<jar jarfile="${cwd}/${libs}/${lib-mrtg-client}" basedir="${cwd}" update="true" >
			<include name="${res-mrtg}/**/*"/>
			<manifest>
				<attribute name="Main-Class" value="org.jrobin.mrtg.client.Client"/>
				<attribute name="Class-Path" value="${lib-xmlrpc}"/>
			</manifest>
		</jar>
	</target>

	<target name="inspector-lib" depends="core-lib">
		<delete file="${cwd}/${libs}/${lib-inspector}" />
		<jar jarfile="${cwd}/${libs}/${lib-inspector}" basedir="${cwd}/${classes}">
			<manifest>
				<attribute name="Main-Class" value="org.jrobin.inspector.RrdInspector"/>
				<attribute name="Class-Path" value="${lib-jrobin}"/>
			</manifest>
			<include name="org/jrobin/inspector/*.class"/>
		</jar>
	</target>

	<target name="convertor-lib" depends="core-lib">
		<delete file="${cwd}/${libs}/${lib-convertor}" />
		<jar jarfile="${cwd}/${libs}/${lib-convertor}" basedir="${cwd}/${classes}">
			<manifest>
				<attribute name="Main-Class" value="org.jrobin.convertor.Convertor"/>
				<attribute name="Class-Path" value="${lib-jrobin}"/>
			</manifest>
			<include name="org/jrobin/convertor/*.class"/>
		</jar>
	</target>

	<target name="all-libs" depends="core-lib,demo-lib,mrtg-server-lib,mrtg-client-lib,inspector-lib,convertor-lib"/>

	<target name="javadoc" depends="compile">
		<javadoc author="false" version="false"
			destdir="${cwd}/${javadoc}"
			packagenames="org.jrobin.core.*,org.jrobin.graph.*"
			excludepackagenames="org.jrobin.core.jrrd.*"
			source="1.4"
			sourcepath="${cwd}/${src}"
			classpath="${classpath}"
            access="protected"
		/>
	</target>

	<target name="dist" depends="all-libs,javadoc">
		<mkdir dir="${cwd}/${dist}"/>
		<delete file="${cwd}/${dist}/${tarfile}>"/>
		<delete file="${cwd}/${dist}/${tgzfile}>"/>
		<property name="prefix" value="jrobin-${version}"/>
		<tar destfile="${cwd}/${dist}/${tarfile}">
			<tarfileset dir="${cwd}/${doc}" prefix="${prefix}/${doc}">
    			<include name="**/*"/>
  			</tarfileset>
			<tarfileset dir="${cwd}/${libs}" prefix="${prefix}/${libs}">
    			<include name="*.jar"/>
  			</tarfileset>
			<tarfileset dir="${cwd}/${src}" prefix="${prefix}/${src}">
				<exclude name="**/dev/**/*"/>
				<exclude name="**/cmd/**/*"/>
    			<include name="**/*.java"/>
  			</tarfileset>
			<tarfileset dir="${cwd}/${res}" prefix="${prefix}/${res}">
    			<include name="**/*"/>
  			</tarfileset>
			<tarfileset dir="${cwd}/${ant}" prefix="${prefix}/${ant}">
    			<include name="*.xml"/>
  			</tarfileset>
		</tar>
		<gzip src="${cwd}/${dist}/${tarfile}" zipfile="${cwd}/${dist}/${tgzfile}"/>
		<delete file="${cwd}/${dist}/${tarfile}"/>
	</target>

</project>

