[jffi-next] 05/24: Tweaks to make sure JFFI is buildable on Windows

Tim Potter tpot-guest at moszumanska.debian.org
Wed Mar 4 04:51:29 UTC 2015


This is an automated email from the git hooks/post-receive script.

tpot-guest pushed a commit to tag 0.6.5
in repository jffi-next.

commit 60414ef5f31362485266d43b7b73035427389761
Author: Vladimir Sizikov <vsizikov at gmail.com>
Date:   Mon Dec 14 19:24:18 2009 +0100

    Tweaks to make sure JFFI is buildable on Windows
    
    Now buildable under the following environments:
    - Cygwin
    - Mingw32
    - WPG System64 (which isa Mingw-64 variant): http://www.cadforte.com/system64.html
    
    P.S. The bare-bones mingw-w64 doesnґt work for me, crashes.
    P.P.S. Please note that WIN64 doesnґt use STDCALL calling convention,
           so I tweaked CallContext and Function.
---
 build.xml           |  4 ++++
 jni/GNUmakefile     | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
 jni/jffi/Function.c |  7 ++++++-
 libtest/GNUmakefile | 39 +++++++++++++++++++++++++++++++++++++--
 4 files changed, 93 insertions(+), 4 deletions(-)

diff --git a/build.xml b/build.xml
index a63d433..3583816 100644
--- a/build.xml
+++ b/build.xml
@@ -72,6 +72,10 @@
 
     -->
     <target name="-pre-init">
+        <!-- d32/d64 options are not supported on Windows -->
+        <condition property="run.jvm.model" value="">
+            <os family="Windows"/>
+        </condition>
         <condition property="run.jvm.model" value="-d64">
           <or>
             <os arch="amd64"/>
diff --git a/jni/GNUmakefile b/jni/GNUmakefile
index 1c4f72c..b5885a8 100755
--- a/jni/GNUmakefile
+++ b/jni/GNUmakefile
@@ -5,6 +5,21 @@ ifeq ($(OS),sunos)
   OS = solaris
 endif
 
+# Default value of $OS on Windows is Windows_NT
+ifeq ($(OS), Windows_NT)
+    # that's how we detect x64...
+    ifneq ($(findstring 64, $(BUILD_OS)),)
+      OS = win64
+    else
+      OS = win32
+    endif
+endif
+
+ifneq ($(findstring cygwin, $(BUILD_OS)),)
+  # cygwin is always x32
+  OS = win32
+endif
+
 CPU ?= $(shell uname -m | sed -e 's/i[345678]86/i386/')
 MODEL = 32 # Default to 32bit compiles
 PLATFORM = $(CPU)-$(OS)
@@ -58,6 +73,28 @@ IFLAGS = -I"$(BUILD_DIR)" -I"$(BUILD_DIR)"/jni -I"$(JFFI_SRC_DIR)" -I"$(LIBFFI_B
 CFLAGS = $(OFLAGS) $(WFLAGS) $(IFLAGS) $(PICFLAGS) $(JDK_INCLUDES)
 CFLAGS += -D_REENTRANT -D_LARGEFILE64_SOURCE -D_GNU_SOURCE
 
+ifeq ($(OS), win64)
+  override CPU = x86_64
+  JDK_INCLUDES=-I$(JNI_DIR)/win32/include -I$(JNI_DIR)/win32/include/win32
+  CC = x86_64-w64-mingw32-gcc -m64
+  PICFLAGS =
+  ifneq ($(findstring cygwin, $(BUILD_OS)),)
+    CC += -mno-cygwin
+    LDFLAGS += -mno-cygwin
+  endif
+  CFLAGS += -mwin32 -D_JNI_IMPLEMENTATION_
+  LDFLAGS += -Wl,--add-stdcall-alias
+  PICFLAGS=
+  SOFLAGS += -shared -mimpure-text -static-libgcc
+  PREFIX =
+  JNIEXT=dll
+  CXX = x86_64-w64-mingw32-g++ -m64
+  AR = x86_64-w64-mingw32-ar
+  LD = x86_64-w64-mingw32-ld
+  STRIP = x86_64-w64-mingw32-strip --strip-debug
+  CONFIGURE_BUILD = x86_64-w64-mingw32
+endif
+
 ifeq ($(OS),cross-mingw32)
   override OS = win32
   override CPU = i386
@@ -156,14 +193,22 @@ FFI_CONFIGURE = $(LIBFFI_SRC_DIR)/configure --disable-static \
 ifdef CONFIGURE_HOST
 	FFI_CONFIGURE += --host=$(CONFIGURE_HOST)
 endif
+
+ifdef CONFIGURE_BUILD
+	FFI_CONFIGURE += --build=$(CONFIGURE_BUILD)
+endif
+
 all:	$(LIBJFFI)
 
 debug:
 	@echo OS="$(OS)"
 	@echo BUILD_OS="$(BUILD_OS)"
+	@echo CPU="$(CPU)"
 	@echo JAVA_HOME="$(JAVA_HOME)"
 	@echo JDK_HOME="$(JDK_HOME)"
-	@echo "OBJS=$(OBJS) JFFI_BUILD_DIR=$(JFFI_BUILD_DIR) PLATFORM=$(PLATFORM)"
+	@echo "PLATFORM=$(PLATFORM)"
+	@echo "JFFI_BUILD_DIR=$(JFFI_BUILD_DIR)"
+	@echo "OBJS=$(OBJS)"
 
 $(LIBJFFI):  $(LIBFFI) $(OBJS)
 	$(CC) -o $@ $(LDFLAGS) $(SOFLAGS) $(OBJS) $(LIBFFI) $(LIBS)
diff --git a/jni/jffi/Function.c b/jni/jffi/Function.c
index 1eb905f..80eaaa5 100644
--- a/jni/jffi/Function.c
+++ b/jni/jffi/Function.c
@@ -71,7 +71,12 @@ Java_com_kenai_jffi_Foreign_newFunction(JNIEnv* env, jobject self,
         rawOffset += FFI_ALIGN(type->size, FFI_SIZEOF_ARG);
     }
 #ifdef _WIN32
-    abi = (flags & com_kenai_jffi_Foreign_F_STDCALL) != 0 ? FFI_STDCALL : FFI_DEFAULT_ABI;
+    #ifdef _WIN64
+      // Win64 doesn't have STDCALL calling convention
+      abi = FFI_DEFAULT_ABI;
+    # else
+      abi = (flags & com_kenai_jffi_Foreign_F_STDCALL) != 0 ? FFI_STDCALL : FFI_DEFAULT_ABI;
+    #endif
 #else
     abi = FFI_DEFAULT_ABI;
 #endif
diff --git a/libtest/GNUmakefile b/libtest/GNUmakefile
index 173102f..2f37ca1 100644
--- a/libtest/GNUmakefile
+++ b/libtest/GNUmakefile
@@ -1,12 +1,27 @@
 # -*- makefile -*-
-OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
+BUILD_OS := $(strip $(shell uname -s | tr '[:upper:]' '[:lower:]'))
+OS ?= $(BUILD_OS)
+
+# Default value of $OS on Windows is Windows_NT
+ifeq ($(OS), Windows_NT)
+    # that's how we detect x64...
+    ifneq ($(findstring 64, $(BUILD_OS)),)
+      OS = win64
+    else
+      OS = win32
+    endif
+endif
+
 CPU = $(shell uname -m | sed -e 's/i[345678]86/i386/')
 MODEL = 32 # Default to 32bit compiles
 PLATFORM = $(CPU)-$(OS)
+
 ifeq ($(OS), sunos)
   OS = solaris
 endif
+
 ifneq ($(findstring cygwin,$(BUILD_OS)),)
+  # cygwin is always x32 for now
   OS = win32
 endif
 
@@ -40,10 +55,26 @@ LDFLAGS += $(SOFLAGS)
 IFLAGS = -I"$(BUILD_DIR)"
 CFLAGS = $(OFLAGS) $(WFLAGS) $(IFLAGS) $(PICFLAGS) -D_REENTRANT
 
+ifeq ($(OS), win64)
+  override CPU = x86_64
+  JDK_INCLUDES=-I$(JNI_DIR)/win32/include -I$(JNI_DIR)/win32/include/win32
+  CC = gcc -m64
+  CXX = g++
+  PICFLAGS =
+  LDFLAGS += -Wl,--add-stdcall-alias
+  PICFLAGS =
+  PREFIX =
+  LIBEXT = dll
+endif
+
 ifeq ($(OS), win32)
-  CC += -mno-cygwin
+  CC += -mno-cygwin -mwin32
   LDFLAGS += -mno-cygwin -Wl,--add-stdcall-alias
+  PREFIX =
+  PICFLAGS =
+  LIBEXT = dll
 endif
+
 ifeq ($(OS), darwin)
   ARCHFLAGS = -arch ppc
   ifeq ($(CPU),i386)
@@ -133,4 +164,8 @@ clean::
 	# nothing to do - ant will delete the build dir
 
 debug::
+	@echo OS="$(OS)"
+	@echo BUILD_OS="$(BUILD_OS)"
+	@echo JAVA_HOME="$(JAVA_HOME)"
+	@echo JDK_HOME="$(JDK_HOME)"
 	@echo "SRCS=$(TEST_SRCS)"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jffi-next.git



More information about the pkg-java-commits mailing list