Merge lp:~james-page/ubuntu/natty/libjna-java/multiarch-fix into lp:ubuntu/natty/libjna-java

Proposed by James Page
Status: Merged
Merged at revision: 9
Proposed branch: lp:~james-page/ubuntu/natty/libjna-java/multiarch-fix
Merge into: lp:ubuntu/natty/libjna-java
Diff against target: 5236 lines (+110/-4974)
15 files modified
.pc/.version (+0/-1)
.pc/01-nbproject.patch/build.xml (+0/-645)
.pc/02-builddir.patch/build.xml (+0/-643)
.pc/03-dynlink-and-cflags.patch/build.xml (+0/-643)
.pc/04-load-native-code-from-fs.patch/src/com/sun/jna/Native.java (+0/-1441)
.pc/05-support-gnu-kfreebsd.patch/build.xml (+0/-647)
.pc/05-support-gnu-kfreebsd.patch/native/Makefile (+0/-275)
.pc/06-remove-gjdoc-inexistent-options.patch/build.xml (+0/-650)
.pc/applied-patches (+0/-6)
build.xml (+15/-19)
debian/changelog (+8/-0)
debian/patches/07-multiarch-support.patch (+86/-0)
debian/patches/series (+1/-0)
native/Makefile (+0/-1)
src/com/sun/jna/Native.java (+0/-3)
To merge this branch: bzr merge lp:~james-page/ubuntu/natty/libjna-java/multiarch-fix
Reviewer Review Type Date Requested Status
James Page Needs Resubmitting
Steve Langasek Needs Fixing
Review via email: mp+54383@code.launchpad.net

Description of the change

Update to path searching code to support multi-arch locations of libraries.

I'm happy with (and have tested) the code that detects and sets the path for i386 and amd64 but I would appreciate close review of both the ARM and PPC multi-arch generation code.

The key part is in the NativeLibrary.java part of the patch.

To post a comment you must log in.
Revision history for this message
James Page (james-page) wrote :

Hmm - handily I also managed to tidy up the .pc folder - looks like the patches where checked in applied to the bzr branch.

debian/patches/07-multiarch-support.patch is the interesting bit.

Revision history for this message
Steve Langasek (vorlon) wrote :

I'm not thrilled about this being handled in non-generic fashion within libjna-java. Why does this need to construct such a path? For native loading we should always be able defer to the built-in search path from libdl as used for dlopen().

++ } else if (Platform.isARM()) {
++ cpu = "arm";
++ kernel = "linuxapcs";
++ }

This looks like it might be based on <http://wiki.debian.org/Multiarch/Tuples>, which has been abandoned in the final multiarch implementation in favor of GNU triplets. Sorry about that, I've marked it now as obsolete on <http://wiki.debian.org/Multiarch>. The triplet used on armel is 'arm-linux-gnueabi' (linuxapcs, in any case, refers to the obsolete OABI interface).

Also, there is an armhf port pending which will also show up as 'arm' with this check, but has a different ABI for library calls and will have its libraries installed in a different path. It would be nice if any solution here was generic enough to handle this architecture too.

Finally, the rationale for this seems to be that libjna-java needs to look up unversioned libraries. This is just plain *wrong* for any caller to do with a shared library. The soname declares the ABI, and if you don't know the soname, you don't know the ABI and should not be trying to poke at its symbols. In the case of libpam.so which started this, the unversioned '.so' symlink shouldn't even be present on a normal system; it's only installed when you have libpam-dev, which should not be a runtime requirement.

review: Needs Fixing
Revision history for this message
James Page (james-page) wrote :

Steve

I agree that I would rather leave library resolution up to libdl and let the system handle it - however that does not change the fact that moving to multi-arch has broken the path search behaviour in libjna-java.

I think that the version-less approach comes from the Java specification/jdk and is probably related to Java being inherently cross platform plus trying to take away complexity from developers.

Most native library loads that I have seen (using jna or native System calls) simply pass the library name - for example 'pam' or 'c'.

Native JDK maps this to libpam.so which as Ubuntu no longer has versionless .so's does not work (but that's a different issue).

In a cross platform world this allows developers to map 'mylibrary' to 'libmylibrary.so' in Linux and 'mylibrary.dll' in Windows.....

If jna can't find a versionless .so it makes an attempt to match to a 'best version' - meaning highest version - by searching its native library path which is created dynamically based on the platform.

jna can use versioned library names i.e. libpam.so.0 - I did a quick test with the pam integration in Jenkins and it works OK (so I will patch this specific library use-case).

However I still think that we should fix the fallback behaviour of jna to work with multi-arch based libraries. I intend to submit this back upstream as well as anyone using a non-Ubuntu distributed version of jna will also have the same issue.

I'll make the amends with reference to the armel platform and the armhf port - where can I find information on what ports/architectures we need to support?

Revision history for this message
Colin Watson (cjwatson) wrote :

On Wed, Mar 23, 2011 at 09:45:25AM -0000, James Page wrote:
> Native JDK maps this to libpam.so which as Ubuntu no longer has
> versionless .so's does not work (but that's a different issue).

Just to be clear, Ubuntu has only ever installed versionless .so files
in development library packages, never in runtime library packages; this
isn't a recent change.

Revision history for this message
James Page (james-page) wrote :

On Wed, 2011-03-23 at 10:01 +0000, Colin Watson wrote:
> Just to be clear, Ubuntu has only ever installed versionless .so files
> in development library packages, never in runtime library packages;
> this
> isn't a recent change.

Hi Colin

The libraries that install into /usr/lib/jni install versionless .so's.

As this directory is specifically for Java Native Integration and the
JVM won't read a versioned .so this is understandable.

The issue here is that libjna-java works around deficiencies in the JVM
native library integration (which is over simplistic) and makes it much
easier to wrap an existing system library in a Java wrapper without
having to provide an intermediary library in /usr/lib/jni
(unversioned....).

I also found libpam.so in ia32-libs on a 64 bit Maverick install which
was clouding my understanding of the issue.

--
James Page
Software Engineer, Ubuntu Server Team

Revision history for this message
Steve Langasek (vorlon) wrote :

On Wed, Mar 23, 2011 at 10:37:24AM -0000, James Page wrote:
> On Wed, 2011-03-23 at 10:01 +0000, Colin Watson wrote:
> > Just to be clear, Ubuntu has only ever installed versionless .so files
> > in development library packages, never in runtime library packages;
> > this
> > isn't a recent change.

> The libraries that install into /usr/lib/jni install versionless .so's.

Yes, but that's not what's meant here by a "library". The runtime system
libraries - those that get referenced via DT_NEEDED entries in the ELF
headers of binaries - need to have revision handling via their sonames,
because they ensure the system continues to interoperate over time.
Dynamically loaded objects in private directories, such as /usr/lib/jni, may
well have other conventions for dealing with ABI changes, but when Java
loads libraries from public system directories, the soname is *the*
convention for ensuring you have the object you were looking for. dlopening
libpam.so, even when it doesn't fail immediately, is still wrong.

> As this directory is specifically for Java Native Integration and the
> JVM won't read a versioned .so this is understandable.

Having looked at the openjdk code, that was not my understanding; but I
guess there may be multiple interfaces for this. :/

> The issue here is that libjna-java works around deficiencies in the JVM
> native library integration (which is over simplistic) and makes it much
> easier to wrap an existing system library in a Java wrapper without
> having to provide an intermediary library in /usr/lib/jni
> (unversioned....).

Well, not so much easier when it means depending on -dev packages, or
soon-to-be-deprecated ia32-libs, to find the library at runtime. :)

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
<email address hidden> <email address hidden>

11. By James Page

Minor amendment to fix arm multi-arch path

Revision history for this message
James Page (james-page) wrote :

Steve

I've pushed a revised branch with the arm multi-arch detection + path creation corrected as above (and as discussed via irc).

debian/patches/07-multiarch-support.patch - still contains the interesting stuff

Cheers

James

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory '.pc'
2=== removed file '.pc/.version'
3--- .pc/.version 2010-04-08 14:51:06 +0000
4+++ .pc/.version 1970-01-01 00:00:00 +0000
5@@ -1,1 +0,0 @@
6-2
7
8=== removed directory '.pc/01-nbproject.patch'
9=== removed file '.pc/01-nbproject.patch/build.xml'
10--- .pc/01-nbproject.patch/build.xml 2010-04-21 16:36:37 +0000
11+++ .pc/01-nbproject.patch/build.xml 1970-01-01 00:00:00 +0000
12@@ -1,645 +0,0 @@
13-<?xml version="1.0" encoding="UTF-8"?>
14-<project name="JNA" default="default" basedir=".">
15- <description>Builds and tests JNA</description>
16-
17- <!--
18- Conventions (since ant can't easily specify arbitrary file dependencies):
19- The uptodate property for a given target TARGET is "-TARGET"; the actual
20- target to generate the uptodate property is named ":TARGET".
21-
22- Properties (except for uptodate properties) separate words by dots, targets
23- by dashes.
24- -->
25-
26- <!-- global properties -->
27- <!-- (all build-related props should go in -dynamic-properties) -->
28- <property name="name" value="jna"/>
29- <property name="jar" value="${name}.jar"/>
30- <property name="testjar" value="${name}-test.jar"/>
31- <property name="debug" value="true"/>
32- <property name="debug.native" value="false"/>
33- <property name="cflags_extra.native" value=""/>
34- <property name="dynlink.native" value="false"/>
35- <property name="native" location="native"/>
36- <property name="src" location="src"/>
37- <property name="dist" location="dist"/>
38- <property name="test.src" location="test"/>
39- <property name="doc" location="doc"/>
40- <property name="javadoc" location="${doc}/javadoc"/>
41- <property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
42- <property name="vendor" value="JNA Development Team"/>
43- <property name="copyright"
44- value="Copyright &amp;copy; 2007-2009 Timothy Wall. All Rights Reserved."/>
45- <buildnumber/>
46- <!-- JNA library release version -->
47- <property name="jna.major" value="3"/>
48- <property name="jna.minor" value="2"/>
49- <property name="jna.revision" value="4"/>
50- <property name="jna.build" value="${build.number}"/>
51- <property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
52- <!-- jnidispatch library release version -->
53- <property name="jni.major" value="3"/>
54- <property name="jni.minor" value="2"/>
55- <property name="jni.revision" value="1"/>
56- <property name="jni.build" value="${build.number}"/>
57- <property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
58- <property name="jni.md5" value="c870290c36c8d3fdf85db7c782febc3f"/>
59- <property name="spec.title" value="Java Native Access (JNA)"/>
60- <property name="spec.vendor" value="${vendor}"/>
61- <property name="spec.version" value="${jna.major}"/>
62- <property name="impl.title" value="com.sun.jna"/>
63- <property name="impl.vendor" value="${spec.vendor}"/>
64- <property name="impl.version" value="${jna.version} (b${jna.build})"/>
65-
66- <property name="compatibility" value="1.4"/>
67- <property name="test.compatibility" value="1.5"/>
68-
69- <!-- Miscellaneous -->
70- <property name="build.compiler.emacs" value="true"/>
71-
72- <target name="default" depends="test" description="Build and Test."/>
73-
74- <import file="nbproject/profiler-build-impl.xml"/>
75- <target name="init" depends="-setup"/>
76- <target name="compile-test-single" depends="compile-tests"/>
77- <target name="compile-single" depends="compile"/>
78-
79- <target name="-dynamic-properties">
80- <echo>Java version ${java.version}, compatibility: ${compatibility}</echo>
81- <echo>JNA version ${jna.version}, native ${jni.version}</echo>
82- <echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
83- <echo>java.home=${java.home}</echo>
84- <echo>java.library.path=${java.library.path}</echo>
85-
86- <replaceregexp match="(&lt;version&gt;).*(&lt;/version&gt;)"
87- replace="\1${jna.version}\2"
88- file="pom.xml"/>
89- <replaceregexp match='VERSION = ".*";'
90- replace='VERSION = "${jna.version}";'
91- file="src/com/sun/jna/Native.java"/>
92-
93- <condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
94- <isset property="omit-jnilib"/>
95- </condition>
96- <condition property="vm.arch" value="-d64" else="">
97- <or>
98- <equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
99- <equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
100- <os arch="x86_64"/>
101- <os arch="ppc64"/>
102- <os arch="sparcv9"/>
103- <os arch="amd64"/>
104- </or>
105- </condition>
106- <condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
107- <and>
108- <os name="SunOS"/>
109- <equals arg1="${vm.arch}" arg2="-d64"/>
110- </and>
111- </condition>
112- <property name="build" value="build${vm.arch}"/>
113- <property name="classes" location="${build}/classes"/>
114- <property name="eclipse.classes" location="build.eclipse/classes"/>
115- <property name="test.classes" location="${build}/test-classes"/>
116- <property name="reports" value="${build}/reports"/>
117-
118- <!-- Add other supported platforms here -->
119- <condition property="jre.arch" value="i386">
120- <equals arg1="x86" arg2="${os.arch}"/>
121- </condition>
122- <condition property="jre.arch" value="amd64">
123- <equals arg1="x86_64" arg2="${os.arch}"/>
124- </condition>
125- <property name="jre.arch" value="${os.arch}"/>
126- <condition property="os.prefix" value="linux-${jre.arch}">
127- <os name="Linux"/>
128- </condition>
129- <condition property="os.prefix" value="win32-${os.arch}">
130- <os family="windows"/>
131- </condition>
132- <!-- Darwin builds are universal, no arch required -->
133- <condition property="os.prefix" value="darwin">
134- <os family="mac"/>
135- </condition>
136- <condition property="os.prefix" value="sunos-${os.arch}">
137- <os name="SunOS"/>
138- </condition>
139- <condition property="os.prefix" value="freebsd-${os.arch}">
140- <os name="FreeBSD"/>
141- </condition>
142- <condition property="os.prefix" value="openbsd-${os.arch}">
143- <os name="OpenBSD"/>
144- </condition>
145- <fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
146- <condition property="jdk.home" value="${java.home}">
147- <available file="${java.home}/include"/>
148- </condition>
149- <condition property="jdk.home" value="${java.home}/..">
150- <available file="${java.home}/../include"/>
151- </condition>
152- <fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
153- <condition property="libjsig"
154- value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
155- <available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
156- </condition>
157- <property name="native.jar" value="${os.prefix}.jar"/>
158- <property name="build.native" location="${build}/native"/>
159- <property name="md5.file" location="${build.native}/sig"/>
160-
161- <mkdir dir="${build}"/>
162- <mkdir dir="${build.native}"/>
163- <mkdir dir="${classes}"/>
164- <mkdir dir="${test.classes}"/>
165- <mkdir dir="${reports}"/>
166- <mkdir dir="${doc}"/>
167-
168- </target>
169-
170- <target name="-setup" depends="-dynamic-properties">
171- <path id="compile-test.path">
172- <pathelement path="${test.src}"/>
173- <path id="test.libs">
174- <fileset dir="lib">
175- <include name="junit.jar"/>
176- </fileset>
177- <pathelement path="${classes}"/>
178- </path>
179- <path id="compile.path">
180- <path id="src.path">
181- <pathelement location="${src}"/>
182- </path>
183- </path>
184- </path>
185-
186- <path id="test.runpath">
187- <pathelement path="${build}/${jar}"/>
188- <pathelement path="${build}/examples.jar"/>
189- <pathelement path="${test.classes}"/>
190- <pathelement path="lib/clover.jar"/>
191- <path refid="test.libs"/>
192- </path>
193- </target>
194-
195- <target name="compile" depends="-setup"
196- description="Compile all Java source">
197- <javac classpathref="compile.path"
198- source="${compatibility}"
199- target="${compatibility}"
200- destdir="${classes}"
201- deprecation="on" debug="${debug}">
202- <src path="${src}"/>
203- </javac>
204- </target>
205-
206- <target name=":jar">
207- <uptodate property="-jar" targetfile="${build}/${jar}">
208- <srcfiles dir="${classes}">
209- <patternset id="jar-compiled">
210- <include name="com/sun/jna/*"/>
211- <include name="com/sun/jna/**/*"/>
212- <exclude name="com/sun/jna/examples/*"/>
213- <exclude name="com/sun/jna/examples/**/*"/>
214- </patternset>
215- </srcfiles>
216- </uptodate>
217- </target>
218- <target name="jar" depends="-setup,native,:jar" unless="-jar"
219- description="Build primary jar">
220- <jar jarfile="${build}/${jar}">
221- <manifest>
222- <attribute name="Main-Class" value="com.sun.jna.Native"/>
223- <section name="com/sun/jna/">
224- <attribute name="Implementation-Title" value="${impl.title}"/>
225- <attribute name="Implementation-Vendor" value="${vendor}"/>
226- <attribute name="Implementation-Version" value="${impl.version}"/>
227- <attribute name="Specification-Title" value="${spec.title}"/>
228- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
229- <attribute name="Specification-Version" value="${spec.version}"/>
230- </section>
231- </manifest>
232- <fileset dir="${classes}" excludes="${jar.omitted}">
233- <patternset refid="jar-compiled"/>
234- </fileset>
235- </jar>
236- </target>
237- <target name="examples" depends="jar,native">
238- <jar jarfile="${build}/examples.jar">
239- <manifest>
240- <attribute name="Class-Path" value="jna.jar"/>
241- <attribute name="Main-Class" value="com.sun.jna.examples.ShapedWindowDemo"/>
242- </manifest>
243- <fileset dir="${src}" includes="**/examples/**/*.png"/>
244- <fileset dir="${classes}" includes="**/examples/*,**/examples/**/*"/>
245- <fileset dir="${classes}" includes="jnidispatch.dll"/>
246- </jar>
247- </target>
248-
249- <target name="javah" depends="compile">
250- <javah classpath="${classes}" destdir="${build.native}" force="yes">
251- <class name="com.sun.jna.Function"/>
252- <class name="com.sun.jna.Pointer"/>
253- <class name="com.sun.jna.Memory"/>
254- <class name="com.sun.jna.Native"/>
255- <class name="com.sun.jna.NativeLibrary"/>
256- <class name="com.sun.jna.CallbackReference"/>
257- </javah>
258- <condition property="grep" value="/usr/sfw/bin/ggrep">
259- <os name="SunOS"/>
260- </condition>
261- <condition property="grep" value="ggrep">
262- <os name="OpenBSD"/>
263- </condition>
264- <property name="grep" value="grep"/>
265- <apply dir="${build.native}" executable="${grep}" parallel="true"
266- failonerror="true" relative="true" output="${md5.file}">
267- <arg value="-A"/>
268- <arg value="1"/>
269- <arg value="JNIEXPORT"/>
270- <fileset dir="${build.native}" includes="*.h"/>
271- </apply>
272- <fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
273- <checksum property="md5" file="${md5.file}" />
274- <condition property="jni.valid" value="true">
275- <or>
276- <equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
277- <equals arg1="${jni.md5}" arg2=""/>
278- </or>
279- </condition>
280- </target>
281-
282- <!-- Invalidate native libraries when native API changes -->
283- <target name="-native-api-check" depends="javah" unless="jni.valid">
284- <echo>Invalidating native code, new checksum is ${md5}</echo>
285- <copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
286- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
287- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
288- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
289- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
290- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
291- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
292- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
293- <copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
294- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
295- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
296- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
297- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparcv9.jar" overwrite="true"/>
298- <delete failOnError="false" includeEmptyDirs="true">
299- <fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
300- </delete>
301- <fail>API for native code has changed. Re-run this build after updating jni.version and jni.md5 in build.xml</fail>
302- </target>
303-
304- <target name=":rsrc">
305- <condition property="-rsrc">
306- <not><os family="windows"/></not>
307- </condition>
308- </target>
309- <target name="rsrc" depends="-setup,:rsrc" unless="-rsrc"
310- description="Generate w32 DLL version resource information">
311- <property name="rsrc" location="${build.native}/jnidispatch.rc"/>
312- <copy todir="${build.native}" file="${native}/jnidispatch.rc"/>
313- <replaceregexp match="FILEVERSION.*"
314- replace="FILEVERSION ${jni.major},${jni.minor},${jni.revision},${jni.build}"
315- file="${rsrc}" byline="true"/>
316- <replaceregexp match="PRODUCTVERSION.*"
317- replace="PRODUCTVERSION ${jna.major},${jna.minor},${jna.revision},${jna.build}"
318- file="${rsrc}" byline="true"/>
319- <replaceregexp match="FileVersion.*"
320- replace="FileVersion&quot;,&quot;${jni.version}&quot;"
321- file="${rsrc}" byline="true"/>
322- <replaceregexp match="Full Version.*"
323- replace="Full Version&quot;,&quot;${jni.version} b${jni.build}&quot;"
324- file="${rsrc}" byline="true"/>
325- <replaceregexp match="ProductVersion.*"
326- replace="ProductVersion&quot;,&quot;${spec.version}&quot;"
327- file="${rsrc}" byline="true"/>
328- </target>
329-
330- <target name="native" depends="-setup,javah,-native-api-check,rsrc"
331- description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
332- <property name="comment" value="# auto-generated by ant"/>
333- <replaceregexp match="^VERSION=.*"
334- replace="VERSION=${jni.version} ${comment}"
335- file="native/Makefile" byline="true"/>
336- <replaceregexp match="^CHECKSUM=.*"
337- replace="CHECKSUM=${jni.md5} ${comment}"
338- file="native/Makefile" byline="true"/>
339- <!-- ensure ARCH is set properly for 64-bit capable platforms -->
340- <!-- use ANT_OPTS=-d64 to build 64-bit if not the platform default -->
341- <property name="ARCH" value="${os.arch}"/>
342- <condition property="make.CC" value="CC=${CC}" else="IGNORE=">
343- <isset property="CC"/>
344- </condition>
345- <condition property="make.ARCH" value="ARCH=${ARCH}" else="IGNORE=">
346- <isset property="ARCH"/>
347- </condition>
348- <condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
349- <isset property="SDKROOT"/>
350- </condition>
351- <condition property="make.SDKROOT"
352- value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
353- <available file="/Developer/SDKs/MacOSX10.5.sdk"/>
354- </condition>
355- <condition property="make.SDKROOT"
356- value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
357- <available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
358- </condition>
359- <!-- Windows' drive letters and spaces in absolute paths wreak havoc on
360- make -->
361- <condition property="make.BUILD" value="BUILD=../${build}/native" else="BUILD=${build.native}">
362- <os family="windows"/>
363- </condition>
364- <condition property="make.PATH" value="PATH=/usr/sfw/bin:/usr/bin:/usr/ccs/bin" else="IGNORE=">
365- <os name="SunOS"/>
366- </condition>
367- <condition property="make" value="/usr/sfw/bin/gmake">
368- <os name="SunOS"/>
369- </condition>
370- <condition property="make" value="gmake">
371- <or>
372- <os name="FreeBSD"/>
373- <os name="OpenBSD"/>
374- </or>
375- </condition>
376- <!-- Default make program -->
377- <property name="make" value="make"/>
378-
379- <exec executable="${make}" dir="${native}" failonerror="true">
380- <arg value="JAVA_HOME=${jdk.home}"/>
381- <arg value="JAVAH=${build.native}"/>
382- <arg value="DEBUG=${debug.native}"/>
383- <arg value="CFLAGS_EXTRA=${cflags_extra.native}"/>
384- <arg value="DYNAMIC_LIBFFI=${dynlink.native}"/>
385- <arg value="${make.CC}"/>
386- <arg value="${make.BUILD}"/>
387- <arg value="${make.SDKROOT}"/>
388- <arg value="${make.ARCH}"/>
389- <arg value="${make.PATH}"/>
390- <arg value="VERSION=${jni.version}"/>
391- <arg value="CHECKSUM=${jni.md5}"/>
392- </exec>
393- <mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
394- <copy todir="${classes}/com/sun/jna/${os.prefix}">
395- <fileset dir="${build.native}"
396- includes="jnidispatch.dll,libjnidispatch.*"/>
397- </copy>
398- <mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
399- <copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
400- failonerror="false">
401- <fileset dir="${build.native}"
402- includes="jnidispatch.dll,libjnidispatch.*"/>
403- </copy>
404- <!-- For web start, native libraries may be provided in the root of -->
405- <!-- an included jar file -->
406- <jar jarfile="${build}/${native.jar}">
407- <fileset dir="${build.native}" includes="jnidispatch.dll,libjnidispatch.*"/>
408- <manifest>
409- <attribute name="Implementation-Version" value="${jni.version} b${jni.build}"/>
410- <attribute name="Specification-Version" value="${jni.version}"/>
411- </manifest>
412- </jar>
413- </target>
414-
415- <target name="compile-tests" depends="compile,native,jar"
416- description="Compile all test code">
417- <javac classpathref="compile-test.path"
418- source="${test.compatibility}"
419- target="${test.compatibility}"
420- destdir="${test.classes}"
421- deprecation="on" debug="${debug}">
422- <src path="${test.src}"/>
423- </javac>
424- <jar jarfile="${build}/${testjar}">
425- <fileset dir="${test.classes}">
426- <patternset refid="jar-compiled"/>
427- </fileset>
428- </jar>
429- <mkdir dir="${build}/jws"/>
430- <copy todir="${build}/jws" file="${build}/${jar}"/>
431- <copy todir="${build}/jws" file="${build}/${testjar}"/>
432- <copy todir="${build}/jws" file="lib/junit.jar"/>
433- <copy todir="${build}/jws" file="lib/clover.jar"/>
434- <jar jarfile="${build}/jws/jnidispatch.jar">
435- <fileset dir="${build.native}" includes="*jnidispatch.*"/>
436- </jar>
437- <signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
438- <fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
439- </signjar>
440- </target>
441-
442- <!-- When running tests from an IDE, be sure to set jna.library.path -->
443- <!-- to where the test library (testlib) is found. -->
444- <target name="test" depends="jar,examples,compile-tests"
445- description="Run all unit tests">
446- <property name="test.fork" value="yes"/>
447- <property name="reports.junit" location="${reports}/junit"/>
448- <property name="results.junit" location="${build}/junit-results"/>
449- <mkdir dir="${results.junit}"/>
450- <echo>Saving test results in ${results.junit}</echo>
451- <property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
452- <condition property="tests.platform" value="**/win32/*Test.java">
453- <os family="windows"/>
454- </condition>
455- <condition property="tests.exclude" value="**/win32/*StdCallTest.java">
456- <and><os family="windows"/><not><os arch="x86"/></not></and>
457- </condition>
458- <condition property="tests.platform" value="**/unix/*Test.java">
459- <and>
460- <os family="unix"/>
461- <not><os family="mac"/></not>
462- </and>
463- </condition>
464- <condition property="vmopt.arch" value="-d64" else="-Dignore">
465- <and>
466- <!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
467- <not><os family="windows"/></not>
468- <equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
469- </and>
470- </condition>
471- <property name="tests.platform" value=""/>
472- <property name="tests.exclude" value=""/>
473- <junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
474- <!-- avoid VM conflicts with JNA protected mode -->
475- <env key="${ld.preload}" file="${libjsig}"/>
476- <jvmarg value="-Djna.library.path=${build.native}"/>
477- <!-- Avoid VM crashes, if possible -->
478- <jvmarg value="-Djna.protected=true"/>
479- <jvmarg value="-Djna.builddir=${build}"/>
480- <jvmarg value="${vmopt.arch}"/>
481- <classpath><path refid="test.runpath"/></classpath>
482- <formatter type="xml"/>
483- <batchtest todir="${results.junit}">
484- <fileset dir="${test.src}">
485- <include name="com/sun/jna/*Test.java"/>
486- <include name="com/sun/jna/examples/*Test.java"/>
487- <include name="${tests.platform}"/>
488- <exclude name="${tests.exclude}"/>
489- </fileset>
490- </batchtest>
491- </junit>
492- <junitreport todir="${results.junit}">
493- <fileset dir="${results.junit}">
494- <include name="TEST-*.xml"/>
495- </fileset>
496- <report todir="${reports.junit}"/>
497- </junitreport>
498- <echo>View test report in file://${reports.junit}/index.html</echo>
499- <fail if="testfailure" unless="clover">One or more tests failed</fail>
500- </target>
501-
502- <target name="with.clover" description="Enable code coverage for tests">
503- <taskdef resource="cloverlib.xml" classpath="lib/clover.jar"/>
504- <property name="clover" value="true"/>
505- <property name="build" value="build.clover"/>
506- <clover-setup/>
507- </target>
508-
509- <target name="clover" depends="with.clover,test"
510- description="Generate test code coverage reports">
511- <property name="reports.clover" value="${reports}/clover"/>
512- <mkdir dir="${reports.clover}"/>
513- <clover-report>
514- <current outfile="${reports.clover}" title="clover">
515- <fileset dir="." includes="**/*.java" excludes="**/examples/**/*.java"/>
516- <testresults dir="${results.junit}" includes="TEST-*.xml"/>
517- <format type="html"/>
518- </current>
519- </clover-report>
520- <echo>Reports generated in ${reports.clover}</echo>
521- </target>
522-
523- <target name="javadoc" depends="-setup">
524- <property name="header"
525- value="&lt;b&gt;JNA API&lt;/&gt;&lt;font size=&quot;-1&quot;&gt; ${jna.version}&lt;/font&gt;"/>
526- <property name="footer"
527- value="&lt;center&gt;&lt;i&gt;${copyright}&lt;/i&gt;&lt;/center&gt;"/>
528-
529- <mkdir dir="${javadoc}"/>
530- <javadoc package="true"
531- windowtitle="JNA API"
532- sourcepathref="src.path"
533- classpathref="compile.path"
534- maxmemory="256m"
535- packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.examples,com.sun.jna.examples.win32,com.sun.jna.exmaples.unix"
536- overview="${src}/com/sun/jna/overview.html"
537- destdir="${javadoc}">
538- <!-- stylesheetfile="${stylesheet}" -->
539- <doctitle>JNA API Documentation</doctitle>
540- <header>${header}</header>
541- <bottom>${footer}</bottom>
542- <link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
543-
544- <packageset dir="${src}" defaultexcludes="yes">
545- <patternset>
546- <include name="com/sun/jna/**/*"/>
547- </patternset>
548- </packageset>
549-
550- <group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
551- <group title="Examples" packages="com.sun.jna.examples,com.sun.jna.examples.dnd"/>
552- <group title="Unix Examples" packages="com.sun.jna.examples.unix"/>
553- <group title="Windows Examples" packages="com.sun.jna.examples.win32"/>
554-
555- <arg value="-notimestamp"/>
556- </javadoc>
557- </target>
558-
559- <target name="dist" depends="jar,compile-tests,native,examples,javadoc"
560- description="Build distribution files">
561- <jar jarfile="${dist}/jna.jar" duplicate="preserve">
562- <manifest>
563- <attribute name="Main-Class" value="com.sun.jna.Native"/>
564- <section name="com/sun/jna/">
565- <attribute name="Implementation-Title" value="${impl.title}"/>
566- <attribute name="Implementation-Vendor" value="${vendor}"/>
567- <attribute name="Implementation-Version" value="${impl.version}"/>
568- <attribute name="Specification-Title" value="${spec.title}"/>
569- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
570- <attribute name="Specification-Version" value="${spec.version}"/>
571- </section>
572- </manifest>
573- <zipfileset src="${build}/${jar}"/>
574- <zipfileset src="${dist}/win32-x86.jar"
575- includes="*jnidispatch*"
576- prefix="com/sun/jna/win32-x86"/>
577- <zipfileset src="${dist}/darwin.jar"
578- includes="*jnidispatch*"
579- prefix="com/sun/jna/darwin"/>
580- <zipfileset src="${dist}/linux-i386.jar"
581- includes="*jnidispatch*"
582- prefix="com/sun/jna/linux-i386"/>
583- <zipfileset src="${dist}/linux-amd64.jar"
584- includes="*jnidispatch*"
585- prefix="com/sun/jna/linux-amd64"/>
586- <zipfileset src="${dist}/linux-ia64.jar"
587- includes="*jnidispatch*"
588- prefix="com/sun/jna/linux-ia64"/>
589- <zipfileset src="${dist}/sunos-x86.jar"
590- includes="*jnidispatch*"
591- prefix="com/sun/jna/sunos-x86"/>
592- <zipfileset src="${dist}/sunos-amd64.jar"
593- includes="*jnidispatch*"
594- prefix="com/sun/jna/sunos-amd64"/>
595- <zipfileset src="${dist}/sunos-sparc.jar"
596- includes="*jnidispatch*"
597- prefix="com/sun/jna/sunos-sparc"/>
598- <zipfileset src="${dist}/sunos-sparcv9.jar"
599- includes="*jnidispatch*"
600- prefix="com/sun/jna/sunos-sparcv9"/>
601- <zipfileset src="${dist}/freebsd-i386.jar"
602- includes="*jnidispatch*"
603- prefix="com/sun/jna/freebsd-i386"/>
604- <zipfileset src="${dist}/freebsd-amd64.jar"
605- includes="*jnidispatch*"
606- prefix="com/sun/jna/freebsd-amd64"/>
607- <zipfileset src="${dist}/openbsd-i386.jar"
608- includes="*jnidispatch*"
609- prefix="com/sun/jna/openbsd-i386"/>
610- <zipfileset src="${dist}/win32-amd64.jar"
611- includes="*jnidispatch*"
612- prefix="com/sun/jna/win32-amd64"/>
613- </jar>
614- <copy todir="${dist}">
615- <fileset dir="${build}">
616- <include name="${native.jar}"/>
617- <include name="examples.jar"/>
618- </fileset>
619- </copy>
620- <zip zipfile="${dist}/doc.zip">
621- <zipfileset dir="${javadoc}" prefix="javadoc"/>
622- </zip>
623- <!-- JNA sources only, for use in Linux build from source/shared libffi -->
624- <zip zipfile="${dist}/src.zip">
625- <zipfileset dir="." includes="build.xml,LICENSE.txt"/>
626- <zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
627- <zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
628- <zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
629- </zip>
630- <!-- Full sources required to build and test everything -->
631- <zip zipfile="${dist}/src-full.zip">
632- <zipfileset src="${dist}/src.zip"/>
633- <zipfileset dir="lib" includes="junit.jar,clover.jar" prefix="lib"/>
634- <zipfileset dir="." includes=".classpath,.project"/>
635- <zipfileset dir="nbproject" includes="**/*" prefix="nbproject"/>
636- <zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
637- </zip>
638- <!-- Sources package as required by maven -->
639- <zip zipfile="${dist}/src-mvn.zip">
640- <zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
641- </zip>
642- </target>
643-
644- <target name="clean" depends="-dynamic-properties">
645- <delete failOnError="false" includeEmptyDirs="true">
646- <fileset dir="${build}"/>
647- </delete>
648- <delete quiet="true" includeEmptyDirs="true">
649- <fileset dir=".clover"/>
650- <fileset dir="${javadoc}"/>
651- <fileset dir="." includes="*~,**/*~"/>
652- </delete>
653- </target>
654-
655-</project>
656-
657-
658
659=== removed directory '.pc/02-builddir.patch'
660=== removed file '.pc/02-builddir.patch/build.xml'
661--- .pc/02-builddir.patch/build.xml 2010-04-21 16:36:37 +0000
662+++ .pc/02-builddir.patch/build.xml 1970-01-01 00:00:00 +0000
663@@ -1,643 +0,0 @@
664-<?xml version="1.0" encoding="UTF-8"?>
665-<project name="JNA" default="default" basedir=".">
666- <description>Builds and tests JNA</description>
667-
668- <!--
669- Conventions (since ant can't easily specify arbitrary file dependencies):
670- The uptodate property for a given target TARGET is "-TARGET"; the actual
671- target to generate the uptodate property is named ":TARGET".
672-
673- Properties (except for uptodate properties) separate words by dots, targets
674- by dashes.
675- -->
676-
677- <!-- global properties -->
678- <!-- (all build-related props should go in -dynamic-properties) -->
679- <property name="name" value="jna"/>
680- <property name="jar" value="${name}.jar"/>
681- <property name="testjar" value="${name}-test.jar"/>
682- <property name="debug" value="true"/>
683- <property name="debug.native" value="false"/>
684- <property name="cflags_extra.native" value=""/>
685- <property name="dynlink.native" value="false"/>
686- <property name="native" location="native"/>
687- <property name="src" location="src"/>
688- <property name="dist" location="dist"/>
689- <property name="test.src" location="test"/>
690- <property name="doc" location="doc"/>
691- <property name="javadoc" location="${doc}/javadoc"/>
692- <property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
693- <property name="vendor" value="JNA Development Team"/>
694- <property name="copyright"
695- value="Copyright &amp;copy; 2007-2009 Timothy Wall. All Rights Reserved."/>
696- <buildnumber/>
697- <!-- JNA library release version -->
698- <property name="jna.major" value="3"/>
699- <property name="jna.minor" value="2"/>
700- <property name="jna.revision" value="4"/>
701- <property name="jna.build" value="${build.number}"/>
702- <property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
703- <!-- jnidispatch library release version -->
704- <property name="jni.major" value="3"/>
705- <property name="jni.minor" value="2"/>
706- <property name="jni.revision" value="1"/>
707- <property name="jni.build" value="${build.number}"/>
708- <property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
709- <property name="jni.md5" value="c870290c36c8d3fdf85db7c782febc3f"/>
710- <property name="spec.title" value="Java Native Access (JNA)"/>
711- <property name="spec.vendor" value="${vendor}"/>
712- <property name="spec.version" value="${jna.major}"/>
713- <property name="impl.title" value="com.sun.jna"/>
714- <property name="impl.vendor" value="${spec.vendor}"/>
715- <property name="impl.version" value="${jna.version} (b${jna.build})"/>
716-
717- <property name="compatibility" value="1.4"/>
718- <property name="test.compatibility" value="1.5"/>
719-
720- <!-- Miscellaneous -->
721- <property name="build.compiler.emacs" value="true"/>
722-
723- <target name="default" depends="test" description="Build and Test."/>
724-
725- <target name="init" depends="-setup"/>
726- <target name="compile-test-single" depends="compile-tests"/>
727- <target name="compile-single" depends="compile"/>
728-
729- <target name="-dynamic-properties">
730- <echo>Java version ${java.version}, compatibility: ${compatibility}</echo>
731- <echo>JNA version ${jna.version}, native ${jni.version}</echo>
732- <echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
733- <echo>java.home=${java.home}</echo>
734- <echo>java.library.path=${java.library.path}</echo>
735-
736- <replaceregexp match="(&lt;version&gt;).*(&lt;/version&gt;)"
737- replace="\1${jna.version}\2"
738- file="pom.xml"/>
739- <replaceregexp match='VERSION = ".*";'
740- replace='VERSION = "${jna.version}";'
741- file="src/com/sun/jna/Native.java"/>
742-
743- <condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
744- <isset property="omit-jnilib"/>
745- </condition>
746- <condition property="vm.arch" value="-d64" else="">
747- <or>
748- <equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
749- <equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
750- <os arch="x86_64"/>
751- <os arch="ppc64"/>
752- <os arch="sparcv9"/>
753- <os arch="amd64"/>
754- </or>
755- </condition>
756- <condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
757- <and>
758- <os name="SunOS"/>
759- <equals arg1="${vm.arch}" arg2="-d64"/>
760- </and>
761- </condition>
762- <property name="build" value="build${vm.arch}"/>
763- <property name="classes" location="${build}/classes"/>
764- <property name="eclipse.classes" location="build.eclipse/classes"/>
765- <property name="test.classes" location="${build}/test-classes"/>
766- <property name="reports" value="${build}/reports"/>
767-
768- <!-- Add other supported platforms here -->
769- <condition property="jre.arch" value="i386">
770- <equals arg1="x86" arg2="${os.arch}"/>
771- </condition>
772- <condition property="jre.arch" value="amd64">
773- <equals arg1="x86_64" arg2="${os.arch}"/>
774- </condition>
775- <property name="jre.arch" value="${os.arch}"/>
776- <condition property="os.prefix" value="linux-${jre.arch}">
777- <os name="Linux"/>
778- </condition>
779- <condition property="os.prefix" value="win32-${os.arch}">
780- <os family="windows"/>
781- </condition>
782- <!-- Darwin builds are universal, no arch required -->
783- <condition property="os.prefix" value="darwin">
784- <os family="mac"/>
785- </condition>
786- <condition property="os.prefix" value="sunos-${os.arch}">
787- <os name="SunOS"/>
788- </condition>
789- <condition property="os.prefix" value="freebsd-${os.arch}">
790- <os name="FreeBSD"/>
791- </condition>
792- <condition property="os.prefix" value="openbsd-${os.arch}">
793- <os name="OpenBSD"/>
794- </condition>
795- <fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
796- <condition property="jdk.home" value="${java.home}">
797- <available file="${java.home}/include"/>
798- </condition>
799- <condition property="jdk.home" value="${java.home}/..">
800- <available file="${java.home}/../include"/>
801- </condition>
802- <fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
803- <condition property="libjsig"
804- value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
805- <available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
806- </condition>
807- <property name="native.jar" value="${os.prefix}.jar"/>
808- <property name="build.native" location="${build}/native"/>
809- <property name="md5.file" location="${build.native}/sig"/>
810-
811- <mkdir dir="${build}"/>
812- <mkdir dir="${build.native}"/>
813- <mkdir dir="${classes}"/>
814- <mkdir dir="${test.classes}"/>
815- <mkdir dir="${reports}"/>
816- <mkdir dir="${doc}"/>
817-
818- </target>
819-
820- <target name="-setup" depends="-dynamic-properties">
821- <path id="compile-test.path">
822- <pathelement path="${test.src}"/>
823- <path id="test.libs">
824- <fileset dir="lib">
825- <include name="junit.jar"/>
826- </fileset>
827- <pathelement path="${classes}"/>
828- </path>
829- <path id="compile.path">
830- <path id="src.path">
831- <pathelement location="${src}"/>
832- </path>
833- </path>
834- </path>
835-
836- <path id="test.runpath">
837- <pathelement path="${build}/${jar}"/>
838- <pathelement path="${build}/examples.jar"/>
839- <pathelement path="${test.classes}"/>
840- <pathelement path="lib/clover.jar"/>
841- <path refid="test.libs"/>
842- </path>
843- </target>
844-
845- <target name="compile" depends="-setup"
846- description="Compile all Java source">
847- <javac classpathref="compile.path"
848- source="${compatibility}"
849- target="${compatibility}"
850- destdir="${classes}"
851- deprecation="on" debug="${debug}">
852- <src path="${src}"/>
853- </javac>
854- </target>
855-
856- <target name=":jar">
857- <uptodate property="-jar" targetfile="${build}/${jar}">
858- <srcfiles dir="${classes}">
859- <patternset id="jar-compiled">
860- <include name="com/sun/jna/*"/>
861- <include name="com/sun/jna/**/*"/>
862- <exclude name="com/sun/jna/examples/*"/>
863- <exclude name="com/sun/jna/examples/**/*"/>
864- </patternset>
865- </srcfiles>
866- </uptodate>
867- </target>
868- <target name="jar" depends="-setup,native,:jar" unless="-jar"
869- description="Build primary jar">
870- <jar jarfile="${build}/${jar}">
871- <manifest>
872- <attribute name="Main-Class" value="com.sun.jna.Native"/>
873- <section name="com/sun/jna/">
874- <attribute name="Implementation-Title" value="${impl.title}"/>
875- <attribute name="Implementation-Vendor" value="${vendor}"/>
876- <attribute name="Implementation-Version" value="${impl.version}"/>
877- <attribute name="Specification-Title" value="${spec.title}"/>
878- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
879- <attribute name="Specification-Version" value="${spec.version}"/>
880- </section>
881- </manifest>
882- <fileset dir="${classes}" excludes="${jar.omitted}">
883- <patternset refid="jar-compiled"/>
884- </fileset>
885- </jar>
886- </target>
887- <target name="examples" depends="jar,native">
888- <jar jarfile="${build}/examples.jar">
889- <manifest>
890- <attribute name="Class-Path" value="jna.jar"/>
891- <attribute name="Main-Class" value="com.sun.jna.examples.ShapedWindowDemo"/>
892- </manifest>
893- <fileset dir="${src}" includes="**/examples/**/*.png"/>
894- <fileset dir="${classes}" includes="**/examples/*,**/examples/**/*"/>
895- <fileset dir="${classes}" includes="jnidispatch.dll"/>
896- </jar>
897- </target>
898-
899- <target name="javah" depends="compile">
900- <javah classpath="${classes}" destdir="${build.native}" force="yes">
901- <class name="com.sun.jna.Function"/>
902- <class name="com.sun.jna.Pointer"/>
903- <class name="com.sun.jna.Memory"/>
904- <class name="com.sun.jna.Native"/>
905- <class name="com.sun.jna.NativeLibrary"/>
906- <class name="com.sun.jna.CallbackReference"/>
907- </javah>
908- <condition property="grep" value="/usr/sfw/bin/ggrep">
909- <os name="SunOS"/>
910- </condition>
911- <condition property="grep" value="ggrep">
912- <os name="OpenBSD"/>
913- </condition>
914- <property name="grep" value="grep"/>
915- <apply dir="${build.native}" executable="${grep}" parallel="true"
916- failonerror="true" relative="true" output="${md5.file}">
917- <arg value="-A"/>
918- <arg value="1"/>
919- <arg value="JNIEXPORT"/>
920- <fileset dir="${build.native}" includes="*.h"/>
921- </apply>
922- <fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
923- <checksum property="md5" file="${md5.file}" />
924- <condition property="jni.valid" value="true">
925- <or>
926- <equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
927- <equals arg1="${jni.md5}" arg2=""/>
928- </or>
929- </condition>
930- </target>
931-
932- <!-- Invalidate native libraries when native API changes -->
933- <target name="-native-api-check" depends="javah" unless="jni.valid">
934- <echo>Invalidating native code, new checksum is ${md5}</echo>
935- <copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
936- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
937- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
938- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
939- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
940- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
941- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
942- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
943- <copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
944- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
945- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
946- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
947- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparcv9.jar" overwrite="true"/>
948- <delete failOnError="false" includeEmptyDirs="true">
949- <fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
950- </delete>
951- <fail>API for native code has changed. Re-run this build after updating jni.version and jni.md5 in build.xml</fail>
952- </target>
953-
954- <target name=":rsrc">
955- <condition property="-rsrc">
956- <not><os family="windows"/></not>
957- </condition>
958- </target>
959- <target name="rsrc" depends="-setup,:rsrc" unless="-rsrc"
960- description="Generate w32 DLL version resource information">
961- <property name="rsrc" location="${build.native}/jnidispatch.rc"/>
962- <copy todir="${build.native}" file="${native}/jnidispatch.rc"/>
963- <replaceregexp match="FILEVERSION.*"
964- replace="FILEVERSION ${jni.major},${jni.minor},${jni.revision},${jni.build}"
965- file="${rsrc}" byline="true"/>
966- <replaceregexp match="PRODUCTVERSION.*"
967- replace="PRODUCTVERSION ${jna.major},${jna.minor},${jna.revision},${jna.build}"
968- file="${rsrc}" byline="true"/>
969- <replaceregexp match="FileVersion.*"
970- replace="FileVersion&quot;,&quot;${jni.version}&quot;"
971- file="${rsrc}" byline="true"/>
972- <replaceregexp match="Full Version.*"
973- replace="Full Version&quot;,&quot;${jni.version} b${jni.build}&quot;"
974- file="${rsrc}" byline="true"/>
975- <replaceregexp match="ProductVersion.*"
976- replace="ProductVersion&quot;,&quot;${spec.version}&quot;"
977- file="${rsrc}" byline="true"/>
978- </target>
979-
980- <target name="native" depends="-setup,javah,-native-api-check,rsrc"
981- description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
982- <property name="comment" value="# auto-generated by ant"/>
983- <replaceregexp match="^VERSION=.*"
984- replace="VERSION=${jni.version} ${comment}"
985- file="native/Makefile" byline="true"/>
986- <replaceregexp match="^CHECKSUM=.*"
987- replace="CHECKSUM=${jni.md5} ${comment}"
988- file="native/Makefile" byline="true"/>
989- <!-- ensure ARCH is set properly for 64-bit capable platforms -->
990- <!-- use ANT_OPTS=-d64 to build 64-bit if not the platform default -->
991- <property name="ARCH" value="${os.arch}"/>
992- <condition property="make.CC" value="CC=${CC}" else="IGNORE=">
993- <isset property="CC"/>
994- </condition>
995- <condition property="make.ARCH" value="ARCH=${ARCH}" else="IGNORE=">
996- <isset property="ARCH"/>
997- </condition>
998- <condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
999- <isset property="SDKROOT"/>
1000- </condition>
1001- <condition property="make.SDKROOT"
1002- value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
1003- <available file="/Developer/SDKs/MacOSX10.5.sdk"/>
1004- </condition>
1005- <condition property="make.SDKROOT"
1006- value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
1007- <available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
1008- </condition>
1009- <!-- Windows' drive letters and spaces in absolute paths wreak havoc on
1010- make -->
1011- <condition property="make.BUILD" value="BUILD=../${build}/native" else="BUILD=${build.native}">
1012- <os family="windows"/>
1013- </condition>
1014- <condition property="make.PATH" value="PATH=/usr/sfw/bin:/usr/bin:/usr/ccs/bin" else="IGNORE=">
1015- <os name="SunOS"/>
1016- </condition>
1017- <condition property="make" value="/usr/sfw/bin/gmake">
1018- <os name="SunOS"/>
1019- </condition>
1020- <condition property="make" value="gmake">
1021- <or>
1022- <os name="FreeBSD"/>
1023- <os name="OpenBSD"/>
1024- </or>
1025- </condition>
1026- <!-- Default make program -->
1027- <property name="make" value="make"/>
1028-
1029- <exec executable="${make}" dir="${native}" failonerror="true">
1030- <arg value="JAVA_HOME=${jdk.home}"/>
1031- <arg value="JAVAH=${build.native}"/>
1032- <arg value="DEBUG=${debug.native}"/>
1033- <arg value="CFLAGS_EXTRA=${cflags_extra.native}"/>
1034- <arg value="DYNAMIC_LIBFFI=${dynlink.native}"/>
1035- <arg value="${make.CC}"/>
1036- <arg value="${make.BUILD}"/>
1037- <arg value="${make.SDKROOT}"/>
1038- <arg value="${make.ARCH}"/>
1039- <arg value="${make.PATH}"/>
1040- <arg value="VERSION=${jni.version}"/>
1041- <arg value="CHECKSUM=${jni.md5}"/>
1042- </exec>
1043- <mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
1044- <copy todir="${classes}/com/sun/jna/${os.prefix}">
1045- <fileset dir="${build.native}"
1046- includes="jnidispatch.dll,libjnidispatch.*"/>
1047- </copy>
1048- <mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
1049- <copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
1050- failonerror="false">
1051- <fileset dir="${build.native}"
1052- includes="jnidispatch.dll,libjnidispatch.*"/>
1053- </copy>
1054- <!-- For web start, native libraries may be provided in the root of -->
1055- <!-- an included jar file -->
1056- <jar jarfile="${build}/${native.jar}">
1057- <fileset dir="${build.native}" includes="jnidispatch.dll,libjnidispatch.*"/>
1058- <manifest>
1059- <attribute name="Implementation-Version" value="${jni.version} b${jni.build}"/>
1060- <attribute name="Specification-Version" value="${jni.version}"/>
1061- </manifest>
1062- </jar>
1063- </target>
1064-
1065- <target name="compile-tests" depends="compile,native,jar"
1066- description="Compile all test code">
1067- <javac classpathref="compile-test.path"
1068- source="${test.compatibility}"
1069- target="${test.compatibility}"
1070- destdir="${test.classes}"
1071- deprecation="on" debug="${debug}">
1072- <src path="${test.src}"/>
1073- </javac>
1074- <jar jarfile="${build}/${testjar}">
1075- <fileset dir="${test.classes}">
1076- <patternset refid="jar-compiled"/>
1077- </fileset>
1078- </jar>
1079- <mkdir dir="${build}/jws"/>
1080- <copy todir="${build}/jws" file="${build}/${jar}"/>
1081- <copy todir="${build}/jws" file="${build}/${testjar}"/>
1082- <copy todir="${build}/jws" file="lib/junit.jar"/>
1083- <copy todir="${build}/jws" file="lib/clover.jar"/>
1084- <jar jarfile="${build}/jws/jnidispatch.jar">
1085- <fileset dir="${build.native}" includes="*jnidispatch.*"/>
1086- </jar>
1087- <signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
1088- <fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
1089- </signjar>
1090- </target>
1091-
1092- <!-- When running tests from an IDE, be sure to set jna.library.path -->
1093- <!-- to where the test library (testlib) is found. -->
1094- <target name="test" depends="jar,examples,compile-tests"
1095- description="Run all unit tests">
1096- <property name="test.fork" value="yes"/>
1097- <property name="reports.junit" location="${reports}/junit"/>
1098- <property name="results.junit" location="${build}/junit-results"/>
1099- <mkdir dir="${results.junit}"/>
1100- <echo>Saving test results in ${results.junit}</echo>
1101- <property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
1102- <condition property="tests.platform" value="**/win32/*Test.java">
1103- <os family="windows"/>
1104- </condition>
1105- <condition property="tests.exclude" value="**/win32/*StdCallTest.java">
1106- <and><os family="windows"/><not><os arch="x86"/></not></and>
1107- </condition>
1108- <condition property="tests.platform" value="**/unix/*Test.java">
1109- <and>
1110- <os family="unix"/>
1111- <not><os family="mac"/></not>
1112- </and>
1113- </condition>
1114- <condition property="vmopt.arch" value="-d64" else="-Dignore">
1115- <and>
1116- <!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
1117- <not><os family="windows"/></not>
1118- <equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
1119- </and>
1120- </condition>
1121- <property name="tests.platform" value=""/>
1122- <property name="tests.exclude" value=""/>
1123- <junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
1124- <!-- avoid VM conflicts with JNA protected mode -->
1125- <env key="${ld.preload}" file="${libjsig}"/>
1126- <jvmarg value="-Djna.library.path=${build.native}"/>
1127- <!-- Avoid VM crashes, if possible -->
1128- <jvmarg value="-Djna.protected=true"/>
1129- <jvmarg value="-Djna.builddir=${build}"/>
1130- <jvmarg value="${vmopt.arch}"/>
1131- <classpath><path refid="test.runpath"/></classpath>
1132- <formatter type="xml"/>
1133- <batchtest todir="${results.junit}">
1134- <fileset dir="${test.src}">
1135- <include name="com/sun/jna/*Test.java"/>
1136- <include name="com/sun/jna/examples/*Test.java"/>
1137- <include name="${tests.platform}"/>
1138- <exclude name="${tests.exclude}"/>
1139- </fileset>
1140- </batchtest>
1141- </junit>
1142- <junitreport todir="${results.junit}">
1143- <fileset dir="${results.junit}">
1144- <include name="TEST-*.xml"/>
1145- </fileset>
1146- <report todir="${reports.junit}"/>
1147- </junitreport>
1148- <echo>View test report in file://${reports.junit}/index.html</echo>
1149- <fail if="testfailure" unless="clover">One or more tests failed</fail>
1150- </target>
1151-
1152- <target name="with.clover" description="Enable code coverage for tests">
1153- <taskdef resource="cloverlib.xml" classpath="lib/clover.jar"/>
1154- <property name="clover" value="true"/>
1155- <property name="build" value="build.clover"/>
1156- <clover-setup/>
1157- </target>
1158-
1159- <target name="clover" depends="with.clover,test"
1160- description="Generate test code coverage reports">
1161- <property name="reports.clover" value="${reports}/clover"/>
1162- <mkdir dir="${reports.clover}"/>
1163- <clover-report>
1164- <current outfile="${reports.clover}" title="clover">
1165- <fileset dir="." includes="**/*.java" excludes="**/examples/**/*.java"/>
1166- <testresults dir="${results.junit}" includes="TEST-*.xml"/>
1167- <format type="html"/>
1168- </current>
1169- </clover-report>
1170- <echo>Reports generated in ${reports.clover}</echo>
1171- </target>
1172-
1173- <target name="javadoc" depends="-setup">
1174- <property name="header"
1175- value="&lt;b&gt;JNA API&lt;/&gt;&lt;font size=&quot;-1&quot;&gt; ${jna.version}&lt;/font&gt;"/>
1176- <property name="footer"
1177- value="&lt;center&gt;&lt;i&gt;${copyright}&lt;/i&gt;&lt;/center&gt;"/>
1178-
1179- <mkdir dir="${javadoc}"/>
1180- <javadoc package="true"
1181- windowtitle="JNA API"
1182- sourcepathref="src.path"
1183- classpathref="compile.path"
1184- maxmemory="256m"
1185- packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.examples,com.sun.jna.examples.win32,com.sun.jna.exmaples.unix"
1186- overview="${src}/com/sun/jna/overview.html"
1187- destdir="${javadoc}">
1188- <!-- stylesheetfile="${stylesheet}" -->
1189- <doctitle>JNA API Documentation</doctitle>
1190- <header>${header}</header>
1191- <bottom>${footer}</bottom>
1192- <link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
1193-
1194- <packageset dir="${src}" defaultexcludes="yes">
1195- <patternset>
1196- <include name="com/sun/jna/**/*"/>
1197- </patternset>
1198- </packageset>
1199-
1200- <group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
1201- <group title="Examples" packages="com.sun.jna.examples,com.sun.jna.examples.dnd"/>
1202- <group title="Unix Examples" packages="com.sun.jna.examples.unix"/>
1203- <group title="Windows Examples" packages="com.sun.jna.examples.win32"/>
1204-
1205- <arg value="-notimestamp"/>
1206- </javadoc>
1207- </target>
1208-
1209- <target name="dist" depends="jar,compile-tests,native,examples,javadoc"
1210- description="Build distribution files">
1211- <jar jarfile="${dist}/jna.jar" duplicate="preserve">
1212- <manifest>
1213- <attribute name="Main-Class" value="com.sun.jna.Native"/>
1214- <section name="com/sun/jna/">
1215- <attribute name="Implementation-Title" value="${impl.title}"/>
1216- <attribute name="Implementation-Vendor" value="${vendor}"/>
1217- <attribute name="Implementation-Version" value="${impl.version}"/>
1218- <attribute name="Specification-Title" value="${spec.title}"/>
1219- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
1220- <attribute name="Specification-Version" value="${spec.version}"/>
1221- </section>
1222- </manifest>
1223- <zipfileset src="${build}/${jar}"/>
1224- <zipfileset src="${dist}/win32-x86.jar"
1225- includes="*jnidispatch*"
1226- prefix="com/sun/jna/win32-x86"/>
1227- <zipfileset src="${dist}/darwin.jar"
1228- includes="*jnidispatch*"
1229- prefix="com/sun/jna/darwin"/>
1230- <zipfileset src="${dist}/linux-i386.jar"
1231- includes="*jnidispatch*"
1232- prefix="com/sun/jna/linux-i386"/>
1233- <zipfileset src="${dist}/linux-amd64.jar"
1234- includes="*jnidispatch*"
1235- prefix="com/sun/jna/linux-amd64"/>
1236- <zipfileset src="${dist}/linux-ia64.jar"
1237- includes="*jnidispatch*"
1238- prefix="com/sun/jna/linux-ia64"/>
1239- <zipfileset src="${dist}/sunos-x86.jar"
1240- includes="*jnidispatch*"
1241- prefix="com/sun/jna/sunos-x86"/>
1242- <zipfileset src="${dist}/sunos-amd64.jar"
1243- includes="*jnidispatch*"
1244- prefix="com/sun/jna/sunos-amd64"/>
1245- <zipfileset src="${dist}/sunos-sparc.jar"
1246- includes="*jnidispatch*"
1247- prefix="com/sun/jna/sunos-sparc"/>
1248- <zipfileset src="${dist}/sunos-sparcv9.jar"
1249- includes="*jnidispatch*"
1250- prefix="com/sun/jna/sunos-sparcv9"/>
1251- <zipfileset src="${dist}/freebsd-i386.jar"
1252- includes="*jnidispatch*"
1253- prefix="com/sun/jna/freebsd-i386"/>
1254- <zipfileset src="${dist}/freebsd-amd64.jar"
1255- includes="*jnidispatch*"
1256- prefix="com/sun/jna/freebsd-amd64"/>
1257- <zipfileset src="${dist}/openbsd-i386.jar"
1258- includes="*jnidispatch*"
1259- prefix="com/sun/jna/openbsd-i386"/>
1260- <zipfileset src="${dist}/win32-amd64.jar"
1261- includes="*jnidispatch*"
1262- prefix="com/sun/jna/win32-amd64"/>
1263- </jar>
1264- <copy todir="${dist}">
1265- <fileset dir="${build}">
1266- <include name="${native.jar}"/>
1267- <include name="examples.jar"/>
1268- </fileset>
1269- </copy>
1270- <zip zipfile="${dist}/doc.zip">
1271- <zipfileset dir="${javadoc}" prefix="javadoc"/>
1272- </zip>
1273- <!-- JNA sources only, for use in Linux build from source/shared libffi -->
1274- <zip zipfile="${dist}/src.zip">
1275- <zipfileset dir="." includes="build.xml,LICENSE.txt"/>
1276- <zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
1277- <zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
1278- <zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
1279- </zip>
1280- <!-- Full sources required to build and test everything -->
1281- <zip zipfile="${dist}/src-full.zip">
1282- <zipfileset src="${dist}/src.zip"/>
1283- <zipfileset dir="lib" includes="junit.jar,clover.jar" prefix="lib"/>
1284- <zipfileset dir="." includes=".classpath,.project"/>
1285- <zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
1286- </zip>
1287- <!-- Sources package as required by maven -->
1288- <zip zipfile="${dist}/src-mvn.zip">
1289- <zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
1290- </zip>
1291- </target>
1292-
1293- <target name="clean" depends="-dynamic-properties">
1294- <delete failOnError="false" includeEmptyDirs="true">
1295- <fileset dir="${build}"/>
1296- </delete>
1297- <delete quiet="true" includeEmptyDirs="true">
1298- <fileset dir=".clover"/>
1299- <fileset dir="${javadoc}"/>
1300- <fileset dir="." includes="*~,**/*~"/>
1301- </delete>
1302- </target>
1303-
1304-</project>
1305-
1306-
1307
1308=== removed directory '.pc/03-dynlink-and-cflags.patch'
1309=== removed file '.pc/03-dynlink-and-cflags.patch/build.xml'
1310--- .pc/03-dynlink-and-cflags.patch/build.xml 2010-04-21 16:36:37 +0000
1311+++ .pc/03-dynlink-and-cflags.patch/build.xml 1970-01-01 00:00:00 +0000
1312@@ -1,643 +0,0 @@
1313-<?xml version="1.0" encoding="UTF-8"?>
1314-<project name="JNA" default="default" basedir=".">
1315- <description>Builds and tests JNA</description>
1316-
1317- <!--
1318- Conventions (since ant can't easily specify arbitrary file dependencies):
1319- The uptodate property for a given target TARGET is "-TARGET"; the actual
1320- target to generate the uptodate property is named ":TARGET".
1321-
1322- Properties (except for uptodate properties) separate words by dots, targets
1323- by dashes.
1324- -->
1325-
1326- <!-- global properties -->
1327- <!-- (all build-related props should go in -dynamic-properties) -->
1328- <property name="name" value="jna"/>
1329- <property name="jar" value="${name}.jar"/>
1330- <property name="testjar" value="${name}-test.jar"/>
1331- <property name="debug" value="true"/>
1332- <property name="debug.native" value="false"/>
1333- <property name="cflags_extra.native" value=""/>
1334- <property name="dynlink.native" value="false"/>
1335- <property name="native" location="native"/>
1336- <property name="src" location="src"/>
1337- <property name="dist" location="dist"/>
1338- <property name="test.src" location="test"/>
1339- <property name="doc" location="doc"/>
1340- <property name="javadoc" location="${doc}/javadoc"/>
1341- <property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
1342- <property name="vendor" value="JNA Development Team"/>
1343- <property name="copyright"
1344- value="Copyright &amp;copy; 2007-2009 Timothy Wall. All Rights Reserved."/>
1345- <buildnumber/>
1346- <!-- JNA library release version -->
1347- <property name="jna.major" value="3"/>
1348- <property name="jna.minor" value="2"/>
1349- <property name="jna.revision" value="4"/>
1350- <property name="jna.build" value="${build.number}"/>
1351- <property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
1352- <!-- jnidispatch library release version -->
1353- <property name="jni.major" value="3"/>
1354- <property name="jni.minor" value="2"/>
1355- <property name="jni.revision" value="1"/>
1356- <property name="jni.build" value="${build.number}"/>
1357- <property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
1358- <property name="jni.md5" value="c870290c36c8d3fdf85db7c782febc3f"/>
1359- <property name="spec.title" value="Java Native Access (JNA)"/>
1360- <property name="spec.vendor" value="${vendor}"/>
1361- <property name="spec.version" value="${jna.major}"/>
1362- <property name="impl.title" value="com.sun.jna"/>
1363- <property name="impl.vendor" value="${spec.vendor}"/>
1364- <property name="impl.version" value="${jna.version} (b${jna.build})"/>
1365-
1366- <property name="compatibility" value="1.4"/>
1367- <property name="test.compatibility" value="1.5"/>
1368-
1369- <!-- Miscellaneous -->
1370- <property name="build.compiler.emacs" value="true"/>
1371-
1372- <target name="default" depends="test" description="Build and Test."/>
1373-
1374- <target name="init" depends="-setup"/>
1375- <target name="compile-test-single" depends="compile-tests"/>
1376- <target name="compile-single" depends="compile"/>
1377-
1378- <target name="-dynamic-properties">
1379- <echo>Java version ${java.version}, compatibility: ${compatibility}</echo>
1380- <echo>JNA version ${jna.version}, native ${jni.version}</echo>
1381- <echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
1382- <echo>java.home=${java.home}</echo>
1383- <echo>java.library.path=${java.library.path}</echo>
1384-
1385- <replaceregexp match="(&lt;version&gt;).*(&lt;/version&gt;)"
1386- replace="\1${jna.version}\2"
1387- file="pom.xml"/>
1388- <replaceregexp match='VERSION = ".*";'
1389- replace='VERSION = "${jna.version}";'
1390- file="src/com/sun/jna/Native.java"/>
1391-
1392- <condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
1393- <isset property="omit-jnilib"/>
1394- </condition>
1395- <condition property="vm.arch" value="-d64" else="">
1396- <or>
1397- <equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
1398- <equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
1399- <os arch="x86_64"/>
1400- <os arch="ppc64"/>
1401- <os arch="sparcv9"/>
1402- <os arch="amd64"/>
1403- </or>
1404- </condition>
1405- <condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
1406- <and>
1407- <os name="SunOS"/>
1408- <equals arg1="${vm.arch}" arg2="-d64"/>
1409- </and>
1410- </condition>
1411- <property name="build" value="build"/>
1412- <property name="classes" location="${build}/classes"/>
1413- <property name="eclipse.classes" location="build.eclipse/classes"/>
1414- <property name="test.classes" location="${build}/test-classes"/>
1415- <property name="reports" value="${build}/reports"/>
1416-
1417- <!-- Add other supported platforms here -->
1418- <condition property="jre.arch" value="i386">
1419- <equals arg1="x86" arg2="${os.arch}"/>
1420- </condition>
1421- <condition property="jre.arch" value="amd64">
1422- <equals arg1="x86_64" arg2="${os.arch}"/>
1423- </condition>
1424- <property name="jre.arch" value="${os.arch}"/>
1425- <condition property="os.prefix" value="linux-${jre.arch}">
1426- <os name="Linux"/>
1427- </condition>
1428- <condition property="os.prefix" value="win32-${os.arch}">
1429- <os family="windows"/>
1430- </condition>
1431- <!-- Darwin builds are universal, no arch required -->
1432- <condition property="os.prefix" value="darwin">
1433- <os family="mac"/>
1434- </condition>
1435- <condition property="os.prefix" value="sunos-${os.arch}">
1436- <os name="SunOS"/>
1437- </condition>
1438- <condition property="os.prefix" value="freebsd-${os.arch}">
1439- <os name="FreeBSD"/>
1440- </condition>
1441- <condition property="os.prefix" value="openbsd-${os.arch}">
1442- <os name="OpenBSD"/>
1443- </condition>
1444- <fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
1445- <condition property="jdk.home" value="${java.home}">
1446- <available file="${java.home}/include"/>
1447- </condition>
1448- <condition property="jdk.home" value="${java.home}/..">
1449- <available file="${java.home}/../include"/>
1450- </condition>
1451- <fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
1452- <condition property="libjsig"
1453- value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
1454- <available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
1455- </condition>
1456- <property name="native.jar" value="${os.prefix}.jar"/>
1457- <property name="build.native" location="${build}/native"/>
1458- <property name="md5.file" location="${build.native}/sig"/>
1459-
1460- <mkdir dir="${build}"/>
1461- <mkdir dir="${build.native}"/>
1462- <mkdir dir="${classes}"/>
1463- <mkdir dir="${test.classes}"/>
1464- <mkdir dir="${reports}"/>
1465- <mkdir dir="${doc}"/>
1466-
1467- </target>
1468-
1469- <target name="-setup" depends="-dynamic-properties">
1470- <path id="compile-test.path">
1471- <pathelement path="${test.src}"/>
1472- <path id="test.libs">
1473- <fileset dir="lib">
1474- <include name="junit.jar"/>
1475- </fileset>
1476- <pathelement path="${classes}"/>
1477- </path>
1478- <path id="compile.path">
1479- <path id="src.path">
1480- <pathelement location="${src}"/>
1481- </path>
1482- </path>
1483- </path>
1484-
1485- <path id="test.runpath">
1486- <pathelement path="${build}/${jar}"/>
1487- <pathelement path="${build}/examples.jar"/>
1488- <pathelement path="${test.classes}"/>
1489- <pathelement path="lib/clover.jar"/>
1490- <path refid="test.libs"/>
1491- </path>
1492- </target>
1493-
1494- <target name="compile" depends="-setup"
1495- description="Compile all Java source">
1496- <javac classpathref="compile.path"
1497- source="${compatibility}"
1498- target="${compatibility}"
1499- destdir="${classes}"
1500- deprecation="on" debug="${debug}">
1501- <src path="${src}"/>
1502- </javac>
1503- </target>
1504-
1505- <target name=":jar">
1506- <uptodate property="-jar" targetfile="${build}/${jar}">
1507- <srcfiles dir="${classes}">
1508- <patternset id="jar-compiled">
1509- <include name="com/sun/jna/*"/>
1510- <include name="com/sun/jna/**/*"/>
1511- <exclude name="com/sun/jna/examples/*"/>
1512- <exclude name="com/sun/jna/examples/**/*"/>
1513- </patternset>
1514- </srcfiles>
1515- </uptodate>
1516- </target>
1517- <target name="jar" depends="-setup,native,:jar" unless="-jar"
1518- description="Build primary jar">
1519- <jar jarfile="${build}/${jar}">
1520- <manifest>
1521- <attribute name="Main-Class" value="com.sun.jna.Native"/>
1522- <section name="com/sun/jna/">
1523- <attribute name="Implementation-Title" value="${impl.title}"/>
1524- <attribute name="Implementation-Vendor" value="${vendor}"/>
1525- <attribute name="Implementation-Version" value="${impl.version}"/>
1526- <attribute name="Specification-Title" value="${spec.title}"/>
1527- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
1528- <attribute name="Specification-Version" value="${spec.version}"/>
1529- </section>
1530- </manifest>
1531- <fileset dir="${classes}" excludes="${jar.omitted}">
1532- <patternset refid="jar-compiled"/>
1533- </fileset>
1534- </jar>
1535- </target>
1536- <target name="examples" depends="jar,native">
1537- <jar jarfile="${build}/examples.jar">
1538- <manifest>
1539- <attribute name="Class-Path" value="jna.jar"/>
1540- <attribute name="Main-Class" value="com.sun.jna.examples.ShapedWindowDemo"/>
1541- </manifest>
1542- <fileset dir="${src}" includes="**/examples/**/*.png"/>
1543- <fileset dir="${classes}" includes="**/examples/*,**/examples/**/*"/>
1544- <fileset dir="${classes}" includes="jnidispatch.dll"/>
1545- </jar>
1546- </target>
1547-
1548- <target name="javah" depends="compile">
1549- <javah classpath="${classes}" destdir="${build.native}" force="yes">
1550- <class name="com.sun.jna.Function"/>
1551- <class name="com.sun.jna.Pointer"/>
1552- <class name="com.sun.jna.Memory"/>
1553- <class name="com.sun.jna.Native"/>
1554- <class name="com.sun.jna.NativeLibrary"/>
1555- <class name="com.sun.jna.CallbackReference"/>
1556- </javah>
1557- <condition property="grep" value="/usr/sfw/bin/ggrep">
1558- <os name="SunOS"/>
1559- </condition>
1560- <condition property="grep" value="ggrep">
1561- <os name="OpenBSD"/>
1562- </condition>
1563- <property name="grep" value="grep"/>
1564- <apply dir="${build.native}" executable="${grep}" parallel="true"
1565- failonerror="true" relative="true" output="${md5.file}">
1566- <arg value="-A"/>
1567- <arg value="1"/>
1568- <arg value="JNIEXPORT"/>
1569- <fileset dir="${build.native}" includes="*.h"/>
1570- </apply>
1571- <fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
1572- <checksum property="md5" file="${md5.file}" />
1573- <condition property="jni.valid" value="true">
1574- <or>
1575- <equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
1576- <equals arg1="${jni.md5}" arg2=""/>
1577- </or>
1578- </condition>
1579- </target>
1580-
1581- <!-- Invalidate native libraries when native API changes -->
1582- <target name="-native-api-check" depends="javah" unless="jni.valid">
1583- <echo>Invalidating native code, new checksum is ${md5}</echo>
1584- <copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
1585- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
1586- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
1587- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
1588- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
1589- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
1590- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
1591- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
1592- <copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
1593- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
1594- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
1595- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
1596- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparcv9.jar" overwrite="true"/>
1597- <delete failOnError="false" includeEmptyDirs="true">
1598- <fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
1599- </delete>
1600- <fail>API for native code has changed. Re-run this build after updating jni.version and jni.md5 in build.xml</fail>
1601- </target>
1602-
1603- <target name=":rsrc">
1604- <condition property="-rsrc">
1605- <not><os family="windows"/></not>
1606- </condition>
1607- </target>
1608- <target name="rsrc" depends="-setup,:rsrc" unless="-rsrc"
1609- description="Generate w32 DLL version resource information">
1610- <property name="rsrc" location="${build.native}/jnidispatch.rc"/>
1611- <copy todir="${build.native}" file="${native}/jnidispatch.rc"/>
1612- <replaceregexp match="FILEVERSION.*"
1613- replace="FILEVERSION ${jni.major},${jni.minor},${jni.revision},${jni.build}"
1614- file="${rsrc}" byline="true"/>
1615- <replaceregexp match="PRODUCTVERSION.*"
1616- replace="PRODUCTVERSION ${jna.major},${jna.minor},${jna.revision},${jna.build}"
1617- file="${rsrc}" byline="true"/>
1618- <replaceregexp match="FileVersion.*"
1619- replace="FileVersion&quot;,&quot;${jni.version}&quot;"
1620- file="${rsrc}" byline="true"/>
1621- <replaceregexp match="Full Version.*"
1622- replace="Full Version&quot;,&quot;${jni.version} b${jni.build}&quot;"
1623- file="${rsrc}" byline="true"/>
1624- <replaceregexp match="ProductVersion.*"
1625- replace="ProductVersion&quot;,&quot;${spec.version}&quot;"
1626- file="${rsrc}" byline="true"/>
1627- </target>
1628-
1629- <target name="native" depends="-setup,javah,-native-api-check,rsrc"
1630- description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
1631- <property name="comment" value="# auto-generated by ant"/>
1632- <replaceregexp match="^VERSION=.*"
1633- replace="VERSION=${jni.version} ${comment}"
1634- file="native/Makefile" byline="true"/>
1635- <replaceregexp match="^CHECKSUM=.*"
1636- replace="CHECKSUM=${jni.md5} ${comment}"
1637- file="native/Makefile" byline="true"/>
1638- <!-- ensure ARCH is set properly for 64-bit capable platforms -->
1639- <!-- use ANT_OPTS=-d64 to build 64-bit if not the platform default -->
1640- <property name="ARCH" value="${os.arch}"/>
1641- <condition property="make.CC" value="CC=${CC}" else="IGNORE=">
1642- <isset property="CC"/>
1643- </condition>
1644- <condition property="make.ARCH" value="ARCH=${ARCH}" else="IGNORE=">
1645- <isset property="ARCH"/>
1646- </condition>
1647- <condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
1648- <isset property="SDKROOT"/>
1649- </condition>
1650- <condition property="make.SDKROOT"
1651- value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
1652- <available file="/Developer/SDKs/MacOSX10.5.sdk"/>
1653- </condition>
1654- <condition property="make.SDKROOT"
1655- value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
1656- <available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
1657- </condition>
1658- <!-- Windows' drive letters and spaces in absolute paths wreak havoc on
1659- make -->
1660- <condition property="make.BUILD" value="BUILD=../${build}/native" else="BUILD=${build.native}">
1661- <os family="windows"/>
1662- </condition>
1663- <condition property="make.PATH" value="PATH=/usr/sfw/bin:/usr/bin:/usr/ccs/bin" else="IGNORE=">
1664- <os name="SunOS"/>
1665- </condition>
1666- <condition property="make" value="/usr/sfw/bin/gmake">
1667- <os name="SunOS"/>
1668- </condition>
1669- <condition property="make" value="gmake">
1670- <or>
1671- <os name="FreeBSD"/>
1672- <os name="OpenBSD"/>
1673- </or>
1674- </condition>
1675- <!-- Default make program -->
1676- <property name="make" value="make"/>
1677-
1678- <exec executable="${make}" dir="${native}" failonerror="true">
1679- <arg value="JAVA_HOME=${jdk.home}"/>
1680- <arg value="JAVAH=${build.native}"/>
1681- <arg value="DEBUG=${debug.native}"/>
1682- <arg value="CFLAGS_EXTRA=${cflags_extra.native}"/>
1683- <arg value="DYNAMIC_LIBFFI=${dynlink.native}"/>
1684- <arg value="${make.CC}"/>
1685- <arg value="${make.BUILD}"/>
1686- <arg value="${make.SDKROOT}"/>
1687- <arg value="${make.ARCH}"/>
1688- <arg value="${make.PATH}"/>
1689- <arg value="VERSION=${jni.version}"/>
1690- <arg value="CHECKSUM=${jni.md5}"/>
1691- </exec>
1692- <mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
1693- <copy todir="${classes}/com/sun/jna/${os.prefix}">
1694- <fileset dir="${build.native}"
1695- includes="jnidispatch.dll,libjnidispatch.*"/>
1696- </copy>
1697- <mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
1698- <copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
1699- failonerror="false">
1700- <fileset dir="${build.native}"
1701- includes="jnidispatch.dll,libjnidispatch.*"/>
1702- </copy>
1703- <!-- For web start, native libraries may be provided in the root of -->
1704- <!-- an included jar file -->
1705- <jar jarfile="${build}/${native.jar}">
1706- <fileset dir="${build.native}" includes="jnidispatch.dll,libjnidispatch.*"/>
1707- <manifest>
1708- <attribute name="Implementation-Version" value="${jni.version} b${jni.build}"/>
1709- <attribute name="Specification-Version" value="${jni.version}"/>
1710- </manifest>
1711- </jar>
1712- </target>
1713-
1714- <target name="compile-tests" depends="compile,native,jar"
1715- description="Compile all test code">
1716- <javac classpathref="compile-test.path"
1717- source="${test.compatibility}"
1718- target="${test.compatibility}"
1719- destdir="${test.classes}"
1720- deprecation="on" debug="${debug}">
1721- <src path="${test.src}"/>
1722- </javac>
1723- <jar jarfile="${build}/${testjar}">
1724- <fileset dir="${test.classes}">
1725- <patternset refid="jar-compiled"/>
1726- </fileset>
1727- </jar>
1728- <mkdir dir="${build}/jws"/>
1729- <copy todir="${build}/jws" file="${build}/${jar}"/>
1730- <copy todir="${build}/jws" file="${build}/${testjar}"/>
1731- <copy todir="${build}/jws" file="lib/junit.jar"/>
1732- <copy todir="${build}/jws" file="lib/clover.jar"/>
1733- <jar jarfile="${build}/jws/jnidispatch.jar">
1734- <fileset dir="${build.native}" includes="*jnidispatch.*"/>
1735- </jar>
1736- <signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
1737- <fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
1738- </signjar>
1739- </target>
1740-
1741- <!-- When running tests from an IDE, be sure to set jna.library.path -->
1742- <!-- to where the test library (testlib) is found. -->
1743- <target name="test" depends="jar,examples,compile-tests"
1744- description="Run all unit tests">
1745- <property name="test.fork" value="yes"/>
1746- <property name="reports.junit" location="${reports}/junit"/>
1747- <property name="results.junit" location="${build}/junit-results"/>
1748- <mkdir dir="${results.junit}"/>
1749- <echo>Saving test results in ${results.junit}</echo>
1750- <property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
1751- <condition property="tests.platform" value="**/win32/*Test.java">
1752- <os family="windows"/>
1753- </condition>
1754- <condition property="tests.exclude" value="**/win32/*StdCallTest.java">
1755- <and><os family="windows"/><not><os arch="x86"/></not></and>
1756- </condition>
1757- <condition property="tests.platform" value="**/unix/*Test.java">
1758- <and>
1759- <os family="unix"/>
1760- <not><os family="mac"/></not>
1761- </and>
1762- </condition>
1763- <condition property="vmopt.arch" value="-d64" else="-Dignore">
1764- <and>
1765- <!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
1766- <not><os family="windows"/></not>
1767- <equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
1768- </and>
1769- </condition>
1770- <property name="tests.platform" value=""/>
1771- <property name="tests.exclude" value=""/>
1772- <junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
1773- <!-- avoid VM conflicts with JNA protected mode -->
1774- <env key="${ld.preload}" file="${libjsig}"/>
1775- <jvmarg value="-Djna.library.path=${build.native}"/>
1776- <!-- Avoid VM crashes, if possible -->
1777- <jvmarg value="-Djna.protected=true"/>
1778- <jvmarg value="-Djna.builddir=${build}"/>
1779- <jvmarg value="${vmopt.arch}"/>
1780- <classpath><path refid="test.runpath"/></classpath>
1781- <formatter type="xml"/>
1782- <batchtest todir="${results.junit}">
1783- <fileset dir="${test.src}">
1784- <include name="com/sun/jna/*Test.java"/>
1785- <include name="com/sun/jna/examples/*Test.java"/>
1786- <include name="${tests.platform}"/>
1787- <exclude name="${tests.exclude}"/>
1788- </fileset>
1789- </batchtest>
1790- </junit>
1791- <junitreport todir="${results.junit}">
1792- <fileset dir="${results.junit}">
1793- <include name="TEST-*.xml"/>
1794- </fileset>
1795- <report todir="${reports.junit}"/>
1796- </junitreport>
1797- <echo>View test report in file://${reports.junit}/index.html</echo>
1798- <fail if="testfailure" unless="clover">One or more tests failed</fail>
1799- </target>
1800-
1801- <target name="with.clover" description="Enable code coverage for tests">
1802- <taskdef resource="cloverlib.xml" classpath="lib/clover.jar"/>
1803- <property name="clover" value="true"/>
1804- <property name="build" value="build.clover"/>
1805- <clover-setup/>
1806- </target>
1807-
1808- <target name="clover" depends="with.clover,test"
1809- description="Generate test code coverage reports">
1810- <property name="reports.clover" value="${reports}/clover"/>
1811- <mkdir dir="${reports.clover}"/>
1812- <clover-report>
1813- <current outfile="${reports.clover}" title="clover">
1814- <fileset dir="." includes="**/*.java" excludes="**/examples/**/*.java"/>
1815- <testresults dir="${results.junit}" includes="TEST-*.xml"/>
1816- <format type="html"/>
1817- </current>
1818- </clover-report>
1819- <echo>Reports generated in ${reports.clover}</echo>
1820- </target>
1821-
1822- <target name="javadoc" depends="-setup">
1823- <property name="header"
1824- value="&lt;b&gt;JNA API&lt;/&gt;&lt;font size=&quot;-1&quot;&gt; ${jna.version}&lt;/font&gt;"/>
1825- <property name="footer"
1826- value="&lt;center&gt;&lt;i&gt;${copyright}&lt;/i&gt;&lt;/center&gt;"/>
1827-
1828- <mkdir dir="${javadoc}"/>
1829- <javadoc package="true"
1830- windowtitle="JNA API"
1831- sourcepathref="src.path"
1832- classpathref="compile.path"
1833- maxmemory="256m"
1834- packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.examples,com.sun.jna.examples.win32,com.sun.jna.exmaples.unix"
1835- overview="${src}/com/sun/jna/overview.html"
1836- destdir="${javadoc}">
1837- <!-- stylesheetfile="${stylesheet}" -->
1838- <doctitle>JNA API Documentation</doctitle>
1839- <header>${header}</header>
1840- <bottom>${footer}</bottom>
1841- <link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
1842-
1843- <packageset dir="${src}" defaultexcludes="yes">
1844- <patternset>
1845- <include name="com/sun/jna/**/*"/>
1846- </patternset>
1847- </packageset>
1848-
1849- <group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
1850- <group title="Examples" packages="com.sun.jna.examples,com.sun.jna.examples.dnd"/>
1851- <group title="Unix Examples" packages="com.sun.jna.examples.unix"/>
1852- <group title="Windows Examples" packages="com.sun.jna.examples.win32"/>
1853-
1854- <arg value="-notimestamp"/>
1855- </javadoc>
1856- </target>
1857-
1858- <target name="dist" depends="jar,compile-tests,native,examples,javadoc"
1859- description="Build distribution files">
1860- <jar jarfile="${dist}/jna.jar" duplicate="preserve">
1861- <manifest>
1862- <attribute name="Main-Class" value="com.sun.jna.Native"/>
1863- <section name="com/sun/jna/">
1864- <attribute name="Implementation-Title" value="${impl.title}"/>
1865- <attribute name="Implementation-Vendor" value="${vendor}"/>
1866- <attribute name="Implementation-Version" value="${impl.version}"/>
1867- <attribute name="Specification-Title" value="${spec.title}"/>
1868- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
1869- <attribute name="Specification-Version" value="${spec.version}"/>
1870- </section>
1871- </manifest>
1872- <zipfileset src="${build}/${jar}"/>
1873- <zipfileset src="${dist}/win32-x86.jar"
1874- includes="*jnidispatch*"
1875- prefix="com/sun/jna/win32-x86"/>
1876- <zipfileset src="${dist}/darwin.jar"
1877- includes="*jnidispatch*"
1878- prefix="com/sun/jna/darwin"/>
1879- <zipfileset src="${dist}/linux-i386.jar"
1880- includes="*jnidispatch*"
1881- prefix="com/sun/jna/linux-i386"/>
1882- <zipfileset src="${dist}/linux-amd64.jar"
1883- includes="*jnidispatch*"
1884- prefix="com/sun/jna/linux-amd64"/>
1885- <zipfileset src="${dist}/linux-ia64.jar"
1886- includes="*jnidispatch*"
1887- prefix="com/sun/jna/linux-ia64"/>
1888- <zipfileset src="${dist}/sunos-x86.jar"
1889- includes="*jnidispatch*"
1890- prefix="com/sun/jna/sunos-x86"/>
1891- <zipfileset src="${dist}/sunos-amd64.jar"
1892- includes="*jnidispatch*"
1893- prefix="com/sun/jna/sunos-amd64"/>
1894- <zipfileset src="${dist}/sunos-sparc.jar"
1895- includes="*jnidispatch*"
1896- prefix="com/sun/jna/sunos-sparc"/>
1897- <zipfileset src="${dist}/sunos-sparcv9.jar"
1898- includes="*jnidispatch*"
1899- prefix="com/sun/jna/sunos-sparcv9"/>
1900- <zipfileset src="${dist}/freebsd-i386.jar"
1901- includes="*jnidispatch*"
1902- prefix="com/sun/jna/freebsd-i386"/>
1903- <zipfileset src="${dist}/freebsd-amd64.jar"
1904- includes="*jnidispatch*"
1905- prefix="com/sun/jna/freebsd-amd64"/>
1906- <zipfileset src="${dist}/openbsd-i386.jar"
1907- includes="*jnidispatch*"
1908- prefix="com/sun/jna/openbsd-i386"/>
1909- <zipfileset src="${dist}/win32-amd64.jar"
1910- includes="*jnidispatch*"
1911- prefix="com/sun/jna/win32-amd64"/>
1912- </jar>
1913- <copy todir="${dist}">
1914- <fileset dir="${build}">
1915- <include name="${native.jar}"/>
1916- <include name="examples.jar"/>
1917- </fileset>
1918- </copy>
1919- <zip zipfile="${dist}/doc.zip">
1920- <zipfileset dir="${javadoc}" prefix="javadoc"/>
1921- </zip>
1922- <!-- JNA sources only, for use in Linux build from source/shared libffi -->
1923- <zip zipfile="${dist}/src.zip">
1924- <zipfileset dir="." includes="build.xml,LICENSE.txt"/>
1925- <zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
1926- <zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
1927- <zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
1928- </zip>
1929- <!-- Full sources required to build and test everything -->
1930- <zip zipfile="${dist}/src-full.zip">
1931- <zipfileset src="${dist}/src.zip"/>
1932- <zipfileset dir="lib" includes="junit.jar,clover.jar" prefix="lib"/>
1933- <zipfileset dir="." includes=".classpath,.project"/>
1934- <zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
1935- </zip>
1936- <!-- Sources package as required by maven -->
1937- <zip zipfile="${dist}/src-mvn.zip">
1938- <zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
1939- </zip>
1940- </target>
1941-
1942- <target name="clean" depends="-dynamic-properties">
1943- <delete failOnError="false" includeEmptyDirs="true">
1944- <fileset dir="${build}"/>
1945- </delete>
1946- <delete quiet="true" includeEmptyDirs="true">
1947- <fileset dir=".clover"/>
1948- <fileset dir="${javadoc}"/>
1949- <fileset dir="." includes="*~,**/*~"/>
1950- </delete>
1951- </target>
1952-
1953-</project>
1954-
1955-
1956
1957=== removed directory '.pc/04-load-native-code-from-fs.patch'
1958=== removed directory '.pc/04-load-native-code-from-fs.patch/src'
1959=== removed directory '.pc/04-load-native-code-from-fs.patch/src/com'
1960=== removed directory '.pc/04-load-native-code-from-fs.patch/src/com/sun'
1961=== removed directory '.pc/04-load-native-code-from-fs.patch/src/com/sun/jna'
1962=== removed file '.pc/04-load-native-code-from-fs.patch/src/com/sun/jna/Native.java'
1963--- .pc/04-load-native-code-from-fs.patch/src/com/sun/jna/Native.java 2010-04-21 16:36:37 +0000
1964+++ .pc/04-load-native-code-from-fs.patch/src/com/sun/jna/Native.java 1970-01-01 00:00:00 +0000
1965@@ -1,1441 +0,0 @@
1966-/* Copyright (c) 2007, 2008, 2009 Timothy Wall, All Rights Reserved
1967- *
1968- * This library is free software; you can redistribute it and/or
1969- * modify it under the terms of the GNU Lesser General Public
1970- * License as published by the Free Software Foundation; either
1971- * version 2.1 of the License, or (at your option) any later version.
1972- * <p/>
1973- * This library is distributed in the hope that it will be useful,
1974- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1975- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1976- * Lesser General Public License for more details.
1977- */
1978-package com.sun.jna;
1979-
1980-import java.awt.Component;
1981-import java.awt.GraphicsEnvironment;
1982-import java.awt.HeadlessException;
1983-import java.awt.Window;
1984-import java.io.File;
1985-import java.io.FileOutputStream;
1986-import java.io.IOException;
1987-import java.io.InputStream;
1988-import java.io.UnsupportedEncodingException;
1989-import java.lang.ref.WeakReference;
1990-import java.lang.reflect.Array;
1991-import java.lang.reflect.Field;
1992-import java.lang.reflect.InvocationHandler;
1993-import java.lang.reflect.Method;
1994-import java.lang.reflect.Modifier;
1995-import java.lang.reflect.Proxy;
1996-import java.net.URL;
1997-import java.net.URISyntaxException;
1998-import java.nio.Buffer;
1999-import java.nio.ByteBuffer;
2000-import java.security.AccessController;
2001-import java.security.PrivilegedAction;
2002-import java.util.ArrayList;
2003-import java.util.Collections;
2004-import java.util.HashMap;
2005-import java.util.Iterator;
2006-import java.util.List;
2007-import java.util.Map;
2008-import java.util.WeakHashMap;
2009-
2010-import com.sun.jna.Callback.UncaughtExceptionHandler;
2011-import com.sun.jna.Structure.FFIType;
2012-
2013-/** Provides generation of invocation plumbing for a defined native
2014- * library interface. Also provides various utilities for native operations.
2015- * <p>
2016- * {@link #getTypeMapper} and {@link #getStructureAlignment} are provided
2017- * to avoid having to explicitly pass these parameters to {@link Structure}s,
2018- * which would require every {@link Structure} which requires custom mapping
2019- * or alignment to define a constructor and pass parameters to the superclass.
2020- * To avoid lots of boilerplate, the base {@link Structure} constructor
2021- * figures out these properties based on its enclosing interface.<p>
2022- * <a name=library_loading></a>
2023- * <h2>Library Loading</h2>
2024- * When JNA classes are loaded, the native shared library (jnidispatch) is
2025- * loaded as well. An attempt is made to load it from the system library path
2026- * using {@link System#loadLibrary}. If not found, the appropriate library
2027- * will be extracted from the class path into a temporary directory and
2028- * loaded from there. If your system has additional security constraints
2029- * regarding execution or load of files (SELinux, for example), you should
2030- * probably install the native library in an accessible location and configure
2031- * your system accordingly, rather than relying on JNA to extract the library
2032- * from its own jar file.
2033- * @see Library
2034- * @author Todd Fast, todd.fast@sun.com
2035- * @author twall@users.sf.net
2036- */
2037-public final class Native {
2038-
2039- private static final String VERSION = "3.2.4";
2040-
2041- private static String nativeLibraryPath = null;
2042- private static boolean unpacked;
2043- private static Map typeMappers = new WeakHashMap();
2044- private static Map alignments = new WeakHashMap();
2045- private static Map options = new WeakHashMap();
2046- private static Map libraries = new WeakHashMap();
2047- private static final UncaughtExceptionHandler DEFAULT_HANDLER =
2048- new UncaughtExceptionHandler() {
2049- public void uncaughtException(Callback c, Throwable e) {
2050- System.err.println("JNA: Callback " + c + " threw the following exception:");
2051- e.printStackTrace();
2052- }
2053- };
2054- private static UncaughtExceptionHandler callbackExceptionHandler = DEFAULT_HANDLER;
2055-
2056- /** The size of a native pointer (<code>void*</code>) on the current
2057- * platform, in bytes.
2058- */
2059- public static final int POINTER_SIZE;
2060- /** Size of a native <code>long</code> type, in bytes. */
2061- public static final int LONG_SIZE;
2062- /** Size of a native <code>wchar_t</code> type, in bytes. */
2063- public static final int WCHAR_SIZE;
2064- /** Size of a native <code>size_t</code> type, in bytes. */
2065- public static final int SIZE_T_SIZE;
2066-
2067- private static final int TYPE_VOIDP = 0;
2068- private static final int TYPE_LONG = 1;
2069- private static final int TYPE_WCHAR_T = 2;
2070- private static final int TYPE_SIZE_T = 3;
2071-
2072- static {
2073- loadNativeLibrary();
2074- POINTER_SIZE = sizeof(TYPE_VOIDP);
2075- LONG_SIZE = sizeof(TYPE_LONG);
2076- WCHAR_SIZE = sizeof(TYPE_WCHAR_T);
2077- SIZE_T_SIZE = sizeof(TYPE_SIZE_T);
2078- // Perform initialization of other JNA classes until *after*
2079- // initializing the above final fields
2080- initIDs();
2081- if (Boolean.getBoolean("jna.protected")) {
2082- setProtected(true);
2083- }
2084- }
2085-
2086- /** Ensure our unpacked native library gets cleaned up if this class gets
2087- garbage-collected.
2088- */
2089- private static final Object finalizer = new Object() {
2090- protected void finalize() {
2091- deleteNativeLibrary();
2092- }
2093- };
2094-
2095- /** Remove any unpacked native library. Forcing the class loader to
2096- unload it first is required on Windows, since the temporary native
2097- library can't be deleted until the native library is unloaded. Any
2098- deferred execution we might install at this point would prevent the
2099- Native class and its class loader from being GC'd, so we instead force
2100- the native library unload just a little bit prematurely.
2101- */
2102- private static boolean deleteNativeLibrary() {
2103- String path = nativeLibraryPath;
2104- if (path == null || !unpacked) return true;
2105- File flib = new File(path);
2106- if (flib.delete()) {
2107- nativeLibraryPath = null;
2108- unpacked = false;
2109- return true;
2110- }
2111- // Reach into the bowels of ClassLoader to force the native
2112- // library to unload
2113- try {
2114- ClassLoader cl = Native.class.getClassLoader();
2115- Field f = ClassLoader.class.getDeclaredField("nativeLibraries");
2116- f.setAccessible(true);
2117- List libs = (List)f.get(cl);
2118- for (Iterator i = libs.iterator();i.hasNext();) {
2119- Object lib = i.next();
2120- f = lib.getClass().getDeclaredField("name");
2121- f.setAccessible(true);
2122- String name = (String)f.get(lib);
2123- if (name.equals(path) || name.indexOf(path) != -1) {
2124- Method m = lib.getClass().getDeclaredMethod("finalize", new Class[0]);
2125- m.setAccessible(true);
2126- m.invoke(lib, new Object[0]);
2127- nativeLibraryPath = null;
2128- if (unpacked) {
2129- if (flib.exists()) {
2130- if (flib.delete()) {
2131- unpacked = false;
2132- return true;
2133- }
2134- return false;
2135- }
2136- }
2137- return true;
2138- }
2139- }
2140- }
2141- catch(Exception e) {
2142- }
2143- return false;
2144- }
2145-
2146- private Native() { }
2147-
2148- private static native void initIDs();
2149-
2150- /** Set whether native memory accesses are protected from invalid
2151- * accesses. This should only be set true when testing or debugging,
2152- * and should not be considered reliable or robust for applications
2153- * where JNA native calls are occurring on multiple threads.
2154- * Protected mode will be automatically set if the
2155- * system property <code>jna.protected</code> has a value of "true"
2156- * when the JNA library is first loaded.<p>
2157- * If not supported by the underlying platform, this setting will
2158- * have no effect.<p>
2159- * NOTE: On platforms which support signals (non-Windows), JNA uses
2160- * signals to trap errors. This may interfere with the JVM's own use of
2161- * signals. When protected mode is enabled, you should make use of the
2162- * jsig library, if available (see <a href="http://java.sun.com/j2se/1.4.2/docs/guide/vm/signal-chaining.html">Signal Chaining</a>).
2163- * In short, set the environment variable <code>LD_PRELOAD</code> to the
2164- * path to <code>libjsig.so</code> in your JRE lib directory
2165- * (usually ${java.home}/lib/${os.arch}/libjsig.so) before launching your
2166- * Java application.
2167- */
2168- public static synchronized native void setProtected(boolean enable);
2169-
2170- /** Returns whether protection is enabled. Check the result of this method
2171- * after calling {@link #setProtected setProtected(true)} to determine
2172- * if this platform supports protecting memory accesses.
2173- */
2174- public static synchronized native boolean isProtected();
2175-
2176- /** Set whether the system last error result is captured after every
2177- * native invocation. Defaults to <code>true</code> (<code>false</code>
2178- * for direct-mapped calls).<p>
2179- * @deprecated The preferred method of obtaining the last error result is
2180- * to declare your mapped method to throw {@link LastErrorException}
2181- * instead.
2182- */
2183- public static synchronized native void setPreserveLastError(boolean enable);
2184-
2185- /** Indicates whether the system last error result is preserved
2186- * after every invocation.<p>
2187- * @deprecated The preferred method of obtaining the last error result is
2188- * to declare your mapped method to throw {@link LastErrorException}
2189- * instead.
2190- */
2191- public static synchronized native boolean getPreserveLastError();
2192-
2193- /** Utility method to get the native window ID for a Java {@link Window}
2194- * as a <code>long</code> value.
2195- * This method is primarily for X11-based systems, which use an opaque
2196- * <code>XID</code> (usually <code>long int</code>) to identify windows.
2197- * @throws HeadlessException if the current VM is running headless
2198- */
2199- public static long getWindowID(Window w) throws HeadlessException {
2200- return getComponentID(w);
2201- }
2202-
2203- /** Utility method to get the native window ID for a heavyweight Java
2204- * {@link Component} as a <code>long</code> value.
2205- * This method is primarily for X11-based systems, which use an opaque
2206- * <code>XID</code> (usually <code>long int</code>) to identify windows.
2207- * @throws HeadlessException if the current VM is running headless
2208- */
2209- public static long getComponentID(Component c) throws HeadlessException {
2210- if (GraphicsEnvironment.isHeadless()) {
2211- throw new HeadlessException("No native windows when headless");
2212- }
2213- if (c.isLightweight()) {
2214- throw new IllegalArgumentException("Component must be heavyweight");
2215- }
2216- if (!c.isDisplayable())
2217- throw new IllegalStateException("Component must be displayable");
2218- // On X11 VMs prior to 1.5, the window must be visible
2219- if (Platform.isX11()
2220- && System.getProperty("java.version").startsWith("1.4")) {
2221- if (!c.isVisible()) {
2222- throw new IllegalStateException("Component must be visible");
2223- }
2224- }
2225- // By this point, we're certain that Toolkit.loadLibraries() has
2226- // been called, thus avoiding AWT/JAWT link errors
2227- // (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6539705).
2228- return getWindowHandle0(c);
2229- }
2230-
2231- /** Utility method to get the native window pointer for a Java
2232- * {@link Window} as a {@link Pointer} value. This method is primarily for
2233- * w32, which uses the <code>HANDLE</code> type (actually
2234- * <code>void *</code>) to identify windows.
2235- * @throws HeadlessException if the current VM is running headless
2236- */
2237- public static Pointer getWindowPointer(Window w) throws HeadlessException {
2238- return getComponentPointer(w);
2239- }
2240-
2241- /** Utility method to get the native window pointer for a heavyweight Java
2242- * {@link Component} as a {@link Pointer} value. This method is primarily
2243- * for w32, which uses the <code>HWND</code> type (actually
2244- * <code>void *</code>) to identify windows.
2245- * @throws HeadlessException if the current VM is running headless
2246- */
2247- public static Pointer getComponentPointer(Component c) throws HeadlessException {
2248- return new Pointer(getComponentID(c));
2249- }
2250-
2251- private static native long getWindowHandle0(Component c);
2252-
2253- /** Convert a direct {@link Buffer} into a {@link Pointer}.
2254- * @throws IllegalArgumentException if the buffer is not direct.
2255- */
2256- public static native Pointer getDirectBufferPointer(Buffer b);
2257-
2258- /** Obtain a Java String from the given native byte array. If there is
2259- * no NUL terminator, the String will comprise the entire array. If the
2260- * system property <code>jna.encoding</code> is set, its value will
2261- * override the platform default encoding (if supported).
2262- */
2263- public static String toString(byte[] buf) {
2264- return toString(buf, System.getProperty("jna.encoding"));
2265- }
2266-
2267- /** Obtain a Java String from the given native byte array, using the given
2268- * encoding. If there is no NUL terminator, the String will comprise the
2269- * entire array. If the <code>encoding</code> parameter is null,
2270- * the platform default encoding will be used.
2271- */
2272- public static String toString(byte[] buf, String encoding) {
2273- String s = null;
2274- if (encoding != null) {
2275- try {
2276- s = new String(buf, encoding);
2277- }
2278- catch(UnsupportedEncodingException e) { }
2279- }
2280- if (s == null) {
2281- s = new String(buf);
2282- }
2283- int term = s.indexOf(0);
2284- if (term != -1)
2285- s = s.substring(0, term);
2286- return s;
2287- }
2288-
2289- /** Obtain a Java String from the given native wchar_t array. If there is
2290- * no NUL terminator, the String will comprise the entire array.
2291- */
2292- public static String toString(char[] buf) {
2293- String s = new String(buf);
2294- int term = s.indexOf(0);
2295- if (term != -1)
2296- s = s.substring(0, term);
2297- return s;
2298- }
2299-
2300- /** Map a library interface to the current process, providing
2301- * the explicit interface class.
2302- * @param interfaceClass
2303- */
2304- public static Object loadLibrary(Class interfaceClass) {
2305- return loadLibrary(null, interfaceClass);
2306- }
2307-
2308- /** Map a library interface to the current process, providing
2309- * the explicit interface class.
2310- * @param interfaceClass
2311- * @param options Map of library options
2312- */
2313- public static Object loadLibrary(Class interfaceClass, Map options) {
2314- return loadLibrary(null, interfaceClass, options);
2315- }
2316-
2317- /** Map a library interface to the given shared library, providing
2318- * the explicit interface class.
2319- * If <code>name</code> is null, attempts to map onto the current process.
2320- * @param name
2321- * @param interfaceClass
2322- */
2323- public static Object loadLibrary(String name, Class interfaceClass) {
2324- return loadLibrary(name, interfaceClass, Collections.EMPTY_MAP);
2325- }
2326-
2327- /** Load a library interface from the given shared library, providing
2328- * the explicit interface class and a map of options for the library.
2329- * If no library options are detected the map is interpreted as a map
2330- * of Java method names to native function names.<p>
2331- * If <code>name</code> is null, attempts to map onto the current process.
2332- * @param name
2333- * @param interfaceClass
2334- * @param options Map of library options
2335- */
2336- public static Object loadLibrary(String name,
2337- Class interfaceClass,
2338- Map options) {
2339- Library.Handler handler =
2340- new Library.Handler(name, interfaceClass, options);
2341- ClassLoader loader = interfaceClass.getClassLoader();
2342- Library proxy = (Library)
2343- Proxy.newProxyInstance(loader, new Class[] {interfaceClass},
2344- handler);
2345- cacheOptions(interfaceClass, options, proxy);
2346- return proxy;
2347- }
2348-
2349- /** Attempts to force initialization of an instance of the library interface
2350- * by loading a public static field of the requisite type.
2351- * Returns whether an instance variable was instantiated.
2352- * Expects that lock on libraries is already held
2353- */
2354- private static void loadLibraryInstance(Class cls) {
2355- if (cls != null && !libraries.containsKey(cls)) {
2356- try {
2357- Field[] fields = cls.getFields();
2358- for (int i=0;i < fields.length;i++) {
2359- Field field = fields[i];
2360- if (field.getType() == cls
2361- && Modifier.isStatic(field.getModifiers())) {
2362- // Ensure the field gets initialized by reading it
2363- libraries.put(cls, new WeakReference(field.get(null)));
2364- break;
2365- }
2366- }
2367- }
2368- catch (Exception e) {
2369- throw new IllegalArgumentException("Could not access instance of "
2370- + cls + " (" + e + ")");
2371- }
2372- }
2373- }
2374-
2375- /** Find the library interface corresponding to the given class. Checks
2376- * all ancestor classes and interfaces for a declaring class which
2377- * implements {@link Library}.
2378- */
2379- static Class findEnclosingLibraryClass(Class cls) {
2380- if (cls == null) {
2381- return null;
2382- }
2383- synchronized(libraries) {
2384- if (options.containsKey(cls)) {
2385- return cls;
2386- }
2387- }
2388- if (Library.class.isAssignableFrom(cls)) {
2389- return cls;
2390- }
2391- if (Callback.class.isAssignableFrom(cls)) {
2392- cls = CallbackReference.findCallbackClass(cls);
2393- }
2394- Class declaring = cls.getDeclaringClass();
2395- Class fromDeclaring = findEnclosingLibraryClass(declaring);
2396- if (fromDeclaring != null) {
2397- return fromDeclaring;
2398- }
2399- return findEnclosingLibraryClass(cls.getSuperclass());
2400- }
2401-
2402-
2403- /** Return the preferred native library configuration options for the given
2404- * class.
2405- * @see Library
2406- */
2407- public static Map getLibraryOptions(Class type) {
2408- synchronized(libraries) {
2409- Class interfaceClass = findEnclosingLibraryClass(type);
2410- if (interfaceClass != null)
2411- loadLibraryInstance(interfaceClass);
2412- else
2413- interfaceClass = type;
2414- if (!options.containsKey(interfaceClass)) {
2415- try {
2416- Field field = interfaceClass.getField("OPTIONS");
2417- field.setAccessible(true);
2418- options.put(interfaceClass, field.get(null));
2419- }
2420- catch (NoSuchFieldException e) {
2421- }
2422- catch (Exception e) {
2423- throw new IllegalArgumentException("OPTIONS must be a public field of type java.util.Map ("
2424- + e + "): " + interfaceClass);
2425- }
2426- }
2427- return (Map)options.get(interfaceClass);
2428- }
2429- }
2430-
2431- /** Return the preferred {@link TypeMapper} for the given native interface.
2432- * See {@link com.sun.jna.Library#OPTION_TYPE_MAPPER}.
2433- */
2434- public static TypeMapper getTypeMapper(Class cls) {
2435- synchronized(libraries) {
2436- Class interfaceClass = findEnclosingLibraryClass(cls);
2437- if (interfaceClass != null)
2438- loadLibraryInstance(interfaceClass);
2439- else
2440- interfaceClass = cls;
2441-
2442- if (!typeMappers.containsKey(interfaceClass)) {
2443- try {
2444- Field field = interfaceClass.getField("TYPE_MAPPER");
2445- field.setAccessible(true);
2446- typeMappers.put(interfaceClass, field.get(null));
2447- }
2448- catch (NoSuchFieldException e) {
2449- Map options = getLibraryOptions(cls);
2450- if (options != null
2451- && options.containsKey(Library.OPTION_TYPE_MAPPER)) {
2452- typeMappers.put(interfaceClass, options.get(Library.OPTION_TYPE_MAPPER));
2453- }
2454- }
2455- catch (Exception e) {
2456- throw new IllegalArgumentException("TYPE_MAPPER must be a public field of type "
2457- + TypeMapper.class.getName() + " ("
2458- + e + "): " + interfaceClass);
2459- }
2460- }
2461- return (TypeMapper)typeMappers.get(interfaceClass);
2462- }
2463- }
2464-
2465- /** Return the preferred structure alignment for the given native interface.
2466- * See {@link com.sun.jna.Library#OPTION_STRUCTURE_ALIGNMENT}.
2467- */
2468- public static int getStructureAlignment(Class cls) {
2469- synchronized(libraries) {
2470- Class interfaceClass = findEnclosingLibraryClass(cls);
2471- if (interfaceClass != null)
2472- loadLibraryInstance(interfaceClass);
2473- else
2474- interfaceClass = cls;
2475- if (!alignments.containsKey(interfaceClass)) {
2476- try {
2477- Field field = interfaceClass.getField("STRUCTURE_ALIGNMENT");
2478- field.setAccessible(true);
2479- alignments.put(interfaceClass, field.get(null));
2480- }
2481- catch(NoSuchFieldException e) {
2482- Map options = getLibraryOptions(interfaceClass);
2483- if (options != null
2484- && options.containsKey(Library.OPTION_STRUCTURE_ALIGNMENT)) {
2485- alignments.put(interfaceClass, options.get(Library.OPTION_STRUCTURE_ALIGNMENT));
2486- }
2487- }
2488- catch(Exception e) {
2489- throw new IllegalArgumentException("STRUCTURE_ALIGNMENT must be a public field of type int ("
2490- + e + "): " + interfaceClass);
2491- }
2492- }
2493- Integer value = (Integer)alignments.get(interfaceClass);
2494- return value != null ? value.intValue() : Structure.ALIGN_DEFAULT;
2495- }
2496- }
2497-
2498- /** Return a byte array corresponding to the given String. If the
2499- * system property <code>jna.encoding</code> is set, its value will override
2500- * the default platform encoding (if supported).
2501- */
2502- static byte[] getBytes(String s) {
2503- try {
2504- return getBytes(s, System.getProperty("jna.encoding"));
2505- }
2506- catch (UnsupportedEncodingException e) {
2507- return s.getBytes();
2508- }
2509- }
2510-
2511- /** Return a byte array corresponding to the given String, using the given
2512- encoding.
2513- */
2514- static byte[] getBytes(String s, String encoding) throws UnsupportedEncodingException {
2515- if (encoding != null) {
2516- return s.getBytes(encoding);
2517- }
2518- return s.getBytes();
2519- }
2520-
2521- /** Obtain a NUL-terminated byte buffer equivalent to the given String,
2522- using <code>jna.encoding</code> or the default platform encoding if
2523- that property is not set.
2524- */
2525- public static byte[] toByteArray(String s) {
2526- byte[] bytes = getBytes(s);
2527- byte[] buf = new byte[bytes.length+1];
2528- System.arraycopy(bytes, 0, buf, 0, bytes.length);
2529- return buf;
2530- }
2531-
2532- /** Obtain a NUL-terminated byte buffer equivalent to the given String,
2533- using the given encoding.
2534- */
2535- public static byte[] toByteArray(String s, String encoding) throws UnsupportedEncodingException {
2536- byte[] bytes = getBytes(s, encoding);
2537- byte[] buf = new byte[bytes.length+1];
2538- System.arraycopy(bytes, 0, buf, 0, bytes.length);
2539- return buf;
2540- }
2541-
2542- /** Obtain a NUL-terminated wide character buffer equivalent to the given
2543- String.
2544- */
2545- public static char[] toCharArray(String s) {
2546- char[] chars = s.toCharArray();
2547- char[] buf = new char[chars.length+1];
2548- System.arraycopy(chars, 0, buf, 0, chars.length);
2549- return buf;
2550- }
2551-
2552- static String getNativeLibraryResourcePath(int osType, String arch, String name) {
2553- String osPrefix;
2554- arch = arch.toLowerCase();
2555- switch(osType) {
2556- case Platform.WINDOWS:
2557- if ("i386".equals(arch))
2558- arch = "x86";
2559- osPrefix = "win32-" + arch;
2560- break;
2561- case Platform.MAC:
2562- osPrefix = "darwin";
2563- break;
2564- case Platform.LINUX:
2565- if ("x86".equals(arch)) {
2566- arch = "i386";
2567- }
2568- else if ("x86_64".equals(arch)) {
2569- arch = "amd64";
2570- }
2571- osPrefix = "linux-" + arch;
2572- break;
2573- case Platform.SOLARIS:
2574- osPrefix = "sunos-" + arch;
2575- break;
2576- default:
2577- osPrefix = name.toLowerCase();
2578- if ("x86".equals(arch)) {
2579- arch = "i386";
2580- }
2581- if ("x86_64".equals(arch)) {
2582- arch = "amd64";
2583- }
2584- if ("powerpc".equals(arch)) {
2585- arch = "ppc";
2586- }
2587- int space = osPrefix.indexOf(" ");
2588- if (space != -1) {
2589- osPrefix = osPrefix.substring(0, space);
2590- }
2591- osPrefix += "-" + arch;
2592- break;
2593- }
2594- return "/com/sun/jna/" + osPrefix;
2595- }
2596-
2597- /**
2598- * Loads the JNA stub library. It will first attempt to load this library
2599- * from the directories specified in jna.boot.library.path. If that fails,
2600- * it will fallback to loading from the system library paths. Finally it will
2601- * attempt to extract the stub library from from the JNA jar file, and load it.
2602- * <p>
2603- * The jna.boot.library.path property is mainly to support jna.jar being
2604- * included in -Xbootclasspath, where java.library.path and LD_LIBRARY_PATH
2605- * are ignored. It might also be useful in other situations.
2606- * </p>
2607- */
2608- private static void loadNativeLibrary() {
2609- String libName = "jnidispatch";
2610- String bootPath = System.getProperty("jna.boot.library.path");
2611- if (bootPath != null) {
2612- String[] dirs = bootPath.split(File.pathSeparator);
2613- for (int i = 0; i < dirs.length; ++i) {
2614- String path = new File(new File(dirs[i]), System.mapLibraryName(libName)).getAbsolutePath();
2615- try {
2616- System.load(path);
2617- nativeLibraryPath = path;
2618- return;
2619- } catch (UnsatisfiedLinkError ex) {
2620- }
2621- if (Platform.isMac()) {
2622- String orig, ext;
2623- if (path.endsWith("dylib")) {
2624- orig = "dylib";
2625- ext = "jnilib";
2626- } else {
2627- orig = "jnilib";
2628- ext = "dylib";
2629- }
2630- try {
2631- path = path.substring(0, path.lastIndexOf(orig)) + ext;
2632- System.load(path);
2633- nativeLibraryPath = path;
2634- return;
2635- } catch (UnsatisfiedLinkError ex) {
2636- }
2637- }
2638- }
2639- }
2640- try {
2641- System.loadLibrary(libName);
2642- nativeLibraryPath = libName;
2643- }
2644- catch(UnsatisfiedLinkError e) {
2645- loadNativeLibraryFromJar();
2646- }
2647- }
2648-
2649- /**
2650- * Attempts to load the native library resource from the filesystem,
2651- * extracting the JNA stub library from jna.jar if not already available.
2652- */
2653- private static void loadNativeLibraryFromJar() {
2654- String libname = System.mapLibraryName("jnidispatch");
2655- String arch = System.getProperty("os.arch");
2656- String name = System.getProperty("os.name");
2657- String resourceName = getNativeLibraryResourcePath(Platform.getOSType(), arch, name) + "/" + libname;
2658- URL url = Native.class.getResource(resourceName);
2659-
2660- // Add an ugly hack for OpenJDK (soylatte) - JNI libs use the usual
2661- // .dylib extension
2662- if (url == null && Platform.isMac()
2663- && resourceName.endsWith(".dylib")) {
2664- resourceName = resourceName.substring(0, resourceName.lastIndexOf(".dylib")) + ".jnilib";
2665- url = Native.class.getResource(resourceName);
2666- }
2667- if (url == null) {
2668- throw new UnsatisfiedLinkError("jnidispatch (" + resourceName
2669- + ") not found in resource path");
2670- }
2671-
2672- File lib = null;
2673- if (url.getProtocol().toLowerCase().equals("file")) {
2674- try {
2675- lib = new File(url.toURI());
2676- }
2677- catch(URISyntaxException e) {
2678- lib = new File(url.getPath());
2679- }
2680- if (!lib.exists()) {
2681- throw new Error("File URL " + url + " could not be properly decoded");
2682- }
2683- }
2684- else {
2685- InputStream is = Native.class.getResourceAsStream(resourceName);
2686- if (is == null) {
2687- throw new Error("Can't obtain jnidispatch InputStream");
2688- }
2689-
2690- FileOutputStream fos = null;
2691- try {
2692- // Suffix is required on windows, or library fails to load
2693- // Let Java pick the suffix, except on windows, to avoid
2694- // problems with Web Start.
2695- lib = File.createTempFile("jna", Platform.isWindows()?".dll":null);
2696- lib.deleteOnExit();
2697- ClassLoader cl = Native.class.getClassLoader();
2698- if (Platform.deleteNativeLibraryAfterVMExit()
2699- && (cl == null
2700- || cl.equals(ClassLoader.getSystemClassLoader()))) {
2701- Runtime.getRuntime().addShutdownHook(new DeleteNativeLibrary(lib));
2702- }
2703- fos = new FileOutputStream(lib);
2704- int count;
2705- byte[] buf = new byte[1024];
2706- while ((count = is.read(buf, 0, buf.length)) > 0) {
2707- fos.write(buf, 0, count);
2708- }
2709- }
2710- catch(IOException e) {
2711- throw new Error("Failed to create temporary file for jnidispatch library: " + e);
2712- }
2713- finally {
2714- try { is.close(); } catch(IOException e) { }
2715- if (fos != null) {
2716- try { fos.close(); } catch(IOException e) { }
2717- }
2718- }
2719- unpacked = true;
2720- }
2721- System.load(lib.getAbsolutePath());
2722- nativeLibraryPath = lib.getAbsolutePath();
2723- }
2724-
2725- /**
2726- * Initialize field and method IDs for native methods of this class.
2727- * Returns the size of a native pointer.
2728- **/
2729- private static native int sizeof(int type);
2730-
2731- private static native String getNativeVersion();
2732- private static native String getAPIChecksum();
2733-
2734- private static final ThreadLocal lastError = new ThreadLocal() {
2735- protected synchronized Object initialValue() {
2736- return new Integer(0);
2737- }
2738- };
2739-
2740- /** Retrieve the last error set by the OS. This corresponds to
2741- * <code>GetLastError()</code> on Windows, and <code>errno</code> on
2742- * most other platforms. The value is preserved per-thread, but whether
2743- * the original value is per-thread depends on the underlying OS. The
2744- * result is undefined if {@link #getPreserveLastError} is
2745- * <code>false</code>.<p>
2746- * The preferred method of obtaining the last error result is
2747- * to declare your mapped method to throw {@link LastErrorException}
2748- * instead.
2749- */
2750- public static int getLastError() {
2751- return ((Integer)lastError.get()).intValue();
2752- }
2753-
2754- /** Set the OS last error code. Whether the setting is per-thread
2755- * or global depends on the underlying OS.
2756- */
2757- public static native void setLastError(int code);
2758-
2759- /** Update the last error value (called from native code). */
2760- static void updateLastError(int e) {
2761- lastError.set(new Integer(e));
2762- }
2763-
2764- /**
2765- * Returns a synchronized (thread-safe) library backed by the specified
2766- * library. This wrapping will prevent simultaneous invocations of any
2767- * functions mapped to a given {@link NativeLibrary}. Note that the
2768- * native library may still be sensitive to being called from different
2769- * threads.
2770- * <p>
2771- * @param library the library to be "wrapped" in a synchronized library.
2772- * @return a synchronized view of the specified library.
2773- */
2774- public static Library synchronizedLibrary(final Library library) {
2775- Class cls = library.getClass();
2776- if (!Proxy.isProxyClass(cls)) {
2777- throw new IllegalArgumentException("Library must be a proxy class");
2778- }
2779- InvocationHandler ih = Proxy.getInvocationHandler(library);
2780- if (!(ih instanceof Library.Handler)) {
2781- throw new IllegalArgumentException("Unrecognized proxy handler: " + ih);
2782- }
2783- final Library.Handler handler = (Library.Handler)ih;
2784- InvocationHandler newHandler = new InvocationHandler() {
2785- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
2786- synchronized(handler.getNativeLibrary()) {
2787- return handler.invoke(library, method, args);
2788- }
2789- }
2790- };
2791- return (Library)Proxy.newProxyInstance(cls.getClassLoader(),
2792- cls.getInterfaces(),
2793- newHandler);
2794- }
2795-
2796- /** If running web start, determine the location of a given native
2797- * library. This value may be used to properly set
2798- * <code>jna.library.path</code> so that JNA can load libraries identified
2799- * by the &lt;nativelib&gt; tag in the JNLP configuration file. Returns
2800- * <code>null</code> if the Web Start native library cache location can not
2801- * be determined. Note that the path returned may be different for any
2802- * given library name.
2803- * <p>
2804- * Use <code>System.getProperty("javawebstart.version")</code> to detect
2805- * whether your code is running under Web Start.
2806- * @throws UnsatisfiedLinkError if the library can't be found by the
2807- * Web Start class loader, which usually means it wasn't included as
2808- * a <code>&lt;nativelib&gt;</code> resource in the JNLP file.
2809- * @return null if unable to query the web start loader.
2810- */
2811- public static String getWebStartLibraryPath(final String libName) {
2812- if (System.getProperty("javawebstart.version") == null)
2813- return null;
2814- try {
2815-
2816- final ClassLoader cl = Native.class.getClassLoader();
2817- Method m = (Method)AccessController.doPrivileged(new PrivilegedAction() {
2818- public Object run() {
2819- try {
2820- Method m = ClassLoader.class.getDeclaredMethod("findLibrary", new Class[] { String.class });
2821- m.setAccessible(true);
2822- return m;
2823- }
2824- catch(Exception e) {
2825- return null;
2826- }
2827- }
2828- });
2829- String libpath = (String)m.invoke(cl, new Object[] { libName });
2830- if (libpath != null) {
2831- return new File(libpath).getParent();
2832- }
2833- return null;
2834- }
2835- catch (Exception e) {
2836- return null;
2837- }
2838- }
2839-
2840- /** For internal use only. */
2841- public static class DeleteNativeLibrary extends Thread {
2842- private final File file;
2843- public DeleteNativeLibrary(File file) {
2844- this.file = file;
2845- }
2846- public void run() {
2847- // If we can't force an unload/delete, spawn a new process
2848- // to do so
2849- if (!deleteNativeLibrary()) {
2850- try {
2851- Runtime.getRuntime().exec(new String[] {
2852- System.getProperty("java.home") + "/bin/java",
2853- "-cp", System.getProperty("java.class.path"),
2854- getClass().getName(),
2855- file.getAbsolutePath(),
2856- });
2857- }
2858- catch(IOException e) { e.printStackTrace(); }
2859- }
2860- }
2861- public static void main(String[] args) {
2862- if (args.length == 1) {
2863- File file = new File(args[0]);
2864- if (file.exists()) {
2865- long start = System.currentTimeMillis();
2866- while (!file.delete() && file.exists()) {
2867- try { Thread.sleep(10); }
2868- catch(InterruptedException e) { }
2869- if (System.currentTimeMillis() - start > 5000) {
2870- System.err.println("Could not remove temp file: "
2871- + file.getAbsolutePath());
2872- break;
2873- }
2874- }
2875- }
2876- }
2877- System.exit(0);
2878- }
2879- }
2880-
2881- /** Returns the native size of the given class, in bytes.
2882- * For use with arrays.
2883- */
2884- public static int getNativeSize(Class type, Object value) {
2885- if (type.isArray()) {
2886- int len = Array.getLength(value);
2887- if (len > 0) {
2888- Object o = Array.get(value, 0);
2889- return len * getNativeSize(type.getComponentType(), o);
2890- }
2891- // Don't process zero-length arrays
2892- throw new IllegalArgumentException("Arrays of length zero not allowed: " + type);
2893- }
2894- if (Structure.class.isAssignableFrom(type)
2895- && !Structure.ByReference.class.isAssignableFrom(type)) {
2896- if (value == null)
2897- value = Structure.newInstance(type);
2898- return ((Structure)value).size();
2899- }
2900- try {
2901- return getNativeSize(type);
2902- }
2903- catch(IllegalArgumentException e) {
2904- throw new IllegalArgumentException("The type \"" + type.getName()
2905- + "\" is not supported: "
2906- + e.getMessage());
2907- }
2908- }
2909-
2910- /** Returns the native size for a given Java class. Structures are
2911- * assumed to be <code>struct</code> pointers unless they implement
2912- * {@link Structure.ByValue}.
2913- */
2914- public static int getNativeSize(Class cls) {
2915- if (NativeMapped.class.isAssignableFrom(cls)) {
2916- cls = NativeMappedConverter.getInstance(cls).nativeType();
2917- }
2918- // boolean defaults to 32 bit integer if not otherwise mapped
2919- if (cls == boolean.class || cls == Boolean.class) return 4;
2920- if (cls == byte.class || cls == Byte.class) return 1;
2921- if (cls == short.class || cls == Short.class) return 2;
2922- if (cls == char.class || cls == Character.class) return WCHAR_SIZE;
2923- if (cls == int.class || cls == Integer.class) return 4;
2924- if (cls == long.class || cls == Long.class) return 8;
2925- if (cls == float.class || cls == Float.class) return 4;
2926- if (cls == double.class || cls == Double.class) return 8;
2927- if (Structure.class.isAssignableFrom(cls)) {
2928- if (Structure.ByValue.class.isAssignableFrom(cls)) {
2929- return Structure.newInstance(cls).size();
2930- }
2931- return POINTER_SIZE;
2932- }
2933- if (Pointer.class.isAssignableFrom(cls)
2934- || Buffer.class.isAssignableFrom(cls)
2935- || Callback.class.isAssignableFrom(cls)
2936- || String.class == cls
2937- || WString.class == cls) {
2938- return POINTER_SIZE;
2939- }
2940- throw new IllegalArgumentException("Native size for type \"" + cls.getName()
2941- + "\" is unknown");
2942- }
2943-
2944- /** Indicate whether the given class is supported as a native argument
2945- * type.
2946- */
2947- public static boolean isSupportedNativeType(Class cls) {
2948- if (Structure.class.isAssignableFrom(cls)) {
2949- return true;
2950- }
2951- try {
2952- return getNativeSize(cls) != 0;
2953- }
2954- catch(IllegalArgumentException e) {
2955- return false;
2956- }
2957- }
2958-
2959- /** Set the default handler invoked when a callback throws an uncaught
2960- * exception. If the given handler is <code>null</code>, the default
2961- * handler will be reinstated.
2962- */
2963- public static void setCallbackExceptionHandler(UncaughtExceptionHandler eh) {
2964- callbackExceptionHandler = eh == null ? DEFAULT_HANDLER : eh;
2965- }
2966-
2967- /** Returns the current handler for callback uncaught exceptions. */
2968- public static UncaughtExceptionHandler getCallbackExceptionHandler() {
2969- return callbackExceptionHandler;
2970- }
2971-
2972- /** When called from a class static initializer, maps all native methods
2973- * found within that class to native libraries via the JNA raw calling
2974- * interface.
2975- * @param libName library name to which functions should be bound
2976- */
2977- public static void register(String libName) {
2978- register(getNativeClass(getCallingClass()),
2979- NativeLibrary.getInstance(libName));
2980- }
2981-
2982- /** When called from a class static initializer, maps all native methods
2983- * found within that class to native libraries via the JNA raw calling
2984- * interface.
2985- * @param lib native library to which functions should be bound
2986- */
2987- public static void register(NativeLibrary lib) {
2988- register(getNativeClass(getCallingClass()), lib);
2989- }
2990-
2991- static Class getNativeClass(Class cls) {
2992- Method[] methods = cls.getDeclaredMethods();
2993- for (int i=0;i < methods.length;i++) {
2994- if ((methods[i].getModifiers() & Modifier.NATIVE) != 0) {
2995- return cls;
2996- }
2997- }
2998- int idx = cls.getName().lastIndexOf("$");
2999- if (idx != -1) {
3000- String name = cls.getName().substring(0, idx);
3001- try {
3002- return getNativeClass(Class.forName(name, true, cls.getClassLoader()));
3003- }
3004- catch(ClassNotFoundException e) {
3005- }
3006- }
3007- throw new IllegalArgumentException("Can't determine class with native methods from the current context (" + cls + ")");
3008- }
3009-
3010- static Class getCallingClass() {
3011- Class[] context = new SecurityManager() {
3012- public Class[] getClassContext() {
3013- return super.getClassContext();
3014- }
3015- }.getClassContext();
3016- if (context.length < 4) {
3017- throw new IllegalStateException("This method must be called from the static initializer of a class");
3018- }
3019- return context[3];
3020- }
3021-
3022- private static Map registeredClasses = new HashMap();
3023- private static Map registeredLibraries = new HashMap();
3024- private static Object unloader = new Object() {
3025- protected void finalize() {
3026- synchronized(registeredClasses) {
3027- for (Iterator i=registeredClasses.entrySet().iterator();i.hasNext();) {
3028- Map.Entry e = (Map.Entry)i.next();
3029- unregister((Class)e.getKey(), (long[])e.getValue());
3030- i.remove();
3031- }
3032- }
3033- }
3034- };
3035-
3036- /** Remove all native mappings for the calling class.
3037- Should only be called if the class is no longer referenced and about
3038- to be garbage collected.
3039- */
3040- public static void unregister() {
3041- unregister(getNativeClass(getCallingClass()));
3042- }
3043-
3044- /** Remove all native mappings for the given class.
3045- Should only be called if the class is no longer referenced and about
3046- to be garbage collected.
3047- */
3048- public static void unregister(Class cls) {
3049- synchronized(registeredClasses) {
3050- if (registeredClasses.containsKey(cls)) {
3051- unregister(cls, (long[])registeredClasses.get(cls));
3052- registeredClasses.remove(cls);
3053- registeredLibraries.remove(cls);
3054- }
3055- }
3056- }
3057-
3058- /** Unregister the native methods for the given class. */
3059- private static native void unregister(Class cls, long[] handles);
3060-
3061- private static String getSignature(Class cls) {
3062- if (cls.isArray()) {
3063- return "[" + getSignature(cls.getComponentType());
3064- }
3065- if (cls.isPrimitive()) {
3066- if (cls == void.class) return "V";
3067- if (cls == boolean.class) return "Z";
3068- if (cls == byte.class) return "B";
3069- if (cls == short.class) return "S";
3070- if (cls == char.class) return "C";
3071- if (cls == int.class) return "I";
3072- if (cls == long.class) return "J";
3073- if (cls == float.class) return "F";
3074- if (cls == double.class) return "D";
3075- }
3076- return "L" + cls.getName().replace(".", "/") + ";";
3077- }
3078-
3079- private static final int CVT_UNSUPPORTED = -1;
3080- private static final int CVT_DEFAULT = 0;
3081- private static final int CVT_POINTER = 1;
3082- private static final int CVT_STRING = 2;
3083- private static final int CVT_STRUCTURE = 3;
3084- private static final int CVT_STRUCTURE_BYVAL = 4;
3085- private static final int CVT_BUFFER = 5;
3086- private static final int CVT_ARRAY_BYTE = 6;
3087- private static final int CVT_ARRAY_SHORT = 7;
3088- private static final int CVT_ARRAY_CHAR = 8;
3089- private static final int CVT_ARRAY_INT = 9;
3090- private static final int CVT_ARRAY_LONG = 10;
3091- private static final int CVT_ARRAY_FLOAT = 11;
3092- private static final int CVT_ARRAY_DOUBLE = 12;
3093- private static final int CVT_ARRAY_BOOLEAN = 13;
3094- private static final int CVT_BOOLEAN = 14;
3095- private static final int CVT_CALLBACK = 15;
3096- private static final int CVT_FLOAT = 16;
3097- private static final int CVT_NATIVE_MAPPED = 17;
3098- private static final int CVT_WSTRING = 18;
3099- private static final int CVT_INTEGER_TYPE = 19;
3100- private static final int CVT_POINTER_TYPE = 20;
3101- private static final int CVT_TYPE_MAPPER = 21;
3102-
3103- private static int getConversion(Class type, TypeMapper mapper) {
3104- if (type == Boolean.class) type = boolean.class;
3105- else if (type == Byte.class) type = byte.class;
3106- else if (type == Short.class) type = short.class;
3107- else if (type == Character.class) type = char.class;
3108- else if (type == Integer.class) type = int.class;
3109- else if (type == Long.class) type = long.class;
3110- else if (type == Float.class) type = float.class;
3111- else if (type == Double.class) type = double.class;
3112- else if (type == Void.class) type = void.class;
3113-
3114- if (mapper != null
3115- && (mapper.getFromNativeConverter(type) != null
3116- || mapper.getToNativeConverter(type) != null)) {
3117- return CVT_TYPE_MAPPER;
3118- }
3119-
3120- if (Pointer.class.isAssignableFrom(type)) {
3121- return CVT_POINTER;
3122- }
3123- if (String.class == type) {
3124- return CVT_STRING;
3125- }
3126- if (WString.class.isAssignableFrom(type)) {
3127- return CVT_WSTRING;
3128- }
3129- if (Buffer.class.isAssignableFrom(type)) {
3130- return CVT_BUFFER;
3131- }
3132- if (Structure.class.isAssignableFrom(type)) {
3133- if (Structure.ByValue.class.isAssignableFrom(type)) {
3134- return CVT_STRUCTURE_BYVAL;
3135- }
3136- return CVT_STRUCTURE;
3137- }
3138- if (type.isArray()) {
3139- switch(type.getName().charAt(1)) {
3140- case 'Z': return CVT_ARRAY_BOOLEAN;
3141- case 'B': return CVT_ARRAY_BYTE;
3142- case 'S': return CVT_ARRAY_SHORT;
3143- case 'C': return CVT_ARRAY_CHAR;
3144- case 'I': return CVT_ARRAY_INT;
3145- case 'J': return CVT_ARRAY_LONG;
3146- case 'F': return CVT_ARRAY_FLOAT;
3147- case 'D': return CVT_ARRAY_DOUBLE;
3148- default: break;
3149- }
3150- }
3151- if (type.isPrimitive()) {
3152- return type == boolean.class ? CVT_BOOLEAN : CVT_DEFAULT;
3153- }
3154- if (Callback.class.isAssignableFrom(type)) {
3155- return CVT_CALLBACK;
3156- }
3157- if (IntegerType.class.isAssignableFrom(type)) {
3158- return CVT_INTEGER_TYPE;
3159- }
3160- if (PointerType.class.isAssignableFrom(type)) {
3161- return CVT_POINTER_TYPE;
3162- }
3163- if (NativeMapped.class.isAssignableFrom(type)) {
3164- return CVT_NATIVE_MAPPED;
3165- }
3166- return CVT_UNSUPPORTED;
3167- }
3168-
3169- /** When called from a class static initializer, maps all native methods
3170- * found within that class to native libraries via the JNA raw calling
3171- * interface.
3172- * @param lib library to which functions should be bound
3173- */
3174- // TODO: derive options from annotations (per-class or per-method)
3175- // options: read parameter type mapping (long/native long),
3176- // method name, library name, call conv
3177- public static void register(Class cls, NativeLibrary lib) {
3178- Method[] methods = cls.getDeclaredMethods();
3179- List mlist = new ArrayList();
3180- TypeMapper mapper = (TypeMapper)
3181- lib.getOptions().get(Library.OPTION_TYPE_MAPPER);
3182-
3183- for (int i=0;i < methods.length;i++) {
3184- if ((methods[i].getModifiers() & Modifier.NATIVE) != 0) {
3185- mlist.add(methods[i]);
3186- }
3187- }
3188- long[] handles = new long[mlist.size()];
3189- for (int i=0;i < handles.length;i++) {
3190- Method method = (Method)mlist.get(i);
3191- String sig = "(";
3192- Class rclass = method.getReturnType();
3193- long rtype, closure_rtype;
3194- Class[] ptypes = method.getParameterTypes();
3195- long[] atypes = new long[ptypes.length];
3196- long[] closure_atypes = new long[ptypes.length];
3197- int[] cvt = new int[ptypes.length];
3198- ToNativeConverter[] toNative = new ToNativeConverter[ptypes.length];
3199- FromNativeConverter fromNative = null;
3200- int rcvt = getConversion(rclass, mapper);
3201- boolean throwLastError = false;
3202- switch (rcvt) {
3203- case CVT_UNSUPPORTED:
3204- throw new IllegalArgumentException(rclass + " is not a supported return type (in method " + method.getName() + " in " + cls + ")");
3205- case CVT_TYPE_MAPPER:
3206- fromNative = mapper.getFromNativeConverter(rclass);
3207- closure_rtype = FFIType.get(rclass).peer;
3208- rtype = FFIType.get(fromNative.nativeType()).peer;
3209- break;
3210- case CVT_NATIVE_MAPPED:
3211- case CVT_INTEGER_TYPE:
3212- case CVT_POINTER_TYPE:
3213- closure_rtype = FFIType.get(Pointer.class).peer;
3214- rtype = FFIType.get(NativeMappedConverter.getInstance(rclass).nativeType()).peer;
3215- break;
3216- case CVT_STRUCTURE:
3217- closure_rtype = rtype = FFIType.get(Pointer.class).peer;
3218- break;
3219- case CVT_STRUCTURE_BYVAL:
3220- closure_rtype = FFIType.get(Pointer.class).peer;
3221- rtype = FFIType.get(rclass).peer;
3222- break;
3223- default:
3224- closure_rtype = rtype = FFIType.get(rclass).peer;
3225- break;
3226- }
3227- for (int t=0;t < ptypes.length;t++) {
3228- Class type = ptypes[t];
3229- sig += getSignature(type);
3230- cvt[t] = getConversion(type, mapper);
3231- if (cvt[t] == CVT_UNSUPPORTED) {
3232- throw new IllegalArgumentException(type + " is not a supported argument type (in method " + method.getName() + " in " + cls + ")");
3233- }
3234- if (cvt[t] == CVT_NATIVE_MAPPED
3235- || cvt[t] == CVT_INTEGER_TYPE) {
3236- type = NativeMappedConverter.getInstance(type).nativeType();
3237- }
3238- else if (cvt[t] == CVT_TYPE_MAPPER) {
3239- toNative[t] = mapper.getToNativeConverter(type);
3240- }
3241- // Determine the type that will be passed to the native
3242- // function, as well as the type to be passed
3243- // from Java initially
3244- switch(cvt[t]) {
3245- case CVT_STRUCTURE_BYVAL:
3246- case CVT_INTEGER_TYPE:
3247- case CVT_POINTER_TYPE:
3248- case CVT_NATIVE_MAPPED:
3249- atypes[t] = FFIType.get(type).peer;
3250- closure_atypes[t] = FFIType.get(Pointer.class).peer;
3251- break;
3252- case CVT_TYPE_MAPPER:
3253- if (type.isPrimitive())
3254- closure_atypes[t] = FFIType.get(type).peer;
3255- else
3256- closure_atypes[t] = FFIType.get(Pointer.class).peer;
3257- atypes[t] = FFIType.get(toNative[t].nativeType()).peer;
3258- break;
3259- case CVT_DEFAULT:
3260- closure_atypes[t] = atypes[t] = FFIType.get(type).peer;
3261- break;
3262- default:
3263- closure_atypes[t] = atypes[t] = FFIType.get(Pointer.class).peer;
3264- break;
3265- }
3266- }
3267- sig += ")";
3268- sig += getSignature(rclass);
3269-
3270- Class[] etypes = method.getExceptionTypes();
3271- for (int e=0;e < etypes.length;e++) {
3272- if (LastErrorException.class.isAssignableFrom(etypes[e])) {
3273- throwLastError = true;
3274- break;
3275- }
3276- }
3277-
3278- String name = method.getName();
3279- FunctionMapper fmapper = (FunctionMapper)lib.getOptions().get(Library.OPTION_FUNCTION_MAPPER);
3280- if (fmapper != null) {
3281- name = fmapper.getFunctionName(lib, method);
3282- }
3283- Function f = lib.getFunction(name, method);
3284- try {
3285- handles[i] = registerMethod(cls, method.getName(),
3286- sig, cvt,
3287- closure_atypes, atypes, rcvt,
3288- closure_rtype, rtype,
3289- rclass,
3290- f.peer, f.getCallingConvention(),
3291- throwLastError,
3292- toNative, fromNative);
3293- }
3294- catch(NoSuchMethodError e) {
3295- throw new UnsatisfiedLinkError("No method " + method.getName() + " with signature " + sig + " in " + cls);
3296- }
3297- }
3298- synchronized(registeredClasses) {
3299- registeredClasses.put(cls, handles);
3300- registeredLibraries.put(cls, lib);
3301- }
3302- cacheOptions(cls, lib.getOptions(), null);
3303- }
3304-
3305- /** Take note of options used for a given library mapping, to facilitate
3306- looking them up later.
3307- */
3308- private static void cacheOptions(Class cls, Map libOptions, Object proxy) {
3309- synchronized(libraries) {
3310- if (!libOptions.isEmpty())
3311- options.put(cls, libOptions);
3312- if (libOptions.containsKey(Library.OPTION_TYPE_MAPPER))
3313- typeMappers.put(cls, libOptions.get(Library.OPTION_TYPE_MAPPER));
3314- if (libOptions.containsKey(Library.OPTION_STRUCTURE_ALIGNMENT))
3315- alignments.put(cls, libOptions.get(Library.OPTION_STRUCTURE_ALIGNMENT));
3316- if (proxy != null) {
3317- libraries.put(cls, new WeakReference(proxy));
3318- }
3319-
3320- // If it's a direct mapping, AND implements a Library interface,
3321- // cache the library interface as well, so that any nested
3322- // classes get the appropriate associated options
3323- if (!cls.isInterface()
3324- && Library.class.isAssignableFrom(cls)) {
3325- Class ifaces[] = cls.getInterfaces();
3326- for (int i=0;i < ifaces.length;i++) {
3327- if (Library.class.isAssignableFrom(ifaces[i])) {
3328- cacheOptions(ifaces[i], libOptions, proxy);
3329- break;
3330- }
3331- }
3332- }
3333- }
3334- }
3335-
3336- private static native long registerMethod(Class cls,
3337- String name,
3338- String signature,
3339- int[] conversions,
3340- long[] closure_arg_types,
3341- long[] arg_types,
3342- int rconversion,
3343- long closure_rtype,
3344- long rtype,
3345- Class rclass,
3346- long fptr,
3347- int callingConvention,
3348- boolean throwLastError,
3349- ToNativeConverter[] toNative,
3350- FromNativeConverter fromNative);
3351-
3352-
3353- // Called from native code
3354- private static NativeMapped fromNative(Class cls, Object value) {
3355- // NOTE: technically should be either CallbackParameterContext or
3356- // FunctionResultContext
3357- return (NativeMapped)NativeMappedConverter.getInstance(cls).fromNative(value, new FromNativeContext(cls));
3358- }
3359- // Called from native code
3360- private static Class nativeType(Class cls) {
3361- return NativeMappedConverter.getInstance(cls).nativeType();
3362- }
3363- // Called from native code
3364- private static Object toNative(ToNativeConverter cvt, Object o) {
3365- // NOTE: technically should be either CallbackResultContext or
3366- // FunctionParameterContext
3367- return cvt.toNative(o, new ToNativeContext());
3368- }
3369- // Called from native code
3370- private static Object fromNative(FromNativeConverter cvt, Object o, Class cls) {
3371- // NOTE: technically should be FunctionResultContext
3372- return cvt.fromNative(o, new FromNativeContext(cls));
3373- }
3374-
3375- public static native long ffi_prep_cif(int abi, int nargs, long ffi_return_type, long ffi_types);
3376- public static native void ffi_call(long cif, long fptr, long resp, long args);
3377- public static native long ffi_prep_closure(long cif, ffi_callback cb);
3378- public static native void ffi_free_closure(long closure);
3379-
3380- /** Returns the size (calculated by libffi) of the given type. */
3381- static native int initialize_ffi_type(long type_info);
3382-
3383- public interface ffi_callback {
3384- void invoke(long cif, long resp, long argp);
3385- }
3386-
3387- /** Prints JNA library details to the console. */
3388- public static void main(String[] args) {
3389- final String DEFAULT_TITLE = "Java Native Access (JNA)";
3390- final String DEFAULT_VERSION = VERSION;
3391- final String DEFAULT_BUILD = VERSION + " (package information missing)";
3392- Package pkg = Native.class.getPackage();
3393- String title = pkg.getSpecificationTitle();
3394- if (title == null) title = DEFAULT_TITLE;
3395- String version = pkg.getSpecificationVersion();
3396- if (version == null) version = DEFAULT_VERSION;
3397- title += " API Version " + version;
3398- System.out.println(title);
3399- version = pkg.getImplementationVersion();
3400- if (version == null) version = DEFAULT_BUILD;
3401- System.out.println("Version: " + version);
3402- System.out.println(" Native: " + getNativeVersion() + " ("
3403- + getAPIChecksum() + ")");
3404- System.exit(0);
3405- }
3406-}
3407
3408=== removed directory '.pc/05-support-gnu-kfreebsd.patch'
3409=== removed file '.pc/05-support-gnu-kfreebsd.patch/build.xml'
3410--- .pc/05-support-gnu-kfreebsd.patch/build.xml 2010-05-26 00:14:07 +0000
3411+++ .pc/05-support-gnu-kfreebsd.patch/build.xml 1970-01-01 00:00:00 +0000
3412@@ -1,647 +0,0 @@
3413-<?xml version="1.0" encoding="UTF-8"?>
3414-<project name="JNA" default="default" basedir=".">
3415- <description>Builds and tests JNA</description>
3416-
3417- <!--
3418- Conventions (since ant can't easily specify arbitrary file dependencies):
3419- The uptodate property for a given target TARGET is "-TARGET"; the actual
3420- target to generate the uptodate property is named ":TARGET".
3421-
3422- Properties (except for uptodate properties) separate words by dots, targets
3423- by dashes.
3424- -->
3425-
3426- <!-- global properties -->
3427- <!-- (all build-related props should go in -dynamic-properties) -->
3428- <property name="name" value="jna"/>
3429- <property name="jar" value="${name}.jar"/>
3430- <property name="testjar" value="${name}-test.jar"/>
3431- <property name="debug" value="true"/>
3432- <property name="debug.native" value="false"/>
3433- <property name="cflags_extra.native" value=""/>
3434- <property name="dynlink.native" value="false"/>
3435- <property name="native" location="native"/>
3436- <property name="src" location="src"/>
3437- <property name="dist" location="dist"/>
3438- <property name="test.src" location="test"/>
3439- <property name="doc" location="doc"/>
3440- <property name="javadoc" location="${doc}/javadoc"/>
3441- <property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
3442- <property name="vendor" value="JNA Development Team"/>
3443- <property name="copyright"
3444- value="Copyright &amp;copy; 2007-2009 Timothy Wall. All Rights Reserved."/>
3445- <buildnumber/>
3446- <!-- JNA library release version -->
3447- <property name="jna.major" value="3"/>
3448- <property name="jna.minor" value="2"/>
3449- <property name="jna.revision" value="4"/>
3450- <property name="jna.build" value="${build.number}"/>
3451- <property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
3452- <!-- jnidispatch library release version -->
3453- <property name="jni.major" value="3"/>
3454- <property name="jni.minor" value="2"/>
3455- <property name="jni.revision" value="1"/>
3456- <property name="jni.build" value="${build.number}"/>
3457- <property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
3458- <property name="jni.md5" value="c870290c36c8d3fdf85db7c782febc3f"/>
3459- <property name="spec.title" value="Java Native Access (JNA)"/>
3460- <property name="spec.vendor" value="${vendor}"/>
3461- <property name="spec.version" value="${jna.major}"/>
3462- <property name="impl.title" value="com.sun.jna"/>
3463- <property name="impl.vendor" value="${spec.vendor}"/>
3464- <property name="impl.version" value="${jna.version} (b${jna.build})"/>
3465-
3466- <property name="compatibility" value="1.4"/>
3467- <property name="test.compatibility" value="1.5"/>
3468-
3469- <!-- Miscellaneous -->
3470- <property name="build.compiler.emacs" value="true"/>
3471-
3472- <target name="default" depends="test" description="Build and Test."/>
3473-
3474- <target name="init" depends="-setup"/>
3475- <target name="compile-test-single" depends="compile-tests"/>
3476- <target name="compile-single" depends="compile"/>
3477-
3478- <target name="-dynamic-properties">
3479- <echo>Java version ${java.version}, compatibility: ${compatibility}</echo>
3480- <echo>JNA version ${jna.version}, native ${jni.version}</echo>
3481- <echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
3482- <echo>java.home=${java.home}</echo>
3483- <echo>java.library.path=${java.library.path}</echo>
3484-
3485- <replaceregexp match="(&lt;version&gt;).*(&lt;/version&gt;)"
3486- replace="\1${jna.version}\2"
3487- file="pom.xml"/>
3488- <replaceregexp match='VERSION = ".*";'
3489- replace='VERSION = "${jna.version}";'
3490- file="src/com/sun/jna/Native.java"/>
3491-
3492- <condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
3493- <isset property="omit-jnilib"/>
3494- </condition>
3495- <condition property="vm.arch" value="-d64" else="">
3496- <or>
3497- <equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
3498- <equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
3499- <os arch="x86_64"/>
3500- <os arch="ppc64"/>
3501- <os arch="sparcv9"/>
3502- <os arch="amd64"/>
3503- </or>
3504- </condition>
3505- <condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
3506- <and>
3507- <os name="SunOS"/>
3508- <equals arg1="${vm.arch}" arg2="-d64"/>
3509- </and>
3510- </condition>
3511- <property name="build" value="build"/>
3512- <property name="classes" location="${build}/classes"/>
3513- <property name="eclipse.classes" location="build.eclipse/classes"/>
3514- <property name="test.classes" location="${build}/test-classes"/>
3515- <property name="reports" value="${build}/reports"/>
3516-
3517- <!-- Add other supported platforms here -->
3518- <condition property="jre.arch" value="i386">
3519- <equals arg1="x86" arg2="${os.arch}"/>
3520- </condition>
3521- <condition property="jre.arch" value="amd64">
3522- <equals arg1="x86_64" arg2="${os.arch}"/>
3523- </condition>
3524- <property name="jre.arch" value="${os.arch}"/>
3525- <condition property="os.prefix" value="linux-${jre.arch}">
3526- <os name="Linux"/>
3527- </condition>
3528- <condition property="os.prefix" value="win32-${os.arch}">
3529- <os family="windows"/>
3530- </condition>
3531- <!-- Darwin builds are universal, no arch required -->
3532- <condition property="os.prefix" value="darwin">
3533- <os family="mac"/>
3534- </condition>
3535- <condition property="os.prefix" value="sunos-${os.arch}">
3536- <os name="SunOS"/>
3537- </condition>
3538- <condition property="os.prefix" value="freebsd-${os.arch}">
3539- <os name="FreeBSD"/>
3540- </condition>
3541- <condition property="os.prefix" value="openbsd-${os.arch}">
3542- <os name="OpenBSD"/>
3543- </condition>
3544- <fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
3545- <condition property="jdk.home" value="${java.home}">
3546- <available file="${java.home}/include"/>
3547- </condition>
3548- <condition property="jdk.home" value="${java.home}/..">
3549- <available file="${java.home}/../include"/>
3550- </condition>
3551- <fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
3552- <condition property="libjsig"
3553- value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
3554- <available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
3555- </condition>
3556- <property name="native.jar" value="${os.prefix}.jar"/>
3557- <property name="build.native" location="${build}/native"/>
3558- <property name="md5.file" location="${build.native}/sig"/>
3559-
3560- <mkdir dir="${build}"/>
3561- <mkdir dir="${build.native}"/>
3562- <mkdir dir="${classes}"/>
3563- <mkdir dir="${test.classes}"/>
3564- <mkdir dir="${reports}"/>
3565- <mkdir dir="${doc}"/>
3566-
3567- </target>
3568-
3569- <target name="-setup" depends="-dynamic-properties">
3570- <path id="compile-test.path">
3571- <pathelement path="${test.src}"/>
3572- <path id="test.libs">
3573- <fileset dir="lib">
3574- <include name="junit.jar"/>
3575- </fileset>
3576- <pathelement path="${classes}"/>
3577- </path>
3578- <path id="compile.path">
3579- <path id="src.path">
3580- <pathelement location="${src}"/>
3581- </path>
3582- </path>
3583- </path>
3584-
3585- <path id="test.runpath">
3586- <pathelement path="${build}/${jar}"/>
3587- <pathelement path="${build}/examples.jar"/>
3588- <pathelement path="${test.classes}"/>
3589- <pathelement path="lib/clover.jar"/>
3590- <path refid="test.libs"/>
3591- </path>
3592- </target>
3593-
3594- <target name="compile" depends="-setup"
3595- description="Compile all Java source">
3596- <javac classpathref="compile.path"
3597- source="${compatibility}"
3598- target="${compatibility}"
3599- destdir="${classes}"
3600- deprecation="on" debug="${debug}">
3601- <src path="${src}"/>
3602- </javac>
3603- </target>
3604-
3605- <target name=":jar">
3606- <uptodate property="-jar" targetfile="${build}/${jar}">
3607- <srcfiles dir="${classes}">
3608- <patternset id="jar-compiled">
3609- <include name="com/sun/jna/*"/>
3610- <include name="com/sun/jna/**/*"/>
3611- <exclude name="com/sun/jna/examples/*"/>
3612- <exclude name="com/sun/jna/examples/**/*"/>
3613- </patternset>
3614- </srcfiles>
3615- </uptodate>
3616- </target>
3617- <target name="jar" depends="-setup,native,:jar" unless="-jar"
3618- description="Build primary jar">
3619- <jar jarfile="${build}/${jar}">
3620- <manifest>
3621- <attribute name="Main-Class" value="com.sun.jna.Native"/>
3622- <section name="com/sun/jna/">
3623- <attribute name="Implementation-Title" value="${impl.title}"/>
3624- <attribute name="Implementation-Vendor" value="${vendor}"/>
3625- <attribute name="Implementation-Version" value="${impl.version}"/>
3626- <attribute name="Specification-Title" value="${spec.title}"/>
3627- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
3628- <attribute name="Specification-Version" value="${spec.version}"/>
3629- </section>
3630- </manifest>
3631- <fileset dir="${classes}" excludes="${jar.omitted}">
3632- <patternset refid="jar-compiled"/>
3633- </fileset>
3634- </jar>
3635- </target>
3636- <target name="examples" depends="jar,native">
3637- <jar jarfile="${build}/examples.jar">
3638- <manifest>
3639- <attribute name="Class-Path" value="jna.jar"/>
3640- <attribute name="Main-Class" value="com.sun.jna.examples.ShapedWindowDemo"/>
3641- </manifest>
3642- <fileset dir="${src}" includes="**/examples/**/*.png"/>
3643- <fileset dir="${classes}" includes="**/examples/*,**/examples/**/*"/>
3644- <fileset dir="${classes}" includes="jnidispatch.dll"/>
3645- </jar>
3646- </target>
3647-
3648- <target name="javah" depends="compile">
3649- <javah classpath="${classes}" destdir="${build.native}" force="yes">
3650- <class name="com.sun.jna.Function"/>
3651- <class name="com.sun.jna.Pointer"/>
3652- <class name="com.sun.jna.Memory"/>
3653- <class name="com.sun.jna.Native"/>
3654- <class name="com.sun.jna.NativeLibrary"/>
3655- <class name="com.sun.jna.CallbackReference"/>
3656- </javah>
3657- <condition property="grep" value="/usr/sfw/bin/ggrep">
3658- <os name="SunOS"/>
3659- </condition>
3660- <condition property="grep" value="ggrep">
3661- <os name="OpenBSD"/>
3662- </condition>
3663- <property name="grep" value="grep"/>
3664- <apply dir="${build.native}" executable="${grep}" parallel="true"
3665- failonerror="true" relative="true" output="${md5.file}">
3666- <arg value="-A"/>
3667- <arg value="1"/>
3668- <arg value="JNIEXPORT"/>
3669- <fileset dir="${build.native}" includes="*.h"/>
3670- </apply>
3671- <fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
3672- <checksum property="md5" file="${md5.file}" />
3673- <condition property="jni.valid" value="true">
3674- <or>
3675- <equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
3676- <equals arg1="${jni.md5}" arg2=""/>
3677- </or>
3678- </condition>
3679- </target>
3680-
3681- <!-- Invalidate native libraries when native API changes -->
3682- <target name="-native-api-check" depends="javah" unless="jni.valid">
3683- <echo>Invalidating native code, new checksum is ${md5}</echo>
3684- <copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
3685- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
3686- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
3687- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
3688- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
3689- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
3690- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
3691- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
3692- <copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
3693- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
3694- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
3695- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
3696- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparcv9.jar" overwrite="true"/>
3697- <delete failOnError="false" includeEmptyDirs="true">
3698- <fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
3699- </delete>
3700- <fail>API for native code has changed. Re-run this build after updating jni.version and jni.md5 in build.xml</fail>
3701- </target>
3702-
3703- <target name=":rsrc">
3704- <condition property="-rsrc">
3705- <not><os family="windows"/></not>
3706- </condition>
3707- </target>
3708- <target name="rsrc" depends="-setup,:rsrc" unless="-rsrc"
3709- description="Generate w32 DLL version resource information">
3710- <property name="rsrc" location="${build.native}/jnidispatch.rc"/>
3711- <copy todir="${build.native}" file="${native}/jnidispatch.rc"/>
3712- <replaceregexp match="FILEVERSION.*"
3713- replace="FILEVERSION ${jni.major},${jni.minor},${jni.revision},${jni.build}"
3714- file="${rsrc}" byline="true"/>
3715- <replaceregexp match="PRODUCTVERSION.*"
3716- replace="PRODUCTVERSION ${jna.major},${jna.minor},${jna.revision},${jna.build}"
3717- file="${rsrc}" byline="true"/>
3718- <replaceregexp match="FileVersion.*"
3719- replace="FileVersion&quot;,&quot;${jni.version}&quot;"
3720- file="${rsrc}" byline="true"/>
3721- <replaceregexp match="Full Version.*"
3722- replace="Full Version&quot;,&quot;${jni.version} b${jni.build}&quot;"
3723- file="${rsrc}" byline="true"/>
3724- <replaceregexp match="ProductVersion.*"
3725- replace="ProductVersion&quot;,&quot;${spec.version}&quot;"
3726- file="${rsrc}" byline="true"/>
3727- </target>
3728-
3729- <target name="native" depends="-setup,javah,-native-api-check,rsrc"
3730- description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
3731- <property name="comment" value="# auto-generated by ant"/>
3732- <replaceregexp match="^VERSION=.*"
3733- replace="VERSION=${jni.version} ${comment}"
3734- file="native/Makefile" byline="true"/>
3735- <replaceregexp match="^CHECKSUM=.*"
3736- replace="CHECKSUM=${jni.md5} ${comment}"
3737- file="native/Makefile" byline="true"/>
3738- <!-- ensure ARCH is set properly for 64-bit capable platforms -->
3739- <!-- use ANT_OPTS=-d64 to build 64-bit if not the platform default -->
3740- <property name="ARCH" value="${os.arch}"/>
3741- <condition property="make.CC" value="CC=${CC}" else="IGNORE=">
3742- <isset property="CC"/>
3743- </condition>
3744- <condition property="make.ARCH" value="ARCH=${ARCH}" else="IGNORE=">
3745- <isset property="ARCH"/>
3746- </condition>
3747- <condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
3748- <isset property="SDKROOT"/>
3749- </condition>
3750- <condition property="make.SDKROOT"
3751- value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
3752- <available file="/Developer/SDKs/MacOSX10.5.sdk"/>
3753- </condition>
3754- <condition property="make.SDKROOT"
3755- value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
3756- <available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
3757- </condition>
3758- <!-- Windows' drive letters and spaces in absolute paths wreak havoc on
3759- make -->
3760- <condition property="make.BUILD" value="BUILD=../${build}/native" else="BUILD=${build.native}">
3761- <os family="windows"/>
3762- </condition>
3763- <condition property="make.PATH" value="PATH=/usr/sfw/bin:/usr/bin:/usr/ccs/bin" else="IGNORE=">
3764- <os name="SunOS"/>
3765- </condition>
3766- <condition property="make" value="/usr/sfw/bin/gmake">
3767- <os name="SunOS"/>
3768- </condition>
3769- <condition property="make" value="gmake">
3770- <or>
3771- <os name="FreeBSD"/>
3772- <os name="OpenBSD"/>
3773- </or>
3774- </condition>
3775- <!-- Default make program -->
3776- <property name="make" value="make"/>
3777-
3778- <exec executable="${make}" dir="${native}" failonerror="true">
3779- <arg value="JAVA_HOME=${jdk.home}"/>
3780- <arg value="JAVAH=${build.native}"/>
3781- <arg value="DEBUG=${debug.native}"/>
3782- <arg value="CFLAGS_EXTRA=${cflags_extra.native}"/>
3783- <arg value="DYNAMIC_LIBFFI=${dynlink.native}"/>
3784- <arg value="${make.CC}"/>
3785- <arg value="${make.BUILD}"/>
3786- <arg value="${make.SDKROOT}"/>
3787- <arg value="${make.ARCH}"/>
3788- <arg value="${make.PATH}"/>
3789- <arg value="VERSION=${jni.version}"/>
3790- <arg value="CHECKSUM=${jni.md5}"/>
3791- </exec>
3792- <antcall target="native-mixedjar"/>
3793- <!-- For web start, native libraries may be provided in the root of -->
3794- <!-- an included jar file -->
3795- <jar jarfile="${build}/${native.jar}">
3796- <fileset dir="${build.native}" includes="jnidispatch.dll,libjnidispatch.*"/>
3797- <manifest>
3798- <attribute name="Implementation-Version" value="${jni.version} b${jni.build}"/>
3799- <attribute name="Specification-Version" value="${jni.version}"/>
3800- </manifest>
3801- </jar>
3802- </target>
3803-
3804- <target name="native-mixedjar" unless="nomixedjar.native">
3805- <mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
3806- <copy todir="${classes}/com/sun/jna/${os.prefix}">
3807- <fileset dir="${build.native}"
3808- includes="jnidispatch.dll,libjnidispatch.*"/>
3809- </copy>
3810- <mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
3811- <copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
3812- failonerror="false">
3813- <fileset dir="${build.native}"
3814- includes="jnidispatch.dll,libjnidispatch.*"/>
3815- </copy>
3816- </target>
3817-
3818- <target name="compile-tests" depends="compile,native,jar"
3819- description="Compile all test code">
3820- <javac classpathref="compile-test.path"
3821- source="${test.compatibility}"
3822- target="${test.compatibility}"
3823- destdir="${test.classes}"
3824- deprecation="on" debug="${debug}">
3825- <src path="${test.src}"/>
3826- </javac>
3827- <jar jarfile="${build}/${testjar}">
3828- <fileset dir="${test.classes}">
3829- <patternset refid="jar-compiled"/>
3830- </fileset>
3831- </jar>
3832- <mkdir dir="${build}/jws"/>
3833- <copy todir="${build}/jws" file="${build}/${jar}"/>
3834- <copy todir="${build}/jws" file="${build}/${testjar}"/>
3835- <copy todir="${build}/jws" file="lib/junit.jar"/>
3836- <copy todir="${build}/jws" file="lib/clover.jar"/>
3837- <jar jarfile="${build}/jws/jnidispatch.jar">
3838- <fileset dir="${build.native}" includes="*jnidispatch.*"/>
3839- </jar>
3840- <signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
3841- <fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
3842- </signjar>
3843- </target>
3844-
3845- <!-- When running tests from an IDE, be sure to set jna.library.path -->
3846- <!-- to where the test library (testlib) is found. -->
3847- <target name="test" depends="jar,examples,compile-tests"
3848- description="Run all unit tests">
3849- <property name="test.fork" value="yes"/>
3850- <property name="reports.junit" location="${reports}/junit"/>
3851- <property name="results.junit" location="${build}/junit-results"/>
3852- <mkdir dir="${results.junit}"/>
3853- <echo>Saving test results in ${results.junit}</echo>
3854- <property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
3855- <condition property="tests.platform" value="**/win32/*Test.java">
3856- <os family="windows"/>
3857- </condition>
3858- <condition property="tests.exclude" value="**/win32/*StdCallTest.java">
3859- <and><os family="windows"/><not><os arch="x86"/></not></and>
3860- </condition>
3861- <condition property="tests.platform" value="**/unix/*Test.java">
3862- <and>
3863- <os family="unix"/>
3864- <not><os family="mac"/></not>
3865- </and>
3866- </condition>
3867- <condition property="vmopt.arch" value="-d64" else="-Dignore">
3868- <and>
3869- <!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
3870- <not><os family="windows"/></not>
3871- <equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
3872- </and>
3873- </condition>
3874- <property name="tests.platform" value=""/>
3875- <property name="tests.exclude" value=""/>
3876- <junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
3877- <!-- avoid VM conflicts with JNA protected mode -->
3878- <env key="${ld.preload}" file="${libjsig}"/>
3879- <jvmarg value="-Djna.library.path=${build.native}"/>
3880- <!-- Avoid VM crashes, if possible -->
3881- <jvmarg value="-Djna.protected=true"/>
3882- <jvmarg value="-Djna.builddir=${build}"/>
3883- <jvmarg value="${vmopt.arch}"/>
3884- <classpath><path refid="test.runpath"/></classpath>
3885- <formatter type="xml"/>
3886- <batchtest todir="${results.junit}">
3887- <fileset dir="${test.src}">
3888- <include name="com/sun/jna/*Test.java"/>
3889- <include name="com/sun/jna/examples/*Test.java"/>
3890- <include name="${tests.platform}"/>
3891- <exclude name="${tests.exclude}"/>
3892- </fileset>
3893- </batchtest>
3894- </junit>
3895- <junitreport todir="${results.junit}">
3896- <fileset dir="${results.junit}">
3897- <include name="TEST-*.xml"/>
3898- </fileset>
3899- <report todir="${reports.junit}"/>
3900- </junitreport>
3901- <echo>View test report in file://${reports.junit}/index.html</echo>
3902- <fail if="testfailure" unless="clover">One or more tests failed</fail>
3903- </target>
3904-
3905- <target name="with.clover" description="Enable code coverage for tests">
3906- <taskdef resource="cloverlib.xml" classpath="lib/clover.jar"/>
3907- <property name="clover" value="true"/>
3908- <property name="build" value="build.clover"/>
3909- <clover-setup/>
3910- </target>
3911-
3912- <target name="clover" depends="with.clover,test"
3913- description="Generate test code coverage reports">
3914- <property name="reports.clover" value="${reports}/clover"/>
3915- <mkdir dir="${reports.clover}"/>
3916- <clover-report>
3917- <current outfile="${reports.clover}" title="clover">
3918- <fileset dir="." includes="**/*.java" excludes="**/examples/**/*.java"/>
3919- <testresults dir="${results.junit}" includes="TEST-*.xml"/>
3920- <format type="html"/>
3921- </current>
3922- </clover-report>
3923- <echo>Reports generated in ${reports.clover}</echo>
3924- </target>
3925-
3926- <target name="javadoc" depends="-setup">
3927- <property name="header"
3928- value="&lt;b&gt;JNA API&lt;/&gt;&lt;font size=&quot;-1&quot;&gt; ${jna.version}&lt;/font&gt;"/>
3929- <property name="footer"
3930- value="&lt;center&gt;&lt;i&gt;${copyright}&lt;/i&gt;&lt;/center&gt;"/>
3931-
3932- <mkdir dir="${javadoc}"/>
3933- <javadoc package="true"
3934- windowtitle="JNA API"
3935- sourcepathref="src.path"
3936- classpathref="compile.path"
3937- maxmemory="256m"
3938- packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.examples,com.sun.jna.examples.win32,com.sun.jna.exmaples.unix"
3939- overview="${src}/com/sun/jna/overview.html"
3940- destdir="${javadoc}">
3941- <!-- stylesheetfile="${stylesheet}" -->
3942- <doctitle>JNA API Documentation</doctitle>
3943- <header>${header}</header>
3944- <bottom>${footer}</bottom>
3945- <link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
3946-
3947- <packageset dir="${src}" defaultexcludes="yes">
3948- <patternset>
3949- <include name="com/sun/jna/**/*"/>
3950- </patternset>
3951- </packageset>
3952-
3953- <group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
3954- <group title="Examples" packages="com.sun.jna.examples,com.sun.jna.examples.dnd"/>
3955- <group title="Unix Examples" packages="com.sun.jna.examples.unix"/>
3956- <group title="Windows Examples" packages="com.sun.jna.examples.win32"/>
3957-
3958- <arg value="-notimestamp"/>
3959- </javadoc>
3960- </target>
3961-
3962- <target name="dist" depends="jar,compile-tests,native,examples,javadoc"
3963- description="Build distribution files">
3964- <jar jarfile="${dist}/jna.jar" duplicate="preserve">
3965- <manifest>
3966- <attribute name="Main-Class" value="com.sun.jna.Native"/>
3967- <section name="com/sun/jna/">
3968- <attribute name="Implementation-Title" value="${impl.title}"/>
3969- <attribute name="Implementation-Vendor" value="${vendor}"/>
3970- <attribute name="Implementation-Version" value="${impl.version}"/>
3971- <attribute name="Specification-Title" value="${spec.title}"/>
3972- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
3973- <attribute name="Specification-Version" value="${spec.version}"/>
3974- </section>
3975- </manifest>
3976- <zipfileset src="${build}/${jar}"/>
3977- <zipfileset src="${dist}/win32-x86.jar"
3978- includes="*jnidispatch*"
3979- prefix="com/sun/jna/win32-x86"/>
3980- <zipfileset src="${dist}/darwin.jar"
3981- includes="*jnidispatch*"
3982- prefix="com/sun/jna/darwin"/>
3983- <zipfileset src="${dist}/linux-i386.jar"
3984- includes="*jnidispatch*"
3985- prefix="com/sun/jna/linux-i386"/>
3986- <zipfileset src="${dist}/linux-amd64.jar"
3987- includes="*jnidispatch*"
3988- prefix="com/sun/jna/linux-amd64"/>
3989- <zipfileset src="${dist}/linux-ia64.jar"
3990- includes="*jnidispatch*"
3991- prefix="com/sun/jna/linux-ia64"/>
3992- <zipfileset src="${dist}/sunos-x86.jar"
3993- includes="*jnidispatch*"
3994- prefix="com/sun/jna/sunos-x86"/>
3995- <zipfileset src="${dist}/sunos-amd64.jar"
3996- includes="*jnidispatch*"
3997- prefix="com/sun/jna/sunos-amd64"/>
3998- <zipfileset src="${dist}/sunos-sparc.jar"
3999- includes="*jnidispatch*"
4000- prefix="com/sun/jna/sunos-sparc"/>
4001- <zipfileset src="${dist}/sunos-sparcv9.jar"
4002- includes="*jnidispatch*"
4003- prefix="com/sun/jna/sunos-sparcv9"/>
4004- <zipfileset src="${dist}/freebsd-i386.jar"
4005- includes="*jnidispatch*"
4006- prefix="com/sun/jna/freebsd-i386"/>
4007- <zipfileset src="${dist}/freebsd-amd64.jar"
4008- includes="*jnidispatch*"
4009- prefix="com/sun/jna/freebsd-amd64"/>
4010- <zipfileset src="${dist}/openbsd-i386.jar"
4011- includes="*jnidispatch*"
4012- prefix="com/sun/jna/openbsd-i386"/>
4013- <zipfileset src="${dist}/win32-amd64.jar"
4014- includes="*jnidispatch*"
4015- prefix="com/sun/jna/win32-amd64"/>
4016- </jar>
4017- <copy todir="${dist}">
4018- <fileset dir="${build}">
4019- <include name="${native.jar}"/>
4020- <include name="examples.jar"/>
4021- </fileset>
4022- </copy>
4023- <zip zipfile="${dist}/doc.zip">
4024- <zipfileset dir="${javadoc}" prefix="javadoc"/>
4025- </zip>
4026- <!-- JNA sources only, for use in Linux build from source/shared libffi -->
4027- <zip zipfile="${dist}/src.zip">
4028- <zipfileset dir="." includes="build.xml,LICENSE.txt"/>
4029- <zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
4030- <zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
4031- <zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
4032- </zip>
4033- <!-- Full sources required to build and test everything -->
4034- <zip zipfile="${dist}/src-full.zip">
4035- <zipfileset src="${dist}/src.zip"/>
4036- <zipfileset dir="lib" includes="junit.jar,clover.jar" prefix="lib"/>
4037- <zipfileset dir="." includes=".classpath,.project"/>
4038- <zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
4039- </zip>
4040- <!-- Sources package as required by maven -->
4041- <zip zipfile="${dist}/src-mvn.zip">
4042- <zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
4043- </zip>
4044- </target>
4045-
4046- <target name="clean" depends="-dynamic-properties">
4047- <delete failOnError="false" includeEmptyDirs="true">
4048- <fileset dir="${build}"/>
4049- </delete>
4050- <delete quiet="true" includeEmptyDirs="true">
4051- <fileset dir=".clover"/>
4052- <fileset dir="${javadoc}"/>
4053- <fileset dir="." includes="*~,**/*~"/>
4054- </delete>
4055- </target>
4056-
4057-</project>
4058-
4059-
4060
4061=== removed directory '.pc/05-support-gnu-kfreebsd.patch/native'
4062=== removed file '.pc/05-support-gnu-kfreebsd.patch/native/Makefile'
4063--- .pc/05-support-gnu-kfreebsd.patch/native/Makefile 2010-05-26 00:14:07 +0000
4064+++ .pc/05-support-gnu-kfreebsd.patch/native/Makefile 1970-01-01 00:00:00 +0000
4065@@ -1,275 +0,0 @@
4066-#
4067-# Makefile for JNA native bits
4068-# Copyright (c) 2007 Timothy Wall All Rights Reserved
4069-#
4070-# You may need to run 'ant javah' at the root before performing a build from
4071-# this directory.
4072-#
4073-# To build with debug information, use 'make DEBUG=true'
4074-#
4075-# Supported platforms (built and tested):
4076-#
4077-# Windows 2000/XP/2003/Vista (x86)
4078-# Darwin/OS X (i386/x86_64/ppc)
4079-# Linux (i386/amd64)
4080-# Solaris (i386/amd64/sparc/sparcv9)
4081-# FreeBSD (i386/amd64)
4082-#
4083-
4084-# Systems which support POSIX signals may be able to support VM crash
4085-# protection simply by defining HAVE_PROTECTION. This has been enabled
4086-# only for those platforms on which it has been tested successfully.
4087-
4088-OS=$(shell uname | sed -e 's/\(CYGWIN\|MINGW32\).*/win32/g' \
4089- -e 's/SunOS.*/solaris/g' \
4090- -e 's/FreeBSD.*/freebsd/g' \
4091- -e 's/OpenBSD.*/openbsd/g' \
4092- -e 's/Darwin.*/darwin/g' \
4093- -e 's/Linux.*/linux/g')
4094-
4095-VERSION=3.2.1 # auto-generated by ant
4096-CHECKSUM=c870290c36c8d3fdf85db7c782febc3f # auto-generated by ant
4097-
4098-JAVA_INCLUDES=-I"$(JAVA_HOME)/include" \
4099- -I"$(JAVA_HOME)/include/$(OS)"
4100-
4101-BUILD=../build/native
4102-JAVAH=$(BUILD)
4103-INSTALLDIR=../build/$(OS)
4104-JNIDISPATCH_OBJS=$(BUILD)/dispatch.o $(BUILD)/callback.o $(EXTRAOBJS)
4105-RSRC=$(BUILD)/rsrc.o
4106-ifneq ($(DYNAMIC_LIBFFI),true)
4107-FFI_SRC=$(shell pwd)/libffi
4108-FFI_BUILD=$(BUILD)/libffi
4109-FFI_LIB=$(FFI_BUILD)/.libs/libffi$(ARSFX)
4110-FFI_ENV=CC="$(CC)" CFLAGS="$(COPT) $(CDEBUG)" CPPFLAGS="$(CDEFINES)"
4111-FFI_CONFIG=--enable-static --disable-shared --with-pic=yes
4112-endif
4113-LIBRARY=$(BUILD)/$(LIBPFX)jnidispatch$(JNISFX)
4114-TESTLIB=$(BUILD)/$(LIBPFX)testlib$(LIBSFX)
4115-TESTLIB2=$(BUILD)/$(LIBPFX)testlib2$(LIBSFX)
4116-
4117-# Reasonable defaults based on GCC
4118-LIBPFX=lib
4119-LIBSFX=.so
4120-ARSFX=.a
4121-JNISFX=$(LIBSFX)
4122-CC=gcc
4123-LD=gcc
4124-LIBS=
4125-# Default to Sun recommendations for JNI compilation
4126-COPT=-O2 -fno-omit-frame-pointer -fno-strict-aliasing
4127-CASM=-S
4128-ifeq ($(DEBUG),true)
4129-CDEBUG=-g
4130-endif
4131-CFLAGS_EXTRA=
4132-COUT=-o $@
4133-CINCLUDES=$(JAVA_INCLUDES) -I"$(JAVAH)" -I$(FFI_BUILD)/include
4134-CDEFINES=-D_REENTRANT
4135-PCFLAGS=-W -Wall -Wno-unused -Wno-parentheses
4136-CFLAGS=$(PCFLAGS) $(CFLAGS_EXTRA) $(COPT) $(CDEBUG) $(CDEFINES) $(CINCLUDES) \
4137- -DVERSION='"$(VERSION)"' -DCHECKSUM='"$(CHECKSUM)"'
4138-LDFLAGS=-o $@ -shared
4139-ifeq ($(DYNAMIC_LIBFFI),true)
4140-CFLAGS += $(shell pkg-config --cflags libffi 2>/dev/null || echo)
4141-LIBS += $(shell pkg-config --libs libffi 2>/dev/null || echo -lffi)
4142-else
4143-# -static-libgcc avoids gcc library incompatibilities across linux systems
4144-LDFLAGS += -static-libgcc
4145-endif
4146-# Avoid bug in X11-based 1.5/1.6 VMs; dynamically load instead of linking
4147-# See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6539705
4148-#LIBS=-L"$(LIBDIR)" -ljawt
4149-STRIP=strip -x
4150-# end defaults
4151-
4152-ifeq ($(OS),win32)
4153-ARCH=$(shell uname -m | sed 's/i.86/i386/g')
4154-CDEFINES=-DHAVE_PROTECTION -DPSAPI_VERSION=1
4155-LIBS=-lpsapi
4156-WINDRES=windres
4157-EXTRAOBJS=$(RSRC)
4158-STRIP=@echo
4159-LIBPFX=
4160-LIBSFX=.dll
4161-
4162-ifeq ($(CC),gcc)
4163-CC += -mno-cygwin
4164-LD += -mno-cygwin -Wl,--add-stdcall-alias
4165-endif
4166-
4167-ifeq ($(ARCH),amd64)
4168-
4169-WINDRES=/usr/local/mingw64-cross/bin/x86_64-pc-mingw32-windres
4170-
4171-# Uncomment to enable MINGW64 cross compiler
4172-# Should build properly as of 090601, but lacks SEH, so MSVC build is preferred
4173-#MINGW = x86_64-pc-mingw32-gcc
4174-ifneq ($(MINGW),)
4175-CC = $(MINGW) -m64 -mno-cygwin
4176-LD = $(CC)
4177-LDFLAGS=-o $@ -shared
4178-LIBS= -lmingwex -lpsapi -lkernel32 -lmsvcrt
4179-FFI_CONFIG += --host=x86_64-pc-mingw32
4180-else
4181-# MSVC (wrapper scripts)
4182-CC=$(FFI_SRC)/../cc.sh -m64
4183-LD=$(FFI_SRC)/../ld.sh -m64
4184-COPT=
4185-LIBS=psapi.lib
4186-ARSFX=.lib
4187-FFI_CONFIG += --host=x86_64-pc-mingw32 && rm -f include/ffitarget.h && cp $(FFI_SRC)/include/*.h $(FFI_SRC)/src/x86/ffitarget.h include
4188-FFI_ENV += LD="$(LD)" CPP=cpp
4189-endif
4190-endif
4191-endif
4192-
4193-ifeq ($(OS),linux)
4194-ARCH=$(shell uname -m | sed 's/i.86/i386/g')
4195-PCFLAGS+=-fPIC
4196-CDEFINES+=-DHAVE_PROTECTION
4197-LDFLAGS+=-Wl,-soname,$@
4198-endif
4199-
4200-ifeq ($(OS),freebsd)
4201-ARCH=$(shell uname -m | sed 's/i.86/i386/g')
4202-PCFLAGS+=-fPIC
4203-CINCLUDES+=-I/usr/X11R6/include
4204-LDFLAGS=-o $@ -shared
4205-CDEFINES+=-DHAVE_PROTECTION -DFFI_MMAP_EXEC_WRIT
4206-endif
4207-
4208-ifeq ($(OS),openbsd)
4209-ARCH=$(shell uname -m | sed 's/i.86/i386/g')
4210-PCFLAGS+=-fPIC
4211-CINCLUDES+=-I/usr/X11R6/include
4212-LDFLAGS=-o $@ -shared
4213-CDEFINES+=-DHAVE_PROTECTION -DFFI_MMAP_EXEC_WRIT
4214-endif
4215-
4216-ifeq ($(OS),solaris)
4217-ifeq ($(ARCH),)
4218-ARCH=$(shell uname -p)
4219-endif
4220-PCFLAGS+=-fPIC
4221-CDEFINES+=-DHAVE_PROTECTION -DFFI_MMAP_EXEC_WRIT
4222-ifeq ($(ARCH), sparcv9)
4223- # alter CC instead of PCFLAGS, since we need to pass it down to libffi
4224- # configure and some of the other settings in PCFLAGS might make the build
4225- # choke
4226- CC += -m64
4227- LD += -m64
4228-endif
4229-endif
4230-
4231-# Enable 64-bit builds if the arch demands it
4232-ifeq ($(CC),gcc)
4233-ifeq ($(ARCH),amd64)
4234- CC += -m64
4235- LD += -m64
4236-endif
4237-endif
4238-
4239-ifeq ($(OS),darwin)
4240-ARCH=$(shell arch)
4241-ifeq ($(ARCH),ppc)
4242-ALT_ARCHS=i386
4243-else
4244-ALT_ARCHS=ppc
4245-endif
4246-LIBSFX=.dylib
4247-JNISFX=.jnilib
4248-ifneq ($(SDKROOT),)
4249-SYSLIBROOT=-Wl,-syslibroot,$(SDKROOT)
4250-ISYSROOT=-isysroot $(SDKROOT)
4251-ARCHFLAGS=-arch ppc -arch i386
4252-ifneq ($(findstring 10.5,$(SDKROOT)),)
4253-ALT_ARCHS+=x86_64
4254-ARCHFLAGS+=-arch x86_64
4255-endif
4256-endif
4257-PCFLAGS+=$(ISYSROOT) -x objective-c
4258-CDEFINES+=-DTARGET_RT_MAC_CFM=0 -DFFI_MMAP_EXEC_WRIT
4259-LDFLAGS=$(ARCHFLAGS) -dynamiclib -o $@ -framework JavaVM \
4260- -compatibility_version $(shell echo ${VERSION}|sed 's/^\([0-9][0-9]*\).*/\1/g') \
4261- -current_version $(VERSION) \
4262- -mmacosx-version-min=10.3 \
4263- -install_name ${@F} \
4264- $(SYSLIBROOT)
4265-# JAWT linkage handled by -framework JavaVM
4266-LIBS=
4267-endif
4268-
4269-# Unfortunately, we have to use different libffi include files depending on
4270-# the target, so we can't do a simple universal build on darwin. Do
4271-# separate builds, then merge the results.
4272-$(BUILD)/%.o : %.c dispatch.h $(FFI_LIB)
4273- @mkdir -p $(BUILD)
4274-ifneq ($(SDKROOT),)
4275- $(CC) -arch $(ARCH) $(CFLAGS) -c $< -o $@.$(ARCH)
4276- for arch in $(ALT_ARCHS); do \
4277- $(CC) -arch $$arch -I$(BUILD)/libffi.$$arch/include $(CFLAGS) -c $< -o $@.$$arch; \
4278- done
4279- lipo -create -output $@ $@.*
4280-else
4281- $(CC) $(CFLAGS) -c $< $(COUT)
4282-endif
4283-
4284-all: $(LIBRARY) $(TESTLIB) $(TESTLIB2)
4285-
4286-install:
4287- mkdir $(INSTALLDIR)
4288- cp $(LIBRARY) $(INSTALLDIR)
4289-
4290-$(RSRC): $(BUILD)/jnidispatch.rc
4291- $(WINDRES) -i $< -o $@ \
4292- || (echo > $@.c && $(CC) $(CFLAGS) -c $@.c $(COUT))
4293-
4294-$(LIBRARY): $(JNIDISPATCH_OBJS) $(FFI_LIB)
4295- $(LD) $(LDFLAGS) $(JNIDISPATCH_OBJS) $(FFI_LIB) $(LIBS)
4296-
4297-$(TESTLIB): $(BUILD)/testlib.o
4298- $(LD) $(LDFLAGS) $<
4299-
4300-ifeq ($(ARSFX),.lib)
4301-TESTDEP=$(TESTLIB:.dll=.lib)
4302-else
4303-TESTDEP=$(TESTLIB)
4304-endif
4305-$(TESTLIB2): $(BUILD)/testlib2.o
4306- $(LD) $(LDFLAGS) $< $(TESTDEP)
4307-
4308-ifneq ($(DYNAMIC_LIBFFI),true)
4309-$(FFI_LIB):
4310- @mkdir -p $(FFI_BUILD)
4311- @if [ ! -f $(FFI_BUILD)/Makefile ]; then \
4312- echo "Configuring libffi ($(ARCH))"; \
4313- (cd $(FFI_BUILD) \
4314- && $(FFI_ENV) $(FFI_SRC)/configure $(FFI_CONFIG)); \
4315- fi
4316- $(MAKE) -C $(FFI_BUILD)
4317-ifneq ($(SDKROOT),)
4318- @for arch in $(ALT_ARCHS); do \
4319- mkdir -p $(BUILD)/libffi.$$arch; \
4320- if [ ! -f $(BUILD)/libffi.$$arch/Makefile ]; then \
4321- echo "Configuring libffi ($$arch)"; \
4322- (cd $(BUILD)/libffi.$$arch \
4323- && CC="$(CC)" CFLAGS="-arch $$arch $(ISYSROOT) $(COPT) $(CDEBUG)" CPPFLAGS="$(CDEFINES)" \
4324- LDFLAGS="-arch $$arch" \
4325- $(FFI_SRC)/configure $(FFI_CONFIG) --host=$$arch-apple-darwin --disable-dependency-tracking); \
4326- fi; \
4327- $(MAKE) -C $(BUILD)/libffi.$$arch; \
4328- done
4329- /usr/bin/libtool -static -o $@.tmp $(FFI_BUILD)/.libs/${@F} $(BUILD)/libffi.*/.libs/${@F}
4330- mv $@.tmp $@
4331-endif
4332-endif
4333-
4334-clean:
4335- $(RM) -rf $(BUILD)
4336-
4337-version:
4338- @echo version=$(VERSION)
4339-
4340-#EOF
4341
4342=== removed directory '.pc/06-remove-gjdoc-inexistent-options.patch'
4343=== removed file '.pc/06-remove-gjdoc-inexistent-options.patch/build.xml'
4344--- .pc/06-remove-gjdoc-inexistent-options.patch/build.xml 2010-05-26 00:14:07 +0000
4345+++ .pc/06-remove-gjdoc-inexistent-options.patch/build.xml 1970-01-01 00:00:00 +0000
4346@@ -1,650 +0,0 @@
4347-<?xml version="1.0" encoding="UTF-8"?>
4348-<project name="JNA" default="default" basedir=".">
4349- <description>Builds and tests JNA</description>
4350-
4351- <!--
4352- Conventions (since ant can't easily specify arbitrary file dependencies):
4353- The uptodate property for a given target TARGET is "-TARGET"; the actual
4354- target to generate the uptodate property is named ":TARGET".
4355-
4356- Properties (except for uptodate properties) separate words by dots, targets
4357- by dashes.
4358- -->
4359-
4360- <!-- global properties -->
4361- <!-- (all build-related props should go in -dynamic-properties) -->
4362- <property name="name" value="jna"/>
4363- <property name="jar" value="${name}.jar"/>
4364- <property name="testjar" value="${name}-test.jar"/>
4365- <property name="debug" value="true"/>
4366- <property name="debug.native" value="false"/>
4367- <property name="cflags_extra.native" value=""/>
4368- <property name="dynlink.native" value="false"/>
4369- <property name="native" location="native"/>
4370- <property name="src" location="src"/>
4371- <property name="dist" location="dist"/>
4372- <property name="test.src" location="test"/>
4373- <property name="doc" location="doc"/>
4374- <property name="javadoc" location="${doc}/javadoc"/>
4375- <property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
4376- <property name="vendor" value="JNA Development Team"/>
4377- <property name="copyright"
4378- value="Copyright &amp;copy; 2007-2009 Timothy Wall. All Rights Reserved."/>
4379- <buildnumber/>
4380- <!-- JNA library release version -->
4381- <property name="jna.major" value="3"/>
4382- <property name="jna.minor" value="2"/>
4383- <property name="jna.revision" value="4"/>
4384- <property name="jna.build" value="${build.number}"/>
4385- <property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
4386- <!-- jnidispatch library release version -->
4387- <property name="jni.major" value="3"/>
4388- <property name="jni.minor" value="2"/>
4389- <property name="jni.revision" value="1"/>
4390- <property name="jni.build" value="${build.number}"/>
4391- <property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
4392- <property name="jni.md5" value="c870290c36c8d3fdf85db7c782febc3f"/>
4393- <property name="spec.title" value="Java Native Access (JNA)"/>
4394- <property name="spec.vendor" value="${vendor}"/>
4395- <property name="spec.version" value="${jna.major}"/>
4396- <property name="impl.title" value="com.sun.jna"/>
4397- <property name="impl.vendor" value="${spec.vendor}"/>
4398- <property name="impl.version" value="${jna.version} (b${jna.build})"/>
4399-
4400- <property name="compatibility" value="1.4"/>
4401- <property name="test.compatibility" value="1.5"/>
4402-
4403- <!-- Miscellaneous -->
4404- <property name="build.compiler.emacs" value="true"/>
4405-
4406- <target name="default" depends="test" description="Build and Test."/>
4407-
4408- <target name="init" depends="-setup"/>
4409- <target name="compile-test-single" depends="compile-tests"/>
4410- <target name="compile-single" depends="compile"/>
4411-
4412- <target name="-dynamic-properties">
4413- <echo>Java version ${java.version}, compatibility: ${compatibility}</echo>
4414- <echo>JNA version ${jna.version}, native ${jni.version}</echo>
4415- <echo>${java.vm.name} (${java.vm.vendor}, ${java.vm.version})</echo>
4416- <echo>java.home=${java.home}</echo>
4417- <echo>java.library.path=${java.library.path}</echo>
4418-
4419- <replaceregexp match="(&lt;version&gt;).*(&lt;/version&gt;)"
4420- replace="\1${jna.version}\2"
4421- file="pom.xml"/>
4422- <replaceregexp match='VERSION = ".*";'
4423- replace='VERSION = "${jna.version}";'
4424- file="src/com/sun/jna/Native.java"/>
4425-
4426- <condition property="jar.omitted" value="**/*jnidispatch*" else="jnilib-included">
4427- <isset property="omit-jnilib"/>
4428- </condition>
4429- <condition property="vm.arch" value="-d64" else="">
4430- <or>
4431- <equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
4432- <equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
4433- <os arch="x86_64"/>
4434- <os arch="ppc64"/>
4435- <os arch="sparcv9"/>
4436- <os arch="amd64"/>
4437- </or>
4438- </condition>
4439- <condition property="ld.preload" value="LD_PRELOAD_64" else="LD_PRELOAD">
4440- <and>
4441- <os name="SunOS"/>
4442- <equals arg1="${vm.arch}" arg2="-d64"/>
4443- </and>
4444- </condition>
4445- <property name="build" value="build"/>
4446- <property name="classes" location="${build}/classes"/>
4447- <property name="eclipse.classes" location="build.eclipse/classes"/>
4448- <property name="test.classes" location="${build}/test-classes"/>
4449- <property name="reports" value="${build}/reports"/>
4450-
4451- <!-- Add other supported platforms here -->
4452- <condition property="jre.arch" value="i386">
4453- <equals arg1="x86" arg2="${os.arch}"/>
4454- </condition>
4455- <condition property="jre.arch" value="amd64">
4456- <equals arg1="x86_64" arg2="${os.arch}"/>
4457- </condition>
4458- <property name="jre.arch" value="${os.arch}"/>
4459- <condition property="os.prefix" value="linux-${jre.arch}">
4460- <os name="Linux"/>
4461- </condition>
4462- <condition property="os.prefix" value="win32-${os.arch}">
4463- <os family="windows"/>
4464- </condition>
4465- <!-- Darwin builds are universal, no arch required -->
4466- <condition property="os.prefix" value="darwin">
4467- <os family="mac"/>
4468- </condition>
4469- <condition property="os.prefix" value="sunos-${os.arch}">
4470- <os name="SunOS"/>
4471- </condition>
4472- <condition property="os.prefix" value="freebsd-${os.arch}">
4473- <os name="FreeBSD"/>
4474- </condition>
4475- <condition property="os.prefix" value="linux-${jre.arch}">
4476- <os name="GNU/kFreeBSD"/>
4477- </condition>
4478- <condition property="os.prefix" value="openbsd-${os.arch}">
4479- <os name="OpenBSD"/>
4480- </condition>
4481- <fail unless="os.prefix" message="OS/arch not supported (${os.name}/${os.arch}), edit build.xml and native/Makefile to add it."/>
4482- <condition property="jdk.home" value="${java.home}">
4483- <available file="${java.home}/include"/>
4484- </condition>
4485- <condition property="jdk.home" value="${java.home}/..">
4486- <available file="${java.home}/../include"/>
4487- </condition>
4488- <fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
4489- <condition property="libjsig"
4490- value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
4491- <available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
4492- </condition>
4493- <property name="native.jar" value="${os.prefix}.jar"/>
4494- <property name="build.native" location="${build}/native"/>
4495- <property name="md5.file" location="${build.native}/sig"/>
4496-
4497- <mkdir dir="${build}"/>
4498- <mkdir dir="${build.native}"/>
4499- <mkdir dir="${classes}"/>
4500- <mkdir dir="${test.classes}"/>
4501- <mkdir dir="${reports}"/>
4502- <mkdir dir="${doc}"/>
4503-
4504- </target>
4505-
4506- <target name="-setup" depends="-dynamic-properties">
4507- <path id="compile-test.path">
4508- <pathelement path="${test.src}"/>
4509- <path id="test.libs">
4510- <fileset dir="lib">
4511- <include name="junit.jar"/>
4512- </fileset>
4513- <pathelement path="${classes}"/>
4514- </path>
4515- <path id="compile.path">
4516- <path id="src.path">
4517- <pathelement location="${src}"/>
4518- </path>
4519- </path>
4520- </path>
4521-
4522- <path id="test.runpath">
4523- <pathelement path="${build}/${jar}"/>
4524- <pathelement path="${build}/examples.jar"/>
4525- <pathelement path="${test.classes}"/>
4526- <pathelement path="lib/clover.jar"/>
4527- <path refid="test.libs"/>
4528- </path>
4529- </target>
4530-
4531- <target name="compile" depends="-setup"
4532- description="Compile all Java source">
4533- <javac classpathref="compile.path"
4534- source="${compatibility}"
4535- target="${compatibility}"
4536- destdir="${classes}"
4537- deprecation="on" debug="${debug}">
4538- <src path="${src}"/>
4539- </javac>
4540- </target>
4541-
4542- <target name=":jar">
4543- <uptodate property="-jar" targetfile="${build}/${jar}">
4544- <srcfiles dir="${classes}">
4545- <patternset id="jar-compiled">
4546- <include name="com/sun/jna/*"/>
4547- <include name="com/sun/jna/**/*"/>
4548- <exclude name="com/sun/jna/examples/*"/>
4549- <exclude name="com/sun/jna/examples/**/*"/>
4550- </patternset>
4551- </srcfiles>
4552- </uptodate>
4553- </target>
4554- <target name="jar" depends="-setup,native,:jar" unless="-jar"
4555- description="Build primary jar">
4556- <jar jarfile="${build}/${jar}">
4557- <manifest>
4558- <attribute name="Main-Class" value="com.sun.jna.Native"/>
4559- <section name="com/sun/jna/">
4560- <attribute name="Implementation-Title" value="${impl.title}"/>
4561- <attribute name="Implementation-Vendor" value="${vendor}"/>
4562- <attribute name="Implementation-Version" value="${impl.version}"/>
4563- <attribute name="Specification-Title" value="${spec.title}"/>
4564- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
4565- <attribute name="Specification-Version" value="${spec.version}"/>
4566- </section>
4567- </manifest>
4568- <fileset dir="${classes}" excludes="${jar.omitted}">
4569- <patternset refid="jar-compiled"/>
4570- </fileset>
4571- </jar>
4572- </target>
4573- <target name="examples" depends="jar,native">
4574- <jar jarfile="${build}/examples.jar">
4575- <manifest>
4576- <attribute name="Class-Path" value="jna.jar"/>
4577- <attribute name="Main-Class" value="com.sun.jna.examples.ShapedWindowDemo"/>
4578- </manifest>
4579- <fileset dir="${src}" includes="**/examples/**/*.png"/>
4580- <fileset dir="${classes}" includes="**/examples/*,**/examples/**/*"/>
4581- <fileset dir="${classes}" includes="jnidispatch.dll"/>
4582- </jar>
4583- </target>
4584-
4585- <target name="javah" depends="compile">
4586- <javah classpath="${classes}" destdir="${build.native}" force="yes">
4587- <class name="com.sun.jna.Function"/>
4588- <class name="com.sun.jna.Pointer"/>
4589- <class name="com.sun.jna.Memory"/>
4590- <class name="com.sun.jna.Native"/>
4591- <class name="com.sun.jna.NativeLibrary"/>
4592- <class name="com.sun.jna.CallbackReference"/>
4593- </javah>
4594- <condition property="grep" value="/usr/sfw/bin/ggrep">
4595- <os name="SunOS"/>
4596- </condition>
4597- <condition property="grep" value="ggrep">
4598- <os name="OpenBSD"/>
4599- </condition>
4600- <property name="grep" value="grep"/>
4601- <apply dir="${build.native}" executable="${grep}" parallel="true"
4602- failonerror="true" relative="true" output="${md5.file}">
4603- <arg value="-A"/>
4604- <arg value="1"/>
4605- <arg value="JNIEXPORT"/>
4606- <fileset dir="${build.native}" includes="*.h"/>
4607- </apply>
4608- <fixcrlf srcdir="${build.native}" includes="sig" eol="unix"/>
4609- <checksum property="md5" file="${md5.file}" />
4610- <condition property="jni.valid" value="true">
4611- <or>
4612- <equals arg1="${jni.md5}" arg2="${md5}" trim="true"/>
4613- <equals arg1="${jni.md5}" arg2=""/>
4614- </or>
4615- </condition>
4616- </target>
4617-
4618- <!-- Invalidate native libraries when native API changes -->
4619- <target name="-native-api-check" depends="javah" unless="jni.valid">
4620- <echo>Invalidating native code, new checksum is ${md5}</echo>
4621- <copy file="${dist}/out-of-date.jar" tofile="${dist}/darwin.jar" overwrite="true"/>
4622- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-x86.jar" overwrite="true"/>
4623- <copy file="${dist}/out-of-date.jar" tofile="${dist}/win32-amd64.jar" overwrite="true"/>
4624- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-i386.jar" overwrite="true"/>
4625- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-amd64.jar" overwrite="true"/>
4626- <copy file="${dist}/out-of-date.jar" tofile="${dist}/linux-ia64.jar" overwrite="true"/>
4627- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-i386.jar" overwrite="true"/>
4628- <copy file="${dist}/out-of-date.jar" tofile="${dist}/freebsd-amd64.jar" overwrite="true"/>
4629- <copy file="${dist}/out-of-date.jar" tofile="${dist}/openbsd-i386.jar" overwrite="true"/>
4630- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-x86.jar" overwrite="true"/>
4631- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-amd64.jar" overwrite="true"/>
4632- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparc.jar" overwrite="true"/>
4633- <copy file="${dist}/out-of-date.jar" tofile="${dist}/sunos-sparcv9.jar" overwrite="true"/>
4634- <delete failOnError="false" includeEmptyDirs="true">
4635- <fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
4636- </delete>
4637- <fail>API for native code has changed. Re-run this build after updating jni.version and jni.md5 in build.xml</fail>
4638- </target>
4639-
4640- <target name=":rsrc">
4641- <condition property="-rsrc">
4642- <not><os family="windows"/></not>
4643- </condition>
4644- </target>
4645- <target name="rsrc" depends="-setup,:rsrc" unless="-rsrc"
4646- description="Generate w32 DLL version resource information">
4647- <property name="rsrc" location="${build.native}/jnidispatch.rc"/>
4648- <copy todir="${build.native}" file="${native}/jnidispatch.rc"/>
4649- <replaceregexp match="FILEVERSION.*"
4650- replace="FILEVERSION ${jni.major},${jni.minor},${jni.revision},${jni.build}"
4651- file="${rsrc}" byline="true"/>
4652- <replaceregexp match="PRODUCTVERSION.*"
4653- replace="PRODUCTVERSION ${jna.major},${jna.minor},${jna.revision},${jna.build}"
4654- file="${rsrc}" byline="true"/>
4655- <replaceregexp match="FileVersion.*"
4656- replace="FileVersion&quot;,&quot;${jni.version}&quot;"
4657- file="${rsrc}" byline="true"/>
4658- <replaceregexp match="Full Version.*"
4659- replace="Full Version&quot;,&quot;${jni.version} b${jni.build}&quot;"
4660- file="${rsrc}" byline="true"/>
4661- <replaceregexp match="ProductVersion.*"
4662- replace="ProductVersion&quot;,&quot;${spec.version}&quot;"
4663- file="${rsrc}" byline="true"/>
4664- </target>
4665-
4666- <target name="native" depends="-setup,javah,-native-api-check,rsrc"
4667- description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
4668- <property name="comment" value="# auto-generated by ant"/>
4669- <replaceregexp match="^VERSION=.*"
4670- replace="VERSION=${jni.version} ${comment}"
4671- file="native/Makefile" byline="true"/>
4672- <replaceregexp match="^CHECKSUM=.*"
4673- replace="CHECKSUM=${jni.md5} ${comment}"
4674- file="native/Makefile" byline="true"/>
4675- <!-- ensure ARCH is set properly for 64-bit capable platforms -->
4676- <!-- use ANT_OPTS=-d64 to build 64-bit if not the platform default -->
4677- <property name="ARCH" value="${os.arch}"/>
4678- <condition property="make.CC" value="CC=${CC}" else="IGNORE=">
4679- <isset property="CC"/>
4680- </condition>
4681- <condition property="make.ARCH" value="ARCH=${ARCH}" else="IGNORE=">
4682- <isset property="ARCH"/>
4683- </condition>
4684- <condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
4685- <isset property="SDKROOT"/>
4686- </condition>
4687- <condition property="make.SDKROOT"
4688- value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
4689- <available file="/Developer/SDKs/MacOSX10.5.sdk"/>
4690- </condition>
4691- <condition property="make.SDKROOT"
4692- value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
4693- <available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
4694- </condition>
4695- <!-- Windows' drive letters and spaces in absolute paths wreak havoc on
4696- make -->
4697- <condition property="make.BUILD" value="BUILD=../${build}/native" else="BUILD=${build.native}">
4698- <os family="windows"/>
4699- </condition>
4700- <condition property="make.PATH" value="PATH=/usr/sfw/bin:/usr/bin:/usr/ccs/bin" else="IGNORE=">
4701- <os name="SunOS"/>
4702- </condition>
4703- <condition property="make" value="/usr/sfw/bin/gmake">
4704- <os name="SunOS"/>
4705- </condition>
4706- <condition property="make" value="gmake">
4707- <or>
4708- <os name="FreeBSD"/>
4709- <os name="OpenBSD"/>
4710- </or>
4711- </condition>
4712- <!-- Default make program -->
4713- <property name="make" value="make"/>
4714-
4715- <exec executable="${make}" dir="${native}" failonerror="true">
4716- <arg value="JAVA_HOME=${jdk.home}"/>
4717- <arg value="JAVAH=${build.native}"/>
4718- <arg value="DEBUG=${debug.native}"/>
4719- <arg value="CFLAGS_EXTRA=${cflags_extra.native}"/>
4720- <arg value="DYNAMIC_LIBFFI=${dynlink.native}"/>
4721- <arg value="${make.CC}"/>
4722- <arg value="${make.BUILD}"/>
4723- <arg value="${make.SDKROOT}"/>
4724- <arg value="${make.ARCH}"/>
4725- <arg value="${make.PATH}"/>
4726- <arg value="VERSION=${jni.version}"/>
4727- <arg value="CHECKSUM=${jni.md5}"/>
4728- </exec>
4729- <antcall target="native-mixedjar"/>
4730- <!-- For web start, native libraries may be provided in the root of -->
4731- <!-- an included jar file -->
4732- <jar jarfile="${build}/${native.jar}">
4733- <fileset dir="${build.native}" includes="jnidispatch.dll,libjnidispatch.*"/>
4734- <manifest>
4735- <attribute name="Implementation-Version" value="${jni.version} b${jni.build}"/>
4736- <attribute name="Specification-Version" value="${jni.version}"/>
4737- </manifest>
4738- </jar>
4739- </target>
4740-
4741- <target name="native-mixedjar" unless="nomixedjar.native">
4742- <mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
4743- <copy todir="${classes}/com/sun/jna/${os.prefix}">
4744- <fileset dir="${build.native}"
4745- includes="jnidispatch.dll,libjnidispatch.*"/>
4746- </copy>
4747- <mkdir dir="${eclipse.classes}/com/sun/jna/${os.prefix}"/>
4748- <copy todir="${eclipse.classes}/com/sun/jna/${os.prefix}"
4749- failonerror="false">
4750- <fileset dir="${build.native}"
4751- includes="jnidispatch.dll,libjnidispatch.*"/>
4752- </copy>
4753- </target>
4754-
4755- <target name="compile-tests" depends="compile,native,jar"
4756- description="Compile all test code">
4757- <javac classpathref="compile-test.path"
4758- source="${test.compatibility}"
4759- target="${test.compatibility}"
4760- destdir="${test.classes}"
4761- deprecation="on" debug="${debug}">
4762- <src path="${test.src}"/>
4763- </javac>
4764- <jar jarfile="${build}/${testjar}">
4765- <fileset dir="${test.classes}">
4766- <patternset refid="jar-compiled"/>
4767- </fileset>
4768- </jar>
4769- <mkdir dir="${build}/jws"/>
4770- <copy todir="${build}/jws" file="${build}/${jar}"/>
4771- <copy todir="${build}/jws" file="${build}/${testjar}"/>
4772- <copy todir="${build}/jws" file="lib/junit.jar"/>
4773- <copy todir="${build}/jws" file="lib/clover.jar"/>
4774- <jar jarfile="${build}/jws/jnidispatch.jar">
4775- <fileset dir="${build.native}" includes="*jnidispatch.*"/>
4776- </jar>
4777- <signjar alias="jna" keystore="jna.keystore" storepass="jnadev" lazy="true">
4778- <fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
4779- </signjar>
4780- </target>
4781-
4782- <!-- When running tests from an IDE, be sure to set jna.library.path -->
4783- <!-- to where the test library (testlib) is found. -->
4784- <target name="test" depends="jar,examples,compile-tests"
4785- description="Run all unit tests">
4786- <property name="test.fork" value="yes"/>
4787- <property name="reports.junit" location="${reports}/junit"/>
4788- <property name="results.junit" location="${build}/junit-results"/>
4789- <mkdir dir="${results.junit}"/>
4790- <echo>Saving test results in ${results.junit}</echo>
4791- <property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
4792- <condition property="tests.platform" value="**/win32/*Test.java">
4793- <os family="windows"/>
4794- </condition>
4795- <condition property="tests.exclude" value="**/win32/*StdCallTest.java">
4796- <and><os family="windows"/><not><os arch="x86"/></not></and>
4797- </condition>
4798- <condition property="tests.platform" value="**/unix/*Test.java">
4799- <and>
4800- <os family="unix"/>
4801- <not><os family="mac"/></not>
4802- </and>
4803- </condition>
4804- <condition property="vmopt.arch" value="-d64" else="-Dignore">
4805- <and>
4806- <!-- Sun 64-bit VM for windows doesn't support the -d64 switch -->
4807- <not><os family="windows"/></not>
4808- <equals arg1="${vm.arch}" arg2="-d64" trim="true"/>
4809- </and>
4810- </condition>
4811- <property name="tests.platform" value=""/>
4812- <property name="tests.exclude" value=""/>
4813- <junit printsummary="yes" fork="${test.fork}" failureproperty="testfailure">
4814- <!-- avoid VM conflicts with JNA protected mode -->
4815- <env key="${ld.preload}" file="${libjsig}"/>
4816- <jvmarg value="-Djna.library.path=${build.native}"/>
4817- <!-- Avoid VM crashes, if possible -->
4818- <jvmarg value="-Djna.protected=true"/>
4819- <jvmarg value="-Djna.builddir=${build}"/>
4820- <jvmarg value="${vmopt.arch}"/>
4821- <classpath><path refid="test.runpath"/></classpath>
4822- <formatter type="xml"/>
4823- <batchtest todir="${results.junit}">
4824- <fileset dir="${test.src}">
4825- <include name="com/sun/jna/*Test.java"/>
4826- <include name="com/sun/jna/examples/*Test.java"/>
4827- <include name="${tests.platform}"/>
4828- <exclude name="${tests.exclude}"/>
4829- </fileset>
4830- </batchtest>
4831- </junit>
4832- <junitreport todir="${results.junit}">
4833- <fileset dir="${results.junit}">
4834- <include name="TEST-*.xml"/>
4835- </fileset>
4836- <report todir="${reports.junit}"/>
4837- </junitreport>
4838- <echo>View test report in file://${reports.junit}/index.html</echo>
4839- <fail if="testfailure" unless="clover">One or more tests failed</fail>
4840- </target>
4841-
4842- <target name="with.clover" description="Enable code coverage for tests">
4843- <taskdef resource="cloverlib.xml" classpath="lib/clover.jar"/>
4844- <property name="clover" value="true"/>
4845- <property name="build" value="build.clover"/>
4846- <clover-setup/>
4847- </target>
4848-
4849- <target name="clover" depends="with.clover,test"
4850- description="Generate test code coverage reports">
4851- <property name="reports.clover" value="${reports}/clover"/>
4852- <mkdir dir="${reports.clover}"/>
4853- <clover-report>
4854- <current outfile="${reports.clover}" title="clover">
4855- <fileset dir="." includes="**/*.java" excludes="**/examples/**/*.java"/>
4856- <testresults dir="${results.junit}" includes="TEST-*.xml"/>
4857- <format type="html"/>
4858- </current>
4859- </clover-report>
4860- <echo>Reports generated in ${reports.clover}</echo>
4861- </target>
4862-
4863- <target name="javadoc" depends="-setup">
4864- <property name="header"
4865- value="&lt;b&gt;JNA API&lt;/&gt;&lt;font size=&quot;-1&quot;&gt; ${jna.version}&lt;/font&gt;"/>
4866- <property name="footer"
4867- value="&lt;center&gt;&lt;i&gt;${copyright}&lt;/i&gt;&lt;/center&gt;"/>
4868-
4869- <mkdir dir="${javadoc}"/>
4870- <javadoc package="true"
4871- windowtitle="JNA API"
4872- sourcepathref="src.path"
4873- classpathref="compile.path"
4874- maxmemory="256m"
4875- packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.examples,com.sun.jna.examples.win32,com.sun.jna.exmaples.unix"
4876- overview="${src}/com/sun/jna/overview.html"
4877- destdir="${javadoc}">
4878- <!-- stylesheetfile="${stylesheet}" -->
4879- <doctitle>JNA API Documentation</doctitle>
4880- <header>${header}</header>
4881- <bottom>${footer}</bottom>
4882- <link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
4883-
4884- <packageset dir="${src}" defaultexcludes="yes">
4885- <patternset>
4886- <include name="com/sun/jna/**/*"/>
4887- </patternset>
4888- </packageset>
4889-
4890- <group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
4891- <group title="Examples" packages="com.sun.jna.examples,com.sun.jna.examples.dnd"/>
4892- <group title="Unix Examples" packages="com.sun.jna.examples.unix"/>
4893- <group title="Windows Examples" packages="com.sun.jna.examples.win32"/>
4894-
4895- <arg value="-notimestamp"/>
4896- </javadoc>
4897- </target>
4898-
4899- <target name="dist" depends="jar,compile-tests,native,examples,javadoc"
4900- description="Build distribution files">
4901- <jar jarfile="${dist}/jna.jar" duplicate="preserve">
4902- <manifest>
4903- <attribute name="Main-Class" value="com.sun.jna.Native"/>
4904- <section name="com/sun/jna/">
4905- <attribute name="Implementation-Title" value="${impl.title}"/>
4906- <attribute name="Implementation-Vendor" value="${vendor}"/>
4907- <attribute name="Implementation-Version" value="${impl.version}"/>
4908- <attribute name="Specification-Title" value="${spec.title}"/>
4909- <attribute name="Specification-Vendor" value="${spec.vendor}"/>
4910- <attribute name="Specification-Version" value="${spec.version}"/>
4911- </section>
4912- </manifest>
4913- <zipfileset src="${build}/${jar}"/>
4914- <zipfileset src="${dist}/win32-x86.jar"
4915- includes="*jnidispatch*"
4916- prefix="com/sun/jna/win32-x86"/>
4917- <zipfileset src="${dist}/darwin.jar"
4918- includes="*jnidispatch*"
4919- prefix="com/sun/jna/darwin"/>
4920- <zipfileset src="${dist}/linux-i386.jar"
4921- includes="*jnidispatch*"
4922- prefix="com/sun/jna/linux-i386"/>
4923- <zipfileset src="${dist}/linux-amd64.jar"
4924- includes="*jnidispatch*"
4925- prefix="com/sun/jna/linux-amd64"/>
4926- <zipfileset src="${dist}/linux-ia64.jar"
4927- includes="*jnidispatch*"
4928- prefix="com/sun/jna/linux-ia64"/>
4929- <zipfileset src="${dist}/sunos-x86.jar"
4930- includes="*jnidispatch*"
4931- prefix="com/sun/jna/sunos-x86"/>
4932- <zipfileset src="${dist}/sunos-amd64.jar"
4933- includes="*jnidispatch*"
4934- prefix="com/sun/jna/sunos-amd64"/>
4935- <zipfileset src="${dist}/sunos-sparc.jar"
4936- includes="*jnidispatch*"
4937- prefix="com/sun/jna/sunos-sparc"/>
4938- <zipfileset src="${dist}/sunos-sparcv9.jar"
4939- includes="*jnidispatch*"
4940- prefix="com/sun/jna/sunos-sparcv9"/>
4941- <zipfileset src="${dist}/freebsd-i386.jar"
4942- includes="*jnidispatch*"
4943- prefix="com/sun/jna/freebsd-i386"/>
4944- <zipfileset src="${dist}/freebsd-amd64.jar"
4945- includes="*jnidispatch*"
4946- prefix="com/sun/jna/freebsd-amd64"/>
4947- <zipfileset src="${dist}/openbsd-i386.jar"
4948- includes="*jnidispatch*"
4949- prefix="com/sun/jna/openbsd-i386"/>
4950- <zipfileset src="${dist}/win32-amd64.jar"
4951- includes="*jnidispatch*"
4952- prefix="com/sun/jna/win32-amd64"/>
4953- </jar>
4954- <copy todir="${dist}">
4955- <fileset dir="${build}">
4956- <include name="${native.jar}"/>
4957- <include name="examples.jar"/>
4958- </fileset>
4959- </copy>
4960- <zip zipfile="${dist}/doc.zip">
4961- <zipfileset dir="${javadoc}" prefix="javadoc"/>
4962- </zip>
4963- <!-- JNA sources only, for use in Linux build from source/shared libffi -->
4964- <zip zipfile="${dist}/src.zip">
4965- <zipfileset dir="." includes="build.xml,LICENSE.txt"/>
4966- <zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
4967- <zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
4968- <zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
4969- </zip>
4970- <!-- Full sources required to build and test everything -->
4971- <zip zipfile="${dist}/src-full.zip">
4972- <zipfileset src="${dist}/src.zip"/>
4973- <zipfileset dir="lib" includes="junit.jar,clover.jar" prefix="lib"/>
4974- <zipfileset dir="." includes=".classpath,.project"/>
4975- <zipfileset dir="${native}" includes="libffi,libffi/**/*" prefix="native"/>
4976- </zip>
4977- <!-- Sources package as required by maven -->
4978- <zip zipfile="${dist}/src-mvn.zip">
4979- <zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
4980- </zip>
4981- </target>
4982-
4983- <target name="clean" depends="-dynamic-properties">
4984- <delete failOnError="false" includeEmptyDirs="true">
4985- <fileset dir="${build}"/>
4986- </delete>
4987- <delete quiet="true" includeEmptyDirs="true">
4988- <fileset dir=".clover"/>
4989- <fileset dir="${javadoc}"/>
4990- <fileset dir="." includes="*~,**/*~"/>
4991- </delete>
4992- </target>
4993-
4994-</project>
4995-
4996-
4997
4998=== removed file '.pc/applied-patches'
4999--- .pc/applied-patches 2010-05-26 00:14:07 +0000
5000+++ .pc/applied-patches 1970-01-01 00:00:00 +0000
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: