summaryrefslogtreecommitdiffstats
path: root/make/gluegen-cpptasks.xml
blob: 6ea364e59f7761708617e16f536f1279b5dad9f2 (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
<?xml version="1.0" encoding="UTF-8"?>
<!--
   - Ant project file which sets up cpptasks to compile native code
   - generated by GlueGen for multiple supported platforms. This Ant
   - project file is not intended to be executed standalone, but imported
   - by other projects which use GlueGen to generate native code and
   - need to compile that native code.
   - 
   - Before importing this file, the property "gluegen.root" must be
   - defined; this is the relative path from the current working
   - directory (e.g., from which the parent project's build.xml is being
   - executed) to the top of the checked-out GlueGen workspace.
   - 
   - This Ant project file depends on the following properties being set
   - externally:
   - 
   -   win32.c.compiler (required to be set on Windows):
   -       one of "vc6", "vc7", "vc8", or "mingw".
   -   c.compiler.debug:
   -       set to "true" if debug version of the compiled
   -       C code is desired.
   -   macosxfat:
   -       set to "true" if universal / fat binaries (both PowerPC
   -       and Intel code) are desired on Mac OS X. Requires
   -       support for cross-compilation from the underlying C
   -       compiler.
   - 
   - The gluegen.cpptasks.detect.os target sets the following
   - properties appropriately. They are only set to "true" if the OS/CPU
   - configuration is exactly as specified.
   - 
   -   isFreeBSD
   -   isHPUX
   -   isIA64
   -   isLinux
   -   isLinuxAMD64
   -   isLinuxIA64
   -   isLinuxX86
   -   isOSX
   -   isSolaris
   -   isSolarisAMD64
   -   isSolarisSparcv9
   -   isUnix
   -   isWindows
   -   isX11
   - 
   - The gluegen.cpptasks.detect.compiler target sets the following
   - properties appropriately. They are only set to "true" if the OS/compiler
   - configuration is exactly as specified.
   - 
   -   isVC6
   -   isVC7
   -   isVC8
   -   isVC8_X64
   -   isVC8Family (= isVC8 || isVC8_X64)
   -   isMingW
   - 
   - The gluegen.cpptasks.configure.compiler initializes several
   - cpptasks compiler and linker configurations designed to support
   - compilation of C code on multiple platforms. Generally if it is
   - necessary to set up include paths, link paths, etc., then these
   - compilers and linkers will need to be subclassed in sub-projects. 
   - However, at least the base-level configuration does not need to
   - be replicated.
   - 
   - The following compiler and linker IDs are defined by this target:
   - 
   -   compiler.cfg.linux
   -   compiler.cfg.linux.amd64
   -   compiler.cfg.solaris
   -   compiler.cfg.solaris.sparcv9
   -   compiler.cfg.solaris.amd64
   -   compiler.cfg.win32.mingw
   -   compiler.cfg.win32.msvc
   -   compiler.cfg.macosx
   -   compiler.cfg.freebsd
   -   compiler.cfg.hpux
   -   linker.cfg.linux
   -   linker.cfg.linux.amd64
   -   linker.cfg.solaris
   -   linker.cfg.solaris.sparcv9
   -   linker.cfg.solaris.amd64
   -   linker.cfg.win32.mingw
   -   linker.cfg.win32.msvc
   -   linker.cfg.macosx
   -   linker.cfg.hpux
  -->
<project name="GlueGen-cpptasks" basedir=".">
  <!-- import cpptasks -->
  <typedef resource="net/sf/antcontrib/cpptasks/antlib.xml" classpath="${gluegen.root}/make/lib/cpptasks.jar"/>

  <!-- Detect OS and compiler configuration -->
  <target name="gluegen.cpptasks.detect.os" unless="gluegen.cpptasks.detected.os">
    <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="isHPUX">
      <os name="HP-UX" />
    </condition>
    <condition property="isLinuxX86">
      <and>
        <istrue value="${isLinux}" />
        <or>
          <os arch="i386" />
          <os arch="x86" />
        </or>
      </and>
    </condition>
    <condition property="isLinuxAMD64">
      <and>
        <istrue value="${isLinux}" />
        <or>
          <os arch="AMD64" />
          <os arch="x86_64" />
        </or>
      </and>
    </condition>
    <condition property="isLinuxIA64">
      <and>
        <istrue value="${isLinux}" />
        <os arch="IA64" />
      </and>
    </condition>
    <condition property="isIA64">
      <os arch="IA64" />
    </condition>
    <condition property="isSolaris32Bit">
      <and>
         <istrue value="${isSolaris}" />
         <or>
          <os arch="i386" />
          <os arch="x86" />
          <os arch="sparc" />
         </or>
      </and>
    </condition>
    <condition property="isSolarisSparcv9">
       <and>
         <istrue value="${isSolaris}" />
          <os arch="sparcv9" />
       </and>
    </condition>
    <condition property="isSolarisAMD64">
       <and>
         <istrue value="${isSolaris}" />
          <os arch="AMD64" />
       </and>
    </condition>

    <!-- Note: assumes X11 platform by default -->
    <condition property="isX11">
      <and>
        <isfalse value="${isWindows}" />
        <isfalse value="${isOSX}" />
      </and>
    </condition>

    <echo message="FreeBSD=${isFreeBSD}" />
    <echo message="HPUX=${isHPUX}" />
    <echo message="IA64=${isIA64}" />
    <echo message="Linux=${isLinux}" />
    <echo message="LinuxAMD64=${isLinuxAMD64}" />
    <echo message="LinuxIA64=${isLinuxIA64}" />
    <echo message="LinuxX86=${isLinuxX86}" />
    <echo message="OS X=${isOSX}" />
    <echo message="Solaris=${isSolaris}" />
    <echo message="SolarisSparcv9=${isSolarisSparcv9}" />
    <echo message="SolarisAMD64=${isSolarisAMD64}" />
    <echo message="Unix=${isUnix}" />
    <echo message="Windows=${isWindows}" />
    <echo message="X11=${isX11}" />

    <property name="gluegen.cpptasks.detected.os" value="true" />
  </target>

  <!-- Detect compiler setup, in particular on Windows; separated
     - out because this must sometimes be called late in the setup process
    -->
  <target name="gluegen.cpptasks.detect.compiler">
    <!-- Set up compiler selection on Windows -->
    <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="isVC8">
      <and>
        <istrue value="${isWindows}" />
        <equals arg1="${win32.c.compiler}" arg2="vc8" />
      </and>
    </condition>
    <condition property="isVC8_X64">
      <and>
        <istrue value="${isWindows}" />
        <equals arg1="${win32.c.compiler}" arg2="vc8_x64" />
      </and>
    </condition>
    <condition property="isVC8Family">
      <or>
        <istrue value="${isVC8}" />
        <istrue value="${isVC8_X64}" />
      </or>
    </condition>
    <condition property="isMingW">
      <and>
        <istrue value="${isWindows}" />
        <equals arg1="${win32.c.compiler}" arg2="mingw" />
      </and>
    </condition>
    <condition property="WindowsFailure">
      <and>
        <istrue  value="${isWindows}" />
        <isfalse value="${isVC6}" />
        <isfalse value="${isVC7}" />
        <isfalse value="${isVC8}" />
        <isfalse value="${isVC8_X64}" />
        <isfalse value="${isMingW}" />
      </and>
    </condition>
    <fail message="Must specify either win32.c.compiler in e.g. jogl.properties or use e.g. win32.vc6 build target" if="WindowsFailure" />
    <echo message="VC6=${isVC6}" />
    <echo message="VC7=${isVC7}" />
    <echo message="VC8=${isVC8}" />
    <echo message="MingW=${isMingW}" />

    <!-- NOTE: the value of the debug and optimise attributes will not be overridden if already set externally -->
    <property name="c.compiler.debug"     value="false" /> 
  </target>

  <target name="gluegen.cpptasks.configure.compiler">
    <!-- 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.solaris.sparcv9" name="suncc">
      <compilerarg value="-fast" />
      <compilerarg value="-xchip=ultra" />
      <compilerarg value="-xarch=v9a" />
      <compilerarg value="-xcode=32" />
    </compiler>

    <compiler id="compiler.cfg.solaris.amd64" 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>

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

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

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

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

    <linker id="linker.cfg.solaris.amd64" 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">
    </linker>
  </target>

</project>