summaryrefslogtreecommitdiffstats
path: root/make/build.xml
blob: 01939e9bd731075a755dd49c0f9fdba8cbe6cfbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
<?xml version="1.0" encoding="UTF-8"?>
<!--
   - Ant build for JOCL.  This build has been tested with ANT 1.9.4.  The
   - optional.jar that contains the optional ANT tasks must be in the ANT
   - classpath (typically the ant/lib directory).
   -
   - A clean download of JOCL 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 jocl.properties)
   -   clean:        clean all built
   -   javadoc:      create the standard developer Javadoc
   -
   - 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.
   -->
<project name="JOCL" basedir="." default="all">

    <property name="project.root"  value=".." />

    <condition property="rootrel.build" value="build">
        <not>
            <isset property="rootrel.build"/>
        </not>
    </condition>

    <property name="build"         value="${project.root}/${rootrel.build}" />
    <property name="gluegen.root"  value="${project.root}/../gluegen" />
    <property name="gluegen.build" value="${gluegen.root}/${rootrel.build}" />

    <!-- This is the version of JOCL you are building -->
    <mkdir dir="${build}" />

    <exec dir="." executable="git" logError="true" failonerror="false" failifexecutionfails="false"
              output="${build}/localbranch.raw">
        <arg line="branch --no-color"/>
    </exec>
    <exec dir="." executable="sed" logError="true" failonerror="false" failifexecutionfails="false"
              outputproperty="jocl.build.branch">
        <arg line="-e '/^[^*]/d' -e 's/* \(.*\)/\1/' ${build}/localbranch.raw"/>
    </exec>
    <property name="jocl.build.branch" value="manual"/> <!-- fallback -->
    <exec dir="${project.root}" executable="git" logError="true" failonerror="false" failifexecutionfails="false"
              outputproperty="jocl.build.commit">
        <arg line="rev-parse HEAD"/>
    </exec>
    <property name="jocl.build.commit" value="manual"/> <!-- fallback -->

    <!-- Pull in GlueGen cpptasks build file -->
    <import file="${gluegen.root}/make/gluegen-cpptasks.xml" />
    <import file="${gluegen.root}/make/jogamp-archivetasks.xml" />
    <import file="${gluegen.root}/make/jogamp-androidtasks.xml" />
    <import file="${gluegen.root}/make/jogamp-env.xml" />

    <!-- ================================================================== -->
    <!--
       - Load user properties which override build defaults.
      -->
    <target name="load.user.properties">
        <property name="user.properties.file" value="${user.home}/jocl.properties" />
        <property file="${user.properties.file}" />
        <echo message="Loaded ${user.properties.file}." />

        <property file="${user.home}/gluegen.properties" />
        <echo message="Loaded ${user.home}/gluegen.properties." />
    </target>

    <target name="set.debug">
        <property name="c.compiler.debug" value="true" /> 
        <property name="c.compiler.optimise"  value="none" /> 
        <property name="javacdebug"       value="true" /> 
        <property name="javacdebuglevel"  value="source,lines,vars" /> 
    </target>

    <!-- ================================================================== -->
    <!--
       - Declare all paths and user defined variables.
      -->
    <target name="init.base" depends="load.user.properties,jogamp.env.init,gluegen.properties.load.user,gluegen.cpptasks.detect.os">
        <property name="jocl.build.number" value="manual"/>
        <property name="jocl.build.id"     value="${version.timestamp}"/>
        <property name="jocl.version"      value="${jogamp.version.base}-b${jocl.build.number}-${version.timestamp}" />

        <!-- The location and name of the configuration ANT file that will
           - validate to ensure that all user-define variables are set. -->
        <property name="validate.user.properties" value="${make}/validate-properties.xml" />

        <!-- GlueGen properties. -->
        <!-- NOTE that these require a checked-out GlueGen workspace as a -->
        <!-- sibling of the JOCL workspace. -->
        <property name="gluegen.make.dir"  value="${gluegen.root}/make" />
        <property name="gluegen.build.xml" value="${gluegen.make.dir}/build.xml" />
        <property name="gluegen.jar"       value="${gluegen.build}/gluegen.jar" />
        <property name="gluegen-rt.jar"    value="${gluegen.build}/gluegen-rt.jar" />

        <property name="jogl.root"     value="${project.root}/../jogl" />
        <property name="jogl.build"    value="${jogl.root}/${rootrel.build}" />
        <property name="jogl-all.jar"  value="${jogl.build}/jar/jogl-all.jar" />
    </target>

    <target name="init.android" if="android-jars.available" >
        <property name="gluegen-rt-android.jar" value="${gluegen.build}/gluegen-rt-android.jar" />

        <path id="javac.android.classpath">
            <pathelement location="${android-min.jar}"/>
            <pathelement location="${gluegen-rt-android.jar}" />
            <pathelement location="${jogl-all.jar}" />
        </path>
    </target>

    <target name="init" depends="init.base, init.android">
        <!-- Names of directories relative to the project root.
             Some of these are used in FileMappers later for dependence information
             and need exact string matching, which is why they use file.separator
             instead of "/". -->
        <property name="rootrel.src" value="src" />
        <property name="rootrel.src.java" value="${rootrel.src}" />
        <property name="rootrel.src.c" value="resources" />
        <property name="rootrel.src.generated" value="${rootrel.build}/gensrc" />
        <property name="rootrel.generated.c.jocl" value="${rootrel.src.generated}/native/jocl" />
        <property name="rootrel.obj" value="${rootrel.build}/obj" />
        <property name="rootrel.obj.jocl" value="${rootrel.obj}/jocl" />

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

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

        <!-- The compiler output directories. -->
        <property name="classes" value="${build}/classes" />
        <property name="obj"      value="${project.root}/${rootrel.obj}" />
        <property name="obj.jocl" value="${project.root}/${rootrel.obj.jocl}" />

        <!-- Create the classpath that includes GlueGen and
           - ANTLR. This requires the user-defined "antlr.jar"
           - property. -->
        <path id="gluegen.classpath">
            <pathelement location="${gluegen.jar}" />
            <pathelement location="${antlr.jar}" />
        </path>

        <path id="javac.classpath">
            <pathelement location="${gluegen.jar}" />
            <pathelement location="${jogl-all.jar}" />
        </path>

        <property name="config" value="${project.root}/make/config" />
        <property name="stub.includes" value="${project.root}/make/stub_includes" />
        <property name="stub.includes.dir" value="stub_includes" /> <!-- NOTE:  this MUST be relative for FileSet -->
        <property name="gen.includes" value="${project.root}/make/stub_includes.gen" />
        <property name="gen.includes.dir" value="stub_includes.gen" /> <!-- NOTE:  this MUST be relative for FileSet -->

        <!-- Directories used for OpenCL header file preprocessing. -->
        <property name="etc.build.dir" value="${build}/etc" />
        <property name="headers.orig" value="${stub.includes}/CL" />
        <property name="headers.dest" value="${gen.includes}/CL" />

        <!-- The headers from which Java files are generated -->
        <fileset id="stub.includes.dependencies.fileset.1" dir="${stub.includes.dir}">
            <include name="CL11/**" />
            <include name="CL12/**" />
            <include name="CL20/**" />
        </fileset>
        <fileset id="stub.includes.dependencies.fileset.2" dir="${gen.includes.dir}">
            <include name="CL11/CL/**" />
            <include name="CL12/CL/**" />
            <include name="CL20/CL/**" />
        </fileset>
        <fileset id="stub.includes.dependencies.fileset.3" file="${gluegen.jar}" />
        <fileset id="stub.includes.dependencies.fileset.4" dir="config">
            <include name="*.cfg" />
            <include name="*.java" />
            <include name="*.c" />
        </fileset>
        <!-- relative paths to stub includes in gluegen project; have to pass separately into gluegen
             task because dirsets won't work with paths outside their root path -->
        <property name="stub.includes.gluegen.all" value="${gluegen.root}/make/stub_includes/gluegen, ${gluegen.root}/make/stub_includes/jni, ${jogl.root}/make/stub_includes/khr, ${jogl.root}/make/stub_includes/opengl"/>
        <property name="stub.includes.gluegen.cc"  value="${gluegen.root}/make/stub_includes/platform" />

        <!-- The resulting jocl.jar. -->
        <property name="jocl.jar" value="${build}/jar/jocl.jar" />
        <property name="jocl-android.jar" value="${build}/jar/jocl-android.jar" />
        <property name="jocl-android.apk" value="${build}/jar/jocl-${os.and.arch}.apk" />

        <path id="jocl_all.classpath">
            <pathelement location="${gluegen-rt.jar}" />
            <pathelement location="${jocl.jar}" />
        </path>

        <!-- Create the required output directories. -->
        <mkdir dir="${src.generated.java}" />
        <mkdir dir="${src.generated.c}" />
        <mkdir dir="${classes}" />
        <mkdir dir="${obj}" />
        <mkdir dir="${obj.jocl}" />
        <mkdir dir="${gen.includes}" />

        <property name="archive.name"        value="jocl-${jocl.version}-${os.and.arch}" />
        <property name="archive"             value="${build}/${archive.name}" />

        <!-- optional android classes - if android -->
        <property name="java.part.android" value="jogamp/opencl/os/android/**"/>

        <condition property="enable.jdk7.features">
            <or>
                <equals arg1="${target.targetlevel}" arg2="1.7"/>
                <equals arg1="${target.targetlevel}" arg2="1.8"/>
            </or>
        </condition>
        <echo message="enable.jdk7.features ${enable.jdk7.features}" />
    </target>

    <!-- ================================================================== -->
    <!-- GlueGen and BuildStaticGLInfo creation, task setup and Java file generation -->
    <!--
       - Build GlueGen
      -->
    <target name="build.gluegen" depends="init" unless="common.gluegen.build.done">
        <property name="common.gluegen.build.done" value="true" />

        <!-- Run the GlueGen build to ensure that the GlueGen ANT task
           - has been built. -->
        <ant antfile="${gluegen.build.xml}" dir="${gluegen.make.dir}" target="base.compile" inheritAll="false" />
    </target>

    <!-- ================================================================== -->
    <!-- Java file generation -->
    <!--
       - Check to see whether we need to rebuild the generated sources.
      -->

    <target name="java.generate.check">
        <!-- Blow away all target files if any dependencies are violated
             (the uptodate task doesn't allow arbitrary source and target filesets but should) -->
        <dependset>
            <srcfileset refid="stub.includes.dependencies.fileset.1" />
            <srcfileset refid="stub.includes.dependencies.fileset.2" />
            <srcfileset refid="stub.includes.dependencies.fileset.3" />
            <srcfileset refid="stub.includes.dependencies.fileset.4" />
            <targetfileset dir=".">
                <include name="${src.generated.java}/**/*.java" />
                <include name="${src.generated.c}/**/*.c" />
            </targetfileset>
        </dependset>

        <!-- Now check for the presence of one well-known file -->
        <uptodate property="java.generate.skip"
                  targetfile="${src.generated.c}/CLImpl11_JNI.c">
            <srcfiles refid="stub.includes.dependencies.fileset.1" />
            <srcfiles refid="stub.includes.dependencies.fileset.2" />
            <srcfiles refid="stub.includes.dependencies.fileset.3" />
            <srcfiles refid="stub.includes.dependencies.fileset.4" />
        </uptodate>
    </target>

    <target name="generate.jdk7.autocloseable" if="${enable.jdk7.features}">
        <echo message="Generating JDK7+ AutoCloseable"/>
        <copy file="${project.root}/src/com/jogamp/opencl/AutoCloseable.jtemplate"
            tofile="${build}/gensrc/java/com/jogamp/opencl/AutoCloseable.java" overwrite="true">
            <filterchain>
                <replaceregex pattern="/\*extends java.lang.AutoCloseable\*/" replace="extends java.lang.AutoCloseable"/>
            </filterchain>
        </copy>       
    </target>

    <target name="generate.jdk6.autocloseable" unless="${enable.jdk7.features}">
        <echo message="Generating JDK6 AutoCloseable"/>
        <copy file="${project.root}/src/com/jogamp/opencl/AutoCloseable.jtemplate"
            tofile="${build}/gensrc/java/com/jogamp/opencl/AutoCloseable.java" overwrite="true">
        </copy>      
    </target>

    <target name="make-build-utilities" depends="init">

        <!--compile build utilities-->
        <mkdir dir="${etc.build.dir}"/>

        <javac destdir="${etc.build.dir}" 
               classpath="${ant.core.lib}" 
               fork="yes"
               includeAntRuntime="false"
               memoryMaximumSize="${javac.memorymax}"
               source="${target.sourcelevel}" 
               target="${target.targetlevel}" 
               bootclasspath="${target.rt.jar}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <src path="${basedir}/../etc/src"/>
            <compilerarg value="-Xlint:all"/>
        </javac>

        <taskdef name="uncomment-function-params" classname="com.jogamp.ant.FunctionParamUncommenter" classpath="${etc.build.dir}"/>
    </target>

    <!--
       - Copies the OpenCl headers to a new directory while uncommenting the function parameters so gluegen will work properly.
      -->
    <target name="preprocess-opencl-headers" depends="make-build-utilities">
        <property name="preprocess.from" value="${stub.includes}/CL${opencl.version}" />
        <property name="preprocess.to"   value="${gen.includes}/CL${opencl.version}/CL" />
        <mkdir dir="${preprocess.to}"/>

        <!-- need to use absolute paths or it won't work inside Eclipse, where user.dir is Eclipse's bin dir-->
        <property name="preprocess.from.abs" value="${basedir}/${stub.includes.dir}/CL${opencl.version}" />
        <property name="preprocess.to.abs"   value="${basedir}/${gen.includes.dir}/CL${opencl.version}/CL" />
        <uncomment-function-params src="${preprocess.from.abs}/cl.h" dest="${preprocess.to.abs}/cl.h"/>
        <uncomment-function-params src="${preprocess.from.abs}/cl_gl.h" dest="${preprocess.to.abs}/cl_gl.h"/>

        <!--nothing to uncomment in these headers-->
        <copy file="${preprocess.from}/cl_platform.h" toDir="${preprocess.to}" overwrite="true"/>
        <copy file="${preprocess.from}/cl_ext.h"      toDir="${preprocess.to}" overwrite="true"/>
        <copy file="${preprocess.from}/cl_gl_ext.h"   toDir="${preprocess.to}" overwrite="true"/>
    </target>

    <!--
       - Setup the generating ANT tasks and use it to generate the Java files
       - from the C OpenCL headers.  This involves setting the taskdef and creating
       - the classpath reference id then running the task on each header.
      -->
    <target name="java.generate" depends="build.gluegen, java.generate.check" unless="java.generate.skip">
        <antcall target="preprocess-opencl-headers" inheritRefs="true">
            <param name="opencl.version" value="11" />
        </antcall>
        <antcall target="preprocess-opencl-headers" inheritRefs="true">
            <param name="opencl.version" value="12" />
        </antcall>
        <antcall target="preprocess-opencl-headers" inheritRefs="true">
            <param name="opencl.version" value="20" />
        </antcall>

        <antcall target="java.generate.impl" inheritRefs="true"/>
    </target>

    <target name="java.generate.impl" depends="generate.jdk6.autocloseable, generate.jdk7.autocloseable">

        <!-- Add the GlueGen task to ANT -->
        <taskdef name="gluegen" classname="com.jogamp.gluegen.ant.GlueGenTask" classpathref="gluegen.classpath" />

        <dirset id="stub.includes.fileset.all.11" dir=".">
            <include name="${gen.includes.dir}/CL11"/>
        </dirset>

        <!-- Use the GlueGen task to generate the Java files -->
        <echo message="GlueGen and JOGL stub include path: ${stub.includes.gluegen.all}"/>
        <echo message="OpenCL stub include path for OpenCL version 1.1: ${toString:stub.includes.fileset.all.11}"/>

        <echo message="Generating CL.java from OpenCL version 1.1"/>
        <gluegen src="${stub.includes}/opencl.h"
                 outputRootDir="${build}"
                 config="${config}/cl-if.cfg"
                 includeRefid="stub.includes.fileset.all.11"
                 literalInclude="${stub.includes.gluegen.all}"
                 emitter="com.jogamp.gluegen.JavaEmitter"
                 dumpCPP="false"
                 debug="false">
            <classpath refid="gluegen.classpath" />
        </gluegen>

        <echo message="Generating CL11.java, CLImpl11.java, CLImpl11_JNI.c, and CLProcAddressTable11.java for OpenCL version 1.1"/>
        <gluegen src="${stub.includes}/opencl.h"
                 outputRootDir="${build}"
                 config="${config}/cl-impl-11.cfg"
                 includeRefid="stub.includes.fileset.all.11"
                 literalInclude="${stub.includes.gluegen.all}"
                 emitter="com.jogamp.gluegen.procaddress.ProcAddressEmitter"
                 debug="false">
            <classpath refid="gluegen.classpath" />
        </gluegen>

        <dirset id="stub.includes.fileset.all.12" dir=".">
            <include name="${gen.includes.dir}/CL12"/>
        </dirset>
        <echo message="OpenCL stub include path for OpenCL version 1.2: ${toString:stub.includes.fileset.all.12}"/>
        <echo message="Generating CL12.java, CLImpl12.java, CLImpl12_JNI.c, and CLProcAddressTable12.java for OpenCL version 1.2"/>
        <gluegen src="${stub.includes}/opencl.h"
                 outputRootDir="${build}"
                 config="${config}/cl-impl-12.cfg"
                 includeRefid="stub.includes.fileset.all.12"
                 literalInclude="${stub.includes.gluegen.all}"
                 emitter="com.jogamp.gluegen.procaddress.ProcAddressEmitter"
                 debug="false">
            <classpath refid="gluegen.classpath" />
        </gluegen>

        <dirset id="stub.includes.fileset.all.20" dir=".">
            <include name="${gen.includes.dir}/CL20"/>
        </dirset>
        <echo message="OpenCL stub include path for OpenCL version 2.0: ${toString:stub.includes.fileset.all.20}"/>
        <echo message="Generating CL20.java, CLImpl20.java, CLImpl20_JNI.c, and CLProcAddressTable20.java for OpenCL version 2.0"/>
        <gluegen src="${stub.includes}/opencl.h"
                 outputRootDir="${build}"
                 config="${config}/cl-impl-20.cfg"
                 includeRefid="stub.includes.fileset.all.20"
                 literalInclude="${stub.includes.gluegen.all}"
                 emitter="com.jogamp.gluegen.procaddress.ProcAddressEmitter"
                 debug="false">
            <classpath refid="gluegen.classpath" />
        </gluegen>

        <!-- Inform the user that the generators have successfully created
           - the necessary Java files -->
        <echo message="" />
        <echo message="GlueGen has successfully generated files." />

    </target>

    <!-- ================================================================== -->
    <!--
       - Compile the original and generated source.
      -->
    <target name="java.compile" depends="java.generate">
        <javac destdir="${classes}" 
               includeantruntime="false"
               excludes="${java.part.android}"
               encoding="UTF-8"
               source="${target.sourcelevel}" 
               target="${target.targetlevel}" 
               bootclasspath="${target.rt.jar}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="javac.classpath"/>
            <src path="${src.java}" />
            <src path="${src.generated.java}" />
            <compilerarg value="-Xlint:all"/>
            <!-- suppress warning due to @CLProperty annotation, which is used at runtime but not during compilation -->
            <compilerarg value="-Xlint:-processing"/>
        </javac>
    </target>

    <target name="android.compile" if="android-jars.available">
        <!--compile gluegen-rt-android last-->
        <javac destdir="${classes}" 
               includeantruntime="false"
               encoding="UTF-8"
               source="${target.sourcelevel}" 
               target="${target.targetlevel}" 
               bootclasspath="${target.rt.jar}"
               debug="${javacdebug}" debuglevel="${javacdebuglevel}">
            <classpath refid="javac.android.classpath"/>
            <src path="${src.java}" />
            <src path="${src.generated.java}" />
            <compilerarg value="-Xlint:all"/>
        </javac>
    </target>

    <!-- ================================================================== -->
    <!--
       - Compile the native C code for JOCL.
      -->

    <target name="rename.mingw.dll" if="isMingW">
        <move file="${src}" tofile="${dest}" />
    </target>

    <target name="rename.dylib" if="isOSX">
        <move file="${src}" tofile="${dest}" />
    </target>

    <macrodef name="c.build">
        <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}" />

            <echo message="compiler.cfg.id.base: @{compiler.cfg.id}"/>
            <echo message="linker.cfg.id.base: @{linker.cfg.id}"/>

            <!-- 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>

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

            <cc outtype="shared" 
                objdir="${obj}" 
                outfile="${obj}/@{output.lib.name}"
                optimize="${c.compiler.optimise}" 
                debug="${c.compiler.debug}"
                multithreaded="true" 
                exceptions="false">

                <compiler extends="@{compiler.cfg.id}" >
                    <fileset dir="${project.root}">
                        <include name="${rootrel.generated.c.jocl}11/*.c"/>
                    </fileset>
                    <sysincludepath path="${java.includes.dir}"/>
                    <sysincludepath path="${java.includes.dir.platform}"/>
                    <sysincludepath path="${stub.includes.gluegen.cc}"/>
                    <includepath path="${jogl.root}/make/stub_includes/opengl"/>
                    <includepath path="${gen.includes.dir}/CL11"/>
                    <!-- This is for the generated headers for handwritten C code -->
                    <includepath path="${src.generated.c}" />
                    <includepath path="${src.c}"/>
                </compiler>

                <compiler extends="@{compiler.cfg.id}" >
                    <fileset dir="${project.root}">
                        <include name="${rootrel.generated.c.jocl}12/*.c"/>
                    </fileset>
                    <sysincludepath path="${java.includes.dir}"/>
                    <sysincludepath path="${java.includes.dir.platform}"/>
                    <sysincludepath path="${stub.includes.gluegen.cc}"/>
                    <includepath path="${jogl.root}/make/stub_includes/opengl"/>
                    <includepath path="${gen.includes.dir}/CL12"/>
                    <!-- This is for the generated headers for handwritten C code -->
                    <includepath path="${src.generated.c}" />
                    <includepath path="${src.c}"/>
                </compiler>

                <compiler extends="@{compiler.cfg.id}" >
                    <fileset dir="${project.root}">
                        <include name="${rootrel.generated.c.jocl}20/*.c"/>
                    </fileset>
                    <sysincludepath path="${java.includes.dir}"/>
                    <sysincludepath path="${java.includes.dir.platform}"/>
                    <sysincludepath path="${stub.includes.gluegen.cc}"/>
                    <includepath path="${jogl.root}/make/stub_includes/opengl"/>
                    <includepath path="${gen.includes.dir}/CL20"/>
                    <!-- This is for the generated headers for handwritten C code -->
                    <includepath path="${src.generated.c}" />
                    <includepath path="${src.c}"/>
                </compiler>

                <linker extends="@{linker.cfg.id}" />
            </cc>

            <antcall target="rename.dylib" inheritRefs="true">
                <param name="src"  value="${obj}/lib@{output.lib.name}.dylib" />
                <param name="dest" value="${obj}/lib@{output.lib.name}.jnilib" />
            </antcall>

            <antcall target="rename.mingw.dll" inheritRefs="true">
                <param name="src"  value="${obj}/lib@{output.lib.name}.so" />
                <param name="dest" value="${obj}/@{output.lib.name}.dll" />
            </antcall>
        </sequential>
    </macrodef>

    <target name="c.build.jocl" depends="init, gluegen.cpptasks.detect.os, gluegen.cpptasks.setup.compiler">
        <echo message="compiler.cfg.id.base: ${compiler.cfg.id.base}"/>
        <echo message="linker.cfg.id.base: ${linker.cfg.id.base}"/>
        <c.build compiler.cfg.id="${compiler.cfg.id.base}"
               output.lib.name="jocl"
               linker.cfg.id="${linker.cfg.id.base}"/>

        <antcall target="gluegen.cpptasks.striplibs" inheritRefs="true">
            <param name="libdir" value="../${rootrel.build}/obj"/>
        </antcall>

        <!-- Create Java Web Start jar file from built file -->
        <copy file="joclversion-natives"
          tofile="${build}/tempversion-natives"
          overwrite="true">
            <filterset>
                <filter token="VERSION" value="${jogamp.version}"/>
                <filter token="BUILD_VERSION" value="${jocl.version}"/>
                <filter token="SCM_BRANCH" value="${jocl.build.branch}"/>
                <filter token="SCM_COMMIT" value="${jocl.build.commit}"/>
                <filter token="BASEVERSION" value="${jogamp.version.base}" />
                <filter token="JAR_CODEBASE_TAG" value="${jogamp.jar.codebase}"/>
            </filterset>
        </copy>
        <native.tag.jar objdir="${build}/obj"
                        nativejarfile="${build}/jar/jocl-natives-${os.and.arch}.jar"
                        manifestfile="${build}/tempversion-natives" 
                        module="opencl"
                        includelibs="*jocl.${native.library.suffix}" />

        <!-- Produce duplicates for different configurations, since non-native-jar aliasing (Bug 1023/Bug 1024) -->
        <copy file="${build}/jar/jocl-natives-${os.and.arch}.jar" tofile="${build}/jar/jocl-android-natives-${os.and.arch}.jar"/>
    </target>

    <!-- ================================================================== -->
    <!--
       - Build the jocl.jar file.
      -->
    <target name="jar" depends="init">
        <!-- Prepare the manifest -->
        <copy file="joclversion"
          tofile="${build}/tempversion"
          overwrite="true">
            <filterset>
                <filter token="VERSION" value="${jogamp.version}"/>
                <filter token="BUILD_VERSION" value="${jocl.version}"/>
                <filter token="SCM_BRANCH" value="${jocl.build.branch}"/>
                <filter token="SCM_COMMIT" value="${jocl.build.commit}"/>
                <filter token="BASEVERSION" value="${jogamp.version.base}" />
                <filter token="JAR_CODEBASE_TAG" value="${jogamp.jar.codebase}"/>
            </filterset>
        </copy>

        <!-- Build the jar excluding any build specific classes. -->
        <jar manifest="${build}/tempversion" destfile="${jocl.jar}" filesonly="true">
            <fileset dir="${classes}">
                <include name="com/jogamp/opencl/**" />
                <include name="jogamp/opencl/**" />
                <exclude name="${java.part.android}" />
            </fileset>
            <fileset dir="resources/assets">
                <include name="**" />
            </fileset>
        </jar>

        <jar manifest="${build}/tempversion" destfile="${jocl-android.jar}" filesonly="true">
            <fileset dir="${classes}">
                <include name="com/jogamp/opencl/**" />
                <include name="jogamp/opencl/**" />
            </fileset>
            <fileset dir="resources/assets">
                <include name="**" />
            </fileset>
        </jar>

        <antcall target="android.package" inheritRefs="true" />
    </target>

    <target name="jocl.build.check.aapt" depends="init">
        <uptodate property="jocl.build.skip.aapt">
          <srcfiles dir= "."                includes="*.xml"/>
          <srcfiles dir= "${src.java}"      includes="**"/>
          <srcfiles dir= "${src.generated}" includes="**"/>
          <mapper type="merge" to="${build}/jar/jocl-${os.and.arch}.apk"/>
        </uptodate>
    </target>

    <target name="android.package" depends="init,jocl.build.check.aapt" if="isAndroid" unless="jocl.build.skip.aapt" >
        <aapt.signed 
            assetsdir="resources/assets"
            jarsrcdir="${src.java}"
            jarbuilddir="${build}/jar"
            jarbasename="jocl-android"
            nativebuilddir="../${rootrel.build}/obj"
            nativebasename="jocl"
            android.abi="${android.abi}"
            androidmanifest.path="resources/android/AndroidManifest-jocl.xml"
            androidresources.path="resources/android/res-jocl"
            jarmanifest.path="${build}/tempversion"
            version.code="${jogamp.version.int}"
            version.name="${jogamp.version}" />
    </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, javadoc.init, javadoc.public, javadoc.dev, javadoc.zip"/>

    <!-- copies ${gluegen-javadoc.path}/** to ${javadoc.root.path}/gluegen/ 
         gluegen-javadoc.path is the parent folder of package-list:
            gluegen-javadoc.path := build/javadoc/gluegen 
            with build/javadoc/gluegen/javadoc/package-list
      -->
    <target name="javadoc.gluegen" depends="init" if="gluegen-javadoc.path">
        <delete dir="${javadoc.root.path}/gluegen" includeEmptyDirs="true" quiet="true" failonerror="false" />
        <mkdir dir="${javadoc.root.path}/gluegen" />

        <copy todir="${javadoc.root.path}/gluegen" failonerror="false">
            <fileset dir="${gluegen-javadoc.path}" includes="**" />
        </copy>
    </target>

    <target name="javadoc.init" depends="init">
        <!-- property name="javadoc.link" value="http://java.sun.com/j2se/1.4.2/docs/api/" /-->
        <!-- property name="javadoc.link" value="http://download.oracle.com/javase/1.5.0/docs/api/" /-->
        <property name="javadoc.link" value="http://docs.oracle.com/javase/6/docs/api/" />

        <!-- Link offline with relative URLs does not work.
             Link online with relative URLs works, 
             so we have to assume the same relative online folder structure:

                 http://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/
                 http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/
                 http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc_dev/
                 http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc_jogl_spec/
                 http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc_nativewindow_spec/

             gluegen rel URL: ../../gluegen/javadoc

             build structure:

                 jogl.root:    build/javadoc/jogl/<javadoc-type>  (we have javadoc, javadoc_dev and javadoc_jogl_spec, ..)
                 gluegen.root: build/javadoc/gluegen/javadoc

            to match the online gluegen rel URL, we need:

                 jogl.root:    build/javadoc/gluegen/javadoc
          -->
        <property name="gluegen.link" value="../../gluegen/javadoc" />
        <property name="javadoc.root.path" value="${build}/javadoc" />
        <property name="javadoc.jocl.public.path" value="${javadoc.root.path}/jocl/javadoc" />
        <property name="javadoc.jocl.dev.path"    value="${javadoc.root.path}/jocl/javadoc_dev" />

        <property name="javadoc.packagenames" value="com.jogamp.opencl.*" />
        <property name="javadoc.dev.packagenames" value="${javadoc.packagenames},jogamp.opencl.*" />

        <!-- if gluegen-javadoc.path is not set, check in default location, 
             ${gluegen.root}/${rootrel.build}/javadoc/gluegen -->
        <available file="${gluegen.build}/javadoc/gluegen/javadoc/package-list" 
                   type="file"
                   property="gluegen-javadoc.path"
                   value="${gluegen.build}/javadoc/gluegen" />
        <antcall target="javadoc.gluegen" inheritRefs="true" />
    </target>

    <target name="javadoc.zip" depends="javadoc.init">
        <archive.7z destfile="${build}/javadoc.7z"
                    basedir="${javadoc.root.path}"
                    includes="jocl/**" />
    </target>

    <target name="javadoc.public" depends="javadoc.init">
        <javadoc packagenames="${javadoc.packagenames}"
                 sourcepath="${src.java};${src.generated.java}"
                 destdir="${javadoc.jocl.public.path}" windowtitle="JOCL API"
                 encoding="UTF-8"
                 source="${target.sourcelevel}"
                 maxmemory="${javac.memorymax}"
                 stylesheetfile="${gluegen.make.dir}/doc/javadoc/stylesheet.css">
            <classpath refid="jocl_all.classpath"/>
            <link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
            <link offline="false" href="${gluegen.link}" />
            <arg value="${javadoc.xarg1}"/>
        </javadoc>
        <copy todir="${javadoc.jocl.public.path}/resources" overwrite="true">
            <fileset dir="${gluegen.make.dir}/doc/javadoc/resources" includes="*" />
        </copy>
    </target>

    <target name="javadoc.dev" depends="javadoc.init">
        <!-- Build the internal developer Javadoc -->
        <javadoc packagenames="${javadoc.dev.packagenames},${javadoc.dev.packagenames.platform}"
                 sourcepath="${src.java};${src.generated.java}"
                 destdir="${javadoc.jocl.dev.path}" windowtitle="JOCL API"
                 encoding="UTF-8"
                 source="${target.sourcelevel}"
                 maxmemory="${javac.memorymax}"
                 stylesheetfile="${gluegen.make.dir}/doc/javadoc/stylesheet.css">
            <classpath refid="jocl_all.classpath"/>
            <link offline="true" href="${javadoc.link}" packagelistLoc="${gluegen.root}/make/142-packages" />
            <link offline="false" href="${gluegen.link}" />
            <arg value="${javadoc.xarg1}"/>
        </javadoc>
        <copy todir="${javadoc.jocl.dev.path}/resources" overwrite="true">
            <fileset dir="${gluegen.make.dir}/doc/javadoc/resources" includes="*" />
        </copy>
    </target>

    <target name="developer-src-zip" depends="init">
        <!--delete includeEmptyDirs="true" quiet="true" failonerror="false">
            <fileset dir="${build}" includes="jocl-java-src.zip" />
        </delete-->
        <zip destfile="${build}/jocl-java-src.zip">
            <fileset dir="${src.java}"/>
            <fileset dir="${build}/gensrc"/>
        </zip>
    </target>

    <!-- Build binary zip archives for developers -->
    <target name="developer-zip-archive" depends="init,developer-src-zip" if="build.archiveon">
        <!-- Clean up and create temporary directory -->
        <delete includeEmptyDirs="true" quiet="true" dir="${archive}" failonerror="false" />
        <mkdir dir="${archive}" />
        <copy file="${build}/artifact.properties" todir="${archive}"/>
        <mkdir dir="${archive}/jar" />
        <copy todir="${archive}/jar">
            <fileset dir="${build}/jar" includes="jocl*.jar"/>
            <fileset dir="${build}/jar" includes="jocl*.apk"/>
        </copy>
        <mkdir dir="${archive}/lib" />
        <copy todir="${archive}/lib">
            <fileset dir="${build}/obj" includes="*.${native.library.suffix}"/>
        </copy>
        <mkdir dir="${archive}/jnlp-files" />
        <copy todir="${archive}/jnlp-files">
            <fileset dir="${project.root}/jnlp-files" includes="*" />
        </copy>
        <mkdir dir="${archive}/www" />
        <copy todir="${archive}/www">
            <fileset dir="${project.root}/www" includes="*" />
        </copy>
        <copy file="../README.txt" todir="${archive}"/>
        <copy file="../LICENSE.txt" todir="${archive}"/>
        <copy todir="${archive}" file="${build}/jocl-java-src.zip"/>
        <archive.7z destfile="${build}/${archive.name}.7z"
             basedir="${build}"
             includes="${archive.name}/**" />
        <!-- Clean up after ourselves -->
        <delete includeEmptyDirs="true" quiet="true" dir="${archive}" failonerror="false" />
    </target>

    <!-- ================================================================== -->
    <!--
       - Clean up all that is built.
      -->
    <target name="clean" depends="init">
        <delete includeEmptyDirs="true" quiet="true">
            <fileset dir="${build}" />
            <fileset dir="${javadoc}" />
            <fileset dir="${javadoc.dev}" />
            <fileset dir="${gen.includes}" />
        </delete>
        <ant antfile="build-test.xml" target="clean"/>
    </target>

    <!-- ================================================================== -->
    <!--
       - Build everything.
      -->
    <target name="all" description="Release build" depends="jocl.build, test.compile, tag.build, developer-zip-archive"/>
    <target name="all.debug" description="Debug build" depends="set.debug, jocl.build, test.compile, tag.build, developer-zip-archive"/>
    <target name="all.ide" description="Debug IDE build, no tagging or archives" depends="set.debug, jocl.build, test.compile"/>

    <target name="jocl.build" depends="init">
        <!-- Generate and compile the Java sources. -->
        <antcall target="java.compile" inheritRefs="true" />
        <antcall target="android.compile" inheritRefs="true" />

        <!-- Compile the native C sources . -->
        <antcall target="c.build.jocl" inheritRefs="true" />

        <!-- build the jar/apk -->
        <antcall target="jar" inheritRefs="true" />
    </target>

    <target name="tag.build" depends="init">
        <copy file="${gluegen.build}/artifact.properties" todir="${build}" overwrite="true" failonerror="false"/>
        <echo message='jocl.build.version=${jogamp.version}${line.separator}'   file="${build}/artifact.properties" append="true"/>
        <echo message='jocl.build.number=${jocl.build.number}${line.separator}' file="${build}/artifact.properties" append="true"/>
        <echo message='jocl.build.id=${jocl.build.id}${line.separator}'         file="${build}/artifact.properties" append="true"/>
        <echo message='jocl.build.branch=${jocl.build.branch}${line.separator}' file="${build}/artifact.properties" append="true"/>
        <echo message='jocl.build.commit=${jocl.build.commit}${line.separator}' file="${build}/artifact.properties" append="true"/>
    </target>

    <!-- ================================================================== -->
    <!--
       - unit tests
      -->

    <target name="test.compile" depends="jocl.build">
        <ant antfile="build-test.xml" target="test.compile" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="test.auto.run" depends="test.compile">
        <ant antfile="build-test.xml" target="test.auto.run" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="junit.run" depends="test.compile">
        <ant antfile="build-test.xml" target="junit.run" inheritRefs="true" inheritAll="true"/>
    </target>

    <target name="test.manual.run" depends="test.compile">
        <ant antfile="build-test.xml" target="test.manual.run" inheritRefs="true" inheritAll="true"/>
    </target>

</project>