Skip to content

Commit adf4b36

Browse files
committed
Remove x86_64-w64-mingw32-nmakehlp.exe. In its place, use the NMAKEHLP_NATIVE variable to find an nmakehlp.exe during cross compilation.
2 parents 95278ef + 66ad467 commit adf4b36

4 files changed

Lines changed: 127 additions & 78 deletions

File tree

win/find_nmakehlp.tcl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
if {$argc != 1} {
2+
puts stderr "Usage: [info script] <path-to-tclsh>"
3+
exit 1
4+
}
5+
6+
set tclsh_path [lindex $argv 0]
7+
8+
# Normalize path separators to forward slashes for manipulation
9+
set normalized [file normalize $tclsh_path]
10+
11+
# Get the directory containing the executable (removes bin\tclsh91.exe)
12+
set bin_dir [file dirname $normalized]
13+
set install_dir [file dirname $bin_dir]
14+
15+
# Build the target path: <install_dir>/lib/nmake/nmakehlp.exe
16+
set nmakehlp_path [file nativename [file join $install_dir lib nmake nmakehlp.exe]]
17+
18+
if {[file exists $nmakehlp_path]} {
19+
puts "NMAKEHLP_NATIVE=$nmakehlp_path"
20+
exit 0
21+
} else {
22+
puts stderr "Error: nmakehlp.exe not found at: $nmakehlp_path"
23+
exit 1
24+
}

win/rules-ext.vc

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)