2022-03-22 21:26:50 -04:00
|
|
|
<project name="OS X Native code" default="nativelibrary" basedir="/dev/null">
|
2014-10-01 15:35:25 -04:00
|
|
|
<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"/>
|
2022-03-22 13:53:08 -04:00
|
|
|
<property name="jvm_headers_path" value="include"/>
|
|
|
|
<property name="jvm_headers_path_md" value="${jvm_headers_path}/darwin"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
|
2022-03-22 13:53:08 -04:00
|
|
|
<!-- 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}">
|
2014-10-01 15:35:25 -04:00
|
|
|
<and>
|
|
|
|
<not><isset property="javavmroot"/></not>
|
2022-03-22 13:53:08 -04:00
|
|
|
<available file="${java.home}/${jvm_headers_path}" type="dir"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</and>
|
2022-03-22 13:53:08 -04:00
|
|
|
</condition>
|
|
|
|
<condition property="javavmroot" value="${env.JAVA_HOME}">
|
2014-10-01 15:35:25 -04:00
|
|
|
<and>
|
|
|
|
<not><isset property="javavmroot"/></not>
|
2022-03-22 13:53:08 -04:00
|
|
|
<available file="${env.JAVA_HOME}/${jvm_headers_path}" type="dir"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</and>
|
2022-03-22 13:53:08 -04:00
|
|
|
</condition>
|
2014-10-01 15:35:25 -04:00
|
|
|
|
|
|
|
<!-- Choose a MacOSX SDK -->
|
|
|
|
|
2022-03-22 13:53:08 -04:00
|
|
|
<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>
|
2014-10-01 15:35:25 -04:00
|
|
|
<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 -->
|
2022-03-22 13:53:08 -04:00
|
|
|
<condition property="compiler" value="clang">
|
|
|
|
<and>
|
|
|
|
<not><isset property="compiler"/></not>
|
|
|
|
<available file="clang" filepath="${env.PATH}"/>
|
|
|
|
</and>
|
|
|
|
</condition>
|
2014-10-01 15:35:25 -04:00
|
|
|
<condition property="compiler" value="gcc-4.2">
|
|
|
|
<and>
|
2022-03-22 13:53:08 -04:00
|
|
|
<not><isset property="compiler"/></not>
|
2014-10-01 15:35:25 -04:00
|
|
|
<available file="gcc-4.2" filepath="${env.PATH}"/>
|
|
|
|
</and>
|
|
|
|
</condition>
|
|
|
|
<condition property="compiler" value="gcc">
|
|
|
|
<and>
|
2022-03-22 13:53:08 -04:00
|
|
|
<not><isset property="compiler"/></not>
|
2014-10-01 15:35:25 -04:00
|
|
|
<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>
|
|
|
|
|
2022-03-22 21:26:50 -04:00
|
|
|
<target name="compile" depends="init">
|
|
|
|
<mkdir dir="${dstdir}" taskname="initializing ${dstdir} folder"/>
|
2022-08-09 21:59:46 -04:00
|
|
|
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" failonerror="true" dest="${dstdir}">
|
2022-03-22 21:26:50 -04:00
|
|
|
<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"/>
|
2022-08-10 11:43:59 -04:00
|
|
|
<arg value="-I${lwjgl.target.gen.headers}"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
<!-- Map from *.m and *.c to .o -->
|
|
|
|
<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
|
2022-03-22 21:26:50 -04:00
|
|
|
<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"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</apply>
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<target name="link" depends="init">
|
|
|
|
<condition property="jdk_lib" value="${java.home}/lib">
|
2014-11-21 13:06:48 -05:00
|
|
|
<available file="${java.home}/lib/libjawt.dylib" type="file"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</condition>
|
2014-11-21 13:06:48 -05:00
|
|
|
<condition property="jdk_lib" value="${java.home}/../Libraries">
|
2014-10-01 15:35:25 -04:00
|
|
|
<not><isset property="jdk_lib"/></not>
|
|
|
|
</condition>
|
2022-03-22 21:26:50 -04:00
|
|
|
|
2022-08-09 21:59:46 -04:00
|
|
|
<apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true">
|
|
|
|
<arg line="${linkerflags} -exported_symbols_list lwjgl.symbols -dynamiclib -o ${lwjgl.target.natives}/${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt -L${sdkroot}/usr/lib"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
<fileset dir="${objdir}" includes="*.o"/>
|
2022-03-22 13:53:08 -04:00
|
|
|
</apply>
|
|
|
|
<echo message="Linked library"/>
|
2022-08-09 21:59:46 -04:00
|
|
|
<apply dir="${lwjgl.target.natives}" executable="strip" os="Mac OS X" failonerror="true">
|
2014-10-01 15:35:25 -04:00
|
|
|
<arg line="-S -X"/>
|
2022-03-22 13:53:08 -04:00
|
|
|
<fileset file="${libname}"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</apply>
|
2022-03-22 13:53:08 -04:00
|
|
|
<echo message="Stripped library"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</target>
|
|
|
|
|
|
|
|
<target name="nativelibrary" depends="init">
|
2022-03-22 13:53:08 -04:00
|
|
|
<echo message=" Java Home: ${java.home}"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
<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">
|
2022-03-22 21:26:50 -04:00
|
|
|
<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}"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</antcall>
|
|
|
|
<antcall target="compile">
|
2022-03-22 21:26:50 -04:00
|
|
|
<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}"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</antcall>
|
2022-03-22 21:26:50 -04:00
|
|
|
<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"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</exec>
|
|
|
|
<antcall target="link">
|
2022-03-22 21:26:50 -04:00
|
|
|
<param name="objdir" location="${lwjgl.target.gen.obj}/i386"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
<param name="libname" value="liblwjgl-i386.dylib"/>
|
2022-03-22 21:26:50 -04:00
|
|
|
<param name="linkerflags" value="-isysroot ${sdkroot} -arch i386 -mmacosx-version-min=${macos_link_ver}"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</antcall>
|
|
|
|
<antcall target="link">
|
2022-03-22 21:26:50 -04:00
|
|
|
<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}"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</antcall>
|
2022-08-09 21:59:46 -04:00
|
|
|
<apply dir="${lwjgl.target.natives}" parallel="true" executable="lipo" os="Mac OS X" failonerror="true">
|
2014-10-01 15:35:25 -04:00
|
|
|
<arg value="-create"/>
|
|
|
|
<srcfile/>
|
|
|
|
<arg value="-output"/>
|
|
|
|
<arg path="liblwjgl.dylib"/>
|
2022-03-22 21:26:50 -04:00
|
|
|
<fileset file="liblwjgl-i386.dylib"/>
|
|
|
|
<fileset file="liblwjgl-x86_64.dylib"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</apply>
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<target name="-build_x86_x64" if="build_x86_64">
|
|
|
|
<antcall target="compile">
|
2022-03-22 21:26:50 -04:00
|
|
|
<param name="dstdir" location="${lwjgl.target.gen.obj}/x86_64"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
<param name="sdkroot" location="${sdkroot}"/>
|
2022-03-22 13:53:08 -04:00
|
|
|
<param name="cflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</antcall>
|
2022-03-22 21:26:50 -04:00
|
|
|
<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"/>
|
2014-10-02 10:34:03 -04:00
|
|
|
</exec>
|
2014-10-01 15:35:25 -04:00
|
|
|
<antcall target="link">
|
2022-03-22 21:26:50 -04:00
|
|
|
<param name="objdir" location="${lwjgl.target.gen.obj}/x86_64"/>
|
|
|
|
<param name="libname" value="liblwjgl-x86_64.dylib"/>
|
2022-03-22 13:53:08 -04:00
|
|
|
<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</antcall>
|
2022-08-09 21:59:46 -04:00
|
|
|
<apply parallel="true" executable="lipo" os="Mac OS X" failonerror="true">
|
2014-10-01 15:35:25 -04:00
|
|
|
<arg value="-create"/>
|
|
|
|
<srcfile/>
|
|
|
|
<arg value="-output"/>
|
2022-08-09 21:59:46 -04:00
|
|
|
<arg path="${lwjgl.target.natives}/liblwjgl.dylib"/>
|
|
|
|
<fileset file="${lwjgl.target.natives}/liblwjgl-x86_64.dylib"/>
|
2014-10-01 15:35:25 -04:00
|
|
|
</apply>
|
|
|
|
</target>
|
2022-03-22 13:53:08 -04:00
|
|
|
</project>
|