diff options
-rw-r--r-- | Makefile | 38 | ||||
-rw-r--r-- | make/build-crosscompile.xml | 86 | ||||
-rwxr-xr-x | make/build.xml | 14 | ||||
-rwxr-xr-x | make/gluegen-cpptasks.xml | 4 |
4 files changed, 136 insertions, 6 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3248e69 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +BITS=32 + +ifeq ($(BITS),32) + CC=gcc32 + NS=win-x86 + SCFLAGS= +else + BITS=64 + CC=gcc64 + NS=win-x64 + SCFLAGS=-D_MSC_VER=1400 +endif + +CFLAGS=-m$(BITS) -shared -c -fno-rtti -fPIC $(SCFLAGS) -I/usr/lib/jvm/java-6-sun/include -I../common/platform-libs/jre-include/win32 +LFLAGS=-m$(BITS) -shared -fno-rtti -fPIC + +SRC1=src/native/common/CPU.c +SRC2=src/native/windows/WindowsDynamicLinkerImpl_JNI.c + +OBJ1=build/obj/$(NS)/CPU.o +OBJ2=build/obj/$(NS)/WindowsDynamicLinkerImpl_JNI.o + +BIN=build/obj/$(NS)/gluegen-rt.dll + +all: $(BIN) + +$(BIN): $(OBJ1) $(OBJ2) + $(CC) $(LFLAGS) $(OBJ1) $(OBJ2) -o $(BIN) + +$(OBJ1): $(SRC1) + $(CC) $(CFLAGS) $(SRC1) -o $(OBJ1) + +$(OBJ2): $(SRC2) + $(CC) $(CFLAGS) $(SRC2) -o $(OBJ2) + +clean: + rm -f $(BIN) $(OBJ1) $(OBJ2) + diff --git a/make/build-crosscompile.xml b/make/build-crosscompile.xml new file mode 100644 index 0000000..aba6e44 --- /dev/null +++ b/make/build-crosscompile.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Document : build-crosscompile.xml + Created on : November 18, 2009, 3:38 PM + Author : Michael Bien + Description: + crosscompiler configuration and ant task for crosscompiling for + linux32/64 and win32/64 on linux64 as host system. +--> +<project name="gluegen-crosscompiler" basedir="." default="gluegen.cross-compile"> + + <import file="build.xml"/> + + <!-- TODO remove hardcoded path --> + <property name="java.includes.dir.windows" value="/media/store/gluegenSetup/win32"/> + + <!-- crosscompiles to other platforms, requirement: linux64 host os --> + <target name="gluegen.cross-compile"> + + <echo message=" - - - cross-compiling gluegen natives - - - "/> + + <antcall target="build.nativelibrary" inheritall="false"> + <param name="namespace" value="linux-amd64"/> + <param name="crosscompile" value="true"/> + <param name="build.dir" value="${build.dir}"/> + <param name="isLinuxAMD64" value="true"/> + <param name="isLinux" value="true"/> + <param name="isUnix" value="true"/> + <param name="isX11" value="true"/> + </antcall> + + <antcall target="build.nativelibrary" inheritall="false"> + <param name="namespace" value="linux-x86"/> + <param name="crosscompile" value="true"/> + <param name="build.dir" value="${build.dir}"/> + <param name="isLinuxX86" value="true"/> + <param name="isLinux" value="true"/> + <param name="isUnix" value="true"/> + <param name="isX11" value="true"/> + </antcall> + + <!-- use mingw crosscompiler to compile for win32 and win64 (linux64 only) --> + <antcall target="build.nativelibrary" inheritall="false"> + <param name="namespace" value="linux-amd64"/> + <param name="crosscompile" value="true"/> + <param name="build.dir" value="${build.dir}"/> + <param name="isLinuxAMD64" value="true"/> + <param name="isLinux" value="true"/> + <param name="isUnix" value="true"/> + <param name="isX11" value="true"/> + + <!-- overwrite --> + <param name="java.includes.dir.platform" value="${java.includes.dir.windows}"/> + <param name="compiler.cfg.id" value="compiler.cfg.linux64.mingw64"/> + <param name="linker.cfg.id" value="linker.cfg.linux64.mingw64.gluegen"/> + </antcall> + + <antcall target="build.nativelibrary" inheritall="false"> + <param name="namespace" value="linux-x86"/> + <param name="crosscompile" value="true"/> + <param name="build.dir" value="${build.dir}"/> + <param name="isLinuxX86" value="true"/> + <param name="isLinux" value="true"/> + <param name="isUnix" value="true"/> + <param name="isX11" value="true"/> + + <!-- overwrite --> + <param name="java.includes.dir.platform" value="${java.includes.dir.windows}"/> + <param name="compiler.cfg.id" value="compiler.cfg.linux64.mingw32"/> + <param name="linker.cfg.id" value="linker.cfg.linux64.mingw32.gluegen"/> + </antcall> + + <echo message=" - - - gluegen natives cross-compiled - - - "/> + + </target> + + + <target name="configure.crosscompiler"> + <linker id="linker.cfg.linux64.mingw64.gluegen" extends="linker.cfg.linux64.mingw64"> + </linker> + + <linker id="linker.cfg.linux64.mingw32.gluegen" extends="linker.cfg.linux64.mingw32"> + </linker> + </target> + +</project>
\ No newline at end of file diff --git a/make/build.xml b/make/build.xml index 7b5f073..7832aea 100755 --- a/make/build.xml +++ b/make/build.xml @@ -329,7 +329,8 @@ <msvc.manifest objdir="${build}/obj" dllname="gluegen-rt" /> </target> - <target name="c.build" depends="c.configure" unless="build.javaonly" > + <target name="c.build" depends="init, c.configure" unless="build.javaonly" > + <fail message="Requires '${c.compiler.src.files.os}'" unless="c.compiler.src.files.os"/> <fail message="Requires '${compiler.cfg.id}'" unless="compiler.cfg.id"/> <fail message="Requires '${linker.cfg.id}'" unless="linker.cfg.id"/> @@ -344,7 +345,10 @@ <condition property="c.compiler.use-debug"><istrue value="${c.compiler.debug}"/></condition> - <mkdir dir="${build}/obj" /> + <!--namespace can be overwritten from outside--> + <property name="namespace" value=""/> + + <mkdir dir="${build}/obj/${namespace}" /> <property name="c.compiler.src.files.common" value="src/native/common/*.c" /> @@ -352,8 +356,8 @@ <echo message="user.dir=${user.dir}" /> <cc outtype="shared" - objdir="${build}/obj" - outfile="${build}/obj/${output.lib.name}" + objdir="${build}/obj/${namespace}" + outfile="${build}/obj/${namespace}/${output.lib.name}" optimize="${c.compiler.optimise}" debug="${c.compiler.debug}" multithreaded="true" @@ -399,7 +403,7 @@ </jar> </target> - <target name="build.nativelibrary" unless="build.javaonly" > + <target name="build.nativelibrary" depends="init" unless="build.javaonly" > <antcall target="c.build" inheritRefs="true" /> </target> diff --git a/make/gluegen-cpptasks.xml b/make/gluegen-cpptasks.xml index d293843..1c905b7 100755 --- a/make/gluegen-cpptasks.xml +++ b/make/gluegen-cpptasks.xml @@ -639,6 +639,7 @@ <linker id="linker.cfg.linux64.mingw32" classname="net.sf.antcontrib.cpptasks.gcc.Gcc32Linker"> <linkerarg value="-m32"/> + <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names --> </linker> <!-- <linker id="linker.cfg.solaris" name="suncc"> @@ -653,7 +654,8 @@ </linker> --> <linker id="linker.cfg.win32.mingw" name="gcc" incremental="false"> - <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names --> + <linkerarg value="-m32"/> + <linkerarg value="-Wl,--kill-at" /> <!-- remove @ from function names --> </linker> <linker id="linker.cfg.win32.msvc" name="msvc" incremental="false"> |