aboutsummaryrefslogtreecommitdiffstats
path: root/make/build.xml
blob: e04f6293572a9e695ebf1599a94e438a80a19fdb (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
<?xml version="1.0" encoding="UTF-8"?>
<!--
   - Ant build for JOAL.  This build has been tested with ANT 1.6.2.  The
   - optional.jar that contains the optional ANT tasks must be in the ANT
   - classpath (typically the ant/lib directory).
   -
   - A clean download of JOAL 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 joal.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
   -
   - Optional properties:
   -   -Djoal.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="JOAL" basedir="." default="all">
    
    <!-- ================================================================== -->
    <!-- 
       - Base initialization and detection of operating system.
      -->
    <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="." />

        <!-- Detection of operating system. -->
        <condition property="isOSX">
	    <and>
	        <os family="mac"/>
		<os family="unix"/>
	    </and>
	</condition>
	<condition property="isUnix">
	    <and>
	        <os family="unix" />
		<not>
		    <os family="mac" />
		</not>
  	    </and>
	</condition>
	<condition property="isLinux">
	    <os name="Linux" />
        </condition>
	<condition property="isSolaris">
	    <os name="SunOS" />
        </condition>
	<condition property="isWindows">
	    <os family="windows" />
	</condition>
	<condition property="isFreeBSD">
	    <os name="FreeBSD" />
        </condition>
	<condition property="isLinuxAMD64">
	    <and>
              <istrue value="${isLinux}" />
              <os arch="AMD64" />
            </and>
        </condition>
	<condition property="isIA64">
	    <os arch="IA64" />
        </condition>
        <echo message="OS X=${isOSX}" />
        <echo message="Windows=${isWindows}" />
        <echo message="Unix=${isUnix}" />
        <echo message="Linux=${isLinux}" />
        <echo message="Solaris=${isSolaris}" />
        <echo message="FreeBSD=${isFreeBSD}" />
        <echo message="LinuxAMD64=${isLinuxAMD64}" />
        <echo message="IA64=${isIA64}" />
    </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}/joal.properties" />
        <property file="${user.properties.file}" />
        <echo message="Loaded ${user.properties.file}." />
        <echo message="antlr.jar=${antlr.jar}" />
        <fail message="antlr.jar was not specified in joal.properties. Please see README.txt for instructions" unless="antlr.jar"/>
        <fail message="joal.lib.dir was not specified in joal.properties. Please see README.txt for instructions" unless="joal.lib.dir"/>
        <condition property="isVC6">
            <and>
              <istrue value="${isWindows}" />
              <equals arg1="${win32.c.compiler}" arg2="vc6" />
            </and>
        </condition>
        <condition property="isVC7">
            <and>
              <istrue value="${isWindows}" />
              <equals arg1="${win32.c.compiler}" arg2="vc7" />
            </and>
        </condition>
        <condition property="isMingw">
            <and>
              <istrue value="${isWindows}" />
              <equals arg1="${win32.c.compiler}" arg2="mingw" />
            </and>
        </condition>
        <echo message="VC6=${isVC6}" />
        <echo message="VC7=${isVC7}" />
        <echo message="MingW=${isMingw}" />
    </target>

    <!-- ================================================================== -->
    <!-- 
       - Set up java.home.dir appropriately on all platforms.
      -->
    <target name="setup.java.home.dir.nonmacosx" depends="load.user.properties" unless="isOSX">
      <!-- java home dir is up one directory as java.home points to '<java-install-dir>/jre' -->
      <property name="java.home.dir" value="${java.home}/.." />
    </target>
    <target name="setup.java.home.dir.macosx" depends="load.user.properties" if="isOSX">
      <property name="java.home.dir" value="/System/Library/Frameworks/JavaVM.framework/Home" />
    </target>
    <target name="setup.java.home.dir" depends="setup.java.home.dir.nonmacosx,setup.java.home.dir.macosx"/>

    <!-- ================================================================== -->
    <!-- 
       - Declare all paths and user defined variables.
      -->
    <target name="declare.common" 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" />
           
        <!-- Properties pointing to root of the workspace containing GlueGen.
             This build.xml expects that GlueGen has already been built and that its
             classes are in the build/classes subdirectory of this other workspace.
             Currently we expect that it is contained in the JOGL project. -->
        <property name="jogl.root" value="../../jogl" />
        <property name="gluegen.classes" value="${jogl.root}/build/classes" />

        <!-- 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}${sep}java" />
        <property name="rootrel.src.c" value="${rootrel.src}${sep}native" />
        <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.joal" value="${rootrel.src.generated}${sep}native${sep}joal" />
        <property name="rootrel.obj" value="${rootrel.build}${sep}obj" />
        <property name="rootrel.obj.joal" value="${rootrel.obj}${sep}joal" />

        <!-- 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}/classes" />
        <property name="src.generated.c" value="${src.generated}/native/joal" />
        
        <!-- The compiler output directories. -->
        <property name="classes" value="${build}/classes" />
        <property name="obj"      value="${project.root}/${rootrel.obj}" />
        <property name="obj.joal" value="${project.root}/${rootrel.obj.joal}" />

        <!-- The 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.openal" value="${stub.includes}/openal" />
        <dirset id="stub.includes.fileset.all" dir=".">
            <include name="${stub.includes.dir}/openal/**" />
        </dirset>
        <fileset id="stub.includes.dependencies.fileset" dir=".">
            <include name="${stub.includes.dir}/openal/**" />
            <include name="*.cfg" />
            <include name="*.java" />
            <include name="*.c" />
        </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" />

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

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

        <!-- The javadoc dirs. -->
        <property name="javadoc" value="${project.root}/javadoc_public" />
        <property name="javadoc.dev" value="${project.root}/javadoc_joal_dev" />
        <property name="javadoc.link" value="http://java.sun.com/j2se/1.4.2/docs/api/" />
        <property name="javadoc.packagenames" value="net.java.games.joal,net.java.games.joal.util" />
        <property name="javadoc.dev.packagenames" value="${javadoc.packagenames},net.java.games.joal.impl" />

	<!-- Names of configuration files used during glue code generation. -->
        <property name="joal.cfg" value="${config}/joal.cfg" />
        <property name="joal.constants.cfg" value="${config}/joal-constants.cfg" />
        <property name="joal.alc.cfg" value="${config}/joal-alc.cfg" />
        <property name="joal.alc.constants.cfg" value="${config}/joal-alc-constants.cfg" />
    </target>
    
    <!-- ================================================================== -->
    <!--
       - Platform specific declares.
      -->
    <target name="declare.win32.vc6" if="isVC6">
      <echo message="Win32.VC6" />
      <property name="c.compiler.include.root"                value="${vc6.root}" />
      <property name="c.linker.lib.root"                      value="${vc6.root}" />

      <property name="compiler.cfg.id"                      value="compiler.cfg.win32.msvc" />
      <property name="linker.cfg.id"                        value="linker.cfg.win32.msvc" />
    </target>
    
    <target name="declare.win32.vc7" if="isVC7">
      <echo message="Win32.VC7" />
      <property name="c.compiler.include.root"                value="${vc7.root}" />
      <property name="c.linker.lib.root"                      value="${vc7.root}" />

      <property name="compiler.cfg.id"                      value="compiler.cfg.win32.msvc" />
      <property name="linker.cfg.id"                        value="linker.cfg.win32.msvc" />
    </target>
    
    <target name="declare.win32.mingw" if="isMingw">
      <echo message="Win32.MingW" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.win32.mingw" />
      <property name="linker.cfg.id"                        value="linker.cfg.win32.mingw" />
    </target>

    <target name="declare.win32" depends="declare.win32.vc6,declare.win32.vc7,declare.win32.mingw" if="isWindows">
      <property name="java.includes.dir.platform"           value="${java.includes.dir.win32}" />
      <property name="java.lib.dir.platform"                value="${java.lib.dir.win32}" />
    </target>

    <target name="declare.linux.x86" if="isLinux" unless="isLinuxAMD64">
      <echo message="Linux.x86" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir.linux}" />
      <property name="java.lib.dir.platform"                value="${java.lib.dir.linux}" />       

      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
    </target>
    
    <target name="declare.linux.amd64" if="isLinuxAMD64">
      <echo message="Linux.AMD64" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir.linux}" />
      <property name="java.lib.dir.platform"                value="${java.lib.dir.linux.amd64}" />       

      <property name="compiler.cfg.id"                      value="compiler.cfg.linux.amd64" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.linux.amd64" /> 
    </target>

    <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64" if="isLinux" />

    <target name="declare.solaris" if="isSolaris">
      <echo message="Solaris" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir.solaris}" />
      <property name="java.lib.dir.platform"                value="${java.lib.dir.solaris}" />

      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.solaris" /> 
    </target>

    <target name="declare.macosx" if="isOSX">
      <echo message="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="compiler.cfg.id"                      value="compiler.cfg.macosx" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.macosx" /> 
    </target>

    <target name="declare.freebsd" if="isFreeBSD">
      <echo message="FreeBSD" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir.freebsd}" />
      <property name="java.lib.dir.platform"                value="${java.lib.dir.linux}" />

      <property name="compiler.cfg.id"                      value="compiler.cfg.freebsd" />
      <property name="linker.cfg.id"                        value="linker.cfg.linux" />
    </target>

    <!-- ================================================================== -->
    <!-- 
       - Initialize all parameters required for the build and create any
       - required directories.
      -->
    <target name="init" depends="declare.common">
        <!-- 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.joal}" />
    </target>

    <target name="declare" depends="init,declare.win32,declare.linux,declare.solaris,declare.macosx,declare.freebsd" />

    <!-- ================================================================== -->
    <!-- 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" />
            <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/joal/AL.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="java.generate.check" unless="java.generate.skip">
        <!-- Add the GlueGen task to ANT -->
        <taskdef name="gluegen" classname="com.sun.gluegen.ant.GlueGenTask"
                 classpathref="antlr.classpath" />
                 
        <!-- Use the GlueGen task to generate the Java files -->

	<!-- Generate the AL interface class and implementation -->
        <gluegen src="${stub.includes.openal}/al.h" 
                 config="${joal.cfg}"
                 includeRefid="stub.includes.fileset.all"
                 emitter="com.sun.gluegen.procaddress.ProcAddressEmitter">
            <classpath refid="antlr.classpath" />
        </gluegen>

	<!-- Generate the ALConstants interface class -->
        <gluegen src="${stub.includes.openal}/al.h" 
                 config="${joal.constants.cfg}"
                 includeRefid="stub.includes.fileset.all"
                 emitter="com.sun.gluegen.JavaEmitter">
            <classpath refid="antlr.classpath" />
        </gluegen>

	<!-- Generate the ALC interface class and implementation -->
        <gluegen src="${stub.includes.openal}/alc.h" 
                 config="${joal.alc.cfg}"
                 includeRefid="stub.includes.fileset.all"
                 emitter="com.sun.gluegen.procaddress.ProcAddressEmitter">
            <classpath refid="antlr.classpath" />
        </gluegen>

	<!-- Generate the ALCConstants interface class -->
        <gluegen src="${stub.includes.openal}/alc.h" 
                 config="${joal.alc.constants.cfg}"
                 includeRefid="stub.includes.fileset.all"
                 emitter="com.sun.gluegen.JavaEmitter">
            <classpath refid="antlr.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}" source="1.4" debug="true" debuglevel="source,lines">
            <src path="${src.java}" />
            <src path="${src.generated.java}" />
            <classpath refid="antlr.classpath" />
        </javac>
    </target>

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

    <target name="c.configure">
    
      <!-- import cpptasks -->
      <typedef resource="net/sf/antcontrib/cpptasks/antlib.xml" classpath="${jogl.root}/make/lib/cpptasks.jar"/>
      <!--typedef resource="net/sf/antcontrib/cpptasks/antlib.xml"/-->

      <!-- compiler configuration -->
      <compiler id="compiler.cfg.linux" name="gcc" />

      <compiler id="compiler.cfg.linux.amd64" name="gcc">
        <compilerarg value="-fPIC"/>
      </compiler>

      <compiler id="compiler.cfg.solaris" name="suncc">
      </compiler>

      <compiler id="compiler.cfg.win32.mingw" name="gcc">
        <defineset>
          <define name="_DEBUG"   if="c.compiler.use-debug"/>        
          <define name="DEBUG"    if="c.compiler.use-debug"/>        
          <define name="NDEBUG"   unless="c.compiler.use-debug"/>        

          <define name="DBUILD_DLL" />
          <define name="_WINGDI_" /> 
          <define name="_STRICT_ANSI" /> 
          <define name="_JNI_IMPLEMENTATION_" />
        </defineset>
      </compiler>

      <compiler id="compiler.cfg.win32.msvc" name="msvc">
        <compilerarg value="/W3"/>      <!-- set warning level -->
        <compilerarg value="/Ob1"/>     <!-- inline only functions marked inline -->
        <compilerarg value="/GF"/>      <!-- enable string pooling -->
        <compilerarg value="/Gy"/>      <!-- enable function level linking -->
        <compilerarg value="/GS"      if="isVC7"/>  <!-- buffer security checks -->
        <compilerarg value="/Wp64"    if="isVC7"/>  <!-- detect 64-bit port problems -->
        <compilerarg value="/RTCcsu"  if="isVC7"/>  <!-- various runtime checks -->
	<!-- Note: previous compiler options for VC7 were:
	     Debug:     /MDd /Yd /GS /RTCs /RTCu /RTCc /W3 /Od /GF /EHsc /Zi /GS /Gy /Wp64 /Zi /D &quot;_DEBUG&quot;
             Optimized: /MD /W3 /O2 /Ob1 /GF /EHsc /GS /Gy /Wp64 /D &quot;NDEBUG&quot; -->

        <sysincludepath path="${c.compiler.include.root}/PlatformSDK/Include"/>
        <sysincludepath path="${c.compiler.include.root}/include"/>

        <defineset>
          <define name="_DEBUG"   if="c.compiler.use-debug"/>        
          <define name="DEBUG"    if="c.compiler.use-debug"/>        
          <define name="NDEBUG"   unless="c.compiler.use-debug"/>        
        </defineset>
      </compiler>

      <compiler id="compiler.cfg.macosx" name="gcc">
        <compilerarg value="-arch" if="macosxfat"/>
        <compilerarg value="ppc" if="macosxfat"/>
        <compilerarg value="-arch" if="macosxfat"/>
        <compilerarg value="i386" if="macosxfat"/>
        <compilerarg value="-Wmost" />
        <compilerarg value="-ObjC" />
        <defineset>
          <define name="macosx" />
        </defineset>
      </compiler>

      <compiler id="compiler.cfg.freebsd" name="gcc">
        <includepath path="/usr/X11R6/include" />
      </compiler>

      <!-- linker configuration -->
 
      <linker id="linker.cfg.linux" name="gcc">
        <syslibset dir="${joal.lib.dir}" libs="openal"/>
      </linker>

      <linker id="linker.cfg.linux.amd64" name="gcc">
        <syslibset dir="${joal.lib.dir}" libs="openal"/>
      </linker>

      <linker id="linker.cfg.solaris" name="suncc">
        <syslibset dir="${joal.lib.dir}" libs="openal"/>
      </linker>

      <linker id="linker.cfg.win32.mingw" name="gcc" incremental="false">
        <linkerarg value="-Wl,--kill-at" />        <!-- remove @ from function names -->
        <syslibset dir="${joal.lib.dir}" libs="openal32, kernel32"/>
      </linker>

      <linker id="linker.cfg.win32.msvc" name="msvc" incremental="false">
        <linkerarg value="/OPT:REF,ICF" />        <!-- enable link-time optimisations -->
        <linkerarg value="/SUBSYSTEM:WINDOWS" />  <!-- output is not a console app as uses WinMain entry point -->
        <linkerarg value="/MACHINE:IX86" />       <!-- explicity set target platform -->
        
        <syslibset dir="${joal.lib.dir}" libs="openal32" />
        <syslibset dir="${c.linker.lib.root}/lib" libs="kernel32" unless="isVC7"/>
        <syslibset dir="${c.linker.lib.root}/PlatformSDK/lib" libs="kernel32" if="isVC7"/>
      </linker>

      <linker id="linker.cfg.macosx" name="gcc">
        <linkerarg value="-arch" if="macosxfat"/>
        <linkerarg value="ppc" if="macosxfat"/>
        <linkerarg value="-arch" if="macosxfat"/>
        <linkerarg value="i386" if="macosxfat"/>
        <linkerarg value="-framework" />
        <linkerarg value="Cocoa" />
        <linkerarg value="-framework" />
        <linkerarg value="OpenGL" />
        <linkerarg value="-framework" if="c.compiler.use-cglib" />
        <linkerarg value="Cg" if="c.compiler.use-cglib" />
      </linker>

      <patternset id="c.src.files.joal">
        <include name="${rootrel.src.c}/*.c"/>
        <include name="${rootrel.generated.c.joal}/*.c"/>
      </patternset>

    </target>

    <target name="c.build" depends="c.configure">
      <fail message="Requires '${c.compiler.src.files}'" unless="c.compiler.src.files"/>
      <fail message="Requires '${compiler.cfg.id}'"      unless="compiler.cfg.id"/>
      <fail message="Requires '${linker.cfg.id}'"        unless="linker.cfg.id"/>
      <fail message="Requires '${output.lib.name}'"      unless="output.lib.name"/>

      <echo message="Output lib name = ${output.lib.name}" />

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

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

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

        <!-- TODO: versioninfo  companyname="java.net"
                      legalcopyright="Copyright"
                      productname="JOAL"
                      productversion="x.y.z"
                      description="Description"
                      fileversion="x.y.z" 
                      filecomments="File Comment" /-->      

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

        <compiler extends="${compiler.cfg.id}" >
          <sysincludepath path="${java.includes.dir}"/>
          <sysincludepath path="${java.includes.dir.platform}"/>
          <includepath path="stub_includes/openal"/>
        </compiler>

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

    <target name="c.rename.joal.lib.mingw" if="isMingw">
      <!-- FIXME: this is a hack; the cpptask should have an option to change the
           suffix or at least understand the override from .so to .dll -->
      <move file="${obj}/libjoal.so" tofile="${obj}/joal.dll" failonerror="false" />
    </target>

    <target name="c.rename.joal.lib.macosx" if="isOSX">
      <!-- FIXME: this is a hack; the cpptask should have an option to change the
           suffix or at least understand the override from dylib to jnilib -->
      <move file="${obj}/libjoal.dylib" tofile="${obj}/libjoal.jnilib" />
    </target>

    <target name="c.build.joal">
      <antcall target="c.build" inheritRefs="true">
        <param name="c.compiler.src.files" value="c.src.files.joal"/>
        <param name="output.lib.name" value="joal_native"/>
      </antcall>
      <antcall target="c.rename.joal.lib.mingw" inheritRefs="true" />
      <antcall target="c.rename.joal.lib.macosx" inheritRefs="true" />
    </target>

    <!-- ================================================================== -->
    <!--
       - Build the joal.jar file.
      -->
    <target name="jar" depends="java.compile">
        <!-- Build the jar excluding any build specific classes. -->
        <jar destfile="${joal.jar}">
            <fileset dir="${classes}">
                <include name="net/java/games/**" />
            </fileset>
            <fileset dir="${gluegen.classes}">
                <include name="com/sun/gluegen/runtime/**" />
            </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" depends="setup.java.home.dir,init">
        <javadoc packagenames="${javadoc.packagenames}"
                 sourcepath="${src.java};${src.generated.java}"
                 classpath="${gluegen.classes}"
                 destdir="${javadoc}" windowtitle="JOAL API"
                 source="1.4"
                 link="${javadoc.link}" />
    </target>

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

    <!-- ================================================================== -->
    <!--
       - Build the platform-independent distribution out of jars built for
       - Windows, Linux and Mac OS X; the Java sources for Joal can't be
       - fully cross-compiled at this time. To run this target, you need to
       - specify the property joal.dist.dir as a System property (i.e.,
       - "ant -Djoal.dist.dir=../dist dist"); directories named joal-linux,
       - joal-win32, and joal-macosx need to be inside that directory and each
       - of those directories needs to contain both the joal.jar for that
       - platform as well as the native code (libjoal.so, joal.dll, or
       - libjoal.jnilib). Also builds jars containing the native code for
       - Windows, Linux, Mac OS X, Solaris/SPARC and Solaris/x86.
      -->
    <target name="dist.check" unless="joal.dist.dir">
        <fail>
  
    ******************************************************************
    ** To build the Joal distribution out of the platform-specific  **
    ** component jars and native code, the property joal.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="${joal.dist.dir}/joal.jar" />
        <delete>
            <fileset dir="${joal.dist.dir}" includes="joal-natives-*.jar" />
        </delete>
        <jar destfile="${joal.dist.dir}/joal.jar" duplicate="preserve">
	    <zipgroupfileset dir="${joal.dist.dir}"
	                     includes="joal-win32/*.jar, joal-linux/*.jar, joal-macosx/*.jar" />
        </jar>
        <jar destfile="${joal.dist.dir}/joal-natives-win32.jar"
             basedir="${joal.dist.dir}/joal-win32"
             includes="joal.dll" />
        <jar destfile="${joal.dist.dir}/joal-natives-linux.jar"
             basedir="${joal.dist.dir}/joal-linux"
             includes="libjoal.so" />
        <jar destfile="${joal.dist.dir}/joal-natives-macosx.jar"
             basedir="${joal.dist.dir}/joal-macosx"
             includes="libjoal.jnilib" />
        <jar destfile="${joal.dist.dir}/joal-natives-solsparc.jar"
             basedir="${joal.dist.dir}/joal-solsparc"
             includes="libjoal.so" />
        <!-- Note: Solaris/x86 elided for now as it requires Mesa to
             be installed -->
        <!-- jar destfile="${joal.dist.dir}/joal-natives-solx86.jar"
             basedir="${joal.dist.dir}/joal-solx86"
             includes="libjoal.so" -->
    </target>

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

    <!-- ================================================================== -->
    <!--
       - Build everything.
      -->
    <target name="all" depends="setup.java.home.dir,init,declare">
        <!-- Generate, compile, and build the jar for the Java sources. -->
        <antcall target="jar" inheritRefs="true" />
        
        <!-- Compile the native C sources . -->
        <antcall target="c.build.joal" inheritRefs="true" />
    </target>

    <!-- ================================================================== -->
    <!--
       - Build and run tests.
      -->

    <target name="runtests" depends="all">
        <ant dir="../unit_tests" target="compile"/>
    	<ant dir="../unit_tests" target="runOpenALTest"/>
    	<ant dir="../unit_tests" target="runSound3DTest"/>
    </target>
</project>