summaryrefslogtreecommitdiffstats
path: root/make/build.xml
blob: 978ab1b9e15d11cdcfe131a346bb938b193174e1 (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
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
<?xml version="1.0" encoding="UTF-8"?>
<!--
   - Ant build for JOGL.  This build has been tested with ANT 1.5.3.  The
   - optional.jar that contains the optional ANT tasks must be in the ANT
   - classpath (typically the ant/lib directory).
   -
   - A clean download of JOGL 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.
   -
   - All targets do the following:
   -   Build the ancillary Ant tasks.
   -   Generate the Java and C files.
   -   Compile all sources.
   -   Create the jogl.jar and platform library.
   - Public targets:
   -   linux
   -   macosx
   -   solaris
   -   win32.vc6
   -   win32.vc7
   -   win32.mingw:  build everything (jar, DSOs) for the current platform
   -   clean:        clean all built
   -   javadoc:      create the standard developer Javadoc
   -   javadoc.dev.win32:
   -   javadoc.dev.x11:
   -   javadoc.dev.macosx: 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.
   -
   - Optional properties:
   -   -Djogl.cg=1 when combined with the build or javadoc targets will cause
   -   the experimental binding to NVidia's Cg language to be built.
   -
   - 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.
   -->
<project name="JOGL" basedir="." default="all">
    
    <!-- ================================================================== -->
    <!-- 
       - Base initialization.
      -->
    <target name="base.init">
        <!-- Set the project root directory to be up one directory. -->
        <property name="project.root" value=".." />
    
        <!-- Set the configuration and build files to this directory. -->
        <property name="make" value="." />
    </target>


    <!-- ================================================================== -->
    <!-- 
       - Load user properties which override build defaults.
      -->
    <target name="load.user.properties" depends="base.init">
        <!-- Load the user specified properties file that defines various host
           - specific paths.  The user will be notified if this is does not
           - exist. -->
        <property name="user.properties.file" value="${user.home}/jogl.properties" />
        <property file="${user.properties.file}" />
        <echo message="Loaded ${user.properties.file}." />
        <echo message="antlr.jar=${antlr.jar}" />
    </target>
    <target name="load.user.properties.macosx" depends="base.init">
        <!-- Load the user specified properties file that defines various host
           - specific paths.  The user will be notified if this is does not
           - exist. -->
        <property name="user.properties.file" value="${user.home}/jogl.properties" />
        <property file="${user.properties.file}" />
        <echo message="Loaded ${user.properties.file}." />
        <echo message="antlr.jar=${antlr.jar}" />
    </target>

    <!-- ================================================================== -->
    <!-- 
       - Set up java.home.dir appropriately on all platforms.
      -->
    <target name="setup.java.home.dir.nonmacosx" depends="load.user.properties" unless="java.home.dir">
        <property name="java.home.dir" value="${java.home}/.." />
    </target>
    <target name="setup.java.home.dir.macosx" depends="load.user.properties.macosx" unless="java.home.dir">
        <property name="java.home.dir" value="/System/Library/Frameworks/JavaVM.framework/Home" />
    </target>


    <!-- ================================================================== -->
    <!-- 
       - Declare all paths and user defined variables.
      -->
    <target name="declare" description="Declare properties" depends="base.init">
        <!-- Shorthand for file.separator -->
        <property name="sep" value="${file.separator}" />

        <!-- 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" />
           
        <!-- The GlueGen and BuildStaticGLInfo build files. -->
        <property name="gluegen.build.xml" value="${make}/build-gluegen.xml" />
        <property name="static.gl.build.xml" value="${make}/build-staticglgen.xml" />
                                                
        <!-- 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.c" value="${rootrel.src}${sep}native${sep}jogl" />
        <property name="rootrel.build" value="build" />
        <property name="rootrel.src.generated" value="${rootrel.build}${sep}gensrc" />
        <property name="rootrel.generated.java" value="${rootrel.src.generated}${sep}classes" />
        <property name="rootrel.generated.c.jogl" value="${rootrel.src.generated}${sep}native${sep}jogl" />
        <property name="rootrel.generated.c.cg" value="${rootrel.src.generated}${sep}native${sep}jogl_cg" />
        <property name="rootrel.obj" value="${rootrel.build}${sep}obj" />
        <property name="rootrel.obj.jogl" value="${rootrel.obj}${sep}jogl" />
        <property name="rootrel.obj.cg" value="${rootrel.obj}${sep}jogl_cg" />

        <!-- The source directories. -->
        <property name="src"   value="${project.root}/${rootrel.src}" />
        <property name="src.c" value="${project.root}/${rootrel.src.c}" />
        <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}/classes" />
        <property name="src.generated.java.cg" value="${src.generated}/classes/net/java/games/cg" />
        <property name="src.generated.c" value="${src.generated}/native/jogl" />
        <property name="src.generated.c.cg" value="${src.generated}/native/jogl_cg" />
        <!-- The composable pipeline source files -->
        <property name="src.generated.java.pipeline"
                  value="net/java/games/jogl/DebugGL.java,net/java/games/jogl/TraceGL.java" />
        
        <!-- The compiler output directories. -->
        <property name="classes" value="${build}/classes" />
        <property name="obj"      value="${project.root}/${rootrel.obj}" />
        <property name="obj.jogl" value="${project.root}/${rootrel.obj.jogl}" />
        <property name="obj.cg"   value="${project.root}/${rootrel.obj.cg}" />

        <!-- The GL headers from which Java files are generated -->
        <property name="config" value="${project.root}/make" />
        <property name="stub.includes" value="${config}/stub_includes" />
        <property name="stub.includes.dir" value="stub_includes" /> <!-- NOTE:  this MUST be relative for FileSet -->
        <property name="stub.includes.x11" value="${stub.includes}/x11" />
        <property name="stub.includes.opengl" value="${stub.includes}/opengl" />
        <property name="stub.includes.common" value="${stub.includes}/common" />
        <dirset id="stub.includes.fileset.all" dir=".">
            <include name="${stub.includes.dir}/opengl/**" />
            <include name="${stub.includes.dir}/macosx/**" />
            <include name="${stub.includes.dir}/win32/**" />
            <include name="${stub.includes.dir}/x11/**" />
        </dirset>
        <fileset id="stub.includes.dependencies.fileset" dir=".">
            <include name="${stub.includes.dir}/opengl/**" />
            <include name="${stub.includes.dir}/macosx/**" />
            <include name="${stub.includes.dir}/win32/**" />
            <include name="${stub.includes.dir}/x11/**" />
            <include name="*.cfg" />
            <include name="*.java" />
            <include name="*.c" />
            <exclude name="cg-common.cfg" />
        </fileset>
        <dirset id="stub.includes.cg.fileset.all" dir=".">
            <include name="${stub.includes.dir}/opengl/**" />
            <include name="${stub.includes.dir}/cg/**" />
            <include name="${stub.includes.dir}/macosx/**" />
            <include name="${stub.includes.dir}/win32/**" />
            <include name="${stub.includes.dir}/x11/**" />
        </dirset>
        <fileset id="stub.includes.cg.dependencies.fileset" dir=".">
            <include name="${stub.includes.dir}/cg/**" />
            <include name="cg-common.cfg" />
        </fileset>

        <property name="java.includes.dir" value="${java.home.dir}/include" /> <!-- NOTE:  this MUST be relative for FileSet -->
        <property name="java.includes.dir.win32" value="${java.includes.dir}/win32" />
        <property name="java.includes.dir.linux" value="${java.includes.dir}/linux" />
        <property name="java.includes.dir.solaris" value="${java.includes.dir}/solaris" />
        <property name="java.includes.dir.macosx" value="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" />
        <property name="java.lib.dir.win32" value="${java.home.dir}/lib" />
        <property name="java.lib.dir.linux" value="${java.home.dir}/jre/lib/i386" />
	<condition property="cpu" value="sparc">
            <os name="SunOS" arch="sparc" />
        </condition>
	<condition property="cpu" value="i386">
            <os name="SunOS" arch="x86" />
        </condition>
        <property name="java.lib.dir.solaris" value="${java.home.dir}/jre/lib/${cpu}" />
        <property name="java.lib.dir.macosx" value="/System/Library/Frameworks/JavaVM.framework/Libraries" />
        <property name="gl.headers" value="${stub.includes.dir}/opengl/**/*.h" /> <!-- NOTE:  this MUST be relative for FileSet --> <!-- CHECK:  this may need to be pruned for each platform -->

        <!-- Java files to exclude based on platform (relative to "src") -->
        <property name="java.excludes.win32" value="net/java/games/jogl/impl/x11/**, net/java/games/jogl/impl/macosx/**" />
        <property name="java.excludes.x11" value="net/java/games/jogl/impl/windows/**, net/java/games/jogl/impl/macosx/**" />
        <property name="java.excludes.macosx" value="net/java/games/jogl/impl/x11/**, net/java/games/jogl/impl/windows/**" />

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

        <!-- The resulting jogl.jar. -->
        <property name="jogl.jar" value="${build}/jogl.jar" />

        <!-- The javadoc dirs. -->
        <property name="javadoc" value="${project.root}/javadoc_public" />
        <property name="javadoc.dev" value="${project.root}/javadoc_jogl_dev" />
        <property name="javadoc.link" value="http://java.sun.com/j2se/1.4.2/docs/api/" />
        <property name="javadoc.packagenames" value="net.java.games.jogl,net.java.games.gluegen.runtime,net.java.games.jogl.util" />
        <property name="javadoc.dev.packagenames.win32"  value="net.java.games.jogl.impl.windows" />
        <property name="javadoc.dev.packagenames.x11"    value="net.java.games.jogl.impl.x11" />
        <property name="javadoc.dev.packagenames.macosx" value="net.java.games.jogl.impl.macosx" />
        <property name="javadoc.dev.packagenames" value="net.java.games.jogl,net.java.games.jogl.impl,net.java.games.jogl.util,net.java.games.gluegen" />
        
    </target>
    
    <!-- ================================================================== -->
    <!--
       - Platform specific declares.
      -->
    <target name="declare.win32" depends="init">
        <!-- Set platform configuration files. -->
        <property name="gl.cfg" value="${config}/gl-win32.cfg" />
        <property name="gl.impl.cfg" value="${config}/gl-impl-win32.cfg" />
        <property name="glu.cfg" value="${config}/glu.cfg" />
        <property name="glu.impl.cfg" value="${config}/glu-impl-win32.cfg" />
        <property name="jawt.cfg" value="${config}/jawt-win32.cfg" />
        <property name="window.cfg" value="${config}/wingdi-win32.cfg" />

        <!-- Set platform directories. -->
        <property name="stub.includes.platform" value="${stub.includes}/win32" />
        <property name="java.includes.dir.platform" value="${java.includes.dir.win32}" />
        <property name="java.lib.dir.platform" value="${java.lib.dir.win32}" />
        <property name="java.excludes.platform" value="${java.excludes.win32}" />
	<property name="stub.includes.fileset.platform.params" value="${stub.includes.dir}/win32/**" />

        <!-- Set Javadoc properties. -->
        <property name="javadoc.dev.packagenames.platform" value="${javadoc.dev.packagenames.win32}" />
    </target>

    <target name="declare.win32.vc.common">
        <property name="c.compiler" value="cl.exe" />
        <property name="c.compiler.flags" value="${c.compiler.optflags} /nologo /TC /c" />
        <property name="c.compiler.obj.suffix" value="obj" />
	<property name="c.compiler.jogl.outputfile.expr" value="/Fo${rootrel.obj.jogl}/*.${c.compiler.obj.suffix}" />
	<property name="c.compiler.includes" value="/I&quot;make/stub_includes/opengl&quot; /I&quot;${c.compiler.include.root}/PlatformSDK/Include&quot; /I&quot;${c.compiler.include.root}/include&quot; /I&quot;${java.includes.dir}&quot; /I&quot;${java.includes.dir.platform}&quot; /I&quot;make/stub_includes/cg&quot;" />
        <property name="c.linker" value="link.exe" />
        <property name="c.linker.flags" value="/DLL /LIBPATH:&quot;${c.linker.lib.root}/PlatformSDK/lib&quot; /LIBPATH:&quot;${c.linker.lib.root}/lib&quot; /LIBPATH:&quot;${java.lib.dir.platform}&quot; /INCREMENTAL:NO /NOLOGO /MACHINE:IX86 /OPT:REF /OPT:ICF /SUBSYSTEM:WINDOWS" />
        <property name="c.linker.jogl.libs" value="opengl32.lib glu32.lib jawt.lib gdi32.lib kernel32.lib" />
        <property name="rootrel.c.linker.jogl.dso" value="${rootrel.obj}/jogl.dll" />
        <property name="c.linker.jogl.dso" value="${project.root}/${rootrel.c.linker.jogl.dso}" />
        <property name="c.linker.jogl.flags" value="/OUT:&quot;${c.linker.jogl.dso}&quot;" />
        <!-- Cg declarations -->
	<property name="c.compiler.cg.outputfile.expr" value="/Fo${rootrel.obj.cg}/*.${c.compiler.obj.suffix}" />
        <property name="c.linker.cg.libs" value="opengl32.lib cg.lib cgGL.lib /LIBPATH:&quot;${windows.cg.lib}&quot;" />
        <property name="rootrel.c.linker.cg.dso" value="${rootrel.obj}/jogl_cg.dll" />
        <property name="c.linker.cg.dso" value="${project.root}/${rootrel.c.linker.cg.dso}" />
        <property name="c.linker.cg.flags" value="/OUT:&quot;${c.linker.cg.dso}&quot;" />
    </target>

    <target name="declare.win32.vc6.debug" if="debug">
	<!-- FIXME: put in debug flags -->
        <property name="c.compiler.optflags"   value="/MD /W3 /O2 /Ob1 /GF /Gy" />
    </target>
    <target name="declare.win32.vc6.optimized" unless="debug">
        <property name="c.compiler.optflags"   value="/MD /W3 /O2 /Ob1 /GF /Gy" />
    </target>

    <target name="declare.win32.vc6.pre" depends="declare.win32,declare.win32.vc6.debug,declare.win32.vc6.optimized">
	<property name="c.compiler.include.root" value="${vc6.root}" />
	<property name="c.linker.lib.root" value="${vc6.root}" />
    </target>

    <target name="declare.win32.vc6" depends="declare.win32.vc6.pre, declare.win32.vc.common" />
    
    <target name="declare.win32.vc7.debug" if="debug">
        <property name="c.compiler.optflags" value="/MDd /Yd /GS /RTCs /RTCu /RTCc /W3 /Od /GF /EHsc /Zi /GS /Gy /Wp64 /Zi /D &quot;_DEBUG&quot;" />
    </target>
    <target name="declare.win32.vc7.optimized" unless="debug">
        <property name="c.compiler.optflags"   value="/MD /W3 /O2 /Ob1 /GF /EHsc /GS /Gy /Wp64 /D &quot;NDEBUG&quot;" />
    </target>

    <target name="declare.win32.vc7.pre" depends="declare.win32,declare.win32.vc7.debug,declare.win32.vc7.optimized">
	<property name="c.compiler.include.root" value="${vc7.root}" />
	<property name="c.linker.lib.root" value="${vc7.root}" />
    </target>

    <target name="declare.win32.vc7" depends="declare.win32.vc7.pre, declare.win32.vc.common" />

    <target name="declare.win32.mingw" depends="declare.win32">
        <property name="c.compiler" value="gcc.exe" />
        <property name="c.compiler.optflags" value="-O3" />
        <property name="c.compiler.flags" value="${c.compiler.optflags} -c -DBUILD_DLL -D_WINGDI_ -D_STRICT_ANSI -D_JNI_IMPLEMENTATION_ -o" />
        <property name="c.compiler.obj.suffix" value="o" />
	<property name="c.compiler.jogl.outputfile.expr" value="${rootrel.obj.jogl}/*.${c.compiler.obj.suffix}" />
	<property name="c.compiler.includes" value="-I&quot;make/stub_includes/opengl&quot; -I&quot;${java.includes.dir}&quot; -I&quot;${java.includes.dir.platform}&quot; -I&quot;make/stub_includes/cg&quot;" />
        <property name="c.linker" value="gcc.exe" />
        <property name="c.linker.flags" value="-shared" />
        <property name="c.linker.jogl.libs" value="-Wl,--kill-at -L&quot;${java.lib.dir.platform}&quot; -lopengl32 -lglu32 -ljawt -lgdi32" />
        <property name="rootrel.c.linker.jogl.dso" value="${rootrel.obj}/jogl.dll" />
        <property name="c.linker.jogl.dso" value="${project.root}/${rootrel.c.linker.jogl.dso}" />
        <property name="c.linker.jogl.flags" value="-o ${c.linker.jogl.dso}" />
        <!-- Cg declarations -->
	<property name="c.compiler.cg.outputfile.expr" value="${rootrel.obj.cg}/*.${c.compiler.obj.suffix}" />
        <property name="c.linker.cg.libs" value="-Wl,--kill-at -L&quot;${windows.cg.lib}&quot; -lopengl32 -lCg -lCgGL" />
        <property name="rootrel.c.linker.cg.dso" value="${rootrel.obj}/jogl_cg.dll" />
        <property name="c.linker.cg.dso" value="${project.root}/${rootrel.c.linker.cg.dso}" />
        <property name="c.linker.cg.flags" value="-o ${c.linker.cg.dso}" />
    </target>

    <target name="declare.x11" depends="init">
        <!-- Set platform configuration files. -->
        <property name="gl.cfg" value="${config}/gl-x11.cfg" />
        <property name="gl.impl.cfg" value="${config}/gl-impl-x11.cfg" />
        <property name="glu.cfg" value="${config}/glu.cfg" />
        <property name="glu.impl.cfg" value="${config}/glu-impl-x11.cfg" />
        <property name="jawt.cfg" value="${config}/jawt-x11.cfg" />
        <property name="window.cfg" value="${config}/glx-x11.cfg" />

        <!-- Set platform directories. -->
        <property name="stub.includes.platform" value="${stub.includes.x11}" />
        <property name="java.excludes.platform" value="${java.excludes.x11}" />
	<property name="stub.includes.fileset.platform.params" value="${stub.includes.dir}/opengl/** ${stub.includes.dir}/x11/**" />

        <!-- Set Javadoc properties. -->
        <property name="javadoc.dev.packagenames.platform" value="${javadoc.dev.packagenames.x11}" />
    </target>

    <target name="declare.linux" depends="declare.x11">
        <property name="java.includes.dir.platform" value="${java.includes.dir.linux}" />
        <property name="java.lib.dir.platform" value="${java.lib.dir.linux}" />

        <!-- Set up gcc -->
        <property name="c.compiler" value="gcc" />
        <property name="c.compiler.optflags" value="-O2" />
        <property name="c.compiler.flags" value="${c.compiler.optflags} -c -o" />
        <property name="c.compiler.obj.suffix" value="o" />
	<property name="c.compiler.jogl.outputfile.expr" value="${rootrel.obj.jogl}/*.${c.compiler.obj.suffix}" />
	<property name="c.compiler.includes" value="-I&quot;make/stub_includes/opengl&quot; -I&quot;${java.includes.dir}&quot; -I&quot;${java.includes.dir.platform}&quot; -I&quot;make/stub_includes/cg&quot;" />
        <property name="c.linker" value="gcc" />
        <property name="c.linker.flags" value="-shared" />
        <property name="c.linker.jogl.libs" value="-L&quot;${java.lib.dir.platform}&quot; -ljawt -lGL -lGLU" />
        <property name="rootrel.c.linker.jogl.dso" value="${rootrel.obj}/libjogl.so" />
        <property name="c.linker.jogl.dso" value="${project.root}/${rootrel.c.linker.jogl.dso}" />
        <property name="c.linker.jogl.flags" value="-o ${c.linker.jogl.dso}" />
        <!-- Cg declarations -->
	<property name="c.compiler.cg.outputfile.expr" value="${rootrel.obj.cg}/*.${c.compiler.obj.suffix}" />
        <property name="c.linker.cg.libs" value="-L&quot;${x11.cg.lib}&quot; -lCg -lCgGL -lGL" />
        <property name="rootrel.c.linker.cg.dso" value="${rootrel.obj}/libjogl_cg.so" />
        <property name="c.linker.cg.dso" value="${project.root}/${rootrel.c.linker.cg.dso}" />
        <property name="c.linker.cg.flags" value="-o ${c.linker.cg.dso}" />
    </target>

    <target name="declare.solaris" depends="declare.x11">
        <property name="java.includes.dir.platform" value="${java.includes.dir.solaris}" />
        <property name="java.lib.dir.platform" value="${java.lib.dir.solaris}" />

        <!-- Set up Solaris CC -->
        <property name="c.compiler" value="cc" />
        <property name="c.compiler.optflags" value="-xO0 -KPIC" />
        <property name="c.compiler.flags" value="${c.compiler.optflags} -c -o" />
        <property name="c.compiler.obj.suffix" value="o" />
	<property name="c.compiler.jogl.outputfile.expr" value="${rootrel.obj.jogl}/*.${c.compiler.obj.suffix}" />
	<property name="c.compiler.includes" value="-I&quot;make/stub_includes/opengl&quot; -I&quot;${java.includes.dir}&quot; -I&quot;${java.includes.dir.platform}&quot;" />
        <property name="c.linker" value="cc" />
        <property name="c.linker.flags" value="-G" />
        <property name="c.linker.jogl.libs" value="-L&quot;${java.lib.dir.platform}&quot; -ljawt -lGL -lGLU" />
        <property name="rootrel.c.linker.jogl.dso" value="${rootrel.obj}/libjogl.so" />
        <property name="c.linker.jogl.dso" value="${project.root}/${rootrel.c.linker.jogl.dso}" />
        <property name="c.linker.jogl.flags" value="-o ${c.linker.jogl.dso}" />
    </target>

    <target name="declare.macosx" depends="init">
        <echo message="*************************************" />
        <echo message="*                                   *" />
        <echo message="*     EXECUTING DECLARE.MACOSX      *" />
        <echo message="*                                   *" />
        <echo message="*************************************" />

        <!-- Set platform configuration files. -->
        <property name="gl.cfg" value="${config}/gl-macosx.cfg" />
        <property name="gl.impl.cfg" value="${config}/gl-impl-macosx.cfg" />
        <property name="glu.cfg" value="${config}/glu.cfg" />
        <property name="glu.impl.cfg" value="${config}/glu-impl-macosx.cfg" />
        <property name="jawt.cfg" value="${config}/jawt-macosx.cfg" />
        <property name="window.cfg" value="${config}/cgl-macosx.cfg" />
        <property name="is.macosx" value="true" />

        <!-- Set platform directories. -->
        <property name="stub.includes.platform" value="${stub.includes}/macosx" />
        <property name="java.includes.dir.platform" value="${java.includes.dir.macosx}" />
        <property name="java.lib.dir.platform" value="${java.lib.dir.macosx}" />
        <property name="java.excludes.platform" value="${java.excludes.macosx}" />
	<property name="stub.includes.fileset.platform.params" value="${stub.includes.dir}/macosx/**" />

        <!-- Set Javadoc properties. -->
        <property name="javadoc.dev.packagenames.platform" value="${javadoc.dev.packagenames.macosx}" />

        <!-- Set up gcc -->
        <property name="c.compiler" value="gcc" />
        <property name="c.compiler.optflags" value="-fast -mcpu=7450 -arch ppc -Dmacosx -fPIC" />
		<!-- Note: specifying -ObjC for all files is sloppy (only needed for      -->
		<!-- JAWT-related .c files) but this doesn't break anything and is easier -->
		<!-- than rewriting the whole Makefile                                    -->
        <property name="c.compiler.flags" value="${c.compiler.optflags} -fno-common -fpascal-strings  -Wmost -ObjC -c -o" />
        <property name="c.compiler.obj.suffix" value="o" />
		<property name="c.compiler.jogl.outputfile.expr" value="${rootrel.obj.jogl}/*.${c.compiler.obj.suffix}" />
		<property name="c.compiler.includes" value="-I&quot;make/stub_includes/opengl&quot; -I&quot;${java.includes.dir}&quot; -I&quot;${java.includes.dir.platform}&quot; -I&quot;make/stub_includes/cg&quot;" />
        <property name="c.linker" value="gcc" />
        <property name="c.linker.flags" value="-arch ppc -prebind -Wl,-single_module -dynamiclib -compatibility_version 1 -current_version 1 -prebind_all_twolevel_modules" />
        <property name="c.linker.jogl.libs" value="-L&quot;${java.lib.dir.platform}&quot; -framework Cocoa -framework OpenGL -ljawt" />
        <property name="rootrel.c.linker.jogl.dso" value="${rootrel.obj}/libjogl.jnilib" />
        <property name="c.linker.jogl.dso" value="${project.root}/${rootrel.c.linker.jogl.dso}" />
        <property name="c.linker.jogl.flags" value="-o ${c.linker.jogl.dso}" />
        <!-- Cg declarations -->
		<property name="c.compiler.cg.outputfile.expr" value="${rootrel.obj.cg}/*.${c.compiler.obj.suffix}" />
        <property name="c.linker.cg.libs" value="-framework OpenGL -lCg -lCgGL" />
        <property name="rootrel.c.linker.cg.dso" value="${rootrel.obj}/libjogl_cg.jnilib" />
        <property name="c.linker.cg.dso" value="${project.root}/${rootrel.c.linker.cg.dso}" />
        <property name="c.linker.cg.flags" value="-o ${c.linker.cg.dso}" />
    </target>
    
    <!-- ================================================================== -->
    <!-- 
       - Initialize all parameters required for the build and create any
       - required directories.
      -->
    <target name="init" depends="declare">
        <!-- Call the external config validator script to make sure the config is ok and consistent -->
        <ant antfile="${validate.user.properties}" inheritall="true"/>
        
        <!-- Create the required output directories. -->
        <mkdir dir="${src.generated.java}" />
        <mkdir dir="${src.generated.c}" />
        <mkdir dir="${classes}" />
        <mkdir dir="${obj}" />
        <mkdir dir="${obj.jogl}" />
        <mkdir dir="${obj.cg}" />
    </target>

    <!-- ================================================================== -->
    <!-- GlueGen and BuildStaticGLInfo creation, task setup and Java file generation -->
    <!--
       - Build GlueGen
      -->
    <target name="build.gluegen" depends="init">
        <!-- Run the GlueGen build to ensure that the GlueGen ANT task
           - has been built. -->
        <ant antfile="${gluegen.build.xml}" target="all" inheritAll="true" />
    
    </target>

    <!--
       - Build BuildStaticGLInfo
      -->
    <target name="build.static.gl" depends="init">
        <!-- Run the BuildStaticGLInfo build to ensure that the BuildStaticGLInfo
           - ANT task has been built. -->
        <ant antfile="${static.gl.build.xml}" target="all" inheritAll="true" />
    
    </target>
    
    <!--
       - 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" />
            <srcfileset dir=".">
	        <include name="${classes}/net/java/games/gluegen/**/*.class" />
            </srcfileset>
            <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">
            <srcfiles refid="stub.includes.dependencies.fileset" />
            <mapper type="merge" to="${src.generated.java}/net/java/games/jogl/GL.java" />
        </uptodate>
    </target>

    <!--
       - Setup the generating ANT tasks and use it to generate the Java files 
       - from the C GL 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, build.static.gl, java.generate.check" unless="java.generate.skip">
        <!-- Create the classpath for the ANT tasks.  This requires 
           - the user-defined "antlr.jar" property (as GlueGen depends on
           - ANTLR at runtime).-->
        <path id="gen.classpath">
            <pathelement path="${classpath}" />
            <pathelement location="${classes}" />
            <pathelement location="${antlr.jar}" />
        </path>
    
        <!-- Add the GlueGen and BuildStaticGLInfo tasks to ANT -->
        <taskdef name="gluegen" classname="net.java.games.gluegen.ant.GlueGenTask"
                 classpathref="gen.classpath" />
        <taskdef name="staticglgen" classname="net.java.games.gluegen.ant.StaticGLGenTask"
                 classpathref="gen.classpath" />
                 
        <!-- Use the GlueGen and BuildStaticGLInfo tasks to generate the 
           - Java files -->

        <!-- Generate GL interface class -->
        <echo message="Generating GL interface class" />
        <gluegen src="${stub.includes.common}/gl.c" 
                 config="${gl.cfg}"
                 includeRefid="stub.includes.fileset.all"
                 emitter="net.java.games.gluegen.opengl.GLEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>

        <!-- Generate GL implementation class -->
        <echo message="Generating GL implementation class" />
        <gluegen src="${stub.includes.common}/gl-impl.c" 
                 config="${gl.impl.cfg}"
                 includeRefid="stub.includes.fileset.all"
                 emitter="net.java.games.gluegen.opengl.GLEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>

        <!-- Generate WGL interface class -->
        <echo message="Generating WGL interface class" />
        <gluegen src="${stub.includes.common}/gl-impl.c" 
                 config="${config}/gl-wgl-win32.cfg"
                 includeRefid="stub.includes.fileset.all"
                 emitter="net.java.games.gluegen.opengl.GLEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>

        <!-- Generate GLX interface class -->
        <echo message="Generating GLX interface class" />
        <gluegen src="${stub.includes.common}/gl-impl.c" 
                 config="${config}/gl-glx-x11.cfg"
                 includeRefid="stub.includes.fileset.all"
                 emitter="net.java.games.gluegen.opengl.GLEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>

        <!-- Generate CGL interface class -->
        <echo message="Generating CGL interface class" />
        <gluegen src="${stub.includes.common}/gl-impl.c" 
                 config="${config}/gl-cgl-macosx.cfg"
                 includeRefid="stub.includes.fileset.all"
                 emitter="net.java.games.gluegen.opengl.GLEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>

	<!-- Generate JAWT class -->
        <!-- NOTE:  the "literalInclude" in this GlueGen call is simply to
           -        get around the fact that neither FileSet nor DirSet can
           -        handle different drives in an effective manner. -->
        <echo message="Generating JAWT interface class" />
        <echo message="java.home.dir=${java.home.dir}" />
	<dirset id="stub.includes.fileset.platform" dir="." includes="${stub.includes.fileset.platform.params}" />
        <gluegen src="${java.includes.dir.platform}/jawt_md.h" 
                 config="${jawt.cfg}"
                 literalInclude="${java.includes.dir}"
                 includeRefid="stub.includes.fileset.platform"
                 emitter="net.java.games.gluegen.JavaEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>

	<!-- Generate WGL/GLX/CGL implementation class -->
        <echo message="Generating WGL/GLX/CGL implementation class" />
        <gluegen src="${stub.includes.platform}/window-system.c" 
                 config="${window.cfg}"
                 includeRefid="stub.includes.fileset.platform"
                 emitter="net.java.games.gluegen.opengl.GLEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>

	<!-- Generate StaticGLInfo class -->
        <echo message="Generating StaticGLInfo class" />
        <staticglgen package="net.java.games.jogl.impl"
                     headers="${gl.headers}"
                     outputdir="${src.generated.java}/net/java/games/jogl/impl">
            <classpath refid="gen.classpath" />
        </staticglgen>

	<!-- Generate GLU interface class -->
        <echo message="Generating GLU interface class" />
        <gluegen src="${stub.includes.common}/glu.c" 
                 config="${glu.cfg}"
                 includeRefid="stub.includes.fileset.all"
                 emitter="net.java.games.gluegen.opengl.GLEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>

	<!-- Generate GLU implementation class -->
        <echo message="Generating GLU implementation class" />
        <gluegen src="${stub.includes.common}/glu-impl.c" 
                 config="${glu.impl.cfg}"
                 includeRefid="stub.includes.fileset.all"
                 emitter="net.java.games.gluegen.opengl.GLEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>

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

    <target name="java.generate.cg.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.cg.dependencies.fileset" />
            <targetfileset dir=".">
                <include name="${src.generated.java.cg}/**/*.java" />
                <include name="${src.generated.c.cg}/**/*.c" />
            </targetfileset>
        </dependset>

        <!-- Now check for the presence of one well-known file -->
        <uptodate property="java.generate.cg.skip">
            <srcfiles refid="stub.includes.cg.dependencies.fileset" />
            <mapper type="merge" to="${src.generated.java}/net/java/games/cg/CgGL.java" />
        </uptodate>
    </target>

    <!--
       - Setup the generating ANT tasks and use it to generate the Java files 
       - from the C GL headers.  This involves setting the taskdef and creating
       - the classpath reference id then running the task on each header.
      -->
    <target name="java.generate.cg" depends="java.generate.cg.check" if="jogl.cg" unless="java.generate.cg.skip">
        <!-- Create the classpath for the ANT tasks.  This requires 
           - the user-defined "antlr.jar" property (as GlueGen depends on
           - ANTLR at runtime).-->
        <path id="gen.classpath">
            <pathelement path="${classpath}" />
            <pathelement location="${classes}" />
            <pathelement location="${antlr.jar}" />
        </path>
    
        <!-- Add the GlueGen and BuildStaticGLInfo tasks to ANT -->
        <taskdef name="gluegen" classname="net.java.games.gluegen.ant.GlueGenTask"
                 classpathref="gen.classpath" />
        <taskdef name="staticglgen" classname="net.java.games.gluegen.ant.StaticGLGenTask"
                 classpathref="gen.classpath" />

        <!-- Generate CgGL interface class -->
        <gluegen src="${stub.includes.common}/cg.c" 
                 config="cg-common.cfg"
                 includeRefid="stub.includes.cg.fileset.all"
                 emitter="net.java.games.gluegen.JavaEmitter">
            <classpath refid="gen.classpath" />
        </gluegen>
    </target>

    <!-- ================================================================== -->
    <!-- 
       - Build and dependency rules for the composable pipeline
      -->
    <target name="java.compile.composable.pipeline.check">
        <!-- Blow away the DebugGL.java and TraceGL.java sources if GL.class has changed
             (the uptodate element doesn't support arbitrary source and destination files) -->
        <dependset>
            <srcfilelist dir="${classes}/net/java/games/jogl" files="GL.class" />
            <srcfilelist dir="${classes}/net/java/games/gluegen/opengl" files="BuildComposablePipeline.class" />
            <targetfileset dir="${src.generated.java}/net/java/games/jogl"
                           includes="DebugGL.java,TraceGL.java" />
        </dependset>
                           
        <!-- Now choose one of the two to test to see if we have to regenerate -->
        <uptodate property="java.compile.composable.pipeline.skip"
                  srcfile="${classes}/net/java/games/jogl/GL.class"
                  targetfile="${src.generated.java}/net/java/games/jogl/DebugGL.java" />
    </target>        

    <target name="java.compile.composable.pipeline" depends="java.compile.composable.pipeline.check" unless="java.compile.composable.pipeline.skip">
        <java classname="net.java.games.gluegen.opengl.BuildComposablePipeline" fork="yes">
            <arg value="net.java.games.jogl.GL" />
            <arg value="${src.generated.java}/net/java/games/jogl" />
            <classpath refid="antlr.classpath" />
        </java>

        <!-- Perform the second pass Java compile which compiles the composable pipelines. -->
        <javac destdir="${classes}" includes="${src.generated.java.pipeline}" source="1.4" debug="true" debuglevel="source,lines">
            <src path="${src}" />
            <src path="${src.generated.java}" />
            <classpath refid="antlr.classpath" />
        </javac>
    </target>          


    <!-- ================================================================== -->
    <!-- 
       - Compile the original and generated source.  The composable pipelines
       - will be generated.
      -->
    <target name="java.compile" depends="java.generate,java.generate.cg">
        <!-- Perform the first pass Java compile. -->
        <javac destdir="${classes}"
               excludes="${java.excludes.platform}" source="1.4" debug="true" debuglevel="source,lines">
            <src path="${src}" />
            <src path="${src.generated.java}" />
            <classpath refid="antlr.classpath" />
        </javac>

        <!-- Generate and build the composable pipeline Java source. -->
        <antcall target="java.compile.composable.pipeline" inheritRefs="true" />
    </target>

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

    <!--
       - Check dependencies to see whether we need to recompile .c or .m files
      -->
    <target name="c.compile.jogl.check.nonmacosx" unless="is.macosx">
        <condition property="c.compile.jogl.skip">
            <and>
                <uptodate>
                    <srcfiles dir="${project.root}" includes="${rootrel.src.c}/*.c" />
                    <mapper type="glob" from="${rootrel.src.c}${sep}*.c" to="${rootrel.obj.jogl}${sep}*.${c.compiler.obj.suffix}" />
                </uptodate>
                <uptodate>
                    <srcfiles dir="${project.root}" includes="${rootrel.generated.c.jogl}/*.c" />
                    <mapper type="glob" from="${rootrel.generated.c.jogl}${sep}*.c" to="${rootrel.obj.jogl}${sep}*.${c.compiler.obj.suffix}" />
                </uptodate>
            </and>
        </condition>
    </target>

    <target name="c.compile.jogl.check.macosx" if="is.macosx">
        <condition property="c.compile.jogl.skip">
            <and>
                <uptodate>
                    <srcfiles dir="${project.root}" includes="${rootrel.src.c}/*.c" />
                    <mapper type="glob" from="${rootrel.src.c}${sep}*.c" to="${rootrel.obj.jogl}${sep}*.${c.compiler.obj.suffix}" />
                </uptodate>
                <uptodate>
                    <srcfiles dir="${project.root}" includes="${rootrel.generated.c.jogl}/*.c" />
                    <mapper type="glob" from="${rootrel.generated.c.jogl}${sep}*.c" to="${rootrel.obj.jogl}${sep}*.${c.compiler.obj.suffix}" />
                </uptodate>
                <uptodate>
                    <srcfiles dir="${project.root}" includes="${rootrel.src.c}/*.m" />
                    <mapper type="glob" from="${rootrel.src.c}${sep}*.m" to="${rootrel.obj.jogl}${sep}*.${c.compiler.obj.suffix}" />
                </uptodate>
            </and>
        </condition>
    </target>

    <target name="c.compile.jogl.check" depends="c.compile.jogl.check.nonmacosx,c.compile.jogl.check.macosx">
    </target>

    <!--
       - Compile source files
      -->
    <target name="c.compile.jogl.macosx.objs" if="is.macosx">
        <apply executable="${c.compiler}" dest="${rootrel.obj.jogl}" dir="${project.root}" relative="true" failonerror="true">
	    <arg line="${c.compiler.includes}" />
	    <arg line="${c.compiler.flags}" />
	    <fileset dir="${project.root}">
                <include name="${rootrel.src.c}/*.m"/>
            </fileset>
            <targetfile />
            <srcfile />
            <mapper type="glob" from="${rootrel.src.c}${sep}*.m" to="${c.compiler.jogl.outputfile.expr}" />
        </apply>
    </target>

    <target name="c.compile.jogl" depends="c.compile.jogl.check" unless="c.compile.jogl.skip">
        <apply executable="${c.compiler}" dest="${rootrel.obj.jogl}" dir="${project.root}" relative="true" failonerror="true">
	    <arg line="${c.compiler.includes}" />
	    <arg line="${c.compiler.flags}" />
	    <fileset dir="${project.root}">
                <include name="${rootrel.src.c}/*.c"/>
            </fileset>
            <targetfile />
            <srcfile />
            <mapper type="glob" from="${rootrel.src.c}${sep}*.c" to="${c.compiler.jogl.outputfile.expr}" />
        </apply>
        <apply executable="${c.compiler}" dest="${rootrel.obj.jogl}" dir="${project.root}" relative="true" failonerror="true">
	    <arg line="${c.compiler.includes}" />
	    <arg line="${c.compiler.flags}" />
	    <fileset dir="${project.root}">
                <include name="${rootrel.generated.c.jogl}/*.c"/>
            </fileset>
            <targetfile />
            <srcfile />
            <mapper type="glob" from="${rootrel.generated.c.jogl}${sep}*.c" to="${c.compiler.jogl.outputfile.expr}" />
        </apply>
        <antcall target="c.compile.jogl.macosx.objs" inheritRefs="true" />
    </target>

    
    <target name="c.compile.cg.check">
        <uptodate property="c.compile.cg.skip">
            <srcfiles dir="${project.root}" includes="${rootrel.generated.c.cg}/*.c" />
            <mapper type="glob" from="${rootrel.generated.c.cg}${sep}*.c" to="${rootrel.obj.cg}${sep}*.${c.compiler.obj.suffix}" />
        </uptodate>
    </target>

    <target name="c.compile.cg" depends="c.compile.cg.check" if="jogl.cg" unless="c.compile.cg.skip">
        <apply executable="${c.compiler}" dest="${rootrel.obj.cg}" dir="${project.root}" relative="true" failonerror="true">
	    <arg line="${c.compiler.includes}" />
	    <arg line="${c.compiler.flags}" />
	    <fileset dir="${project.root}">
                <include name="${rootrel.generated.c.cg}/*.c"/>
            </fileset>
            <targetfile />
            <srcfile />
            <mapper type="glob" from="${rootrel.generated.c.cg}${sep}*.c" to="${c.compiler.cg.outputfile.expr}" />
        </apply>
    </target>

    <!--
       - Link object files
      -->
    <target name="c.link.jogl.check">
        <!-- Check object files against resulting DSO/DLL -->
        <uptodate property="c.link.jogl.skip">
            <srcfiles id="c.link.jogl.obj.fileset" dir="${project.root}" includes="${rootrel.obj.jogl}/*.${c.compiler.obj.suffix}" />
            <mapper type="merge" to="${rootrel.c.linker.jogl.dso}" />
        </uptodate>
    </target>

    <target name="c.link.jogl" depends="c.link.jogl.check" unless="c.link.jogl.skip">
        <pathconvert pathsep=" " property="c.link.jogl.obj.files" refid="c.link.jogl.obj.fileset" />
        <exec dir="." executable="${c.linker}" failonerror="true">
            <arg line="${c.linker.jogl.flags}" />
            <arg line="${c.linker.flags}" />
            <arg line="${c.link.jogl.obj.files}" />
            <arg line="${c.linker.jogl.libs}" />
        </exec>        
    </target>

    <target name="c.link.cg.check">
        <!-- Check object files against resulting DSO/DLL -->
        <uptodate property="c.link.cg.skip">
            <srcfiles id="c.link.cg.obj.fileset" dir="${project.root}" includes="${rootrel.obj.cg}/*.${c.compiler.obj.suffix}" />
            <mapper type="merge" to="${rootrel.c.linker.cg.dso}" />
        </uptodate>
    </target>

    <target name="c.link.cg" depends="c.link.cg.check" if="jogl.cg" unless="c.link.cg.skip">
        <pathconvert pathsep=" " property="c.link.cg.obj.files" refid="c.link.cg.obj.fileset" />
        <exec dir="." executable="${c.linker}" failonerror="true">
            <arg line="${c.linker.cg.flags}" />
            <arg line="${c.linker.flags}" />
            <arg line="${c.link.cg.obj.files}" />
            <arg line="${c.linker.cg.libs}" />
        </exec>        
    </target>

    <target name="c.compile.jogl.win32.vc6" depends="declare.win32.vc6">
        <antcall target="c.compile.jogl" inheritRefs="true" />
        <antcall target="c.link.jogl" inheritRefs="true" />
        <antcall target="c.compile.cg" inheritRefs="true" />
        <antcall target="c.link.cg" inheritRefs="true" />
    </target>

    <target name="c.compile.jogl.win32.vc7" depends="declare.win32.vc7">
        <antcall target="c.compile.jogl" inheritRefs="true" />
        <antcall target="c.link.jogl" inheritRefs="true" />
        <antcall target="c.compile.cg" inheritRefs="true" />
        <antcall target="c.link.cg" inheritRefs="true" />
    </target>

    <target name="c.compile.jogl.win32.mingw" depends="declare.win32.mingw">
        <antcall target="c.compile.jogl" inheritRefs="true" />
        <antcall target="c.link.jogl" inheritRefs="true" />
        <antcall target="c.compile.cg" inheritRefs="true" />
        <antcall target="c.link.cg" inheritRefs="true" />
    </target>

    <target name="c.compile.jogl.linux" depends="declare.linux">
        <antcall target="c.compile.jogl" inheritRefs="true" />
        <antcall target="c.link.jogl" inheritRefs="true" />
        <antcall target="c.compile.cg" inheritRefs="true" />
        <antcall target="c.link.cg" inheritRefs="true" />
    </target>
    
    <target name="c.compile.jogl.solaris" depends="declare.solaris">
        <antcall target="c.compile.jogl" inheritRefs="true" />
        <antcall target="c.link.jogl" inheritRefs="true" />
    </target>
    
    <target name="c.compile.jogl.macosx" depends="declare.macosx">
        <antcall target="c.compile.jogl" inheritRefs="true" />
        <antcall target="c.link.jogl" inheritRefs="true" />
        <antcall target="c.compile.cg" inheritRefs="true" />
        <antcall target="c.link.cg" inheritRefs="true" />
    </target>
    
    <!-- ================================================================== -->
    <!--
       - Build the jogl.jar file.
      -->
    <target name="jar" depends="java.compile">
        <!-- Build the jar excluding any build specific classes. -->
        <jar destfile="${jogl.jar}">
            <fileset dir="${classes}">
                <include name="net/java/games/jogl/**" />
                <include name="net/java/games/gluegen/runtime/**" />
                <include name="net/java/games/cg/**" />
            </fileset>
        </jar>

    </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.nocg" depends="setup.java.home.dir.nonmacosx,init" unless="jogl.cg">
        <!-- Build the general Javadoc -->
        <javadoc packagenames="${javadoc.packagenames}"
                 sourcepath="${src};${src.generated.java}"        
                 destdir="${javadoc}" windowtitle="JOGL API"
                 source="1.4"
                 link="${javadoc.link}" />
    </target>

    <!-- Same as above but with Cg directories added -->
    <target name="javadoc.cg" depends="setup.java.home.dir.nonmacosx,init" if="jogl.cg">
        <!-- Build the general Javadoc -->
        <javadoc packagenames="${javadoc.packagenames},net.java.games.cg"
                 sourcepath="${src};${src.generated.java}"        
                 destdir="${javadoc}" windowtitle="JOGL API"
                 source="1.4"
                 link="${javadoc.link}" />
    </target>

    <target name="javadoc" depends="javadoc.nocg,javadoc.cg" />

    <target name="javadoc.dev.nocg" depends="init" unless="jogl.cg">
        <!-- Build the internal developer Javadoc -->
        <javadoc packagenames="${javadoc.dev.packagenames},${javadoc.dev.packagenames.platform}"
                 sourcepath="${src};${src.generated.java}"        
                 destdir="${javadoc.dev}" windowtitle="JOGL API"
                 source="1.4"
                 link="${javadoc.link}" />
    </target>

    <!-- Same as above but with Cg directories added -->
    <target name="javadoc.dev.cg" depends="init" if="jogl.cg">
        <!-- Build the internal developer Javadoc -->
        <javadoc packagenames="${javadoc.dev.packagenames},${javadoc.dev.packagenames.platform},net.java.games.cg"
                 sourcepath="${src};${src.generated.java}"        
                 destdir="${javadoc.dev}" windowtitle="JOGL API"
                 source="1.4"
                 link="${javadoc.link}" />
    </target>

    <target name="javadoc.dev.win32"  depends="setup.java.home.dir.nonmacosx,declare.win32,javadoc.dev.nocg,javadoc.dev.cg" />
    <target name="javadoc.dev.x11"    depends="setup.java.home.dir.nonmacosx,declare.x11,javadoc.dev.nocg,javadoc.dev.cg" />
    <target name="javadoc.dev.macosx" depends="setup.java.home.dir.macosx,declare.macosx,javadoc.dev.nocg,javadoc.dev.cg" />

    <!-- ================================================================== -->
    <!--
       - Build the platform-independent distribution out of jars built for
       - Windows, Linux and Mac OS X; the Java sources for Jogl can't be
       - fully cross-compiled at this time. To run this target, you need to
       - specify the property jogl.dist.dir as a System property (i.e.,
       - "ant -Djogl.dist.dir=../dist dist"); directories named jogl-linux,
       - jogl-win32, and jogl-macosx need to be inside that directory and each
       - of those directories needs to contain both the jogl.jar for that
       - platform as well as the native code (libjogl.so, jogl.dll, or
       - libjogl.jnilib). Also builds jars containing the native code for
       - Windows, Linux, Mac OS X, Solaris/SPARC and Solaris/x86.
      -->
    <target name="dist.check" unless="jogl.dist.dir">
        <fail>
  
    ******************************************************************
    ** To build the Jogl distribution out of the platform-specific  **
    ** component jars and native code, the property jogl.dist.dir   **
    ** needs to be specified on the command line. Please read the   **
    ** comments associated with the "dist" target in the build.xml. **
    ******************************************************************
        </fail>
    </target>

    <target name="dist" depends="dist.check">
        <delete file="${jogl.dist.dir}/jogl.jar" />
        <delete>
            <fileset dir="${jogl.dist.dir}" includes="jogl-natives-*.jar" />
        </delete>
        <jar destfile="${jogl.dist.dir}/jogl.jar" duplicate="preserve">
	    <zipgroupfileset dir="${jogl.dist.dir}"
	                     includes="jogl-win32/*.jar, jogl-linux/*.jar, jogl-macosx/*.jar" />
        </jar>
        <jar destfile="${jogl.dist.dir}/jogl-natives-win32.jar"
             basedir="${jogl.dist.dir}/jogl-win32"
             includes="jogl.dll,jogl_cg.dll" />
        <jar destfile="${jogl.dist.dir}/jogl-natives-linux.jar"
             basedir="${jogl.dist.dir}/jogl-linux"
             includes="libjogl.so,libjogl_cg.so" />
        <jar destfile="${jogl.dist.dir}/jogl-natives-macosx.jar"
             basedir="${jogl.dist.dir}/jogl-macosx"
             includes="libjogl.jnilib" />
        <jar destfile="${jogl.dist.dir}/jogl-natives-solsparc.jar"
             basedir="${jogl.dist.dir}/jogl-solsparc"
             includes="libjogl.so" />
        <!-- Note: Solaris/x86 elided for now as it requires Mesa to
             be installed -->
        <!-- jar destfile="${jogl.dist.dir}/jogl-natives-solx86.jar"
             basedir="${jogl.dist.dir}/jogl-solx86"
             includes="libjogl.so" -->
    </target>

    <!-- ================================================================== -->
    <!--
       - Clean up all that is built.
      -->
    <target name="clean" depends="declare">
        <!-- Let GlueGen clean itself up. -->
        <ant antfile="${gluegen.build.xml}" target="clean" inheritAll="true" />
    
        <delete includeEmptyDirs="true" quiet="true">
            <fileset dir="${build}" />
            <fileset dir="${javadoc}" />
            <fileset dir="${javadoc.dev}" />
        </delete>

    </target>

    <!-- ================================================================== -->
    <!--
       - Inform the user that one of the platform targets should be used.
      -->
    <target name="all">
        <fail>
        
Use a platform specific target:  linux, macosx, solaris, win32.vc6, win32.vc7, win32.mingw
        </fail>
    </target>      

    <!--
       - Win32 with MS VC6
      -->
    <target name="win32.vc6" depends="setup.java.home.dir.nonmacosx, declare.win32">
        <!-- Generate, compile, and build the jar for the Java sources. -->
        <antcall target="jar" inheritRefs="true" />
        
        <!-- Compile the native C sources and build the jogl.dll. -->
        <antcall target="c.compile.jogl.win32.vc6" />
    </target>

    <!--
       - Win32 with MS VC7
      -->
    <target name="win32.vc7" depends="setup.java.home.dir.nonmacosx, declare.win32">
        <!-- Generate, compile, and build the jar for the Java sources. -->
        <antcall target="jar" inheritRefs="true" />
        
        <!-- Compile the native C sources and build the jogl.dll. -->
        <antcall target="c.compile.jogl.win32.vc7" />
    </target>

    <!--
       - Win32 with mingw32
      -->
    <target name="win32.mingw" depends="setup.java.home.dir.nonmacosx, declare.win32">
        <!-- Generate, compile, and build the jar for the Java sources. -->
        <antcall target="jar" inheritRefs="true" />
        
        <!-- Compile the native C sources and build the jogl.dll. -->
        <antcall target="c.compile.jogl.win32.mingw" />
    </target>

    <!--
       - Linux (assuming GCC)
      -->
    <target name="linux" depends="setup.java.home.dir.nonmacosx, declare.linux">
        <!-- Generate, compile, and build the jar for the Java sources. -->
        <antcall target="jar" inheritRefs="true" />

        <!-- Compile the native C sources and build the jogl lib. -->
        <antcall target="c.compile.jogl.linux" />
    </target>

    <!--
       - Solaris (assuming Solaris CC)
      -->
    <target name="solaris" depends="setup.java.home.dir.nonmacosx, declare.solaris">
        <!-- Generate, compile, and build the jar for the Java sources. -->
        <antcall target="jar" inheritRefs="true" />

        <!-- Compile the native C sources and build the jogl lib. -->
        <antcall target="c.compile.jogl.solaris" />
    </target>

    <!--
       - Mac OSX
      -->
    <target name="macosx" depends="setup.java.home.dir.macosx, declare.macosx">
        <!-- Generate, compile, and build the jar for the Java sources. -->
        <antcall target="jar" inheritRefs="true" />
        
        <!-- Compile the native C sources and build the jogl lib. -->
        <antcall target="c.compile.jogl.macosx" />
    </target>
</project>