1 <project name="gdx-box2d-Linux-32" basedir="." default="postcompile"> 2 <!-- include the environment --> 3 <property environment="env"/> 4 <!-- output directory for temporary object files --> 5 <property name="buildDir" value="target/linux32" /> 6 <!-- output directory for the shared library --> 7 <property name="libsDir" value="../libs/linux32" /> 8 <!-- the name of the shared library --> 9 <property name="libName" value="libgdx-box2d.so"/> 10 <!-- the jni header jniPlatform to use --> 11 <property name="jniPlatform" value="linux"/> 12 <!-- the compilerPrefix for the C & C++ compilers --> 13 <property name="compilerPrefix" value=""/> 14 <!-- the compilerSuffix for the C & C++ compilers --> 15 <property name="compilerSuffix" value="" /> 16 17 <!-- define gcc compiler, options and files to compile --> 18 <property name="gcc" value="${compilerPrefix}gcc${compilerSuffix}"/> 19 <property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m32 -fPIC"/> 20 <fileset id="gcc-files" dir="./"> 21 <exclude name="target/"/> 22 <include name="memcpy_wrap.c"/> 23 <include name="**/*.c"/> 24 25 26 </fileset> 27 28 <!-- define g++ compiler, options and files to compile --> 29 <property name="g++" value="${compilerPrefix}g++${compilerSuffix}"/> 30 <property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m32 -fPIC"/> 31 <fileset id="g++-files" dir="./"> 32 <exclude name="target/"/> 33 <include name="**/*.cpp"/> 34 35 36 </fileset> 37 38 <!-- define linker and options --> 39 <property name="linker" value="${compilerPrefix}g++${compilerSuffix}"/> 40 <property name="linker-opts" value="-shared -m32"/> 41 <property name="libraries" value=""/> 42 43 <!-- cleans the build directory, removes all object files and shared libs --> 44 <target name="clean"> 45 <delete includeemptydirs="true" quiet="true"> 46 <fileset dir="${buildDir}"/> 47 <fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/> 48 </delete> 49 </target> 50 51 <target name="precompile"> 52 <condition property="compiler-found"> 53 <and> 54 <or> 55 <!-- Include both b/c Windows might be either --> 56 <available file="${g++}" filepath="${env.PATH}"/> 57 <available file="${g++}" filepath="${env.Path}"/> 58 </or> 59 <or> 60 <!-- Include both b/c Windows might be either --> 61 <available file="${gcc}" filepath="${env.PATH}"/> 62 <available file="${gcc}" filepath="${env.Path}"/> 63 </or> 64 </and> 65 </condition> 66 <condition property="has-compiler"> 67 <equals arg1="${compiler-found}" arg2="true"/> 68 </condition> 69 70 </target> 71 72 <target name="create-build-dir" depends="precompile" if="has-compiler"> 73 <!-- FIXME this is pretty nasty :/ --> 74 <copy todir="${buildDir}"> 75 <fileset refid="g++-files"/> 76 <fileset refid="gcc-files"/> 77 </copy> 78 <delete> 79 <fileset dir="${buildDir}"> 80 <include name="*"/> 81 <exclude name="*.o"/> 82 </fileset> 83 </delete> 84 </target> 85 86 <!-- compiles all C and C++ files to object files in the build directory --> 87 <target name="compile" depends="create-build-dir" if="has-compiler"> 88 <mkdir dir="${buildDir}"/> 89 <apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true"> 90 <arg line="${g++-opts}"/> 91 <arg value="-Ijni-headers"/> 92 <arg value="-Ijni-headers/${jniPlatform}"/> 93 <arg value="-I."/> 94 95 <srcfile/> 96 <arg value="-o"/> 97 <targetfile/> 98 <fileset refid="g++-files"/> 99 <compositemapper> 100 <mapper type="glob" from="*.cpp" to="*.o"/> 101 <mapper type="glob" from="*.mm" to="*.o"/> 102 </compositemapper> 103 </apply> 104 <apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true"> 105 <arg line="${gcc-opts}"/> 106 <arg value="-Ijni-headers"/> 107 <arg value="-Ijni-headers/${jniPlatform}"/> 108 <arg value="-I."/> 109 110 <srcfile/> 111 <arg value="-o"/> 112 <targetfile/> 113 <fileset refid="gcc-files"/> 114 <compositemapper> 115 <mapper type="glob" from="*.c" to="*.o"/> 116 <mapper type="glob" from="*.m" to="*.o"/> 117 </compositemapper> 118 </apply> 119 </target> 120 121 <!-- links the shared library based on the previously compiled object files --> 122 <target name="link" depends="compile" if="has-compiler"> 123 <fileset dir="${buildDir}" id="objFileSet"> 124 <patternset> 125 <include name="**/*.o" /> 126 </patternset> 127 </fileset> 128 <pathconvert pathsep=" " property="objFiles" refid="objFileSet" /> 129 <mkdir dir="${libsDir}" /> 130 <exec executable="${linker}" failonerror="true" dir="${buildDir}"> 131 <arg line="${linker-opts}" /> 132 <arg value="-o" /> 133 <arg path="${libsDir}/${libName}" /> 134 <arg line="${objFiles}"/> 135 <arg line="${libraries}" /> 136 </exec> 137 </target> 138 139 <target name="postcompile" depends="link"> 140 141 </target> 142 </project> 143