<?xml version="1.0" ?>
<project basedir="." default="all" name="OSX Plugin">
    <description>OSX JInput Plugin</description>
    <property name="src" location="src" />
    <property name="build" location="classes"/>
    <property name="bin" location="bin" />
    <property name="plugins" location="plugins" />
    
    <target name="init">
		<mkdir dir="${build}"/>
		<mkdir dir="${bin}"/>
		<condition property="macosx">
			<and>
				<os family="mac" />
				<os family="unix" />
			</and>
		</condition>
    </target>

    <target depends="init" name="compile">
        <javac debug="true" deprecation="true" destdir="${build}" source="1.4" srcdir="src/java">
            <classpath>
                <pathelement location="../../coreAPI/bin/jinput-core.jar"/>
                <pathelement location="../../lib/jutils.jar"/>
            </classpath>
        </javac>
    </target>

	<target depends="init,compile" name="jar">
        <jar jarfile="${bin}/HIDWrapper.jar" compress="true" basedir="${build}">
            <include name="**/*.class"/>
        </jar> 
    </target>

    <target depends="compileNativeJinputLib,jar" description="Build everything." name="all">
    </target>

    <target name="javadoc" depends="init" description="Javadoc for OS X plugin for JInput.">
        <mkdir dir="apidocs"/>
        <javadoc packagenames="net.java.games.input.*" 
                 destdir="apidocs"
                 additionalparam="-source 1.4"
                 link="../../../coreAPI/apidocs">
            <sourcepath>
                <pathelement location="src/java"/>
            </sourcepath>
             <classpath>
                <pathelement location="../../coreAPI/bin/jinput-core.jar"/>
                <pathelement location="../../lib/jutils.jar"/>
            </classpath>
        </javadoc>
    </target>

    <target description="Clean all build products." name="clean">
		<delete dir="classes" failonerror="no"/>
		<delete dir="bin" failonerror="no"/>
		<delete dir="apidocs" failonerror="no"/>
		<ant inheritAll="false" antfile="src/native/build.xml" target="clean"/>
    </target>

    <target depends="init,compile" name="createJNIHeaders">
        <javah destdir="src/native">
            <classpath>
                <pathelement path="${build}"/>
                <pathelement location="../../coreAPI/classes"/>
            </classpath>
			<class name="net.java.games.input.OSXHIDDeviceIterator"/>
			<class name="net.java.games.input.OSXHIDDevice"/>
			<class name="net.java.games.input.OSXHIDQueue"/>
        </javah>
    </target>

	
    <target name="compileNativeJinputLib" depends="init,createJNIHeaders" if="macosx">
        <ant dir="src/native" target="compileNativeJinputLib"/>
		<copy todir="${bin}">
			<fileset dir="src/native" includes="*.jnilib"/>
		</copy>
    </target>
</project>
