<project default="buildme">

  <!-- Change the source.dir value to the name of your source directory -->
  <property name="source.dir"   value="."/>

  <!-- Change the output.dir value to the name of your output directory -->
  <property name="output.dir"   value="output"/>

  <!-- Change the error.dir value to the name of your error directory -->
  <property name="error.dir"   value="err"/>

  <!-- Change the list.dir value to the name of your list directory -->
  <property name="list.dir"   value="list"/>

  <!-- Change the compile.options value to your compiler options -->
  <property name="compile.options" 
	value="-ef -eo=${error.dir} -lf -lo=${list.dir}"/>

  <!-- Change the iscobol.dir value to the isCOBOL install directory -->
  <property name="iscobol.dir"   value="/opt/veryant/iscobol"/>

  <fileset id="cblfiles" dir="${source.dir}" includes="*.cbl">
    <depend targetdir="${output.dir}">
      <mapper>
        <globmapper from="*.cbl" to="*.class" casesensitive="no"/>
      </mapper>
    </depend>
  </fileset>
  <pathconvert property="cbllist" refid="cblfiles" pathsep=" "/>

  <condition property="cbllist.not.empty">
    <not>
      <equals arg1="${cbllist}" arg2=" " trim="true"/>
    </not>
  </condition>

  <target name="dirs">
    <mkdir dir="${output.dir}"/>
    <mkdir dir="${error.dir}"/>
    <mkdir dir="${list.dir}"/>
  </target>

  <target name="iscobol" if="cbllist.not.empty" >
    <java classname="com.iscobol.compiler.Pcc" output="build.out">
      <arg line="-jj -od=${output.dir} ${compile.options} ${cbllist}"/>
      <classpath>
        <pathelement location="${iscobol.dir}/lib/iscobol.jar"/>
        <pathelement location="${iscobol.dir}/lib/isxms.jar"/>
      </classpath>
    </java>
  </target>

  <target name="buildme" depends="dirs,iscobol">
    <javac srcdir="${output.dir}" destdir="${output.dir}" fork="true" memoryMaximumSize="128m">
      <classpath>
        <pathelement location="${iscobol.dir}/lib/iscobol.jar"/>
        <pathelement location="${iscobol.dir}/lib/isxms.jar"/>
      </classpath>
    </javac>
  </target>
</project>
