summaryrefslogtreecommitdiffstats
path: root/win/rules.vc
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2011-04-20 22:13:41 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2011-04-20 22:13:41 (GMT)
commit95c1b15bcdb4d087a64ead65b5b133d07513d5c8 (patch)
treec89445aa64180cf755e799eed6801ff68dc39fb3 /win/rules.vc
parentd2a3e689071f70fd61345d002e2bcc87732049aa (diff)
parent7f792b880aa3a8d14f800a2f2bf5af2df9fe36da (diff)
downloadtcl-95c1b15bcdb4d087a64ead65b5b133d07513d5c8.zip
tcl-95c1b15bcdb4d087a64ead65b5b133d07513d5c8.tar.gz
tcl-95c1b15bcdb4d087a64ead65b5b133d07513d5c8.tar.bz2
Support cross-compilation to x64 from ix86 hosts when using NMAKE.
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>
Diffstat (limited to 'win/rules.vc')
-rw-r--r--win/rules.vc87
1 files changed, 45 insertions, 42 deletions
diff --git a/win/rules.vc b/win/rules.vc
index b502b19..01e44e0 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,50 @@ 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] \
+ && ![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 $(ERRNUL) /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 +208,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.
#----------------------------------------------------------
@@ -698,6 +700,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)'