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