summaryrefslogtreecommitdiffstats
path: root/make/build.xml
blob: 884c499edc7dae66734bea8da82446ae2e94d14e (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
<?xml version="1.0" encoding="UTF-8"?>
<!--
   - Ant build for GlueGen and corresponding ANT tasks. Also builds
   - JOGL-specific BuildStaticGLInfo and its corresponding ANT task.
   -
   - This build has been tested with ANT 1.6.2 and ANTLR 2.7.4.
   -
   - Public targets:
   -   all:  clean and build GlueGen and GlueGen Ant task
   -   clean:  clean all built
  -->
<project name="GlueGen" basedir="." default="all">
  <target name="load.user.properties" unless="user.properties.file">
    <!-- 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}/gluegen.properties" />
    <property file="${user.properties.file}" />
    <echo message="Loaded ${user.properties.file}." />
    <fail message="antlr.jar was not specified in gluegen.properties. Please see README.txt for instructions" unless="antlr.jar"/>
    <echo message="antlr.jar=${antlr.jar}" />
  </target>

  <target name="setup-excludes-1" if="gluegen.nsig">
    <property name="gluegen.excludes" value="" />
  </target>

  <target name="setup-excludes-2" unless="gluegen.nsig">
    <property name="gluegen.excludes" value="com/sun/gluegen/runtime/BufferFactoryInternal.java,com/sun/gluegen/nativesig/**" />
  </target>

  <target name="init" depends="load.user.properties,setup-excludes-1,setup-excludes-2">
    <!-- Declare all paths and user defined variables. -->

    <!-- The source directories. -->
    <property name="src.java" value="../src/java" />
    <property name="build"    value="../build" />

    <!-- The generated source directories. -->
    <property name="src.generated"      value="../build/gensrc" />
    <property name="src.generated.java" value="../build/gensrc/java" />

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

    <!-- Call the external config validator script to make sure the config is ok and consistent -->
    <ant antfile="validate-properties.xml" inheritall="true"/>

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

    <!-- Create the classpath for ANTLR.  This requires the user-defined
      - "antlr.jar" property. -->
    <path id="antlr.classpath">
      <pathelement location="${antlr.jar}" />
    </path>
    
    <!-- The location of the GlueGen source and the C grammar files. -->
    <property name="gluegen" value="${src.java}/com/sun/gluegen" />
    <property name="c.grammar" value="${gluegen}/cgram" />
        
    <!-- The resulting location of the generated Java files from the
      - C grammar via ANTLR. -->
    <property name="gluegen.build" value="${src.generated.java}/com/sun/gluegen" />
    <property name="generated.java.from.grammar" value="${gluegen.build}/cgram" />
  </target>

  <!--
    - Using ANTLR generate the specified Java files.
    -
    - @param target the grammar file to process
    - @param output.dir the directory to write the generated files to.  If
    -        the directory does not exist, it will be created.
    -->
  <target name="generate.c.grammar">
    <!-- Generate the Java files -->
    <antlr target="${output.dir}/${target}" outputdirectory="${output.dir}">
      <classpath refid="antlr.classpath" />
    </antlr>
  </target>
    
  <!--
    - Using ANTLR generate the specified Java files with an overridden
    - grammar file.
    -
    - @param target the grammar file to process
    - @param glib the overridding grammar file
    - @param output.dir the directory to write the generated files to.  If
    -        the directory does not exist, it will be created.
   -->
  <target name="generate.c.grammar.glib">
    <!-- Generate the Java files -->
    <antlr target="${output.dir}/${target}" glib="${output.dir}/${glib}" outputdirectory="${output.dir}">
      <classpath refid="antlr.classpath" />
    </antlr>
  </target>

  <!-- Use GlueGen to generate the source code for the NativeLibrary
       implementation. Note that to make the build process simpler (in
       particular, the nightly builds) we do not do this every time we
       run the build, but instead check in the generated sources to
       the source tree. -->

  <property name="gluegen.root" value="../" />
  <import file="gluegen-cpptasks.xml" />
  <target name="generate.nativelibrary.sources" depends="init" >
    <!-- Define the appropriate include paths -->
    <dirset id="stub.includes.fileset.windows" dir=".">
      <include name="stub_includes/windows/**" />
    </dirset>
    <dirset id="stub.includes.fileset.unix" dir=".">
      <include name="stub_includes/unix/**" />
    </dirset>
    <dirset id="stub.includes.fileset.macosx" dir=".">
      <include name="stub_includes/macosx/**" />
    </dirset>
    <!-- Define the classpath we should use -->
    <path id="gluegen.classpath" >
      <pathelement location="${classes}" />
      <pathelement location="${antlr.jar}" />
    </path>
    <!-- Define the GlueGen task we just built -->
    <taskdef name="gluegen" classname="com.sun.gluegen.ant.GlueGenTask"
             classpathref="gluegen.classpath" />

    <!-- Execute it against all of the OSs' header files -->
    <gluegen src="stub_includes/windows/dynamic-linker.h"
             config="dynlink-windows.cfg"
             includeRefId="stub.includes.fileset.windows"
             emitter="com.sun.gluegen.JavaEmitter">
      <classpath refid="gluegen.classpath" />
    </gluegen>
    <gluegen src="stub_includes/unix/dynamic-linker.h"
             config="dynlink-unix.cfg"
             includeRefId="stub.includes.fileset.unix"
             emitter="com.sun.gluegen.JavaEmitter">
      <classpath refid="gluegen.classpath" />
    </gluegen>
    <gluegen src="stub_includes/macosx/dynamic-linker.h"
             config="dynlink-macosx.cfg"
             includeRefId="stub.includes.fileset.macosx"
             emitter="com.sun.gluegen.JavaEmitter">
      <classpath refid="gluegen.classpath" />
    </gluegen>
  </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" >
      <property name="java.includes.dir" value="${java.home.dir}/include" />
    </target>

    <!-- ================================================================== -->
    <!-- 
       - Compile the native C code for GlueGen's dynamic linker interface.
      -->

    <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" />
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-windows-i586.jar" />
    </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" />
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-windows-i586.jar" />
    </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" />
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-windows-i586.jar" />
    </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" />
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-windows-amd64.jar" />
    </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" />
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-windows-i586.jar" />
    </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="c.src.dir"                            value="windows" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir}/win32" />
      <property name="gluegen.rt.natives.dso"               value="gluegen-rt.dll" />
    </target>

    <target name="declare.linux.x86" if="isLinuxX86">
      <echo message="Linux.x86" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-linux-i586.jar" />
    </target>
    
    <target name="declare.linux.amd64" if="isLinuxAMD64">
      <echo message="Linux.AMD64" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux.amd64" />
      <property name="linker.cfg.id"                        value="linker.cfg.linux.amd64" />
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-linux-amd64.jar" />
    </target>
    
    <target name="declare.linux.ia64" if="isLinuxIA64">
      <echo message="Linux.IA64" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.linux" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.linux" /> 
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-linux-ia64.jar" />
    </target>

    <target name="declare.linux" depends="declare.linux.x86,declare.linux.amd64,declare.linux.ia64" if="isLinux" >
      <property name="c.src.dir"                            value="unix" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir}/linux" />
      <property name="gluegen.rt.natives.dso"               value="libgluegen-rt.so" />
    </target>

    <target name="declare.solaris32" if="isSolaris32Bit">
      <echo message="Solaris" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.solaris" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.solaris" /> 
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-solaris-${os.arch}.jar" />
    </target>
 
    <target name="declare.solarisSparcv9" if="isSolarisSparcv9">
      <echo message="SolarisSparcv9" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.solarisSparcv9" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.solarisSparcv9" /> 
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-solaris-sparcv9.jar" />
    </target>

    <target name="declare.solarisAMD64" if="isSolarisAMD64">
      <echo message="SolarisAMD64" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.solarisAMD64" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.solarisAMD64" /> 
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-solaris-amd64.jar" />
    </target>
   
    <target name="declare.solaris" depends="declare.solaris32,declare.solarisSparcv9,declare.solarisAMD64" if="isSolaris" >
      <property name="c.src.dir"                            value="unix" />
      <property name="java.includes.dir.platform"           value="${java.includes.dir}/solaris" />
      <property name="gluegen.rt.natives.dso"               value="libgluegen-rt.so" />
    </target>

    <target name="declare.macosx.ppc" unless="macosxfat">
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-macosx-ppc.jar" />
    </target>

    <target name="declare.macosx.universal" if="macosxfat">
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-macosx-universal.jar" />
    </target>

    <target name="declare.macosx" depends="declare.macosx.ppc,declare.macosx.universal" if="isOSX">
      <echo message="MacOSX" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.macosx" /> 
      <property name="linker.cfg.id"                        value="linker.cfg.macosx" /> 
      <property name="c.src.dir"                            value="macosx" />
      <property name="java.includes.dir.platform"           value="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" />
      <property name="gluegen.rt.natives.dso"               value="libgluegen-rt.jnilib" />
    </target>
    
    <target name="declare.freebsd" if="isFreeBSD">
      <echo message="FreeBSD" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.freebsd" />
      <property name="linker.cfg.id"                        value="linker.cfg.linux" />
      <property name="c.src.dir"                            value="unix" />
      <property name="java.includes.dir.freebsd"            value="${java.includes.dir}/freebsd" />
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-freebsd-i586.jar" />
      <property name="gluegen.rt.natives.dso"               value="libgluegen-rt.so" />
    </target>

    <target name="declare.hpux" if="isHPUX">
      <echo message="HP-UX" />
      <property name="compiler.cfg.id"                      value="compiler.cfg.hpux" />
      <property name="linker.cfg.id"                        value="linker.cfg.hpux" />
      <property name="c.src.dir"                            value="unix" />
      <property name="java.includes.dir.hpux"               value="${java.includes.dir}/hp-ux" />
      <property name="gluegen.rt.natives.jar"               value="gluegen-rt-natives-hpux-hppa.jar" />
      <property name="gluegen.rt.natives.dso"               value="libgluegen-rt.so" />
    </target>

    <target name="c.configure" depends="gluegen.cpptasks.detect.os,gluegen.cpptasks.detect.compiler,setup.java.home.dir,declare.win32,declare.linux,declare.solaris,declare.macosx,declare.freebsd,declare.hpux" unless="build.javaonly" >
      <!-- 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.solarisSparcv9" name="suncc">
        <compilerarg value="-fast" />
        <compilerarg value="-xchip=ultra" />
        <compilerarg value="-xarch=v9a" />
        <compilerarg value="-xcode=32" />
      </compiler>

      <compiler id="compiler.cfg.solarisAMD64" name="suncc">
        <compilerarg value="-fast" />
        <compilerarg value="-xchip=opteron" />
        <compilerarg value="-xarch=amd64" />
  <!--      <compilerarg value="-xcache=64/64/2:1024/64/16" />   -->
      </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; -->
        <compilerarg value="/GS"      if="isVC8"/>  <!-- buffer security checks -->
        <compilerarg value="/Wp64"    if="isVC8"/>  <!-- detect 64-bit port problems -->
        <compilerarg value="/RTCcsu"  if="isVC8"/>  <!-- various runtime checks -->

        <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" />

      <compiler id="compiler.cfg.hpux" name="aCC">
        <!-- Interpret source as ANSI C89 (not C++) -->
        <compilerarg value="-Ae"/> 
        <!-- Dereferences are performed with four-byte loads and stores. -->
        <compilerarg value="+u4"/>
        <!-- Suppress warnings: 
                 942: signed/unsigned assignment compatibility
                 129: redeclarations in stub_includes -->
        <compilerarg value="+W942,129"/>
        <defineset>
           <!-- aCC doesn't seem to define a generic system macro, a la 
               "__sun". The documentation claims it defines the following,
               but don't seem to work: __HP_aCC, __LP64__, __RISC_0__. 
               HP-UX docs on JNI say to use the defs below 
               (http://www.hp.com/products1/unix/java/infolibrary/prog_guide/JNI_java2.html) -->
           <!-- Single underscore prefix, as recommended by aCC docs... -->
           <define name="_HPUX"/> 
           <define name="_POSIX_C_SOURCE" value="199506L"/>
        </defineset>
      </compiler>
 
      <!-- linker configuration -->
 
      <linker id="linker.cfg.linux" name="gcc" />

      <linker id="linker.cfg.linux.amd64" name="gcc" />

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

      <linker id="linker.cfg.solarisSparcv9" name="suncc">
        <linkerarg value="-xarch=v9a" />
      </linker>

      <linker id="linker.cfg.solarisAMD64" name="suncc">
        <linkerarg value="-xarch=amd64" />
      </linker>

      <linker id="linker.cfg.win32.mingw" name="gcc" incremental="false">
        <linkerarg value="-Wl,--kill-at" />        <!-- remove @ from function names -->
      </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:X86" if="isVC6" />       <!-- explicity set target platform -->
        <linkerarg value="/MACHINE:X86" if="isVC7" />       <!-- explicity set target platform -->
        <linkerarg value="/MACHINE:X86" if="isVC8" />       <!-- explicity set target platform -->
        <linkerarg value="/MACHINE:X64" if="isVC8_X64"/>    <!-- explicity set target platform (IX64) -->
      </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"/>
      </linker>

      <linker id="linker.cfg.hpux" name="aCC" />

      <!-- Common properties -->
      <property name="java.includes.dir" value="${java.home.dir}/include" /> <!-- NOTE:  this MUST be relative for FileSet -->

      <property name="c.compiler.src.files" value="src/native/${c.src.dir}/*.c" />

      <property name="output.lib.name" value="gluegen-rt" />
    </target>

    <target name="c.rename.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="../build/obj/libgluegen-rt.so" tofile="../build/obj/gluegen-rt.dll" />
    </target>

    <target name="c.rename.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="../build/obj/libgluegen-rt.dylib" tofile="../build/obj/libgluegen-rt.jnilib" />
    </target>

    <target name="c.build" depends="c.configure" unless="build.javaonly" >
      <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>

      <mkdir dir="../build/obj" />

      <echo message="Compiling ${c.compiler.src.files}" />
      <echo message="user.dir=${user.dir}" />

      <cc outtype="shared" 
          objdir="../build/obj" 
          outfile="../build/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="GlueGen" 
                      productversion="x.y.z"
                      description="Description"
                      fileversion="x.y.z" 
                      filecomments="File Comment" /-->      

        <fileset dir="..">
          <patternset>
            <include name="${c.compiler.src.files}" />
          </patternset>
        </fileset>

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

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

      <antcall target="c.rename.lib.mingw" inheritRefs="true" />
      <antcall target="c.rename.lib.macosx" inheritRefs="true" />
      <!-- Create Java Web Start jar file from built file -->
      <jar destfile="../build/${gluegen.rt.natives.jar}">
        <fileset dir="../build/obj">
          <include name="${gluegen.rt.natives.dso}" />
        </fileset>
      </jar>
    </target>  

  <target name="build.nativelibrary" if="build.native" >
    <antcall target="c.build" inheritRefs="true" />
  </target>

  <!-- ================================================================== -->
  <!--
    - Build GlueGen.
    -->
  <target name="gluegen.build" depends="init">
    <!-- Because ANTLR looks for importVocab files in the current
         working directory, it likes to have all of its files,
         including supergrammars, in one place, so copy all of the
         grammars to the output directory up front so we don't put
         temporary files into the source tree -->
    <mkdir dir="${generated.java.from.grammar}" />
    <copy todir="${generated.java.from.grammar}">
      <fileset dir="${c.grammar}">
        <include name="*.g" />
      </fileset>
    </copy>

    <!-- Generate the Java files from the C grammar using ANTLR. -->
    <antcall target="generate.c.grammar">
      <param name="output.dir" value="${generated.java.from.grammar}" />
      <param name="target" value="StdCParser.g" />
    </antcall>
    <antcall target="generate.c.grammar.glib">
      <param name="output.dir" value="${generated.java.from.grammar}" />
      <param name="target" value="GnuCParser.g" />
      <param name="glib" value="StdCParser.g" />
    </antcall>
    <antcall target="generate.c.grammar">
      <param name="output.dir" value="${generated.java.from.grammar}" />
      <param name="target" value="GnuCTreeParser.g" />
    </antcall>
    <antcall target="generate.c.grammar.glib">
      <param name="output.dir" value="${generated.java.from.grammar}" />
      <param name="target" value="GnuCEmitter.g" />
      <param name="glib" value="GnuCTreeParser.g" />
    </antcall>
    <antcall target="generate.c.grammar.glib">
      <param name="output.dir" value="${generated.java.from.grammar}" />
      <param name="target" value="HeaderParser.g" />
      <param name="glib" value="GnuCTreeParser.g" />
    </antcall>

    <!-- Build GlueGen using the generated Java files along with the
      - original source. -->
    <javac destdir="${classes}" source="1.4" debug="true" debuglevel="source,lines" excludes="${gluegen.excludes}">
      <src path="${src.java}" />
      <src path="${src.generated.java}" />
      <classpath refid="antlr.classpath" />
    </javac>

    <!-- Build the (native code) NativeLibrary support for
         gluegen-rt.jar using the just-built GlueGen. -->
    <antcall target="build.nativelibrary" inheritRefs="true" />

    <!-- Build gluegen.jar. -->
    <jar destfile="${build}/gluegen.jar" manifest="Manifest">
      <fileset dir="${classes}">
        <include name="**/*.class" />
      </fileset>
    </jar>

    <!-- Build gluegen-rt.jar. -->
    <jar destfile="${build}/gluegen-rt.jar">
      <fileset dir="${classes}">
        <include name="com/sun/gluegen/runtime/*.class" />
      </fileset>
    </jar>

    <!-- Copy antlr.jar into build directory for convenience so
         gluegen.jar can be run via "java -jar". antlr.jar is
         referenced via a Class-Path entry in the Manifest of
         gluegen.jar. -->
    <copy file="${antlr.jar}" todir="${build}" />
  </target>

  <target name="all" depends="gluegen.build" />

  <target name="clean">
    <delete includeEmptyDirs="true" quiet="true">
      <fileset dir="../build" />
    </delete>
  </target>    
</project>