aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/OSX/src/native/build.xml
blob: 8dd4662d3426ff8807811df70c95ad1528da48fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?xml version="1.0" ?>
<project name="OS X Plugin, Native code" basedir="." default="compileNativeJinputLib">
	<description>OSX JInput Native Plugin</description>

	<target name="init">
		<mkdir dir="ppc"/>
		<mkdir dir="i386"/>
		<mkdir dir="x86_64"/>
	</target>
	
	<target name="clean">
		<delete failonerror="false">
			<fileset dir="i386"/>
			<fileset dir="x86_64"/>
			<fileset dir="ppc"/>
			<fileset file="libjinput-osx.jnilib"/>
		</delete>
	</target>

	<target name="compile">
		<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
			<arg line="${cflags} -O2 -Wall -c -fPIC -I${sdkroot}/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I../../../../common/src/native -I.."/>
			<mapper type="glob" from="*.c" to="*.o"/>
			<fileset dir="." includes="*.c"/>
			<fileset dir="../../../common/src/native" includes="*.c"/>
		</apply>
	</target>
	
	<target name="link">
		<apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
			<arg line="${linkerflags} -dynamiclib -o ${libname} -framework JavaVM -framework CoreFoundation -framework IOKit -framework CoreServices"/>
			<fileset dir="${objdir}" includes="*.o"/>
		</apply>
		<apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
			<arg line="-S -X"/>
			<fileset dir="." includes="${libname}"/>
		</apply>
	</target>
	
	<target name="compileNativeJinputLib" depends="init">
		<property name="ppc_sdkroot" location="/Developer/SDKs/MacOSX10.3.9.sdk"/>
		<property name="universal_sdkroot" location="/Developer/SDKs/MacOSX10.4u.sdk"/>
		<property name="x86_64_sdkroot" location="/Developer/SDKs/MacOSX10.5.sdk"/>
		<property name="ppc_flags" value="-isysroot ${universal_sdkroot} -arch ppc -mmacosx-version-min=10.3"/>
		<property name="universal_flags" value="-isysroot ${universal_sdkroot} -arch i386 -mmacosx-version-min=10.4"/>
		<property name="x86_64_flags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
		<antcall target="compile">
			<param name="dstdir" location="ppc"/>
			<param name="compiler" value="gcc-4.0"/>
			<param name="sdkroot" location="${universal_sdkroot}"/>
			<param name="cflags" value="${ppc_flags}"/>
		</antcall>
		<antcall target="link">
			<param name="objdir" location="ppc"/>
			<param name="libname" value="libjinput-osx-ppc.jnilib"/>
			<param name="linker" value="gcc-4.0"/>
			<param name="linkerflags" value="${ppc_flags}"/>
		</antcall>
		<antcall target="compile">
			<param name="dstdir" location="i386"/>
			<param name="compiler" value="gcc-4.0"/>
			<param name="sdkroot" location="${universal_sdkroot}"/>
			<param name="cflags" value="${universal_flags}"/>
		</antcall>
		<antcall target="link">
			<param name="objdir" location="i386"/>
			<param name="libname" value="libjinput-osx-i386.jnilib"/>
			<param name="linker" value="gcc-4.0"/>
			<param name="linkerflags" value="${universal_flags}"/>
		</antcall>
		<antcall target="compile">
			<param name="dstdir" location="x86_64"/>
			<param name="compiler" value="gcc-4.0"/>
			<param name="sdkroot" location="${x86_64_sdkroot}"/>
			<param name="cflags" value="${x86_64_flags}"/>
		</antcall>
		<antcall target="link">
			<param name="objdir" location="x86_64"/>
			<param name="libname" value="libjinput-osx-x86_64.jnilib"/>
			<param name="linker" value="gcc-4.0"/>
			<param name="linkerflags" value="${x86_64_flags}"/>
		</antcall>
		<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" >
			<arg value="-create"/>
			<srcfile/>
			<arg value="-output"/>
			<arg path="libjinput-osx.jnilib"/>
			<fileset file="ppc/libjinput-osx-ppc.jnilib"/>
			<fileset file="i386/libjinput-osx-i386.jnilib"/>
			<fileset file="x86_64/libjinput-osx-x86_64.jnilib"/>
		</apply>
	</target>
</project>