aboutsummaryrefslogtreecommitdiffstats
path: root/make/build.xml
blob: 3c2a8fd53fd3ad84c1b077354c98a4962dc4ba9b (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
<?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.
   -
   - Public targets:
   -   all: (default; autodetects OS and chooses C compiler from joal.properties)
   -   clean:        clean all built
   -   javadoc:      create the standard developer Javadoc
   -
   - Thanks to Rob Grzywinski and Artur Biesiadowski for the bulk of the
   - ANT build, including the GlueGen and StaticGLInfo tasks, the building of
   - the Java generated sources, the first and second phase Java compiles, and
   - the building of the jar file. Thanks to Alex Radeski for the bulk of the
   - port to the ant-contrib CPPTask framework. Thanks to Athomas Goldberg for
   - the original OS detection code.
   -->
<project name="JOAL" basedir="." default="all">
    
  <!-- This is the version of JOAL you are building -->
  <property name="base_version" value="1.1.3"/>

  <!-- Uncomment this property to perform a full release build -->
  <!-- property name="release-build" value="true" / -->

  <!-- Pull in GlueGen cpptasks build file -->
  <property name="gluegen.root" value="../../gluegen" />
  <import file="${gluegen.root}/make/gluegen-cpptasks.xml" />

  <!-- Set up version string (used in several places) based on whether we're
       doing a release build or not -->
  <target name="setup-version-string-release" if="release-build">
      <property name="version-string" value="${base_version}" />
  </target>

  <target name="setup-version-string-prerelease" unless="release-build">
      <tstamp>
           <format property="timestamp" pattern="yyyyMMdd"/>
      </tstamp>
      <property name="version-string" value="${base_version}-pre-${timestamp}" />
  </target>

    <target name="setup-version-string" depends="setup-version-string-release,setup-version-string-prerelease" />

   <!-- On jpackage.org-compatible systems, antlr.jar can be found in /usr/share/java -->
   <available property="antlr.jar" file="/usr/share/java/antlr.jar"
              value="/usr/share/java/antlr.jar"/>

    <!-- ================================================================== -->
    <!-- 
       - Load user properties which override build defaults.
      -->
    <target name="load.user.properties">
        <!-- 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}." />
        <property file="${user.home}/gluegen.properties" />
        <echo message="Loaded ${user.home}/gluegen.properties." />
        <echo message="antlr.jar=${antlr.jar}" />
        <fail message="antlr.jar was not specified in joal.properties or gluegen.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"/>
    </target>

    <!-- ================================================================== -->
    <!-- 
       - Base initialization and detection of operating system.
      -->
    <target name="base.init" depends="load.user.properties,gluegen.cpptasks.detect.os">
        <!-- 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>

    <!-- ================================================================== -->
    <!-- 
       - Set up java.home.dir appropriately on all platforms.
      -->
    <target name="setup.java.home.dir.nonmacosx" depends="base.init" 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="base.init" 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="setup.java.home.dir, gluegen.cpptasks.detect.compiler">
        <!-- The location and name of the configuration ANT file that will 
           - validate to ensure that all user-define variables are set. -->
        <property name="validate.user.properties" value="${make}/validate-properties.xml" />
           
        <!-- GlueGen properties. -->
        <!-- NOTE that these require a checked-out GlueGen workspace as a -->
        <!-- sibling of the JOAL workspace. -->
        <property name="gluegen.make.dir" value="../../gluegen/make" />
        <property name="gluegen.build.xml" value="${gluegen.make.dir}/build.xml" />
        <property name="gluegen.jar" value="../../gluegen/build/gluegen.jar" />
        <property name="gluegen-rt.jar" value="../../gluegen/build/gluegen-rt.jar" />

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

        <!-- 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}/java" />
        <property name="rootrel.src.c" value="${rootrel.src}/native" />
        <property name="rootrel.build" value="build" />
        <property name="rootrel.src.generated" value="${rootrel.build}/gensrc" />
        <property name="rootrel.generated.java" value="${rootrel.src.generated}/classes" />
        <property name="rootrel.generated.c.joal" value="${rootrel.src.generated}/native/joal" />
        <property name="rootrel.obj" value="${rootrel.build}/obj" />
        <property name="rootrel.obj.joal" value="${rootrel.obj}/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.1" dir="${stub.includes.dir}">
            <include name="openal/**" />
        </fileset>
        <fileset id="stub.includes.dependencies.fileset.2" file="${gluegen.jar}" />
        <fileset id="stub.includes.dependencies.fileset.3" dir=".">
            <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" />
        <property name="java.includes.dir.freebsd" value="${java.includes.dir}/freebsd" />
        <property name="java.includes.dir.hpux" value="${java.includes.dir}/hp-ux" />

        <!-- 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,net.java.games.sound3d" />
        <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="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="compiler.cfg.id"                      value="compiler.cfg.win32.msvc" />
      <property name="linker.cfg.id"                        value="linker.cfg.win32.msvc" />
    </target>
    
    <target name="declare.win32.vc8" if="isVC8">
      <echo message="Win32.VC8" />
      <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.vc8_x64" if="isVC8_X64">
      <echo message="Win32.VC8_X64" />
      <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.vc8,declare.win32.vc8_x64,declare.win32.mingw" if="isWindows">
      <property name="java.includes.dir.platform"           value="${java.includes.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="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="compiler.cfg.id"                      value="compiler.cfg.linux.amd64" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.linux.amd64" /> 
    </target>

    <target name="declare.linux.ia64" if="isLinuxIA64">
      <echo message="Linux.IA64" />
      <property name="java.includes.dir.platform"           value="${java.includes.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" depends="declare.linux.x86,declare.linux.amd64,declare.linux.ia64" if="isLinux" />

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

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

    <target name="declare.solaris.sparcv9" if="isSolarisSparcv9">
      <echo message="SolarisSparcv9" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir.solaris}" />

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

    <target name="declare.solaris.amd64" if="isSolarisAMD64">
      <echo message="SolarisAMD64" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir.solaris}" />

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

    <target name="declare.macosx.ppc" if="isOSXPPC">
      <echo message="MacOSX PPC" />
    </target>

    <target name="declare.macosx.universal" if="isOSXUniversal">
      <echo message="MacOSX Universal" />
    </target>

    <target name="declare.macosx" if="isOSX" depends="declare.macosx.ppc,declare.macosx.universal">
      <echo message="MacOSX" />
      <property name="java.includes.dir.platform"           value="${java.includes.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="compiler.cfg.id"                      value="compiler.cfg.freebsd" />
      <property name="linker.cfg.id"                        value="linker.cfg.linux" />
    </target>

    <target name="declare.hpux" if="isHPUX">
      <echo message="HP-UX" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir.hpux}" />

      <property name="compiler.cfg.id"                      value="compiler.cfg.hpux" />
      <property name="linker.cfg.id"                        value="linker.cfg.hpux" />
    </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.solaris32,declare.macosx,declare.freebsd" />

    <!-- ================================================================== -->
    <!-- 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}" dir="${gluegen.make.dir}" target="all" inheritAll="false" />
    </target>

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

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

        <!-- Now check for the presence of one well-known file -->
        <uptodate property="java.generate.skip"
                  targetfile="${src.generated.java}/net/java/games/joal/AL.java">
            <srcfiles refid="stub.includes.dependencies.fileset.1" />
            <srcfiles refid="stub.includes.dependencies.fileset.2" />
            <srcfiles refid="stub.includes.dependencies.fileset.3" />
        </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, java.generate.check" unless="java.generate.skip">
        <!-- Add the GlueGen task to ANT -->
        <taskdef name="gluegen" classname="com.sun.gluegen.ant.GlueGenTask"
                 classpathref="gluegen.classpath" />
                 
        <!-- Use the GlueGen task to generate the Java files -->

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

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

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

    <!-- ================================================================== -->
    <!-- 
       - Compile the original and generated source.
      -->
    <target name="java.compile" depends="java.generate">
        <javac destdir="${classes}" classpath="${gluegen-rt.jar}" source="1.4" debug="true" debuglevel="source,lines">
            <src path="${src.java}" />
            <src path="${src.generated.java}" />
        </javac>
    </target>

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

    <target name="c.configure" depends="gluegen.cpptasks.configure.compiler">
      <!-- linker configuration -->
 
      <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_native.so" tofile="${obj}/joal_native.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_native.dylib" tofile="${obj}/libjoal_native.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" />
      <!-- Create Java Web Start jar file from built file -->
      <jar destfile="../build/joal-natives-${os.and.arch}.jar">
        <fileset dir="../build/obj">
          <include name="*joal_native.${native.library.suffix}" />
        </fileset>
        <fileset dir="lib/${os.and.arch}">
          <include name="*.${native.library.suffix}" />
        </fileset>
      </jar>
    </target>

    <!-- ================================================================== -->
    <!--
       - Build the joal.jar file.
      -->
    <target name="jar" depends="java.compile,setup-version-string">
        <!-- Prepare the manifest -->
        <copy file="joalversion"
          tofile="tempversion"
          overwrite="true">
          <filterset>
              <filter token="VERSION" value="${version-string}"/>
              <filter token="BASEVERSION" value="${base_version}"/>
          </filterset>
        </copy>

        <!-- Build the jar excluding any build specific classes. -->
        <jar manifest="tempversion" destfile="${joal.jar}">
            <fileset dir="${classes}">
                <include name="net/java/games/**" />
                <include name="com/sun/gluegen/runtime/**" />
            </fileset>
        </jar>
        <delete file="tempversion"/>
    </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}"
                 destdir="${javadoc}" windowtitle="JOAL API"
                 source="1.4"
                 linkoffline="${javadoc.link} 142-packages" />
    </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"
                 linkoffline="${javadoc.link} 142-packages" />
    </target>

    <!-- Build zip archives for developers, both source and binaries -->
    <target name="zip" depends="setup-version-string">
        <!-- Clean up and create temporary directory -->
        <delete dir="../build/tmp" failonerror="false" />
        <delete>
            <fileset dir="../build">
                <include name="*.zip" />
            </fileset>
        </delete>
        <property name="joal.tmp.version" value="joal-${version-string}-${os.and.arch}" />
        <mkdir dir="../build/tmp/${joal.tmp.version}/lib" />
        <copy file="../build/joal.jar" todir="../build/tmp/${joal.tmp.version}/lib" />
        <copy file="${gluegen-rt.jar}" todir="../build/tmp/${joal.tmp.version}/lib" />
        <copy todir="../build/tmp/${joal.tmp.version}/lib">
            <fileset dir="../build/obj">
                <include name="*.${native.library.suffix}" />
            </fileset>
        </copy>
        <copy todir="../build/tmp/${joal.tmp.version}/lib">
            <fileset dir="../../gluegen/build/obj">
                <include name="*.${native.library.suffix}" />
            </fileset>
        </copy>
        <copy file="../README.txt" todir="../build/tmp/${joal.tmp.version}" />
        <copy file="../LICENSE.txt" todir="../build/tmp/${joal.tmp.version}" />
        <zip destfile="../build/${joal.tmp.version}.zip"
             basedir="../build/tmp"
             includes="${joal.tmp.version}/**" />
	<!-- Build a source archive as well -->
        <delete file="../build/joal-${version-string}-src.zip" />
        <zip destfile="../build/joal-${version-string}-src.zip"
	     basedir="../.."
	     includes="gluegen/LICENSE.txt,gluegen/doc/**,gluegen/make/**,gluegen/src/**,joal/README.txt,joal/LICENSE.txt,joal/make/**,joal/src/**,joal/build/gensrc/classes/net/java/games/joal/AL.java,joal/build/gensrc/classes/net/java/games/joal/ALC.java,joal/build/gensrc/classes/net/java/games/joal/ALCConstants.java,joal/build/gensrc/classes/net/java/games/joal/ALCcontext.java,joal/build/gensrc/classes/net/java/games/joal/ALCdevice.java,joal/build/gensrc/classes/net/java/games/joal/ALConstants.java"
	     excludes="**/*.class,**/*~"
	     />
    </target>

    <!-- ================================================================== -->
    <!--
       - Build the Java Web Start binaries out of native library builds for
       - each individual platform. 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 the native code for that platform
       - (libjoal_native.so, joal_native.dll, or libjoal_native.jnilib).
      -->
    <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,setup-version-string">
        <delete>
            <fileset dir="${joal.dist.dir}" includes="*.jar" />
            <fileset dir="${joal.dist.dir}" includes="*.zip" />
        </delete>
        <!-- Copy Java Web Start jar files, source archive(s) and binary zip archives -->
        <copy todir="${joal.dist.dir}">
           <fileset dir="${joal.dist.dir}/joal-win/32">
             <include name="*.jar" />
             <include name="*.zip" />
           </fileset>
           <fileset dir="${joal.dist.dir}/joal-linux/32">
             <include name="*.jar" />
             <!-- Pick up source archive from Linux build as well -->
             <include name="*.zip" />
           </fileset>
           <fileset dir="${joal.dist.dir}/joal-macosx/ppc">
             <include name="*.jar" />
             <include name="*.zip" />
           </fileset>
           <fileset dir="${joal.dist.dir}/joal-macosx/fat">
             <include name="*.jar" />
             <include name="*.zip" />
           </fileset>
           <!-- NOTE: No OpenAL for Windows/AMD64, Linux/AMD64 or Solaris at the moment -->
        </copy>
        <!-- Build one archive containing all jars related to Java Web Start -->
        <tstamp>
             <format property="timestamp" pattern="yyyyMMdd"/>
        </tstamp>
        <zip destfile="${joal.dist.dir}/joal-${version-string}-webstart.zip"
	     basedir="${joal.dist.dir}"
	     includes="*.jar"
	     />
    </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="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" />

        <!-- Build zip archives. -->
        <antcall target="zip" 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>