<?xml version="1.0"?>



<project name="GangliaIntegrator" default="all" basedir=".">

  <property environment="env"/>
  <property name="jacorb.home" value="${env.JACORB_HOME}"/>
  <property name="jacorb.libpath" value="${env.JACORB_HOME}/lib"/>
  <property name="src.dir" value="${basedir}/src"/>
  <property name="classes.dir" value="${basedir}/classes"/>
  <property name="doc.dir" value="${basedir}/doc"/>
  <property name="javadoc.dir" value="${doc.dir}/javadoc"/>
  <condition property="jacorb.idlcompiler" value="idl">
    <os family="unix" />
  </condition>
  <condition property="jacorb.idlcompiler" value="idl.bat">
    <os family="windows" />
  </condition>
  
  <condition property="runit.name" value="runit">
    <os family="unix" />
  </condition>
  <condition property="runit.name" value="runit.bat">
    <os family="windows" />
  </condition>
  
  <condition property="classpath.separator" value=":">
    <os family="unix" />
  </condition>
  <condition property="classpath.separator" value=";">
    <os family="windows" />
  </condition>


  <!-- =================================================================== -->
  <!-- Creates Directories                                                 -->
  <!-- =================================================================== -->

  <target name="prepare" >
    <mkdir dir="${classes.dir}"/>
  </target>

  <!-- =================================================================== -->
  <!-- Create runit helper script                                          -->
  <!-- =================================================================== -->

  <target name="makeRunit" depends="prepare">
    <echo file="${classes.dir}/${runit.name}"
          message="java -Djacorb.home=&quot;${jacorb.home}&quot;
-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB
-Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton
-classpath .${classpath.separator}&quot;${jacorb.libpath}/wrapper-3.1.0.jar&quot;${classpath.separator}&quot;${jacorb.libpath}/antlr-2.7.2.jar&quot;${classpath.separator}&quot;${jacorb.home}/lib/avalon-framework-4.1.5.jar&quot;${classpath.separator}&quot;${jacorb.home}/lib/backport-util-concurrent.jar&quot;${classpath.separator}&quot;${jacorb.home}/lib/idl.jar&quot;${classpath.separator}&quot;${jacorb.home}/lib/jacorb.jar&quot;${classpath.separator}&quot;${jacorb.home}/lib/logkit-1.2.jar&quot;${classpath.separator}&quot;${jacorb.home}/lib/picocontainer-1.2.jar&quot; GangliaIntegrator.GangliaIntegratorLauncher"/>
  </target>

  <!-- =================================================================== -->
  <!-- Compiles GangliaIntegrator.idl                                      -->
  <!-- =================================================================== -->

  <target name="giIdl">
    <exec dir="${src.dir}" executable="&quot;${jacorb.home}/bin/${jacorb.idlcompiler}&quot;">
      <arg line="../../../shared/idls/GangliaIntegrator.idl"/>
    </exec>
  </target>

  <!-- =================================================================== -->
  <!-- Compile IDL generated classes                                       -->
  <!-- =================================================================== -->
  <target name="all" depends="giIdl, makeRunit, compile">
  </target>

  <!-- =================================================================== -->
  <!-- Compile IDL generated classes                                       -->
  <!-- =================================================================== -->
  <target name="compile">
    <echo message="Sources: ${src.dir}"/>
    <echo message="Dest   : ${classes.dir}"/>
    <javac srcdir="${src.dir}"
            destdir="${classes.dir}"
            debug="on"
            deprecation="on"
            optimize="off"
            includes="**/*.java"
            classpath="${basedir}:${jacorb.home}/lib/jacorb.jar"/>
    <copy file="jacorb.properties" todir="${classes.dir}"/>
    <copy file="ClusterInformationCollector.properties" todir="${classes.dir}"/>
    <chmod file="${classes.dir}/runit" perm="755"/>
  </target>

  <!-- =================================================================== -->
  <!-- Cleanup                                                             -->
  <!-- =================================================================== -->

  <target name="clean" >
    <!-- Deletes all .class -->
    <delete dir="${classes.dir}"/>
    <!--Deletes IDL generated source files -->
    <delete includeEmptyDirs="true">
      <fileset dir="${src.dir}">
        <exclude name="GangliaIntegrator/**"/>
		<exclude name="GangliaIntegrator.idl" />
      </fileset>
    </delete>
    <delete dir="${doc.dir}"/>
  </target>

  <!-- =================================================================== -->
  <!-- Prepare to generate documentation                                   -->
  <!-- =================================================================== -->

  <target name="preparedoc" depends="giIdl">
    <mkdir dir="${doc.dir}"/>
  </target>

  <!-- =================================================================== -->
  <!-- Generates Javadoc                                                   -->
  <!-- =================================================================== -->

  <target name="javadoc" depends="preparedoc">
    <mkdir dir="${javadoc.dir}"/>
    <javadoc destdir="./doc/javadoc"
              classpath=".:types:interfaces:${jacorb.home}/lib/jacorb.jar">
      <fileset dir="${src.dir}"
                includes="**/*.java"/>
    </javadoc>
  </target>
</project>

