<?xml version="1.0"?>

<!--
/*
 * $RCSfile: build.xml,v $
 *
 * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
 *
 * Use is subject to license terms.
 *
 * $Revision: 1.12 $
 * $Date: 2008/02/28 20:18:49 $
 * $State: Exp $
 */
 -->

<project name="vecmath-1.5.2" default="jar-debug" basedir=".">

  <!-- *************************************** -->
  <!-- *** Begin build-specific properties *** -->
  <!-- *************************************** -->

  <!--
  * The following properties specify the current version of 3D.
  * The "version_base" property specifies the dot-dot base version
  * number of 3D; it must contain exactly three integer numbers
  * separated by "periods ("."). It should match the version base
  * defined in the j3d-core build.xml file.
  -->
  <property name="version_base"       value="1.5.2"/>

  <!-- ************************************* -->
  <!-- *** End build-specific properties *** -->
  <!-- ************************************* -->


  <!-- Set global properties for this build -->
  <property name="src"     location="src"/>
  <property name="build"   location="build"/>
  <property name="dist"    location="dist"/>
  <property name="version" value="1_5_2"/>
  <property name="docname" value="vecmath-${version}-doc"/>
  
  <property name="build.spec.title" value="3D Vector Math Package"/>
  <property name="build.impl.title" value="3D Vector Math Package"/>
  <property name="build.spec.vendor" value=""/>
  <property name="build.impl.vendor" value=""/>
  <property name="build.impl.vendor.id" value=""/>

  <target name="echo">	
    <echo message="user.name = ${user.name}"/>
    <echo message="user.home = ${user.home}"/>
    <echo message="java.home = ${java.home}"/>
    <echo message="ant.home  = ${ant.home}"/>
    <echo message="O/S arch is ${os.arch}"/>
    <echo message="O/S name is ${os.name}"/>
  </target>


  <target name="init">
    <!-- Create the time stamp -->
    <tstamp>
	<format property="buildtime"
		pattern="yyyy-MM-dd'T'HH:mm:ss"/>
    </tstamp>

    <!-- Create the base build directory -->
    <mkdir dir="${build}"/>
  </target>

  <target name="compile-debug" depends="init">

    <!-- Create the debug build directory structure used for compile -->
    <mkdir dir="${build}/debug/classes"/>
    <mkdir dir="${build}/debug/gen"/>

    <!-- Compile the java code from ${src} into ${build}/debug/classes -->
    <javac srcdir="${src}"
           destdir="${build}/debug/classes"	   
	   source="1.5"
	   target="1.5"
	   debug="true"
           deprecation="on"
    />

    <!-- Copy the I18N property files while retaining package location -->
    <copy todir="${build}/debug/classes">
        <fileset dir="${src}" includes="**/*.properties"/>
    </copy>
  </target>

  <target name="compile-opt" depends="init">

    <!-- Create the opt build directory structure used for compile -->
    <mkdir dir="${build}/opt/classes"/>
    <mkdir dir="${build}/opt/gen"/>

    <!-- Compile the java code from ${src} into ${build}/opt/classes -->
    <javac srcdir="${src}"
           destdir="${build}/opt/classes"	   
	   source="1.5"
	   target="1.5"
           debug="true"
           debuglevel="lines,source"
           deprecation="on"
    />

    <!-- Copy the I18N property files while retaining package location -->
    <copy todir="${build}/opt/classes">
        <fileset dir="${src}" includes="**/*.properties"/>
    </copy>
  </target>

  <target name="compile" depends="compile-opt,compile-debug"/>

  <target name="jar-debug" depends="compile-debug">
    <!-- Create the jar directory -->
    <mkdir dir="${build}/debug/lib/ext"/>

    <copy todir="${build}/debug/gen"
          overwrite="true">
        <fileset dir="${src}" includes="VECMATH.MF"/>
        <filterset>
            <filter token="VERSION_BASE" value="${version_base}"/>
            <filter token="SPEC_TITLE" value="${build.spec.title}"/>
            <filter token="SPEC_VENDOR" value="${build.spec.vendor}"/>
            <filter token="IMPL_TITLE" value="${build.impl.title}"/>
            <filter token="IMPL_VENDOR" value="${build.impl.vendor}"/>
            <filter token="IMPL_VENDOR_ID" value="${build.impl.vendor.id}"/>
        </filterset>
    </copy>

    <!-- Copy the copyright file and all license files -->
    <copy todir="${build}/debug/classes/javax">
      <fileset dir="." includes="COPYRIGHT.txt"/>
      <fileset dir="." includes="*LICENSE*.txt"/>
    </copy>

    <!-- Put everything in ${build}/debug/classes into the vecmath.jar file -->
    <jar jarfile="${build}/debug/lib/ext/vecmath.jar"
         manifest="${build}/debug/gen/VECMATH.MF" compress="false" update="yes">
	<fileset dir="${build}/debug/classes"/>
    </jar>
  </target>

  <target name="jar-opt" depends="compile-opt">
    <!-- Create the jar directory -->
    <mkdir dir="${build}/opt/lib/ext"/>

    <copy todir="${build}/opt/gen"
          overwrite="true">
        <fileset dir="${src}" includes="VECMATH.MF"/>
        <filterset>
            <filter token="VERSION_BASE" value="${version_base}"/>
            <filter token="SPEC_TITLE" value="${build.spec.title}"/>
            <filter token="SPEC_VENDOR" value="${build.spec.vendor}"/>
            <filter token="IMPL_TITLE" value="${build.impl.title}"/>
            <filter token="IMPL_VENDOR" value="${build.impl.vendor}"/>
            <filter token="IMPL_VENDOR_ID" value="${build.impl.vendor.id}"/>
        </filterset>
    </copy>

    <!-- Copy the copyright file and all license files -->
    <copy todir="${build}/opt/classes/javax">
      <fileset dir="." includes="COPYRIGHT.txt"/>
      <fileset dir="." includes="*LICENSE*.txt"/>
    </copy>

    <!-- Put everything in ${build}/classes/opt into the vecmath.jar file -->
    <jar jarfile="${build}/opt/lib/ext/vecmath.jar"
         manifest="${build}/opt/gen/VECMATH.MF" compress="false" update="yes">
	<fileset dir="${build}/opt/classes"/>
    </jar>
  </target>

  <target name="jar" depends="jar-opt,jar-debug"/>

  <target name="docs" depends="init">
    <!-- Create the build directory structure used by docs -->
    <mkdir dir="${build}/javadocs"/>

    <!-- Compile the javadoc from ${src} into ${build}/javadocs -->
    <javadoc sourcepath="${src}"
	     packagenames="javax.vecmath.*"
	     maxmemory="128m"
             destdir="${build}/javadocs"
             windowtitle="Vecmath ${version}">
    </javadoc>

    <!-- Copy the copyright file -->
    <copy todir="${build}/javadocs">
      <fileset dir="." includes="COPYRIGHT.txt"/>
    </copy>
  </target>

  <target name="dist" depends="jar-opt,docs">
    <!-- Create the distribution directory -->
    <mkdir dir="${dist}/lib/ext"/>

    <!-- Copy the jar file -->
    <copy file="${build}/opt/lib/ext/vecmath.jar" todir="${dist}/lib/ext"/>

    <!-- Create the docs distribution directory -->
    <mkdir dir="${dist}/javadocs"/>

    <!-- Put everything in ${build}/javadocs into the zip docname file -->
    <zip zipfile="${dist}/javadocs/${docname}.zip" basedir="${build}/javadocs"/>
  </target>

  <target name="all" depends="jar-debug,dist"/>

  <target name="clean-dist">
    <!-- Delete the ${dist} directory tree  -->
    <delete dir="${dist}"/>
  </target>

  <target name="clean">
    <!-- Delete the ${build}, and ${dist} directory trees  -->
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>

  <description>
The following ant targets are available ("jar-debug" is the default):

      all           - execute targets jar-debug and dist

      clean         - removes WS/build/ and WS/dist/

      clean-dist    - removes WS/dist

      compile       - execute targets compile-debug and compile-opt
 
      compile-debug - builds all classes in WS/src into class files
                      under WS/build/classes/debug

      compile-opt   - builds all classes in WS/src/ into class files 
                      under WS/build/classes/opt

      dist          - creates WS/dist/lib/opt/ext/vecmath.jar
                      from class files under WS/build/classes/opt and
                      creates WS/dist/doc/vecmath-${version}-doc.zip from
		      javadoc under WS/build/javadocs

      docs          - builds all classes in WS/src into javadoc under 
                      WS/build/javadocs

      echo          - echo some useful information, such as user.home,
                      ant.home and java.home

      jar           - execute targets jar-debug and jar-opt

      jar-debug     - creates WS/build/lib/debug/ext/vecmath.jar
                      from class files under WS/build/classes/debug

      jar-opt       - creates WS/build/lib/opt/ext/vecmath.jar
                      from class files under WS/build/classes/opt
  </description>
</project>
