From 2f844fc87ba0a26b3443b6a59d85a6080582c9b7 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Fri, 22 Jun 2012 11:36:58 +0200 Subject: [PATCH] Fix build issues on Cygwin and MinGW with optional MSys. --- src/Makefile | 36 +++++++++++++++++++++++------------- src/lj_arch.h | 6 +++++- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/Makefile b/src/Makefile index c3aa2ca2..6e0c7463 100644 --- a/src/Makefile +++ b/src/Makefile @@ -259,16 +259,19 @@ endif # System detection. ############################################################################## -ifneq (,$(findstring Windows,$(OS))) +ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM)) HOST_SYS= Windows + HOST_RM= del else HOST_SYS:= $(shell uname -s) - ifneq (,$(findstring CYGWIN,$(TARGET_SYS))) + ifneq (,$(findstring MINGW,$(HOST_SYS))) HOST_SYS= Windows + HOST_MSYS= mingw + endif + ifneq (,$(findstring CYGWIN,$(HOST_SYS))) + HOST_SYS= Windows + HOST_MSYS= cygwin endif -endif -ifeq (Windows,$(HOST_SYS)) - HOST_RM= del endif TARGET_SYS?= $(HOST_SYS) @@ -475,18 +478,15 @@ TARGET_O= $(LUAJIT_A) TARGET_T= $(LUAJIT_T) $(LUAJIT_SO) TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO) -ifeq (Windows,$(HOST_SYS)) - MINILUA_T= host/minilua.exe - MINILUA_X= host\minilua - BUILDVM_T= host/buildvm.exe - BUILDVM_X= host\buildvm - ALL_RM:= $(subst /,\,$(ALL_RM)) -endif ifeq (Windows,$(TARGET_SYS)) TARGET_DYNCC= $(STATIC_CC) LJVM_MODE= coffasm - LUAJIT_SO= $(TARGET_DLLNAME) LUAJIT_T= luajit.exe + ifeq (cygwin,$(HOST_MSYS)) + LUAJIT_SO= cyg$(TARGET_DLLNAME) + else + LUAJIT_SO= $(TARGET_DLLNAME) + endif # Mixed mode is not supported on Windows. And static mode doesn't work well. # C modules cannot be loaded, because they bind to lua51.dll. ifneq (static,$(BUILDMODE)) @@ -507,6 +507,16 @@ ifeq (PS3,$(TARGET_SYS)) BUILDMODE= static endif +ifeq (Windows,$(HOST_SYS)) + MINILUA_T= host/minilua.exe + BUILDVM_T= host/buildvm.exe + ifeq (,$(HOST_MSYS)) + MINILUA_X= host\minilua + BUILDVM_X= host\buildvm + ALL_RM:= $(subst /,\,$(ALL_RM)) + endif +endif + ifeq (static,$(BUILDMODE)) TARGET_DYNCC= @: TARGET_T= $(LUAJIT_T) diff --git a/src/lj_arch.h b/src/lj_arch.h index c9e9b307..a3d51542 100644 --- a/src/lj_arch.h +++ b/src/lj_arch.h @@ -122,7 +122,11 @@ #define LJ_ARCH_BITS 32 #define LJ_ARCH_ENDIAN LUAJIT_LE #define LJ_ARCH_HASFPU 1 -#define LJ_ABI_WIN LJ_TARGET_WINDOWS +#if LJ_TARGET_WINDOWS || __CYGWIN__ +#define LJ_ABI_WIN 1 +#else +#define LJ_ABI_WIN 0 +#endif #define LJ_TARGET_X86 1 #define LJ_TARGET_X86ORX64 1 #define LJ_TARGET_EHRETREG 0