<?xml version="1.0" ?>

<!--
ANT build.xml file for PortInspector

 -> ant jar to build a jarfile (PortInspector.jar)
 -> ant native to build a native, dynamically linked executable (airport-portinspector)
 -> ant clean or ant distclean to clean up after the builds

Copyright (C) 2006 Julien BLACHE <jblache@debian.org>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License version 2 as
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
-->

<project name="PortInspector" default="post" basedir=".">

  <property name="mainclassname" value="airportinspector.PortInspector"/>
  <property name="builddir" value="build" />
  <property name="executable" value="airport2-portinspector" />
  <property name="jarname" value="PortInspector.jar" />

  <target name="common-init">
  </target>

  <target name="jar-init" depends="common-init">
    <mkdir dir="${builddir}" />
  </target>

  <target name="native-init" depends="common-init">
  </target>

  <target name="jar-compile" depends="jar-init">
    <javac srcdir="." destdir="${builddir}" debug="off" optimize="on" nowarn="on" />

  </target>

  <target name="jar" depends="jar-compile">
    <jar jarfile="${jarname}" basedir="${builddir}" includes="**">

      <manifest>
	<attribute name="Main-Class" value="${mainclassname}" />
      </manifest>
    </jar>
  </target>

  <target name="native-compile" depends="native-init">
    <apply executable="gcj" parallel="false" relative="true" failonerror="true">
      <arg value="-fjni" />
      <arg value="-g0" />
      <arg value="-c" />
      <arg value="-o" />
      <targetfile />
      <srcfile />
      <fileset dir="." includes="**/*.java" />
      <mapper type="glob" from="*.java" to="*.o" />
    </apply>
  </target>

  <target name="native" depends="native-compile, objects-up-to-date" unless="objects_up_to_date">
    <dependset>
      <srcfileset dir="." includes="**/*.o" />
      <targetfilelist dir="." files="${executable}" />
    </dependset>    

    <apply executable="gcj" dest="." parallel="true" skipemptyfilesets="true">
      <arg line="--main=${mainclassname}" />
      <arg value="-o" />
      <targetfile />
      <srcfile />
      <fileset dir="." includes="**/*.o" />
      <mapper type="merge" to="${executable}" />
    </apply>

    <apply executable="strip">
      <fileset dir="." includes="${executable}" />
    </apply>
  </target>

  <target name="objects-up-to-date">
    <uptodate property="objects_up_to_date" targetfile="${executable}">
      <srcfiles dir= "." includes="**/*.o" />
    </uptodate>
  </target>

  <target name="clean">
    <delete quiet="true" dir="${builddir}" />
    <delete quiet="true" file="${jarname}" />
    <delete quiet="true" file="${executable}" />
    <delete>
      <fileset dir="." includes="**/*.o" />
    </delete>
  </target>

  <target name="distclean" depends="clean">
    <delete>
      <fileset dir="." includes="**/*~" defaultexcludes="no" />
    </delete>
  </target>

</project>
