<?xml version="1.0" encoding="UTF-8"?>
<!--
   - Ant build for NEWT.  This build has been tested with ANT 1.7.0.  The
   - optional.jar that contains the optional ANT tasks must be in the ANT
   - classpath (typically the ant/lib directory).
   -
   - A clean download of NEWT is required for this build.
   -
   - This build has no dependence on environment variables; the needed
   - ones (e.g. java.home, ANT_HOME) are all set by the Ant wrapper shell
   - script, by the virtual machine, or elsewhere. However, on all platforms,
   - the C compiler and linker should be in the path. All other paths that
   - need to be set are in host.properties.
   -
   - NOTE:  because the GlueGen config files have their own relative paths
   -        which cannot be overridden by GlueGen, GlueGen MUST be run from
   -        the "make" directory. This also means that this build.xml MUST
   -        be run from the "make" directory.
   -
   - Public targets:
   -   all: (default; autodetects OS and chooses C compiler from newt.properties)
   -   clean:        clean all built
   -   javadoc:      create the standard developer Javadoc (recommended)
   -                 (Note: should build all first - may be dependence in the future)
   -   javadoc.spec: create the standard developer Javadoc but exclude com.jogamp.* classes
   -   javadoc.dev:  create the internal developer Javadoc.  This includes the
   -                       Java and C file generators. Note that it is only supported
   -                       to create the Javadoc for the platform on which you are
   -                       currently running.
   -
   - Note: on Windows the "win32.c.compiler" property in newt.properties
   - is required to select the appropriate C compiler. See the example
   - newt.properties in this directory for valid values. On Mac OS X
   - universal binaries may also be built by setting the "macosxfat"
   - property in newt.properties; again see the example file in this
   - directory.
   -
   - Thanks to Rob Grzywinski and Artur Biesiadowski for the bulk of the
   - ANT build, including the GlueGen and StaticGLInfo tasks, the building of
   - the Java generated sources, the first and second phase Java compiles, and
   - the building of the jar file. Thanks to Alex Radeski for the bulk of the
   - port to the ant-contrib CPPTask framework. Thanks to Athomas Goldberg for
   - the original OS detection code.
   -
   - Some environment defs affecting compilation

   - Some environment defs affecting native compilation
       setup.noNativeDesktop
       setup.addNativeKD
       setup.addNativeIntelGDL
       setup.addNativeBroadcom  ( always true if 'isLinux' )

   - Internal settings, may not be necessary to set them manually,
     since all JAR archives are orthogonal.
       setup.noAWT
       setup.noOpenGL

   -->
<project name="NEWT" basedir="." default="all">

    <import file="build-common.xml"/>

    <!-- needed for outofdate task -->
    <taskdef resource="net/sf/antcontrib/antlib.xml">
      <classpath> <pathelement location="${ant-contrib.jar}"/> </classpath>
    </taskdef>

    <!-- ================================================================== -->
    <!--
       - Base initialization and detection of operating system.
      -->
    <target name="base.init" depends="common.init">

        <condition property="setup.addNativeBroadcom">
           <isset property="isLinux"/>
        </condition>

        <condition property="setup.nonatives">
            <and>
                <isfalse value="${isWindows}" />
                <isfalse value="${isOSX}" />
                <isfalse value="${isIOS}" />
                <isfalse value="${isX11}" />
                <isfalse value="${isAndroid}" />
                <isfalse value="${setup.addNativeKD}" />
                <isfalse value="${setup.addNativeIntelGDL}" />
                <isfalse value="${setup.addNativeBroadcom}" />
                <isfalse value="${setup.addNativeDRMGBM}" />
            </and>
        </condition>

        <echo message="setup.noOpenGL: ${setup.noOpenGL}" />
        <echo message="isWindows: ${isWindows}" />
        <echo message="isOSX: ${isOSX}" />
        <echo message="isIOS: ${isIOS}" />
        <echo message="isX11: ${isX11}" />
        <echo message="isAndroid: ${isAndroid}" />
        <echo message="setup.addNativeKD: ${setup.addNativeKD}" />
        <echo message="setup.addNativeIntelGDL: ${setup.addNativeIntelGDL}" />
        <echo message="setup.addNativeBroadcom: ${setup.addNativeBroadcom}" />
        <echo message="setup.nonatives: ${setup.nonatives}" />

        <!-- partitioning -->

        <property name="java.part.core"
                  value="com/jogamp/newt/* com/jogamp/newt/event/* com/jogamp/newt/util/* com/jogamp/newt/util/applet/* jogamp/newt/* jogamp/newt/event/* jogamp/newt/driver/*"/>

        <property name="java.part.core.assets"
                  value="jogamp/newt/assets/**"/>

        <property name="java.part.opengl"
                  value="com/jogamp/newt/opengl/** jogamp/newt/driver/opengl/**"/>

        <property name="java.part.driver.awt"
                  value="jogamp/newt/driver/awt/**"/>

        <property name="java.part.awt"
                  value="com/jogamp/newt/awt/** com/jogamp/newt/event/awt/** jogamp/newt/awt/** ${java.part.driver.awt}"/>

        <property name="java.part.swt"
                  value="com/jogamp/newt/swt/** jogamp/newt/swt/**"/>

        <property name="java.part.javafx"
                  value="com/jogamp/newt/javafx/** jogamp/newt/javafx/**"/>

        <property name="java.part.applet3"
                  value="com/jogamp/newt/util/applet3/**"/>

        <property name="java.part.driver.linux"
                  value="jogamp/newt/driver/linux/**"/>

        <property name="java.part.driver.x11"
                  value="jogamp/newt/driver/x11/**"/>

        <property name="java.part.driver.windows"
                  value="jogamp/newt/driver/windows/**"/>

        <property name="java.part.driver.macosx"
                  value="jogamp/newt/driver/macosx/**"/>

        <property name="java.part.driver.ios"
                  value="jogamp/newt/driver/ios/**"/>

        <property name="java.part.driver.kd"
                  value="jogamp/newt/driver/kd/**"/>

        <property name="java.part.driver.intelgdl"
                  value="jogamp/newt/driver/intel/gdl/**"/>

        <property name="java.part.driver.bcm.old"
                  value="jogamp/newt/driver/bcm/egl/**"/>

        <property name="java.part.driver.bcm.vc"
                  value="jogamp/newt/driver/bcm/vc/**"/>

        <property name="java.part.driver.egl.gbm"
                  value="jogamp/newt/driver/egl/gbm/**"/>

        <property name="java.part.driver.android"
                  value="jogamp/newt/driver/android/**"/>

        <property name="java.part.nonjava"
                  value="${java.part.core.assets}"/>

        <!-- condition excludes -->

        <condition property="java.excludes.awt"
                   value="${java.part.awt}">
           <isset property="setup.noAWT"/>
        </condition>

        <condition property="java.excludes.swt"
                   value="${java.part.swt}">
           <isset property="setup.noSWT"/>
        </condition>

        <condition property="java.excludes.javafx"
                   value="${java.part.javafx}">
           <isset property="setup.noJFX"/>
        </condition>

        <condition property="java.excludes.applet3"
                   value="${java.part.applet3}">
           <not>
               <isset property="plugin3-jars.available"/>
           </not>
        </condition>

        <condition property="java.excludes.opengl" value="${java.part.opengl}">
           <isset property="setup.noOpenGL"/>
        </condition>

        <property name="java.excludes.all" value="${java.excludes.awt}, ${java.excludes.swt}, ${java.excludes.javafx}, ${java.excludes.applet3}, ${java.excludes.opengl}" />
        <echo message="java.excludes.all: ${java.excludes.all}" />

    </target>

    <!-- ================================================================== -->
    <!--
       - Declare all paths and user defined variables.
      -->
    <target name="declare.common" description="Declare properties" depends="base.init">
        <property name="rootrel.src" value="src/newt" />
        <property name="rootrel.src.java" value="${rootrel.src}/classes" />
        <property name="rootrel.src.c" value="${rootrel.src}/native" />

        <!-- The source directories. -->
        <property name="src.java" value="${project.root}/${rootrel.src.java}" />
        <property name="src.c"    value="${project.root}/${rootrel.src.c}" />

        <!-- The generated source directories. -->
        <property name="src.generated" value="${build.newt}/gensrc" />
        <property name="src.generated.c" value="${src.generated}/native/newt" />

        <!-- The compiler output directories. -->
        <property name="classes" value="${build.newt}/classes" />

        <!-- The javadoc dirs. -->
        <property name="javadoc" value="${project.root}/javadoc_newt_public" />
        <property name="javadoc.spec" value="${project.root}/javadoc_newt_spec" />
        <property name="javadoc.dev" value="${project.root}/javadoc_newt_dev" />
        <property name="javadoc.windowtitle" value="NEWT API -- ${jogamp.version.base} Specification" />
        <property name="javadoc.overview" value="spec-overview.html" />
        <property name="javadoc.spec.packagenames" value="com.jogamp.newt, com.jogamp.newt.event, com.jogamp.newt.opengl, com.jogamp.newt.util" />

        <property name="javadoc.packagenames" value="${javadoc.spec.packagenames}" />

        <property name="javadoc.dev.packagenames" value="${javadoc.packagenames},com.jogamp.newt.*" />
    <property name="javadoc.bottom" value="Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to &lt;a href=&quot;http://jcp.org/en/jsr/detail?id=231&quot;&gt;license terms&lt;/a&gt;." />
    </target>

    <!-- ================================================================== -->
    <!--
       - Initialize all parameters required for the build and create any
       - required directories.
      -->
    <target name="init" depends="declare.common">
        <mkdir dir="${src.generated.c}" />
        <mkdir dir="${src.generated.c}/Android" />
        <mkdir dir="${src.generated.c}/X11" />
        <mkdir dir="${src.generated.c}/MacOSX" />
        <mkdir dir="${src.generated.c}/iOS" />
        <mkdir dir="${src.generated.c}/Windows" />
        <mkdir dir="${src.generated.c}/KD" />
        <mkdir dir="${src.generated.c}/IntelGDL" />
        <mkdir dir="${src.generated.c}/bcm/egl" />
        <mkdir dir="${src.generated.c}/bcm/vc/iv" />
        <mkdir dir="${src.generated.c}/egl/gbm" />
        <mkdir dir="${classes}" />
        <mkdir dir="${obj.newt}" />
    </target>

    <!-- ================================================================== -->
    <!--
       - Compile the original and generated source.
      -->
    <target name="java.compile.javase">

        <!-- create KD native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               nativeheaderdir="${src.generated.c}/KD"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
            <include name="jogamp/newt/driver/kd/WindowDriver.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <!-- create Intel GDL native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               nativeheaderdir="${src.generated.c}/IntelGDL"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
            <include name="jogamp/newt/driver/intel/gdl/DisplayDriver.java" />
            <include name="jogamp/newt/driver/intel/gdl/ScreenDriver.java" />
            <include name="jogamp/newt/driver/intel/gdl/WindowDriver.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <!-- create Broadcom EGL native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               nativeheaderdir="${src.generated.c}/bcm/egl"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
            <include name="jogamp/newt/driver/bcm/egl/WindowDriver.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <!-- create Broadcom VideoCore IV native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               nativeheaderdir="${src.generated.c}/bcm/vc/iv"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
            <include name="jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java" />
            <include name="jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java" />
            <include name="jogamp/newt/driver/bcm/vc/iv/WindowDriver.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <!-- create EGL GBM native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               nativeheaderdir="${src.generated.c}/egl/gbm"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
            <include name="jogamp/newt/driver/egl/gbm/DisplayDriver.java" />
            <include name="jogamp/newt/driver/egl/gbm/ScreenDriver.java" />
            <include name="jogamp/newt/driver/egl/gbm/WindowDriver.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <!-- create Windows native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               nativeheaderdir="${src.generated.c}/Windows"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
            <include name="jogamp/newt/driver/windows/WindowDriver.java" />
            <include name="jogamp/newt/driver/windows/ScreenDriver.java" />
            <include name="jogamp/newt/driver/windows/DisplayDriver.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <!-- create MacOS native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               nativeheaderdir="${src.generated.c}/MacOSX"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
            <include name="jogamp/newt/driver/macosx/WindowDriver.java" />
            <include name="jogamp/newt/driver/macosx/ScreenDriver.java" />
            <include name="jogamp/newt/driver/macosx/DisplayDriver.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <!-- create iOS native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               nativeheaderdir="${src.generated.c}/iOS"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
            <include name="jogamp/newt/driver/ios/WindowDriver.java" />
            <include name="jogamp/newt/driver/ios/ScreenDriver.java" />
            <include name="jogamp/newt/driver/ios/DisplayDriver.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <!-- create X11 native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               nativeheaderdir="${src.generated.c}/X11"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
            <include name="jogamp/newt/driver/x11/WindowDriver.java" />
            <include name="jogamp/newt/driver/x11/ScreenDriver.java" />
            <include name="jogamp/newt/driver/x11/DisplayDriver.java" />
            <include name="jogamp/newt/driver/x11/RandR11.java" />
            <include name="jogamp/newt/driver/x11/RandR13.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <javac destdir="${classes}"
               excludes="${java.excludes.all} ${java.part.driver.android}"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <src path="${src.java}" />
            <classpath refid="jogl_nativewindow_gluegen.classpath"/>
        </javac>

        <!-- make shadercode, fonts etc available in classpath -->
        <copy todir="${classes}">
            <fileset dir="${src.java}"
                     includes="${java.part.nonjava}"
                     excludes="**/*.java"/>
        </copy>
    </target>

    <target name="java.compile.android" if="android-jars.available">

        <!-- create Android native headers -->
        <javac srcdir="${src.java}"
               destdir="${classes}"
               excludes="${java.excludes.all}"
               nativeheaderdir="${src.generated.c}/Android"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="jogl_nativewindow_gluegen_android.classpath"/>
            <include name="jogamp/newt/driver/android/WindowDriver.java" />
          <compilerarg value="-implicit:none" />
        </javac>

        <javac destdir="${classes}"
               excludes="${java.excludes.all}"
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               encoding="UTF-8"
               release="${target.releaselevel}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <src path="${src.java}" />
            <classpath refid="jogl_nativewindow_gluegen_android.classpath"/>
        </javac>
    </target>

    <!-- ================================================================== -->
    <!--
       - Compile the native C code for JOGL (and optionally the Cg binding).
      -->

    <target name="c.configure.1" depends="gluegen.cpptasks.detect.os,gluegen.cpptasks.setup.compiler">
      <!-- compiler configuration -->
      <!-- Note that we can use the base setups in the gluegen-cpptasks for most of these -->
      <compiler id="compiler.cfg.freebsd.newt" extends="compiler.cfg.freebsd">
        <includepath path="/usr/local/include" />
      </compiler>

      <compiler id="compiler.cfg.linux.armv6.newt.x11" extends="compiler.cfg.linux.armv6">
        <!-- Need to force /usr/include headers on to include path (after all others), due to crosscompiler usage -->
        <compilerarg value="-idirafter" />
        <compilerarg value="/usr/include" />
      </compiler>

      <compiler id="compiler.cfg.linux.aarch64.newt.x11" extends="compiler.cfg.linux.aarch64">
        <!-- Need to force /usr/include headers on to include path (after all others), due to crosscompiler usage -->
        <compilerarg value="-idirafter" />
        <compilerarg value="/usr/include" />
      </compiler>

      <!-- linker configuration -->

      <linker id="linker.cfg.freebsd.newt.x11" extends="linker.cfg.freebsd">
        <linkerarg value="-L/usr/local/lib"/>
        <syslibset libs="X11"/>
        <syslibset libs="Xrandr"/>
        <syslibset libs="Xcursor"/>
        <syslibset libs="Xi"/>
      </linker>

      <linker id="linker.cfg.freebsd.amd64.newt.x11" extends="linker.cfg.freebsd.amd64">
        <linkerarg value="-L/usr/local/lib"/>
        <syslibset libs="X11"/>
        <syslibset libs="Xrandr"/>
        <syslibset libs="Xcursor"/>
        <syslibset libs="Xi"/>
      </linker>

      <linker id="linker.cfg.linux.newt.bcm_egl" extends="linker.cfg.linux">
        <syslibset libs="EGL"/>
        <syslibset libs="GLES_CM"/>
      </linker>

      <linker id="linker.cfg.linux.newt.bcm_vc" extends="linker.cfg.linux">
        <!-- syslibset libs="EGL"/ -->
      </linker>

      <linker id="linker.cfg.linux.newt.x11" extends="linker.cfg.linux">
        <syslibset libs="X11"/>
        <syslibset libs="Xrandr"/>
        <syslibset libs="Xcursor"/>
        <syslibset libs="Xi"/>
        <!--syslibset libs="xcb" /-->
        <!--syslibset libs="X11-xcb" /-->
      </linker>

      <linker id="linker.cfg.linux.newt.drm" extends="linker.cfg.linux">
        <syslibset libs="drm"/>
        <syslibset libs="gbm"/>
      </linker>

      <linker id="linker.cfg.linux.x86.newt.x11" extends="linker.cfg.linux.x86">
        <syslibset libs="X11"/>
        <syslibset libs="Xrandr"/>
        <syslibset libs="Xcursor"/>
        <syslibset libs="Xi"/>
        <!--syslibset libs="xcb" /-->
        <!--syslibset libs="X11-xcb" /-->
      </linker>

      <linker id="linker.cfg.linux.x86.newt.drm" extends="linker.cfg.linux.x86">
        <syslibset libs="drm"/>
        <syslibset libs="gbm"/>
      </linker>

      <linker id="linker.cfg.linux.amd64.newt.x11" extends="linker.cfg.linux.amd64">
        <syslibset libs="X11"/>
        <syslibset libs="Xrandr"/>
        <syslibset libs="Xcursor"/>
        <syslibset libs="Xi"/>
        <!--syslibset libs="xcb" /-->
        <!--syslibset libs="X11-xcb" /-->
      </linker>

      <linker id="linker.cfg.linux.amd64.newt.drm" extends="linker.cfg.linux.amd64">
        <syslibset libs="drm"/>
        <syslibset libs="gbm"/>
      </linker>

      <linker id="linker.cfg.linux.armv6.newt.x11" extends="linker.cfg.linux.armv6">
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="X11" />
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xrandr" />
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xcursor" />
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xi" />
      </linker>

      <linker id="linker.cfg.linux.armv6.newt.drm" extends="linker.cfg.linux.armv6">
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="drm" />
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="gbm" />
      </linker>

      <linker id="linker.cfg.linux.aarch64.newt.x11" extends="linker.cfg.linux.aarch64">
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="X11" />
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xrandr" />
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xcursor" />
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="Xi" />
      </linker>

      <linker id="linker.cfg.linux.aarch64.newt.drm" extends="linker.cfg.linux.aarch64">
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="drm" />
        <syslibset dir="${TARGET_PLATFORM_USRLIBS}" libs="gbm" />
      </linker>

      <linker id="linker.cfg.android.newt" extends="linker.cfg.android">
        <syslibset dir="${env.ANDROID_TOOLCHAIN_SYSROOT1}/usr/lib" libs="android" />
      </linker>

      <linker id="linker.cfg.solaris.newt.x11" extends="linker.cfg.solaris">
        <syslibset libs="X11"/>
        <syslibset libs="Xrandr"/>
        <syslibset libs="Xcursor"/>
        <syslibset libs="Xi"/>
      </linker>

      <linker id="linker.cfg.solaris.sparcv9.newt.x11" extends="linker.cfg.solaris.sparcv9">
        <linkerarg value="-L/usr/lib/sparcv9"/>
        <syslibset libs="X11"/>
        <syslibset libs="Xrandr"/>
        <syslibset libs="Xcursor"/>
        <syslibset libs="Xi"/>
      </linker>

      <linker id="linker.cfg.solaris.amd64.newt.x11" extends="linker.cfg.solaris.amd64">
        <linkerarg value="-L/usr/lib/amd64"/>
        <syslibset libs="X11"/>
        <syslibset libs="Xrandr"/>
        <syslibset libs="Xcursor"/>
        <syslibset libs="Xi"/>
      </linker>

      <linker id="linker.cfg.win32.mingw.newt" extends="linker.cfg.win32.mingw">
        <linkerarg value="-Wl,--kill-at" />        <!-- remove @ from function names -->
        <syslibset libs="gdi32, kernel32"/>
      </linker>

      <linker id="linker.cfg.win64.mingw.newt" extends="linker.cfg.win64.mingw">
        <linkerarg value="-Wl,--kill-at" />        <!-- remove @ from function names -->
        <syslibset libs="gdi32, kernel32"/>
      </linker>

      <linker id="linker.cfg.win32.msvc.newt" extends="linker.cfg.win32.msvc">
        <syslibset libs="gdi32, user32, kernel32" />
      </linker>

      <linker id="linker.cfg.macosx.newt" extends="linker.cfg.macosx">
        <linkerarg value="-weak_framework" />
        <linkerarg value="AppKit" />
        <linkerarg value="-weak_framework" />
        <linkerarg value="QuartzCore" />
        <linkerarg value="-weak_framework" />
        <linkerarg value="Carbon" />
        <linkerarg value="-weak_framework" />
        <linkerarg value="Cocoa" />
      </linker>

      <linker id="linker.cfg.ios.amd64.newt" extends="linker.cfg.ios.amd64">
        <!-- linkerarg value="-v" / -->
        <linkerarg value="-weak_framework" />
        <linkerarg value="UIKit" />
        <linkerarg value="-weak_framework" />
        <linkerarg value="QuartzCore" />
        <linkerarg value="-weak_framework" />
        <linkerarg value="OpenGLES" /> <!-- hack to get the CAEAGL in .. -->
      </linker>

      <linker id="linker.cfg.ios.arm64.newt" extends="linker.cfg.ios.arm64">
        <!-- linkerarg value="-v" / -->
        <linkerarg value="-weak_framework" />
        <linkerarg value="UIKit" />
        <linkerarg value="-weak_framework" />
        <linkerarg value="QuartzCore" />
        <linkerarg value="-weak_framework" />
        <linkerarg value="OpenGLES" /> <!-- hack to get the CAEAGL in .. -->
      </linker>

      <linker id="linker.cfg.hpux.newt" extends="linker.cfg.hpux">
        <syslibset dir="/usr/lib" libs="X11"/>
      </linker>
    </target>

    <target name="c.configure.win32.vc" if="isVCFamily">
      <echo message="Win32.VC" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.win32.msvc" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.win32.msvc.newt" />
    </target>

    <target name="c.configure.win32.mingw" if="isMingW32">
      <echo message="Win32.MingW" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.win32.mingw" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.win32.mingw.newt" />
    </target>

    <target name="c.configure.win64.mingw" if="isMingW64">
      <echo message="Win64.MingW" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.win64.mingw" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.win64.mingw.newt" />
    </target>

    <target name="c.configure.linux.x86" if="isLinuxX86">
      <echo message="Linux.x86" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux.x86" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.x86.newt.x11"
                                                            else="linker.cfg.linux.x86">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.x86.newt.drm"/>
    </target>

    <target name="c.configure.linux.amd64" if="isLinuxAMD64">
      <echo message="Linux.AMD64" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux.amd64" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.amd64.newt.x11"
                                                            else="linker.cfg.linux.amd64">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.amd64.newt.drm"/>
    </target>

    <target name="c.configure.linux.armv6" if="isLinuxARMv6">
      <echo message="Linux.armv6" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux.armv6.newt.x11" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.armv6.newt.x11"
                                                            else="linker.cfg.linux.armv6">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.armv6.newt.drm"/>
    </target>

    <target name="c.configure.linux.aarch64" if="isLinuxARM64">
      <echo message="Linux.aarch64" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux.aarch64.newt.x11" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.aarch64.newt.x11"
                                                            else="linker.cfg.linux.aarch64">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.aarch64.newt.drm"/>
    </target>

    <target name="c.configure.linux.hppa" if="isLinuxHppa">
      <echo message="Linux.hppa" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.newt.x11"
                                                            else="linker.cfg.linux">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.newt.drm"/>
    </target>

    <target name="c.configure.linux.mips" if="isLinuxMips">
      <echo message="Linux.mips" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.newt.x11"
                                                            else="linker.cfg.linux">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.newt.drm"/>
    </target>

    <target name="c.configure.linux.mipsel" if="isLinuxMipsel">
      <echo message="Linux.mips" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.newt.x11"
                                                            else="linker.cfg.linux">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.newt.drm"/>
    </target>

    <target name="c.configure.linux.ppc" if="isLinuxPpc">
      <echo message="Linux.ppc" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.newt.x11"
                                                            else="linker.cfg.linux">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.newt.drm"/>
    </target>

    <target name="c.configure.linux.ppc64le" if="isLinuxPpc64le">
      <echo message="Linux.ppc64le" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.newt.x11"
                                                            else="linker.cfg.linux">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.newt.drm"/>
    </target>

    <target name="c.configure.linux.riscv64" if="isLinuxRiscV64">
      <echo message="Linux.riscv64" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.newt.x11"
                                                            else="linker.cfg.linux">
          <isset property="isX11" />
      </condition>
      <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" />
    </target>

    <target name="c.configure.linux.s390" if="isLinuxs390">
      <echo message="Linux.S390" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.newt.x11"
                                                            else="linker.cfg.linux">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.newt.drm"/>
    </target>

    <target name="c.configure.linux.sparc" if="isLinuxSparc">
      <echo message="Linux.sparc" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.linux.newt.x11"
                                                            else="linker.cfg.linux">
          <isset property="isX11" />
      </condition>
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.newt.drm"/>
    </target>

    <target name="c.configure.linux.ia64" if="isLinuxIA64">
      <echo message="Linux.IA64" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.linux.newt.x11" />
      <property name="linker.cfg.id.drm"                    value="linker.cfg.linux.newt.drm"/>
    </target>

    <target name="c.configure.linux" depends="c.configure.linux.x86,c.configure.linux.amd64,c.configure.linux.armv6,c.configure.linux.aarch64,c.configure.linux.hppa,c.configure.linux.mips,c.configure.linux.mipsel,c.configure.linux.ppc,c.configure.linux.ppc64le,c.configure.linux.riscv64,c.configure.linux.s390,c.configure.linux.sparc,c.configure.linux.ia64,c.configure.x11" if="isLinux"/>

    <target name="c.configure.android" if="isAndroid">
      <echo message="Android" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.android" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.android.newt" />
    </target>

    <target name="c.configure.solaris32" depends="c.configure.x11" if="isSolaris32Bit">
      <echo message="Solaris" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.solaris.newt.x11" />
    </target>


    <target name="c.configure.solaris.sparcv9" depends="c.configure.x11" if="isSolarisSparcv9">
      <echo message="SolarisSparcv9" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris.sparcv9" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.solaris.sparcv9.newt.x11" />
    </target>


    <target name="c.configure.solaris.amd64" depends="c.configure.x11" if="isSolarisAMD64">
      <echo message="SolarisAMD64" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris.amd64" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.solaris.amd64.newt.x11" />
    </target>

    <target name="c.configure.freebsd.x86" if="isFreeBSDX86">
      <echo message="FreeBSD.x86" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.freebsd.newt" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.freebsd.newt.x11"
                                                            else="linker.cfg.freebsd">
          <isset property="isX11" />
      </condition>
      <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" />
    </target>

    <target name="c.configure.freebsd.amd64" if="isFreeBSDAMD64">
      <echo message="FreeBSD.AMD64" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.freebsd.newt" />
      <condition property="linker.cfg.id.oswin"             value="linker.cfg.freebsd.amd64.newt.x11"
                                                            else="linker.cfg.freebsd.amd64">
          <isset property="isX11" />
      </condition>
      <echo message="linker.cfg.id.oswin ${linker.cfg.id.oswin}" />
    </target>

    <target name="c.configure.freebsd" depends="c.configure.freebsd.x86,c.configure.freebsd.amd64,c.configure.x11" if="isFreeBSD"/>

    <target name="c.configure.hpux" depends="c.configure.x11" if="isHPUX">
      <echo message="HP-UX" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.hpux" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.hpux.newt.x11" />
    </target>

    <target name="c.configure.win32" depends="c.configure.win32.vc,c.configure.win32.mingw,c.configure.win64.mingw" if="isWindows" />

    <target name="c.configure.x11" if="isX11" />

    <target name="c.configure.macosx" if="isOSX">
      <property name="compiler.cfg.id"                      value="compiler.cfg.macosx" />
      <property name="linker.cfg.id.oswin"                  value="linker.cfg.macosx.newt" />
    </target>

    <target name="c.configure.ios.amd64" if="isIOSAmd64">
      <property name="compiler.cfg.id"                     value="compiler.cfg.ios.amd64" />
      <property name="linker.cfg.id.oswin"                 value="linker.cfg.ios.amd64.newt" />
    </target>

    <target name="c.configure.ios.arm64" if="isIOSArm64">
      <property name="compiler.cfg.id"                     value="compiler.cfg.ios.arm64" />
      <property name="linker.cfg.id.oswin"                 value="linker.cfg.ios.arm64.newt" />
    </target>

    <target name="c.configure.2" depends="c.configure.win32,c.configure.linux,c.configure.android,c.configure.solaris32,c.configure.solaris.sparcv9,c.configure.solaris.amd64,c.configure.macosx,c.configure.ios.amd64,c.configure.ios.arm64,c.configure.freebsd,c.configure.hpux" />

    <target name="c.configure" depends="c.configure.1,c.configure.2" />

    <macrodef name="c.build">
      <attribute name="c.compiler.src.files" />
      <attribute name="compiler.cfg.id" />
      <attribute name="linker.cfg.id" />
      <attribute name="output.lib.name" />
      <attribute name="c.compiler.use-jawt" default="false"/>
      <sequential>
        <echo message="Output lib name = @{output.lib.name}" />

        <!-- NOTE: the value of the debug and optimise attributes will not be overridden if already set externally -->
        <property name="c.compiler.debug"     value="false" />
        <!-- Optimise flags one of { none, size, speed, minimal, full, aggressive, extreme, unsafe } -->
        <property name="c.compiler.optimise"  value="none" />

        <condition property="c.compiler.use-debug"><istrue value="${c.compiler.debug}"/></condition>

        <patternset id="c.src.files.newt.head">
          <include name="${rootrel.src.c}/JVM_JNI6.c" />
          <include name="${rootrel.src.c}/NewtCommon.c" />
          <!-- include name="${rootrel.src.c}/timespec.c"   /--> <!-- currently used for X11 and OSX with special PERF DEBUG MODE-->
          <include name="${rootrel.src.c}/WindowsWindow.c"    if="isWindows"/>
          <include name="${rootrel.src.c}/WindowsEDID.c"      if="isWindows"/>
          <include name="${rootrel.src.c}/MacWindow.m"        if="isOSX"/>
          <include name="${rootrel.src.c}/MacNewtNSWindow.m"  if="isOSX"/>
          <include name="${rootrel.src.c}/IOSWindow.m"        if="isIOS"/>
          <include name="${rootrel.src.c}/IOSNewtUIWindow.m"  if="isIOS"/>
          <include name="${rootrel.src.c}/AndroidWindow.c"    if="isAndroid"/>
          <include name="${rootrel.src.c}/X11Display.c"       if="isX11"/>
          <!-- include name="${rootrel.src.c}/X11Event.c"      if="isX11"/-->
          <!-- include name="${rootrel.src.c}/XCBEvent.c"      if="isX11"/-->
          <include name="${rootrel.src.c}/X11Screen.c"        if="isX11"/>
          <include name="${rootrel.src.c}/X11RandR11.c"       if="isX11"/>
          <include name="${rootrel.src.c}/X11RandR13.c"       if="isX11"/>
          <include name="${rootrel.src.c}/X11Window.c"        if="isX11"/>
          <include name="${rootrel.src.c}/KDWindow.c"         if="setup.addNativeKD"/>
          <include name="${rootrel.src.c}/IntelGDL.c"         if="setup.addNativeIntelGDL"/>
          <include name="${rootrel.src.c}/bcm_egl.c"          if="setup.addNativeBroadcom"/>
          <include name="${rootrel.src.c}/bcm_vc_iv.c"        if="setup.addNativeBroadcom"/>
        </patternset>

        <patternset id="c.src.files.newt.drmgbm">
          <include name="${rootrel.src.c}/JVM_JNI6.c" />
          <include name="${rootrel.src.c}/NewtCommon.c" />
          <include name="${rootrel.src.c}/drm_gbm.c"          if="setup.addNativeDRMGBM"/>
          <include name="${rootrel.src.c}/drm_gbm_legacy.c"   if="setup.addNativeDRMGBM"/>
        </patternset>

        <echo message="Compiling @{output.lib.name}" />

        <!-- have to wrap cc task with outofdate, because otherwise cc links a new library
             even when no files have been compiled -->
        <outofdate>
          <sourcefiles>
            <fileset dir="${project.root}"><patternset refid="@{c.compiler.src.files}"/></fileset>
          </sourcefiles>
          <targetfiles>
            <fileset dir="${obj.newt}" includes="${native.library.prefix}@{output.lib.name}.${native.library.suffix}"/>
          </targetfiles>
          <sequential>
            <cc outtype="${output.lib.type}"
                usehighleveltool="true"
                writesoname="true"
                objdir="${obj.newt}"
                outfile="${obj.newt}/@{output.lib.name}"
                optimize="${c.compiler.optimise}"
                debug="${c.compiler.debug}"
                multithreaded="true"
                exceptions="false"
                rtti="false">

              <fileset dir="${project.root}"><patternset refid="@{c.compiler.src.files}"/></fileset>

              <compiler extends="@{compiler.cfg.id}" >
                <sysincludepath path="${java.includes.dir}"/>
                <sysincludepath path="${java.includes.dir.platform}"/>
                <sysincludepath path="${stub.includes.gluegen.cc}"/>
                <includepath path="stub_includes/khr"/>
                <includepath path="stub_includes/egl"/>
                <!-- This is for finding Xrandr.h on Solaris. -->
                <includepath path="/usr/X11/include" />
                <!-- This is for the generated headers for handwritten C code -->
                <includepath path="${src.generated.c}" />
                <includepath path="${src.generated.c}/Android"      if="isAndroid"/>
                <includepath path="${src.generated.c}/X11"          if="isX11"/>
                <includepath path="${src.generated.c}/MacOSX"       if="isOSX"/>
                <includepath path="${src.generated.c}/iOS"          if="isIOS"/>
                <includepath path="${src}/nativewindow/native"      if="isIOS"/>
                <includepath path="${src}/nativewindow/native/ios"  if="isIOS"/>
                <includepath path="${src.generated.c}/Windows"      if="isWindows"/>
                <includepath path="${src.generated.c}/KD"           if="setup.addNativeKD" />
                <includepath path="${src.generated.c}/IntelGDL"     if="setup.addNativeIntelGDL" />
                <includepath path="stub_includes/embedded/IntelGDL" if="setup.addNativeIntelGDL" />
                <includepath path="${src.generated.c}/bcm/egl"      if="setup.addNativeBroadcom" />
                <includepath path="${src.generated.c}/bcm/vc/iv"    if="setup.addNativeBroadcom" />
                <includepath path="${src.generated.c}/egl/gbm"      if="setup.addNativeDRMGBM" />
                <includepath path="stub_includes/drm"               if="setup.addNativeDRMGBM" />
                <!-- This must come last to not override real include paths -->
                <!-- includepath path="stub_includes/macosx" if="isOSX" / -->
              </compiler>

              <linker extends="@{linker.cfg.id}">
                <syslibset dir="${java.lib.platform}" libs="jawt" if="@{output.lib.name}.useLibJAWT"/>
                <syslibset dir="${java.lib.platform}/server" libs="jvm" if="@{output.lib.name}.useLibJVM"/>
              </linker>
            </cc>

            <gluegen.make.libsymbols builddir="${build}"
                nativelib="${obj.newt}/${native.library.prefix}@{output.lib.name}.${native.library.suffix}"
                symbolsfile="${obj.newt}/${native.library.prefix}@{output.lib.name}.symbols"/>

          	<!-- this stripping may be called more than once on the same library dir,
          	     but that should cause no harm, and doing it here inside outofdate
          	     prevents the JARs from always being rebuilt even if no source code changes -->
          	<antcall target="gluegen.cpptasks.striplibs" inheritRefs="true">
                <param name="libdir" value="${obj.newt}"/>
            </antcall>

          </sequential>
        </outofdate>
      </sequential>
    </macrodef>

    <target name="c.build.newt.windowlib.drmgbm" if="setup.addNativeDRMGBM">
      <echo message="Using compiler.cfg.id ${compiler.cfg.id}" />
      <echo message="Using linker.cfg.id.drm   ${linker.cfg.id.drm}" />
      <c.build c.compiler.src.files="c.src.files.newt.drmgbm"
               output.lib.name="newt_drm"
               compiler.cfg.id="${compiler.cfg.id}"
               linker.cfg.id="${linker.cfg.id.drm}"/>
    </target>

    <target name="c.build.newt.windowlib.head" unless="setup.nonatives">
      <echo message="Using compiler.cfg.id ${compiler.cfg.id}" />
      <echo message="Using linker.cfg.id.oswin ${linker.cfg.id.oswin}" />
      <c.build c.compiler.src.files="c.src.files.newt.head"
               output.lib.name="newt_head"
               compiler.cfg.id="${compiler.cfg.id}"
               linker.cfg.id="${linker.cfg.id.oswin}"/>
    </target>

    <target name="c.manifest" if="isVC8Family">
      <!-- exec mt, the Microsoft Manifest Tool, to include DLL manifests in order to resolve the location of msvcr80.dll -->
      <msvc.manifest objdir="${obj.newt}" dllname="newt" />
    </target>

    <target name="c.build.newt.natives" depends="c.build.newt.windowlib.head, c.build.newt.windowlib.drmgbm" unless="setup.nonatives">
    </target>

    <target name="c.build.newt" depends="c.configure,c.build.newt.natives">
      <antcall target="c.manifest" inheritRefs="true" />
    </target>

    <!-- ================================================================== -->
    <!--
       - Build the newt.jar files.
      -->
    <target name="setup-manifestfile">
        <property name="manifestfile" value="newtversion"/>
        <copy file="${manifestfile}"
          tofile="${build.newt}/manifest.mf"
          overwrite="true">
          <filterset>
              <filter token="VERSION" value="${jogamp.version}"/>
              <filter token="BUILD_VERSION" value="${jogl.version}"/>
              <filter token="SCM_BRANCH" value="${jogl.build.branch}"/>
              <filter token="SCM_COMMIT" value="${jogl.build.commit}"/>
              <filter token="BASEVERSION" value="${jogamp.version.base}"/>
              <filter token="JAR_CODEBASE_TAG" value="${jogamp.jar.codebase}"/>
          </filterset>
        </copy>
        <copy file="${manifestfile}-natives"
          tofile="${build.newt}/manifest-natives.mf"
          overwrite="true">
          <filterset>
              <filter token="VERSION" value="${jogamp.version}"/>
              <filter token="BUILD_VERSION" value="${jogl.version}"/>
              <filter token="SCM_BRANCH" value="${jogl.build.branch}"/>
              <filter token="SCM_COMMIT" value="${jogl.build.commit}"/>
              <filter token="BASEVERSION" value="${jogamp.version.base}"/>
              <filter token="JAR_CODEBASE_TAG" value="${jogamp.jar.codebase}"/>
          </filterset>
        </copy>
    </target>

    <target name="build-jars-awt" depends="setup-manifestfile" unless="setup.noAWT">
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-awt.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.awt}"/>
        </jar>
    </target>

    <target name="build-jars-swt" depends="setup-manifestfile" unless="setup.noSWT">
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-swt.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.swt}"/>
        </jar>
    </target>

    <target name="build-jars-javafx" depends="setup-manifestfile" unless="setup.noJFX">
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-javafx.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.javafx}"/>
        </jar>
    </target>

    <target name="build-jars-opengl" depends="setup-manifestfile" unless="setup.noOpenGL">
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-ogl.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.opengl}"/>
        </jar>
    </target>

    <target name="build-jars-driver" depends="setup-manifestfile">
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-linux.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.linux}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-x11.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.x11}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-win.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.windows}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-osx.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.macosx}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-ios.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.ios}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-kd.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.kd}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-bcm-old.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.bcm.old}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-bcm-vc.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.bcm.vc}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-egl-gbm.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.egl.gbm}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-intelgdl.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.intelgdl}"/>
        </jar>
    </target>

    <target name="build-jars-javase" depends="setup-manifestfile,build-jars-opengl,build-jars-awt,build-jars-swt,build-jars-javafx,build-jars-driver">
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.core} ${java.part.nonjava}"/>
        </jar>
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-event.jar}" filesonly="true">
            <fileset dir="${classes}">
                <include name="com/jogamp/newt/Display*" />
                <include name="com/jogamp/newt/Screen*" />
                <include name="com/jogamp/newt/Window*" />
                <include name="com/jogamp/newt/ScreenMode*" />
                <include name="com/jogamp/newt/event/**" />
                <include name="jogamp/newt/Debug*" />
            </fileset>
        </jar>
    </target>

    <target name="build-jars-android" depends="setup-manifestfile" if="android-jars.available">
        <jar manifest="${build.newt}/manifest.mf" destfile="${newt-driver-android.jar}" filesonly="true">
            <fileset dir="${classes}"
                     includes="${java.part.driver.android}"/>
        </jar>
    </target>

    <target name="native.jar.deps" depends="build-jars-javase">
      <uptodate property="native.jar.skip" targetfile="${build.newt}/newt-natives-${os.and.arch}.jar">
        <srcfiles dir="${obj.newt}" includes="*.${native.library.suffix}" />
        <!-- srcfiles file="${build.newt}/manifest-natives.mf"/ -->
      </uptodate>
    </target>

    <target name="build-jars-native" depends="gluegen.cpptasks.detect.os,setup-manifestfile,native.jar.deps" unless="native.jar.skip">
        <native.tag.jar objdir="${obj.newt}"
                        nativejarfile="${build.newt}/newt-natives-${os.and.arch}.jar"
                        manifestfile="${build.newt}/manifest-natives.mf"
                        module="newt"
                        includelibs="*.${native.library.suffix}" />
    </target>

    <!-- ================================================================== -->
    <!--
       - Build the Javadocs for the sources.
       - NOTE:  these are not entirely correct as the javadocs targets depend
       -        on the platform specific build targets.  To circumvent any
       -        errors, ensure that the source is built first.
      -->
    <target name="javadoc" depends="init">
        <!-- Build the general Javadoc -->
        <javadoc packagenames="${javadoc.packagenames}"
                 excludepackagenames="${java.excludes.javadoc.packagenames}"
                 sourcepath="${src.java};${src.generated.java}"
                 destdir="${javadoc}" windowtitle="${javadoc.windowtitle}"
                 overview="${javadoc.overview}"
                 encoding="UTF-8"
                 source="${target.sourcelevel}"
                 maxmemory="${javac.memorymax}"
                 linkoffline="${javadoc.link} 142-packages"
         bottom="${javadoc.bottom}" >
         <classpath refid="jogl_doc.classpath"/>
          <arg value="${javadoc.xarg1}"/>
        </javadoc>
    </target>

    <target name="javadoc.spec" depends="init">
        <!-- Build the general Javadoc -->
        <javadoc packagenames="${javadoc.spec.packagenames}"
                 excludepackagenames="${java.excludes.javadoc.packagenames}"
                 sourcepath="${src.java};${src.generated.java}"
                 destdir="${javadoc.spec}" windowtitle="${javadoc.windowtitle}"
                 overview="${javadoc.overview}"
                 encoding="UTF-8"
                 source="${target.sourcelevel}"
                 maxmemory="${javac.memorymax}"
                 linkoffline="${javadoc.link} 142-packages"
                 bottom="${javadoc.bottom}" >
         <classpath refid="jogl_doc.classpath"/>
          <arg value="${javadoc.xarg1}"/>
        </javadoc>
    </target>

    <target name="javadoc.dev" depends="init">
        <!-- Build the internal developer Javadoc -->
        <javadoc packagenames="${javadoc.dev.packagenames}"
                 excludepackagenames="${java.excludes.javadoc.packagenames}"
                 sourcepath="${src.java};${src.generated.java}"
                 destdir="${javadoc.dev}" windowtitle="${javadoc.windowtitle}"
                 overview="${javadoc.overview}"
                 encoding="UTF-8"
                 source="${target.sourcelevel}"
                 maxmemory="${javac.memorymax}"
                 linkoffline="${javadoc.link} 142-packages"
         bottom="${javadoc.bottom}" >
         <classpath refid="jogl_doc.classpath"/>
          <arg value="${javadoc.xarg1}"/>
        </javadoc>
    </target>

    <target name="all.doc" description="Build NEWT docs" depends="init,javadoc,javadoc.spec,javadoc.dev" />

    <!-- ================================================================== -->
    <!--
       - Clean up all that is built.
      -->
    <target name="clean" description="Remove all build products" depends="declare.common">
        <delete includeEmptyDirs="true" quiet="true">
            <fileset dir="${build.newt}" />
            <fileset dir="${javadoc}" />
            <fileset dir="${javadoc.spec}" />
            <fileset dir="${javadoc.dev}" />
        </delete>
    </target>

    <!-- ================================================================== -->
    <!--
       - Build everything.
      -->
    <target name="all" description="Build NEWT JAR file(s) and native libraries." depends="init,java.compile.javase,build-jars-javase,java.compile.android,build-jars-android,c.build.newt,build-jars-native,generate.version.txt" />

    <target name="generate.version.txt" depends="init">
        <!-- Create a version.txt file indicating which version we just built -->
        <echo message="${jogl.version}" file="${build.newt}/version.txt" />
    </target>

</project>
