<?xml version="1.0"?>
<!DOCTYPE project PUBLIC "-//ANT//DTD project//EN" "tools/ant.dtd">
<!-- ============================================================= -->
<!-- Generic ANT build file                                        -->
<!--   this file is used for Samurai Graph                         -->
<!--                                                               -->
<!--                                                               -->
<!-- Author: Yoshihiro OKUMURA                                     -->
<!-- $Id: build.xml,v 1.26 2005/02/03 05:56:47 kuromaru Exp $      -->
<!--                                                               -->
<!-- ============================================================= -->

<project name="samurai-graph" default="jar" basedir=".">

  <description>
      SAMURAI GRAPH Project
  </description>

  <!-- project name -->
  <property name="project" value="samurai-graph"/>
  <!-- version number -->
  <property name="version" value="0.4.1"/>

  <!-- directory definition -->
  <property name="SG.srcdir"          value="src"/>
  <property name="SG.dstdir"          value="dist"/>
  <property name="SG.dst.libdir"      value="${SG.dstdir}/lib"/>
  <property name="SG.dst.docdir"      value="${SG.dstdir}/doc"/>
  <property name="SG.dst.examplesdir" value="${SG.dstdir}/examples"/>
  <property name="SG.mfdir"           value="${SG.srcdir}/META-INF"/>
  <property name="SG.resdir"          value="${SG.srcdir}/resources"/>
  <property name="SG.changelogdir"    value="${SG.srcdir}/changelog"/>
  <property name="SG.classes"         value="${SG.srcdir}/classes"/>
  <property name="SG.src.distdir"     value="srcdist"/>
  <property name="SG.javadoc.dstdir"  value="javadoc"/>
  <property name="SG.examplesdir"     value="examples/data"/>
  <property name="SG.src.basedir"     value="${SG.srcdir}/jp/riken/brain/ni/samuraigraph"/>

  <!-- helper properties -->
  <property name="HP.src.basedir"               value="helper"/>
  <property name="HP.classes"                   value="${HP.src.basedir}/classes"/>
  <property name="HP.mfdir"                     value="${HP.src.basedir}/META-INF"/>

  <!-- server jar properties -->
  <property name="SG.server.mf"      value="${SG.mfdir}/SERVER.MF"/>
  <property name="SG.server.basedir" value="${SG.classes}/server"/>
  <property name="SG.server.jar"
    value="${SG.dstdir}/${project}.jar"/>
  <!-- 
  <property name="SG.server.jar"
    value="${SG.dstdir}/${project}-${version}.jar"/>
  -->

  <!-- client jar properties -->
  <property name="SG.client.mf"      value="${SG.mfdir}/CLIENT.MF" />
  <property name="SG.client.basedir" value="${SG.classes}/client"/>
  <property name="SG.client.jar"
    value="${SG.dstdir}/${project}-client.jar"/>
  <!-- 
  <property name="SG.client.jar"
    value="${SG.dstdir}/${project}-${version}-client.jar"/>
  -->

  <!-- helper jar properties -->
  <property name="HP.src.libdir"                value="${HP.src.basedir}/lib"/>
  <property name="HP.upgrade-helper.mf"         value="${HP.mfdir}/UPGRADE.MF" />
  <property name="HP.upgrade-helper.basedir"    value="${HP.classes}"/>
  <property name="HP.upgrade-helper.jar"        value="${HP.src.libdir}/upgrade-helper.jar"/>

  <!-- vectorgraphics -->
  <property name="VG.src.basedir" value="contrib/vectorgraphics"/>
  <property name="VG.src.libdir"  value="${VG.src.basedir}/lib"/>
  <property name="VG.src.docdir"  
    value="${VG.src.basedir}/web/freehep/vectorgraphics/"/>
  <property name="VG.dst.libdir" value="${SG.dst.libdir}/vectorgraphics"/>
  <property name="VG.dst.docdir" value="${SG.dst.docdir}/vectorgraphics"/>

  <!-- classpath -->
  <path id="VG.classpath">
    <pathelement path="${classpath}"/>
    <fileset dir="${VG.src.libdir}">
      <include name="freehep-*.jar"/>
    </fileset>
  </path>

  <!-- all -->
  <target name="all" depends="jar,javadoc"/>

  <!-- prepare -->
  <target name="prepare">
    <!-- clean up distribution direction -->
    <delete dir="${SG.dstdir}"/>
    <!-- distribution image -->
    <mkdir dir="${SG.dstdir}"/>
    <mkdir dir="${SG.dst.libdir}"/>
    <mkdir dir="${SG.dst.docdir}"/>
    <mkdir dir="${SG.dst.examplesdir}"/>
    <mkdir dir="${VG.dst.libdir}"/>
    <mkdir dir="${VG.dst.docdir}"/>

    <!-- copy samurai-graph static contents -->
    <copy file="COPYING.txt" todir="${SG.dstdir}"/>
    <copy file="LICENSE.txt" todir="${SG.dstdir}"/>
    <copy todir="${SG.dst.examplesdir}">
      <fileset dir="${SG.examplesdir}">
        <include name="**/*.txt"/>
        <include name="**/*.sgp"/>
      </fileset>
    </copy>

    <!-- copy vectorgraphics libraries -->
    <copy todir="${VG.dst.libdir}">
      <fileset dir="${VG.src.libdir}">
        <include name="**/freehep-*.jar"/>
      </fileset>
    </copy>
    <copy 
      file="${VG.src.docdir}/ReleaseNotes-1.2.2.xhtml"
      tofile="${VG.dst.docdir}/ReleaseNotes-1.2.2.html"
    />
    <copy file="${VG.src.basedir}/LGPL.txt" todir="${VG.dst.docdir}"/>
    <copy file="${VG.src.basedir}/LICENSE.txt" todir="${VG.dst.docdir}"/>
    <copy file="${VG.src.basedir}/SAMURAIGRAPH-ChangeLog.txt" todir="${VG.dst.docdir}"/>

    <!-- for jar -->
    <mkdir dir="${SG.classes}"/>
    <mkdir dir="${SG.server.basedir}"/>
    <mkdir dir="${SG.client.basedir}"/>
    <mkdir dir="${SG.server.basedir}/resources"/>
    <copy todir="${SG.server.basedir}/resources">
      <fileset dir="${SG.resdir}">
        <include name="**/*.gif"/>
        <include name="**/*.png"/>
      </fileset>
    </copy>
    <copy todir="${SG.server.basedir}/resources">
      <fileset dir="${SG.changelogdir}">
        <include name="**/*.xml"/>
        <include name="**/*.dtd"/>
      </fileset>
    </copy>

    <mkdir dir="${HP.classes}"/>
    <mkdir dir="${HP.upgrade-helper.basedir}"/>
    <mkdir dir="${HP.src.libdir}"/>

  </target>

  <!-- compile -->
  <target name="compile" depends="prepare">
    <javac
       srcdir="${SG.src.basedir}/base"
       destdir="${SG.server.basedir}"
       encoding="SJIS"
       classpathref="VG.classpath"
    />
    <javac
       srcdir="${SG.src.basedir}/data"
       destdir="${SG.server.basedir}"
       encoding="SJIS"
       classpathref="VG.classpath"
    />
    <javac
       srcdir="${SG.src.basedir}/figure"
       destdir="${SG.server.basedir}"
       encoding="SJIS"
       classpathref="VG.classpath"
    />
    <javac
       srcdir="${SG.src.basedir}/figure/java2d"
       destdir="${SG.server.basedir}"
       encoding="SJIS"
       classpathref="VG.classpath"
    />
    <javac
       srcdir="${SG.src.basedir}/application"
       destdir="${SG.server.basedir}"
       encoding="SJIS"
       classpathref="VG.classpath"
    />
    <!-- compile sources of helper applications -->
    <javac
       srcdir="${HP.src.basedir}/jp/riken/brain/ni/helper"
       destdir="${HP.upgrade-helper.basedir}"
       encoding="SJIS"
    />
  </target>

  <!-- jar file creation -->
  <target name="jar" depends="compile">
    <jar
      jarfile="${SG.server.jar}"
      basedir="${SG.server.basedir}"
      manifest="${SG.server.mf}"
    />
    <!-- <jar -->
    <!--      jarfile="${SG.client.jar}" -->
    <!--      basedir="${SG.client.basedir}" -->
    <!--      manifest="${SG.client.mf}" -->
    <!-- /> -->
    <jar
     jarfile="${HP.upgrade-helper.jar}"
     basedir="${HP.classes}"
     manifest="${HP.upgrade-helper.mf}"
    />
  </target>

  <!-- JavaDoc creation -->
  <target name="javadoc" depends="prepare">
    <mkdir dir="${SG.javadoc.dstdir}"/>
    <javadoc 
       encoding="SJIS"
       docencoding="iso-2022-jp"
       locale="ja"
       destdir="${SG.javadoc.dstdir}">
       <fileset dir="${SG.src.basedir}/base"/>
       <fileset dir="${SG.src.basedir}/data"/>
       <fileset dir="${SG.src.basedir}/figure"/>
       <fileset dir="${SG.src.basedir}/figure/java2d"/>
       <fileset dir="${SG.src.basedir}/application"/>
    </javadoc>
  </target>

  <!-- JavaDoc creation -->
  <target name="srcdst">
    <mkdir dir="${SG.src.dstdir}"/>
    <copy file="COPYING.txt" todir="${SG.src.dstdir}"/>
    <copy file="LICENSE.txt" todir="${SG.src.dstdir}"/>
    <copy todir="${SG.src.dstdir}/examples">
      <fileset dir="${SG.examplesdir}" excludes="**/CVS*"/>
    </copy>
    <copy todir="${SG.src.dstdir}/examples/data">
      <fileset dir="${SG.examplesdir}" excludes="**/CVS*"/>
    </copy>
  </target>

  <!-- clean -->
  <target name="clean">
    <delete dir="${SG.dstdir}"/>
    <delete dir="${SG.classes}"/>
    <delete dir="${SG.javadoc.dstdir}"/>
    <delete dir="${HP.classes}"/>
    <delete dir="${HP.src.libdir}"/>
  </target>

</project>
