<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- $Id: build.xml,v 8.15 2008/02/20 06:30:52 nisinaka Exp $ -->

<project name="Jun4Java" default="Jun" basedir="..">

  <property name="Jun_VERSION" value="699" />
  <property name="StPL_VERSION" value="89" />

  <property name="src"      value="src" />
  <property name="lib"      value="lib" />
  <property name="classes"  value="lib/classes" />
  <property name="javadoc"  value="doc/JavaDoc" />

  <property name="jun.jar"  value="${lib}/jun${Jun_VERSION}.jar" />
  <property name="StPL.jar" value="${lib}/StPL${StPL_VERSION}.jar" />

  <!-- Please set the property 'jogl.home' to the path where you have installed the JOGL. -->
  <property name="jogl.jar" value="${jogl.home}/lib/jogl.jar" />

  <!-- Please set the property 'qt4j.home' to the path where you have installed the QuickTime for Java. -->
  <property name="qt4j.zip" value="${qt4j.home}/QTSystem/QTJava.zip" />

  <path id="extra_path">
    <fileset dir="lib">
      <include name="**/jai_core.jar" />
      <include name="**/jai_codec.jar" />
      <include name="**/mlibwrapper_jai.jar" />
      <include name="**/JimiProClasses.zip" />
    </fileset>
    <pathelement location="${jogl.jar}" />
    <pathelement location="${qt4j.zip}" />
  </path>


  <!--                                                -->
  <!-- Compile and create JAR file of the Jun library -->
  <!--                                                -->
  <target name="Jun" depends="init,properties,StPL">
    <available property="jogl.available" file="${jogl.jar}" />
    <available property="qt4j.available" file="${qt4j.zip}" />

    <available property="jai.available"
      classname="javax.media.jai.JAI"
      classpathref="extra_path" />

    <available property="jimi.available"
      classname="com.sun.jimi.core.Jimi"
      classpathref="extra_path" />

    <javac srcdir="${src}"
      destdir="${classes}"
      source="1.4"
      target="1.4"
      fork="yes"
      memoryMaximumSize="256m">

      <classpath>
        <pathelement location="${StPL.jar}" />
        <path refid="extra_path" />
      </classpath>
      <include name="jp/co/sra/**/*.java" />
      <exclude name="jp/co/sra/jun/**/JunJai*.java" unless="jai.available" />
      <exclude name="jp/co/sra/jun/**/JunJimi*.java" unless="jimi.available" />
      <exclude name="jp/co/sra/jun/opengl/support/JOGL*.java" unless="jogl.available" />
      <exclude name="jp/co/sra/qt4jun/JunQTJ*.java" unless="qt4j.available" />
      <exclude name="jp/co/sra/smalltalk/*.java" />
    </javac>

    <jar jarfile="${jun.jar}">
      <fileset dir="${src}">
        <include name="jp/co/sra/**/*.properties" />
        <include name="jp/co/sra/**/*.gif" />
        <include name="jp/co/sra/**/*.jpg" />
        <include name="jp/co/sra/**/*.png" />
        <include name="jp/co/sra/**/*.lst" />
        <include name="jp/co/sra/**/*.wrl" />
      </fileset>
      <fileset dir="${classes}">
        <include name="jp/co/sra/**/*.class" />
        <exclude name="jp/co/sra/jun/**/JunJai*.class" unless="jai.available" />
        <exclude name="jp/co/sra/jun/**/JunJimi*.class" unless="jimi.available" />
        <exclude name="jp/co/sra/jun/opengl/support/JOGL*.class" unless="jogl.available" />
        <exclude name="jp/co/sra/qt4jun/JunQTJ*.class" unless="qt4j.available" />
        <exclude name="jp/co/sra/smalltalk/**/*.class" />
      </fileset>
      <manifest>
        <attribute name="Build-By" value="Jun Project Team" />
        <attribute name="Main-Class" value="jp.co.sra.jun.system.support.JunLauncher" />
      </manifest>
    </jar>
  </target>


  <!--                                                 -->
  <!-- Compile and create JAR file of the StPL library -->
  <!--                                                 -->
  <target name="StPL" depends="init">
    <javac srcdir="${src}" destdir="${classes}" source="1.4" target="1.4">
      <include name="jp/co/sra/smalltalk/**/*.java" />
    </javac>

    <jar jarfile="${StPL.jar}" basedir="${classes}">
      <include name="jp/co/sra/smalltalk/**/*.class" />
      <manifest>
        <attribute name="Build-By" value="Jun Project Team" />
      </manifest>
    </jar>
  </target>


  <!--                         -->
  <!-- Execute the JunLauncher -->
  <!--                         -->
  <target name="test" depends="Jun">
    <java classname="jp.co.sra.jun.system.support.JunLauncher"
      fork="yes"
      jvm="${java.home}/bin/java"
      maxmemory="512m">
      <!-- <arg line="-view Awt -rendering IMAGE" /> -->
      <!-- <arg line="-view Metal -rendering IMAGE" /> -->
      <classpath>
        <pathelement location="${jun.jar}" />
        <pathelement location="${StPL.jar}" />
        <path refid="extra_path" />
      </classpath>
    </java>
  </target>


  <!--                                      -->
  <!-- Generate the API document by JavaDoc -->
  <!--                                      -->
  <target name="javadoc">
    <mkdir dir="${javadoc}" />
    <javadoc locale="en_US"
      packagenames="jp.co.sra.*"
      sourcepath="${src}"
      destdir="${javadoc}"
      author="true"
      version="true"
      private="true"
      maxmemory="134217728"
      windowTitle="Jun for Java (Jun${Jun_VERSION})">
      
      <doctitle><![CDATA[Jun for Java (Jun${Jun_VERSION})]]></doctitle>
      <bottom><![CDATA[<CENTER>Copyright (C) 1999-2008 SRA (Software Research Associates, Inc.)<BR>Copyright (C) 1999-2005 Information-technology Promotion Agency, Japan (IPA)<BR>Copyright (C) 2001-2008 SRA/KTL (SRA Key Technology Laboratory, Inc.)</CENTER>]]></bottom>
      <classpath>
        <path refid="extra_path" />
      </classpath>
    </javadoc>
  </target>


  <!--        -->
  <!-- Others -->
  <!--        -->
  <target name="init">
    <tstamp/>
    <mkdir dir="${classes}" />
  </target>

  <!-- Generate the property files in ASCII -->
  <target name="properties">
    <native2ascii
      src="${src}"
      encoding="Shift_JIS"
      includes="**/*.properties.Shift_JIS"
      dest="${src}"
      ext=""
      />
  </target>

  <!-- Deletes the classes files -->
  <target name="clean">
    <delete dir="${classes}/jp/co/sra" />
  </target>

  <!-- Deletes the all generated files -->
  <target name="distclean">
    <delete file="${jun.jar}" />
    <delete file="${StPL.jar}" />
    <delete dir="${classes}" />
    <delete dir="${javadoc}" />
  </target>

</project>
