@@ -31,19 +31,31 @@ macro to the name of the project makefile.
3131# We extract version numbers using the nmakehlp program. For now use
3232# the local copy of nmakehlp. Once we locate Tcl, we will use that
3333# one if it is newer.
34- !if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
3534!if [$(CC) -nologo -DNDEBUG "nmakehlp.c" -link -subsystem:console > nul]
3635!endif
37- !else
38- !if [copy x86_64-w64-mingw32-nmakehlp.exe nmakehlp.exe >NUL]
39- !endif
40- !endif
4136
4237# First locate the Tcl directory that we are working with.
4338!if "$(TCLDIR)" != ""
4439
4540_RULESDIR = $(TCLDIR:/=\)
4641
42+ # We need a nmakehlp that will run on the host machine as part of the build.
43+ # if TCLSH_NATIVE is set for cross compilation, we'll try to find an associated
44+ # nmakehlp.exe that runs on the build architecture.
45+ !ifdef TCLSH_NATIVE
46+ !ifndef NMAKEHLP_NATIVE
47+ !if [$(TCLSH_NATIVE) $(TCLDIR)\win\find_nmakehlp.tcl $(TCLSH_NATIVE) > find_nmakehlp.out]
48+ !error TCLSH_NATIVE is set, but unable to find associated nmakehlp.exe nearby.
49+ !else
50+ !include find_nmakehlp.out
51+ !endif
52+ !endif
53+ !endif
54+
55+ !ifndef NMAKEHLP_NATIVE
56+ NMAKEHLP_NATIVE=nmakehlp
57+ !endif
58+
4759!else
4860
4961# If an installation path is specified, that is also the Tcl directory.
@@ -53,7 +65,7 @@ _RULESDIR=$(INSTALLDIR:/=\)
5365!else
5466# Locate Tcl sources
5567!if [echo _RULESDIR = \> nmakehlp.out] \
56- || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
68+ || [$(NMAKEHLP_NATIVE) -L generic\tcl.h >> nmakehlp.out]
5769_RULESDIR = ..\..\tcl
5870!else
5971!include nmakehlp.out
@@ -82,17 +94,17 @@ _RULESDIR = .
8294!if exist("rules.vc") # The extension has its own copy
8395
8496!if [echo TCL_RULES_MAJOR = \> versions.vc] \
85- && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc]
97+ && [$(NMAKEHLP_NATIVE) -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MAJOR >> versions.vc]
8698!endif
8799!if [echo TCL_RULES_MINOR = \>> versions.vc] \
88- && [nmakehlp -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MINOR >> versions.vc]
100+ && [$(NMAKEHLP_NATIVE) -V "$(_RULESDIR)\rules.vc" RULES_VERSION_MINOR >> versions.vc]
89101!endif
90102
91103!if [echo OUR_RULES_MAJOR = \>> versions.vc] \
92- && [nmakehlp -V "rules.vc" RULES_VERSION_MAJOR >> versions.vc]
104+ && [$(NMAKEHLP_NATIVE) -V "rules.vc" RULES_VERSION_MAJOR >> versions.vc]
93105!endif
94106!if [echo OUR_RULES_MINOR = \>> versions.vc] \
95- && [nmakehlp -V "rules.vc" RULES_VERSION_MINOR >> versions.vc]
107+ && [$(NMAKEHLP_NATIVE) -V "rules.vc" RULES_VERSION_MINOR >> versions.vc]
96108!endif
97109!include versions.vc
98110# We have a newer version of the support files, use them
@@ -120,4 +132,4 @@ NMAKEHLPC = $(_RULESDIR)\nmakehlp.c
120132!error *** Could not locate rules.vc in $(_RULESDIR)
121133!endif
122134
123- !endif # _RULES_EXT_VC
135+ !endif # _RULES_EXT_VC
0 commit comments