Posted to tcl by patthoyts at Wed Apr 20 08:04:14 GMT 2011view raw
- From fc8bcccb56137c25154d213838e4b0a508762476 Mon Sep 17 00:00:00 2001
- From: Pat Thoyts <patthoyts@users.sourceforge.net>
- Date: Wed, 20 Apr 2011 01:40:51 +0100
- Subject: [PATCH] Support cross-compilation to x64 from ix86 hosts.
- Part of the build uses tclsh to generate files. Ensure we can specify
- a runnable executable using TCLSH_NATIVE when cross-compiling.
- This patch also gets smarter about finding the compiler version,
- the compiler target architecture and the native architecture.
- Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
- ---
- win/makefile.vc | 13 +++++++-
- win/rules.vc | 88 ++++++++++++++++++++++++++++--------------------------
- 2 files changed, 57 insertions(+), 44 deletions(-)
- diff --git a/win/makefile.vc b/win/makefile.vc
- index 35aef18..7dc96b7 100644
- --- a/win/makefile.vc
- +++ b/win/makefile.vc
- @@ -208,6 +208,15 @@ TCLDDELIB = $(OUT_DIR)\$(TCLDDELIBNAME)
- TCLTEST = $(OUT_DIR)\$(PROJECT)test.exe
- CAT32 = $(OUT_DIR)\cat32.exe
- +# Can we run what we build? IX86 runs on all architectures.
- +!ifndef TCLSH_NATIVE
- +!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
- +TCLSH_NATIVE = $(TCLSH)
- +!else
- +!error You must explicitly set TCLSH_NATIVE for cross-compilation
- +!endif
- +!endif
- +
- ### Make sure we use backslash only.
- LIB_INSTALL_DIR = $(_INSTALLDIR)\lib
- BIN_INSTALL_DIR = $(_INSTALLDIR)\bin
- @@ -1015,13 +1024,13 @@ install-libraries: tclConfig install-msgs install-tzdata
- install-tzdata:
- @echo Installing time zone data
- @set TCL_LIBRARY=$(ROOT)/library
- - @$(TCLSH) "$(ROOT)/tools/installData.tcl" \
- + @$(TCLSH_NATIVE) "$(ROOT)/tools/installData.tcl" \
- "$(ROOT)/library/tzdata" "$(SCRIPT_INSTALL_DIR)/tzdata"
- install-msgs:
- @echo Installing message catalogs
- @set TCL_LIBRARY=$(ROOT)/library
- - @$(TCLSH) "$(ROOT)/tools/installData.tcl" \
- + @$(TCLSH_NATIVE) "$(ROOT)/tools/installData.tcl" \
- "$(ROOT)/library/msgs" "$(SCRIPT_INSTALL_DIR)/msgs"
- #---------------------------------------------------------------------
- diff --git a/win/rules.vc b/win/rules.vc
- index 865b10d..c30b1cd 100644
- --- a/win/rules.vc
- +++ b/win/rules.vc
- @@ -27,18 +27,6 @@ _INSTALLDIR = C:\Program Files\Tcl
- _INSTALLDIR = $(INSTALLDIR:/=\)
- !endif
- -!ifndef MACHINE
- -!if "$(CPU)" == "" || "$(CPU)" == "i386"
- -MACHINE = IX86
- -!else
- -MACHINE = $(CPU)
- -!endif
- -!endif
- -
- -!ifndef CFG_ENCODING
- -CFG_ENCODING = \"cp1252\"
- -!endif
- -
- #----------------------------------------------------------
- # Set the proper copy method to avoid overwrite questions
- # to the user when copying files and selecting the right
- @@ -64,6 +52,51 @@ ERRNULL = >NUL # Win9x shell cannot redirect stderr
- !endif
- MKDIR = mkdir
- +#------------------------------------------------------------------------------
- +# Determine the host and target architectures and compiler version.
- +#------------------------------------------------------------------------------
- +
- +_HASH=^#
- +_VC_MANIFEST_EMBED_EXE=
- +_VC_MANIFEST_EMBED_DLL=
- +VCVER=0
- +!if ![echo VCVERSION=_MSC_VER > vercl.x] \
- + && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
- + && ![echo ARCH=IX86 >> vercl.x] \
- + && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
- + && ![echo ARCH=AMD64 >> vercl.x] \
- + && ![echo $(_HASH)endif >> vercl.x] \
- + && ![echo VCVERSION=_MSC_VER >> vercl.x] \
- + && ![cl -nologo -TC -P vercl.x $(ERRNULL)]
- +!include vercl.i
- +!if ![echo VCVER= ^\> vercl.vc] \
- + && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
- +!include vercl.vc
- +!endif
- +!endif
- +!if ![del /q/f vercl.x vercl.i vercl.vc]
- +!endif
- +
- +!if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
- +NATIVE_ARCH=IX86
- +!else
- +NATIVE_ARCH=AMD64
- +!endif
- +
- +# Since MSVC8 we must deal with manifest resources.
- +!if $(VCVERSION) >= 1400
- +_VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1
- +_VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2
- +!endif
- +
- +!ifndef MACHINE
- +MACHINE=$(ARCH)
- +!endif
- +
- +!ifndef CFG_ENCODING
- +CFG_ENCODING = \"cp1252\"
- +!endif
- +
- !message ===============================================================================
- #----------------------------------------------------------
- @@ -176,36 +209,6 @@ LINKERFLAGS =-ltcg
- !endif
- #----------------------------------------------------------
- -# MSVC8 (ships with Visual Studio 2005) generates a manifest
- -# file that we should link into the binaries. This is how.
- -#----------------------------------------------------------
- -
- -_VC_MANIFEST_EMBED_EXE=
- -_VC_MANIFEST_EMBED_DLL=
- -VCVER=0
- -!if ![echo VCVERSION=_MSC_VER > vercl.x] \
- - && ![cl -nologo -TC -P vercl.x $(ERRNULL)]
- -!include vercl.i
- -!if $(VCVERSION) >= 1600
- -VCVER=10
- -!elseif $(VCVERSION) >= 1500
- -VCVER=9
- -!elseif $(VCVERSION) >= 1400
- -VCVER=8
- -!elseif $(VCVERSION) >= 1300
- -VCVER=7
- -!elseif $(VCVERSION) >= 1200
- -VCVER=6
- -!endif
- -!endif
- -
- -# Since MSVC8 we must deal with manifest resources.
- -!if $(VCVERSION) >= 1400
- -_VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1
- -_VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2
- -!endif
- -
- -#----------------------------------------------------------
- # Decode the options requested.
- #----------------------------------------------------------
- @@ -667,6 +670,7 @@ TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
- !message *** Suffix for binaries will be '$(SUFX)'
- !message *** Optional defines are '$(OPTDEFINES)'
- !message *** Compiler version $(VCVER). Target machine is $(MACHINE)
- +!message *** Host architecture is $(NATIVE_ARCH)
- !message *** Compiler options '$(COMPILERFLAGS) $(OPTIMIZATIONS) $(DEBUGFLAGS) $(WARNINGS)'
- !message *** Link options '$(LINKERFLAGS)'
- --
- 1.7.4.msysgit.0