lwjgl/platform_build/macosx_ant/build.xml

210 lines
9.3 KiB
XML

<project name="OS X Native code" default="nativelibrary" basedir="/dev/null">
<target name="init">
<property environment="env" />
<!-- Ask Xcode for correct path to XCode tools -->
<!-- Will fail if XCode Command Line Tools are not installed on 10.7+ (Lion) -->
<exec executable="xcode-select" outputproperty="developer_path" errorproperty="xcode-select.error" failonerror="false" failifexecutionfails="false">
<arg value="-print-path" />
</exec>
<!-- Default to /Developer if xcode-select fails -->
<condition property="developer_path" value="/Developer">
<isset property="xcode-select.error" />
</condition>
<property name="sdk_path" value="Platforms/MacOSX.platform/Developer/SDKs"/>
<property name="jvm_headers_path" value="include"/>
<property name="jvm_headers_path_md" value="${jvm_headers_path}/darwin"/>
<!-- TODO: detect link version -->
<!--<property name="macos_link_ver" value="10.5"/>-->
<property name="macos_link_ver" value="10.9"/>
<condition property="javavmroot" value="${java.home}">
<and>
<not><isset property="javavmroot"/></not>
<available file="${java.home}/${jvm_headers_path}" type="dir"/>
</and>
</condition>
<condition property="javavmroot" value="${env.JAVA_HOME}">
<and>
<not><isset property="javavmroot"/></not>
<available file="${env.JAVA_HOME}/${jvm_headers_path}" type="dir"/>
</and>
</condition>
<!-- Choose a MacOSX SDK -->
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX.sdk" type="dir"/>
</and>
</condition>
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.9.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.9.sdk" type="dir"/>
</and>
</condition>
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk" type="dir"/>
</and>
</condition>
<!-- If we're on 10.7 or lower, use gcc instead of clang -->
<condition property="compiler" value="clang">
<and>
<not><isset property="compiler"/></not>
<available file="clang" filepath="${env.PATH}"/>
</and>
</condition>
<condition property="compiler" value="gcc-4.2">
<and>
<not><isset property="compiler"/></not>
<available file="gcc-4.2" filepath="${env.PATH}"/>
</and>
</condition>
<condition property="compiler" value="gcc">
<and>
<not><isset property="compiler"/></not>
<available file="gcc" filepath="${env.PATH}"/>
</and>
</condition>
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk" type="dir"/>
</and>
</condition>
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk" type="dir"/>
</and>
</condition>
<condition property="sdkroot" value="${developer_path}/SDKs/MacOSx10.6.sdk"> <!-- Old XCode location -->
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/SDKs/MacOSx10.6.sdk" type="dir"/>
</and>
</condition>
</target>
<target name="compile" depends="init">
<mkdir dir="${dstdir}" taskname="initializing ${dstdir} folder"/>
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
<arg line="${cflags} -ObjC -O3 -Wall -Wunused -c -fPIC -I${javavmroot}/${jvm_headers_path_md} -I${javavmroot}/${jvm_headers_path} -I${lwjgl.src.native}/common -I${lwjgl.src.native}/common/opengl -I${lwjgl.src.native}/macosx"/>
<!-- Map from *.m and *.c to .o -->
<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
<fileset dir="${lwjgl.src.native}/macosx" includes="*.m"/>
<fileset dir="${lwjgl.src.native}/macosx" includes="*.c"/>
<fileset dir="${lwjgl.src.native}/common" includes="*.c"/>
<fileset dir="${lwjgl.src.native}/common/opengl" includes="*.c"/>
<fileset dir="${lwjgl.target.gen.native}/openal" includes="*.c"/>
<fileset dir="${lwjgl.target.gen.native}/opencl" includes="*.c"/>
<fileset dir="${lwjgl.target.gen.native}/opengl" includes="*.c"/>
</apply>
</target>
<target name="link" depends="init">
<condition property="jdk_lib" value="${java.home}/lib">
<available file="${java.home}/lib/libjawt.dylib" type="file"/>
</condition>
<condition property="jdk_lib" value="${java.home}/../Libraries">
<not><isset property="jdk_lib"/></not>
</condition>
<apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true" skipemptyfilesets="false">
<arg line="${linkerflags} -exported_symbols_list lwjgl.symbols -dynamiclib -o ${lwjgl.target.bundle}/${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt -L${sdkroot}/usr/lib"/>
<fileset dir="${objdir}" includes="*.o"/>
</apply>
<echo message="Linked library"/>
<apply dir="${lwjgl.target.bundle}" executable="strip" os="Mac OS X" failonerror="true" skipemptyfilesets="false">
<arg line="-S -X"/>
<fileset file="${libname}"/>
</apply>
<echo message="Stripped library"/>
</target>
<target name="nativelibrary" depends="init">
<echo message=" Java Home: ${java.home}"/>
<echo message=" Compiler: ${compiler}"/>
<echo message=" Mac OS SDK: ${sdkroot}"/>
<echo message="JavaVM.framework: ${javavmroot}"/>
<condition property="build_x86_64" value="1">
<equals arg1="${compiler}" arg2="clang"/>
</condition>
<antcall target="-build"/>
</target>
<target name="-build" depends="-build_universal,-build_x86_x64"/>
<target name="-build_universal" unless="build_x86_64">
<antcall target="compile">
<param name="dstdir" location="${lwjgl.target.gen.obj}/i386"/>
<param name="sdkroot" location="${sdkroot}"/>
<param name="cflags" value="-isysroot ${sdkroot} -arch i386 -mmacosx-version-min=${macos_link_ver}"/>
</antcall>
<antcall target="compile">
<param name="dstdir" location="${lwjgl.target.gen.obj}/x86_64"/>
<param name="sdkroot" location="${sdkroot}"/>
<param name="cflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
</antcall>
<exec vmlauncher="true" executable="sh" output="${lwjgl.target.gen.obj}/i386/lwjgl.symbols" failonerror="true" logError="true">
<arg path="platform_build/macosx_ant/build-symbol-list"/>
<arg path="${lwjgl.target.gen.obj}/i386"/>
</exec>
<exec vmlauncher="true" executable="sh" output="${lwjgl.target.gen.obj}/x86_64/lwjgl.symbols" failonerror="true" logError="true">
<arg path="platform_build/macosx_ant/build-symbol-list"/>
<arg path="${lwjgl.target.gen.obj}/x86_64"/>
</exec>
<antcall target="link">
<param name="objdir" location="${lwjgl.target.gen.obj}/i386"/>
<param name="libname" value="liblwjgl-i386.dylib"/>
<param name="linkerflags" value="-isysroot ${sdkroot} -arch i386 -mmacosx-version-min=${macos_link_ver}"/>
</antcall>
<antcall target="link">
<param name="objdir" location="${lwjgl.target.gen.obj}/x86_64"/>
<param name="libname" value="liblwjgl-x86_64.dylib"/>
<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
</antcall>
<apply dir="${lwjgl.target.bundle}" parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="false">
<arg value="-create"/>
<srcfile/>
<arg value="-output"/>
<arg path="liblwjgl.dylib"/>
<fileset file="liblwjgl-i386.dylib"/>
<fileset file="liblwjgl-x86_64.dylib"/>
</apply>
</target>
<target name="-build_x86_x64" if="build_x86_64">
<antcall target="compile">
<param name="dstdir" location="${lwjgl.target.gen.obj}/x86_64"/>
<param name="sdkroot" location="${sdkroot}"/>
<param name="cflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
</antcall>
<exec vmlauncher="true" executable="sh" output="${lwjgl.target.gen.obj}/x86_64/lwjgl.symbols" failonerror="true" logError="true">
<arg path="platform_build/macosx_ant/build-symbol-list"/>
<arg path="${lwjgl.target.gen.obj}/x86_64"/>
</exec>
<antcall target="link">
<param name="objdir" location="${lwjgl.target.gen.obj}/x86_64"/>
<param name="libname" value="liblwjgl-x86_64.dylib"/>
<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
</antcall>
<apply parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="false">
<arg value="-create"/>
<srcfile/>
<arg value="-output"/>
<arg path="${lwjgl.target.bundle}/liblwjgl.dylib"/>
<fileset file="${lwjgl.target.bundle}/liblwjgl-x86_64.dylib"/>
</apply>
</target>
</project>