| 1 |
#------------------------------------------------------------- -*- makefile -*- |
| 2 |
# rules.vc -- |
| 3 |
# |
| 4 |
# Part of the nmake based build system for Tcl and its extensions. |
| 5 |
# This file does all the hard work in terms of parsing build options, |
| 6 |
# compiler switches, defining common targets and macros. The Tcl makefile |
| 7 |
# directly includes this. Extensions include it via "rules-ext.vc". |
| 8 |
# |
| 9 |
# See TIP 477 (https://core.tcl-lang.org/tips/doc/main/tip/477.md) for |
| 10 |
# detailed documentation. |
| 11 |
# |
| 12 |
# See the file "license.terms" for information on usage and redistribution |
| 13 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 14 |
# |
| 15 |
# Copyright (c) 2001-2003 David Gravereaux. |
| 16 |
# Copyright (c) 2003-2008 Patrick Thoyts |
| 17 |
# Copyright (c) 2017 Ashok P. Nadkarni |
| 18 |
#------------------------------------------------------------------------------ |
| 19 |
|
| 20 |
!ifndef _RULES_VC |
| 21 |
_RULES_VC = 1 |
| 22 |
|
| 23 |
# The following macros define the version of the rules.vc nmake build system |
| 24 |
# For modifications that are not backward-compatible, you *must* change |
| 25 |
# the major version. |
| 26 |
RULES_VERSION_MAJOR = 1 |
| 27 |
RULES_VERSION_MINOR = 10 |
| 28 |
|
| 29 |
# The PROJECT macro must be defined by parent makefile. |
| 30 |
!if "$(PROJECT)" == "" |
| 31 |
!error *** Error: Macro PROJECT not defined! Please define it before including rules.vc |
| 32 |
!endif |
| 33 |
|
| 34 |
!if "$(PRJ_PACKAGE_TCLNAME)" == "" |
| 35 |
PRJ_PACKAGE_TCLNAME = $(PROJECT) |
| 36 |
!endif |
| 37 |
|
| 38 |
# Also special case Tcl and Tk to save some typing later |
| 39 |
DOING_TCL = 0 |
| 40 |
DOING_TK = 0 |
| 41 |
!if "$(PROJECT)" == "tcl" |
| 42 |
DOING_TCL = 1 |
| 43 |
!elseif "$(PROJECT)" == "tk" |
| 44 |
DOING_TK = 1 |
| 45 |
!endif |
| 46 |
|
| 47 |
!ifndef NEED_TK |
| 48 |
# Backwards compatibility |
| 49 |
!ifdef PROJECT_REQUIRES_TK |
| 50 |
NEED_TK = $(PROJECT_REQUIRES_TK) |
| 51 |
!else |
| 52 |
NEED_TK = 0 |
| 53 |
!endif |
| 54 |
!endif |
| 55 |
|
| 56 |
!ifndef NEED_TCL_SOURCE |
| 57 |
NEED_TCL_SOURCE = 0 |
| 58 |
!endif |
| 59 |
|
| 60 |
!ifdef NEED_TK_SOURCE |
| 61 |
!if $(NEED_TK_SOURCE) |
| 62 |
NEED_TK = 1 |
| 63 |
!endif |
| 64 |
!else |
| 65 |
NEED_TK_SOURCE = 0 |
| 66 |
!endif |
| 67 |
|
| 68 |
################################################################ |
| 69 |
# Nmake is a pretty weak environment in syntax and capabilities |
| 70 |
# so this file is necessarily verbose. It's broken down into |
| 71 |
# the following parts. |
| 72 |
# |
| 73 |
# 0. Sanity check that compiler environment is set up and initialize |
| 74 |
# any built-in settings from the parent makefile |
| 75 |
# 1. First define the external tools used for compiling, copying etc. |
| 76 |
# as this is independent of everything else. |
| 77 |
# 2. Figure out our build structure in terms of the directory, whether |
| 78 |
# we are building Tcl or an extension, etc. |
| 79 |
# 3. Determine the compiler and linker versions |
| 80 |
# 4. Build the nmakehlp helper application |
| 81 |
# 5. Determine the supported compiler options and features |
| 82 |
# 6. Extract Tcl, Tk, and possibly extensions, version numbers from the |
| 83 |
# headers |
| 84 |
# 7. Parse the OPTS macro value for user-specified build configuration |
| 85 |
# 8. Parse the STATS macro value for statistics instrumentation |
| 86 |
# 9. Parse the CHECKS macro for additional compilation checks |
| 87 |
# 10. Based on this selected configuration, construct the output |
| 88 |
# directory and file paths |
| 89 |
# 11. Construct the paths where the package is to be installed |
| 90 |
# 12. Set up the actual options passed to compiler and linker based |
| 91 |
# on the information gathered above. |
| 92 |
# 13. Define some standard build targets and implicit rules. These may |
| 93 |
# be optionally disabled by the parent makefile. |
| 94 |
# 14. (For extensions only.) Compare the configuration of the target |
| 95 |
# Tcl and the extensions and warn against discrepancies. |
| 96 |
# |
| 97 |
# One final note about the macro names used. They are as they are |
| 98 |
# for historical reasons. We would like legacy extensions to |
| 99 |
# continue to work with this make include file so be wary of |
| 100 |
# changing them for consistency or clarity. |
| 101 |
|
| 102 |
# 0. Sanity check compiler environment |
| 103 |
|
| 104 |
# Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or |
| 105 |
# VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir) |
| 106 |
|
| 107 |
!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR) |
| 108 |
MSG = ^ |
| 109 |
Visual C++ compiler environment not initialized. |
| 110 |
!error $(MSG) |
| 111 |
!endif |
| 112 |
|
| 113 |
# We need to run from the directory the parent makefile is located in. |
| 114 |
# nmake does not tell us what makefile was used to invoke it so parent |
| 115 |
# makefile has to set the MAKEFILEVC macro or we just make a guess and |
| 116 |
# warn if we think that is not the case. |
| 117 |
!if "$(MAKEFILEVC)" == "" |
| 118 |
|
| 119 |
!if exist("$(PROJECT).vc") |
| 120 |
MAKEFILEVC = $(PROJECT).vc |
| 121 |
!elseif exist("makefile.vc") |
| 122 |
MAKEFILEVC = makefile.vc |
| 123 |
!endif |
| 124 |
!endif # "$(MAKEFILEVC)" == "" |
| 125 |
|
| 126 |
!if !exist("$(MAKEFILEVC)") |
| 127 |
MSG = ^ |
| 128 |
You must run nmake from the directory containing the project makefile.^ |
| 129 |
If you are doing that and getting this message, set the MAKEFILEVC^ |
| 130 |
macro to the name of the project makefile. |
| 131 |
!message WARNING: $(MSG) |
| 132 |
!endif |
| 133 |
|
| 134 |
|
| 135 |
################################################################ |
| 136 |
# 1. Define external programs being used |
| 137 |
|
| 138 |
#---------------------------------------------------------- |
| 139 |
# Set the proper copy method to avoid overwrite questions |
| 140 |
# to the user when copying files and selecting the right |
| 141 |
# "delete all" method. |
| 142 |
#---------------------------------------------------------- |
| 143 |
# Tcl Bug be40b736: use rd/md instead rmdir/mkdir. |
| 144 |
# Otherwise, an eventual cygwin version with different |
| 145 |
# parameters may be used. |
| 146 |
#---------------------------------------------------------- |
| 147 |
|
| 148 |
RMDIR = rd /S /Q |
| 149 |
CPY = xcopy /i /y >NUL |
| 150 |
CPYDIR = xcopy /e /i /y >NUL |
| 151 |
COPY = copy /y >NUL |
| 152 |
MKDIR = md |
| 153 |
|
| 154 |
###################################################################### |
| 155 |
# 2. Figure out our build environment in terms of what we're building. |
| 156 |
# |
| 157 |
# (a) Tcl itself |
| 158 |
# (b) Tk |
| 159 |
# (c) a Tcl extension using libraries/includes from an *installed* Tcl |
| 160 |
# (d) a Tcl extension using libraries/includes from Tcl source directory |
| 161 |
# |
| 162 |
# This last is needed because some extensions still need |
| 163 |
# some Tcl interfaces that are not publicly exposed. |
| 164 |
# |
| 165 |
# The fragment will set the following macros: |
| 166 |
# ROOT - root of this module sources |
| 167 |
# COMPATDIR - source directory that holds compatibility sources |
| 168 |
# DOCDIR - source directory containing documentation files |
| 169 |
# GENERICDIR - platform-independent source directory |
| 170 |
# WIN_DIR - Windows-specific source directory |
| 171 |
# TESTDIR - directory containing test files |
| 172 |
# TOOLSDIR - directory containing build tools |
| 173 |
# _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set |
| 174 |
# when building Tcl itself. |
| 175 |
# _INSTALLDIR - native form of the installation path. For Tcl |
| 176 |
# this will be the root of the Tcl installation. For extensions |
| 177 |
# this will be the lib directory under the root. |
| 178 |
# TCLINSTALL - set to 1 if _TCLDIR refers to |
| 179 |
# headers and libraries from an installed Tcl, and 0 if built against |
| 180 |
# Tcl sources. Not set when building Tcl itself. Yes, not very well |
| 181 |
# named. |
| 182 |
# _TCL_H - native path to the tcl.h file |
| 183 |
# |
| 184 |
# If Tk is involved, also sets the following |
| 185 |
# _TKDIR - native form Tk installation OR Tk source. Not set if building |
| 186 |
# Tk itself. |
| 187 |
# TKINSTALL - set 1 if _TKDIR refers to installed Tk and 0 if Tk sources |
| 188 |
# _TK_H - native path to the tk.h file |
| 189 |
|
| 190 |
# Root directory for sources and assumed subdirectories |
| 191 |
ROOT = $(MAKEDIR)\.. |
| 192 |
# The following paths CANNOT have spaces in them as they appear on the |
| 193 |
# left side of implicit rules. |
| 194 |
!ifndef COMPATDIR |
| 195 |
COMPATDIR = $(ROOT)\compat |
| 196 |
!endif |
| 197 |
!ifndef DOCDIR |
| 198 |
DOCDIR = $(ROOT)\doc |
| 199 |
!endif |
| 200 |
!ifndef GENERICDIR |
| 201 |
GENERICDIR = $(ROOT)\generic |
| 202 |
!endif |
| 203 |
!ifndef TOOLSDIR |
| 204 |
TOOLSDIR = $(ROOT)\tools |
| 205 |
!endif |
| 206 |
!ifndef TESTDIR |
| 207 |
TESTDIR = $(ROOT)\tests |
| 208 |
!endif |
| 209 |
!ifndef LIBDIR |
| 210 |
!if exist("$(ROOT)\library") |
| 211 |
LIBDIR = $(ROOT)\library |
| 212 |
!else |
| 213 |
LIBDIR = $(ROOT)\lib |
| 214 |
!endif |
| 215 |
!endif |
| 216 |
!ifndef DEMODIR |
| 217 |
!if exist("$(LIBDIR)\demos") |
| 218 |
DEMODIR = $(LIBDIR)\demos |
| 219 |
!else |
| 220 |
DEMODIR = $(ROOT)\demos |
| 221 |
!endif |
| 222 |
!endif # ifndef DEMODIR |
| 223 |
# Do NOT use WINDIR because it is Windows internal environment |
| 224 |
# variable to point to c:\windows! |
| 225 |
WIN_DIR = $(ROOT)\win |
| 226 |
|
| 227 |
!ifndef RCDIR |
| 228 |
!if exist("$(WIN_DIR)\rc") |
| 229 |
RCDIR = $(WIN_DIR)\rc |
| 230 |
!else |
| 231 |
RCDIR = $(WIN_DIR) |
| 232 |
!endif |
| 233 |
!endif |
| 234 |
RCDIR = $(RCDIR:/=\) |
| 235 |
|
| 236 |
# The target directory where the built packages and binaries will be installed. |
| 237 |
# INSTALLDIR is the (optional) path specified by the user. |
| 238 |
# _INSTALLDIR is INSTALLDIR using the backslash separator syntax |
| 239 |
!ifdef INSTALLDIR |
| 240 |
### Fix the path separators. |
| 241 |
_INSTALLDIR = $(INSTALLDIR:/=\) |
| 242 |
!else |
| 243 |
### Assume the normal default. |
| 244 |
_INSTALLDIR = $(HOMEDRIVE)\Tcl |
| 245 |
!endif |
| 246 |
|
| 247 |
!if $(DOING_TCL) |
| 248 |
|
| 249 |
# BEGIN Case 2(a) - Building Tcl itself |
| 250 |
|
| 251 |
# Only need to define _TCL_H |
| 252 |
_TCL_H = ..\generic\tcl.h |
| 253 |
|
| 254 |
# END Case 2(a) - Building Tcl itself |
| 255 |
|
| 256 |
!elseif $(DOING_TK) |
| 257 |
|
| 258 |
# BEGIN Case 2(b) - Building Tk |
| 259 |
|
| 260 |
TCLINSTALL = 0 # Tk always builds against Tcl source, not an installed Tcl |
| 261 |
!if "$(TCLDIR)" == "" |
| 262 |
!if [echo TCLDIR = \> nmakehlp.out] \ |
| 263 |
|| [nmakehlp -L generic\tcl.h >> nmakehlp.out] |
| 264 |
!error *** Could not locate Tcl source directory. |
| 265 |
!endif |
| 266 |
!include nmakehlp.out |
| 267 |
!endif # TCLDIR == "" |
| 268 |
|
| 269 |
_TCLDIR = $(TCLDIR:/=\) |
| 270 |
_TCL_H = $(_TCLDIR)\generic\tcl.h |
| 271 |
!if !exist("$(_TCL_H)") |
| 272 |
!error Could not locate tcl.h. Please set the TCLDIR macro to point to the Tcl *source* directory. |
| 273 |
!endif |
| 274 |
|
| 275 |
_TK_H = ..\generic\tk.h |
| 276 |
|
| 277 |
# END Case 2(b) - Building Tk |
| 278 |
|
| 279 |
!else |
| 280 |
|
| 281 |
# BEGIN Case 2(c) or (d) - Building an extension other than Tk |
| 282 |
|
| 283 |
# If command line has specified Tcl location through TCLDIR, use it |
| 284 |
# else default to the INSTALLDIR setting |
| 285 |
!if "$(TCLDIR)" != "" |
| 286 |
|
| 287 |
_TCLDIR = $(TCLDIR:/=\) |
| 288 |
!if exist("$(_TCLDIR)\include\tcl.h") # Case 2(c) with TCLDIR defined |
| 289 |
TCLINSTALL = 1 |
| 290 |
_TCL_H = $(_TCLDIR)\include\tcl.h |
| 291 |
!elseif exist("$(_TCLDIR)\generic\tcl.h") # Case 2(d) with TCLDIR defined |
| 292 |
TCLINSTALL = 0 |
| 293 |
_TCL_H = $(_TCLDIR)\generic\tcl.h |
| 294 |
!endif |
| 295 |
|
| 296 |
!else # # Case 2(c) for extensions with TCLDIR undefined |
| 297 |
|
| 298 |
# Need to locate Tcl depending on whether it needs Tcl source or not. |
| 299 |
# If we don't, check the INSTALLDIR for an installed Tcl first |
| 300 |
|
| 301 |
!if exist("$(_INSTALLDIR)\include\tcl.h") && !$(NEED_TCL_SOURCE) |
| 302 |
|
| 303 |
TCLINSTALL = 1 |
| 304 |
TCLDIR = $(_INSTALLDIR)\.. |
| 305 |
# NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions |
| 306 |
# later so the \.. accounts for the /lib |
| 307 |
_TCLDIR = $(_INSTALLDIR)\.. |
| 308 |
_TCL_H = $(_TCLDIR)\include\tcl.h |
| 309 |
|
| 310 |
!else # exist(...) && !$(NEED_TCL_SOURCE) |
| 311 |
|
| 312 |
!if [echo _TCLDIR = \> nmakehlp.out] \ |
| 313 |
|| [nmakehlp -L generic\tcl.h >> nmakehlp.out] |
| 314 |
!error *** Could not locate Tcl source directory. |
| 315 |
!endif |
| 316 |
!include nmakehlp.out |
| 317 |
TCLINSTALL = 0 |
| 318 |
TCLDIR = $(_TCLDIR) |
| 319 |
_TCL_H = $(_TCLDIR)\generic\tcl.h |
| 320 |
|
| 321 |
!endif # exist(...) && !$(NEED_TCL_SOURCE) |
| 322 |
|
| 323 |
!endif # TCLDIR |
| 324 |
|
| 325 |
!ifndef _TCL_H |
| 326 |
MSG =^ |
| 327 |
Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and default path does not contain tcl.h. |
| 328 |
!error $(MSG) |
| 329 |
!endif |
| 330 |
|
| 331 |
# Now do the same to locate Tk headers and libs if project requires Tk |
| 332 |
!if $(NEED_TK) |
| 333 |
|
| 334 |
!if "$(TKDIR)" != "" |
| 335 |
|
| 336 |
_TKDIR = $(TKDIR:/=\) |
| 337 |
!if exist("$(_TKDIR)\include\tk.h") |
| 338 |
TKINSTALL = 1 |
| 339 |
_TK_H = $(_TKDIR)\include\tk.h |
| 340 |
!elseif exist("$(_TKDIR)\generic\tk.h") |
| 341 |
TKINSTALL = 0 |
| 342 |
_TK_H = $(_TKDIR)\generic\tk.h |
| 343 |
!endif |
| 344 |
|
| 345 |
!else # TKDIR not defined |
| 346 |
|
| 347 |
# Need to locate Tcl depending on whether it needs Tcl source or not. |
| 348 |
# If we don't, check the INSTALLDIR for an installed Tcl first |
| 349 |
|
| 350 |
!if exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE) |
| 351 |
|
| 352 |
TKINSTALL = 1 |
| 353 |
# NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions |
| 354 |
# later so the \.. accounts for the /lib |
| 355 |
_TKDIR = $(_INSTALLDIR)\.. |
| 356 |
_TK_H = $(_TKDIR)\include\tk.h |
| 357 |
TKDIR = $(_TKDIR) |
| 358 |
|
| 359 |
!else # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE) |
| 360 |
|
| 361 |
!if [echo _TKDIR = \> nmakehlp.out] \ |
| 362 |
|| [nmakehlp -L generic\tk.h >> nmakehlp.out] |
| 363 |
!error *** Could not locate Tk source directory. |
| 364 |
!endif |
| 365 |
!include nmakehlp.out |
| 366 |
TKINSTALL = 0 |
| 367 |
TKDIR = $(_TKDIR) |
| 368 |
_TK_H = $(_TKDIR)\generic\tk.h |
| 369 |
|
| 370 |
!endif # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE) |
| 371 |
|
| 372 |
!endif # TKDIR |
| 373 |
|
| 374 |
!ifndef _TK_H |
| 375 |
MSG =^ |
| 376 |
Failed to find tk.h. The TKDIR macro is set incorrectly or is not set and default path does not contain tk.h. |
| 377 |
!error $(MSG) |
| 378 |
!endif |
| 379 |
|
| 380 |
!endif # NEED_TK |
| 381 |
|
| 382 |
!if $(NEED_TCL_SOURCE) && $(TCLINSTALL) |
| 383 |
MSG = ^ |
| 384 |
*** Warning: This extension requires the source distribution of Tcl.^ |
| 385 |
*** Please set the TCLDIR macro to point to the Tcl sources. |
| 386 |
!error $(MSG) |
| 387 |
!endif |
| 388 |
|
| 389 |
!if $(NEED_TK_SOURCE) |
| 390 |
!if $(TKINSTALL) |
| 391 |
MSG = ^ |
| 392 |
*** Warning: This extension requires the source distribution of Tk.^ |
| 393 |
*** Please set the TKDIR macro to point to the Tk sources. |
| 394 |
!error $(MSG) |
| 395 |
!endif |
| 396 |
!endif |
| 397 |
|
| 398 |
|
| 399 |
# If INSTALLDIR set to Tcl installation root dir then reset to the |
| 400 |
# lib dir for installing extensions |
| 401 |
!if exist("$(_INSTALLDIR)\include\tcl.h") |
| 402 |
_INSTALLDIR=$(_INSTALLDIR)\lib |
| 403 |
!endif |
| 404 |
|
| 405 |
# END Case 2(c) or (d) - Building an extension |
| 406 |
!endif # if $(DOING_TCL) |
| 407 |
|
| 408 |
################################################################ |
| 409 |
# 3. Determine compiler version and architecture |
| 410 |
# In this section, we figure out the compiler version and the |
| 411 |
# architecture for which we are building. This sets the |
| 412 |
# following macros: |
| 413 |
# VCVERSION - the internal compiler version as 1200, 1400, 1910 etc. |
| 414 |
# This is also printed by the compiler in dotted form 19.10 etc. |
| 415 |
# VCVER - the "marketing version", for example Visual C++ 6 for internal |
| 416 |
# compiler version 1200. This is kept only for legacy reasons as it |
| 417 |
# does not make sense for recent Microsoft compilers. Only used for |
| 418 |
# output directory names. |
| 419 |
# ARCH - set to IX86, ARM64 or AMD64 depending on 32- or 64-bit target |
| 420 |
# NATIVE_ARCH - set to IX86, ARM64 or AMD64 for the host machine |
| 421 |
# MACHINE - same as $(ARCH) - legacy |
| 422 |
# _VC_MANIFEST_EMBED_{DLL,EXE} - commands for embedding a manifest if needed |
| 423 |
|
| 424 |
cc32 = $(CC) # built-in default. |
| 425 |
link32 = link |
| 426 |
lib32 = lib |
| 427 |
rc32 = $(RC) # built-in default. |
| 428 |
|
| 429 |
#---------------------------------------------------------------- |
| 430 |
# Figure out the compiler architecture and version by writing |
| 431 |
# the C macros to a file, preprocessing them with the C |
| 432 |
# preprocessor and reading back the created file |
| 433 |
|
| 434 |
_HASH=^# |
| 435 |
_VC_MANIFEST_EMBED_EXE= |
| 436 |
_VC_MANIFEST_EMBED_DLL= |
| 437 |
VCVER=0 |
| 438 |
!if ![echo VCVERSION=_MSC_VER > vercl.x] \ |
| 439 |
&& ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \ |
| 440 |
&& ![echo ARCH=IX86 >> vercl.x] \ |
| 441 |
&& ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \ |
| 442 |
&& ![echo ARCH=AMD64 >> vercl.x] \ |
| 443 |
&& ![echo $(_HASH)elif defined(_M_ARM64) >> vercl.x] \ |
| 444 |
&& ![echo ARCH=ARM64 >> vercl.x] \ |
| 445 |
&& ![echo $(_HASH)endif >> vercl.x] \ |
| 446 |
&& ![$(cc32) -nologo -TC -P vercl.x 2>NUL] |
| 447 |
!include vercl.i |
| 448 |
!if $(VCVERSION) < 1900 |
| 449 |
!if ![echo VCVER= ^\> vercl.vc] \ |
| 450 |
&& ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc] |
| 451 |
!include vercl.vc |
| 452 |
!endif |
| 453 |
!else |
| 454 |
# The simple calculation above does not apply to new Visual Studio releases |
| 455 |
# Keep the compiler version in its native form. |
| 456 |
VCVER = $(VCVERSION) |
| 457 |
!endif |
| 458 |
!endif |
| 459 |
|
| 460 |
!if ![del 2>NUL /q/f vercl.x vercl.i vercl.vc] |
| 461 |
!endif |
| 462 |
|
| 463 |
#---------------------------------------------------------------- |
| 464 |
# The MACHINE macro is used by legacy makefiles so set it as well |
| 465 |
!ifdef MACHINE |
| 466 |
!if "$(MACHINE)" == "x86" |
| 467 |
!undef MACHINE |
| 468 |
MACHINE = IX86 |
| 469 |
!elseif "$(MACHINE)" == "arm64" |
| 470 |
!undef MACHINE |
| 471 |
MACHINE = ARM64 |
| 472 |
!elseif "$(MACHINE)" == "x64" |
| 473 |
!undef MACHINE |
| 474 |
MACHINE = AMD64 |
| 475 |
!endif |
| 476 |
!if "$(MACHINE)" != "$(ARCH)" |
| 477 |
!error Specified MACHINE macro $(MACHINE) does not match detected target architecture $(ARCH). |
| 478 |
!endif |
| 479 |
!else |
| 480 |
MACHINE=$(ARCH) |
| 481 |
!endif |
| 482 |
|
| 483 |
#--------------------------------------------------------------- |
| 484 |
# The PLATFORM_IDENTIFY macro matches the values returned by |
| 485 |
# the Tcl platform::identify command |
| 486 |
!if "$(MACHINE)" == "AMD64" |
| 487 |
PLATFORM_IDENTIFY = win32-x86_64 |
| 488 |
!elseif "$(MACHINE)" == "ARM64" |
| 489 |
PLATFORM_IDENTIFY = win32-arm |
| 490 |
!else |
| 491 |
PLATFORM_IDENTIFY = win32-ix86 |
| 492 |
!endif |
| 493 |
|
| 494 |
# The MULTIPLATFORM macro controls whether binary extensions are installed |
| 495 |
# in platform-specific directories. Intended to be set/used by extensions. |
| 496 |
!ifndef MULTIPLATFORM_INSTALL |
| 497 |
MULTIPLATFORM_INSTALL = 0 |
| 498 |
!endif |
| 499 |
|
| 500 |
#------------------------------------------------------------ |
| 501 |
# Figure out the *host* architecture by reading the registry |
| 502 |
|
| 503 |
!if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86] |
| 504 |
NATIVE_ARCH=IX86 |
| 505 |
!elseif ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i ARM | findstr /i 64-bit] |
| 506 |
NATIVE_ARCH=ARM64 |
| 507 |
!else |
| 508 |
NATIVE_ARCH=AMD64 |
| 509 |
!endif |
| 510 |
|
| 511 |
# Since MSVC8 we must deal with manifest resources. |
| 512 |
!if $(VCVERSION) >= 1400 |
| 513 |
_VC_MANIFEST_EMBED_EXE=if exist [email protected] mt -nologo -manifest [email protected] -outputresource:$@;1 |
| 514 |
_VC_MANIFEST_EMBED_DLL=if exist [email protected] mt -nologo -manifest [email protected] -outputresource:$@;2 |
| 515 |
!endif |
| 516 |
|
| 517 |
################################################################ |
| 518 |
# 4. Build the nmakehlp program |
| 519 |
# This is a helper app we need to overcome nmake's limiting |
| 520 |
# environment. We will call out to it to get various bits of |
| 521 |
# information about supported compiler options etc. |
| 522 |
# |
| 523 |
# Tcl itself will always use the nmakehlp.c program which is |
| 524 |
# in its own source. It will be kept updated there. |
| 525 |
# |
| 526 |
# Extensions built against an installed Tcl will use the installed |
| 527 |
# copy of Tcl's nmakehlp.c if there is one and their own version |
| 528 |
# otherwise. In the latter case, they would also be using their own |
| 529 |
# rules.vc. Note that older versions of Tcl do not install nmakehlp.c |
| 530 |
# or rules.vc. |
| 531 |
# |
| 532 |
# Extensions built against Tcl sources will use the one from the Tcl source. |
| 533 |
# |
| 534 |
# When building an extension using a sufficiently new version of Tcl, |
| 535 |
# rules-ext.vc will define NMAKEHLPC appropriately to point to the |
| 536 |
# copy of nmakehlp.c to be used. |
| 537 |
|
| 538 |
!ifndef NMAKEHLPC |
| 539 |
# Default to the one in the current directory (the extension's own nmakehlp.c) |
| 540 |
NMAKEHLPC = nmakehlp.c |
| 541 |
|
| 542 |
!if !$(DOING_TCL) |
| 543 |
!if $(TCLINSTALL) |
| 544 |
!if exist("$(_TCLDIR)\lib\nmake\nmakehlp.c") |
| 545 |
NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c |
| 546 |
!endif |
| 547 |
!else # !$(TCLINSTALL) |
| 548 |
!if exist("$(_TCLDIR)\win\nmakehlp.c") |
| 549 |
NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c |
| 550 |
!endif |
| 551 |
!endif # $(TCLINSTALL) |
| 552 |
!endif # !$(DOING_TCL) |
| 553 |
|
| 554 |
!endif # NMAKEHLPC |
| 555 |
|
| 556 |
# We always build nmakehlp even if it exists since we do not know |
| 557 |
# what source it was built from. |
| 558 |
!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)" |
| 559 |
!if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul] |
| 560 |
!endif |
| 561 |
!else |
| 562 |
!if [copy $(NMAKEHLPC:nmakehlp.c=x86_64-w64-mingw32-nmakehlp.exe) nmakehlp.exe >NUL] |
| 563 |
!endif |
| 564 |
!endif |
| 565 |
|
| 566 |
################################################################ |
| 567 |
# 5. Test for compiler features |
| 568 |
# Visual C++ compiler options have changed over the years. Check |
| 569 |
# which options are supported by the compiler in use. |
| 570 |
# |
| 571 |
# The following macros are set: |
| 572 |
# OPTIMIZATIONS - the compiler flags to be used for optimized builds |
| 573 |
# DEBUGFLAGS - the compiler flags to be used for debug builds |
| 574 |
# LINKERFLAGS - Flags passed to the linker |
| 575 |
# |
| 576 |
# Note that these are the compiler settings *available*, not those |
| 577 |
# that will be *used*. The latter depends on the OPTS macro settings |
| 578 |
# which we have not yet parsed. |
| 579 |
# |
| 580 |
# Also note that some of the flags in OPTIMIZATIONS are not really |
| 581 |
# related to optimization. They are placed there only for legacy reasons |
| 582 |
# as some extensions expect them to be included in that macro. |
| 583 |
|
| 584 |
# -Op improves float consistency. Note only needed for older compilers |
| 585 |
# Newer compilers do not need or support this option. |
| 586 |
!if [nmakehlp -c -Op] |
| 587 |
FPOPTS = -Op |
| 588 |
!endif |
| 589 |
|
| 590 |
# Strict floating point semantics - present in newer compilers in lieu of -Op |
| 591 |
!if [nmakehlp -c -fp:strict] |
| 592 |
FPOPTS = $(FPOPTS) -fp:strict |
| 593 |
!endif |
| 594 |
|
| 595 |
!if "$(MACHINE)" == "IX86" |
| 596 |
### test for pentium errata |
| 597 |
!if [nmakehlp -c -QI0f] |
| 598 |
!message *** Compiler has 'Pentium 0x0f fix' |
| 599 |
FPOPTS = $(FPOPTS) -QI0f |
| 600 |
!else |
| 601 |
!message *** Compiler does not have 'Pentium 0x0f fix' |
| 602 |
!endif |
| 603 |
!endif |
| 604 |
|
| 605 |
### test for optimizations |
| 606 |
# /O2 optimization includes /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy as per |
| 607 |
# documentation. Note we do NOT want /Gs as that inserts a _chkstk |
| 608 |
# stack probe at *every* function entry, not just those with more than |
| 609 |
# a page of stack allocation resulting in a performance hit. However, |
| 610 |
# /O2 documentation is misleading as its stack probes are simply the |
| 611 |
# default page size locals allocation probes and not what is implied |
| 612 |
# by an explicit /Gs option. |
| 613 |
|
| 614 |
OPTIMIZATIONS = $(FPOPTS) |
| 615 |
|
| 616 |
!if [nmakehlp -c -O2] |
| 617 |
OPTIMIZING = 1 |
| 618 |
OPTIMIZATIONS = $(OPTIMIZATIONS) -O2 |
| 619 |
!else |
| 620 |
# Legacy, really. All modern compilers support this |
| 621 |
!message *** Compiler does not have 'Optimizations' |
| 622 |
OPTIMIZING = 0 |
| 623 |
!endif |
| 624 |
|
| 625 |
# Checks for buffer overflows in local arrays |
| 626 |
!if [nmakehlp -c -GS] |
| 627 |
OPTIMIZATIONS = $(OPTIMIZATIONS) -GS |
| 628 |
!endif |
| 629 |
|
| 630 |
# Link time optimization. Note that this option (potentially) makes |
| 631 |
# generated libraries only usable by the specific VC++ version that |
| 632 |
# created it. Requires /LTCG linker option |
| 633 |
!if [nmakehlp -c -GL] |
| 634 |
OPTIMIZATIONS = $(OPTIMIZATIONS) -GL |
| 635 |
CC_GL_OPT_ENABLED = 1 |
| 636 |
!else |
| 637 |
# In newer compilers -GL and -YX are incompatible. |
| 638 |
!if [nmakehlp -c -YX] |
| 639 |
OPTIMIZATIONS = $(OPTIMIZATIONS) -YX |
| 640 |
!endif |
| 641 |
!endif # [nmakehlp -c -GL] |
| 642 |
|
| 643 |
DEBUGFLAGS = $(FPOPTS) |
| 644 |
|
| 645 |
# Run time error checks. Not available or valid in a release, non-debug build |
| 646 |
# RTC is for modern compilers, -GZ is legacy |
| 647 |
!if [nmakehlp -c -RTC1] |
| 648 |
DEBUGFLAGS = $(DEBUGFLAGS) -RTC1 |
| 649 |
!elseif [nmakehlp -c -GZ] |
| 650 |
DEBUGFLAGS = $(DEBUGFLAGS) -GZ |
| 651 |
!endif |
| 652 |
|
| 653 |
#---------------------------------------------------------------- |
| 654 |
# Linker flags |
| 655 |
|
| 656 |
# LINKER_TESTFLAGS are for internal use when we call nmakehlp to test |
| 657 |
# if the linker supports a specific option. Without these flags link will |
| 658 |
# return "LNK1561: entry point must be defined" error compiling from VS-IDE: |
| 659 |
# They are not passed through to the actual application / extension |
| 660 |
# link rules. |
| 661 |
!ifndef LINKER_TESTFLAGS |
| 662 |
LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmakehlp.out |
| 663 |
!endif |
| 664 |
|
| 665 |
LINKERFLAGS = |
| 666 |
|
| 667 |
# If compiler has enabled link time optimization, linker must too with -ltcg |
| 668 |
!ifdef CC_GL_OPT_ENABLED |
| 669 |
!if [nmakehlp -l -ltcg $(LINKER_TESTFLAGS)] |
| 670 |
LINKERFLAGS = $(LINKERFLAGS) -ltcg |
| 671 |
!endif |
| 672 |
!endif |
| 673 |
|
| 674 |
|
| 675 |
################################################################ |
| 676 |
# 6. Extract various version numbers from headers |
| 677 |
# For Tcl and Tk, version numbers are extracted from tcl.h and tk.h |
| 678 |
# respectively. For extensions, versions are extracted from the |
| 679 |
# configure.in or configure.ac from the TEA configuration if it |
| 680 |
# exists, and unset otherwise. |
| 681 |
# Sets the following macros: |
| 682 |
# TCL_MAJOR_VERSION |
| 683 |
# TCL_MINOR_VERSION |
| 684 |
# TCL_RELEASE_SERIAL |
| 685 |
# TCL_PATCH_LEVEL |
| 686 |
# TCL_PATCH_LETTER |
| 687 |
# TCL_VERSION |
| 688 |
# TK_MAJOR_VERSION |
| 689 |
# TK_MINOR_VERSION |
| 690 |
# TK_RELEASE_SERIAL |
| 691 |
# TK_PATCH_LEVEL |
| 692 |
# TK_PATCH_LETTER |
| 693 |
# TK_VERSION |
| 694 |
# DOTVERSION - set as (for example) 2.5 |
| 695 |
# VERSION - set as (for example 25) |
| 696 |
#-------------------------------------------------------------- |
| 697 |
|
| 698 |
!if [echo REM = This file is generated from rules.vc > versions.vc] |
| 699 |
!endif |
| 700 |
!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \ |
| 701 |
&& [nmakehlp -V "$(_TCL_H)" "define TCL_MAJOR_VERSION" >> versions.vc] |
| 702 |
!endif |
| 703 |
!if [echo TCL_MINOR_VERSION = \>> versions.vc] \ |
| 704 |
&& [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc] |
| 705 |
!endif |
| 706 |
!if [echo TCL_RELEASE_SERIAL = \>> versions.vc] \ |
| 707 |
&& [nmakehlp -V "$(_TCL_H)" TCL_RELEASE_SERIAL >> versions.vc] |
| 708 |
!endif |
| 709 |
!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \ |
| 710 |
&& [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc] |
| 711 |
!endif |
| 712 |
|
| 713 |
!if defined(_TK_H) |
| 714 |
!if [echo TK_MAJOR_VERSION = \>> versions.vc] \ |
| 715 |
&& [nmakehlp -V $(_TK_H) "define TK_MAJOR_VERSION" >> versions.vc] |
| 716 |
!endif |
| 717 |
!if [echo TK_MINOR_VERSION = \>> versions.vc] \ |
| 718 |
&& [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc] |
| 719 |
!endif |
| 720 |
!if [echo TK_RELEASE_SERIAL = \>> versions.vc] \ |
| 721 |
&& [nmakehlp -V "$(_TK_H)" TK_RELEASE_SERIAL >> versions.vc] |
| 722 |
!endif |
| 723 |
!if [echo TK_PATCH_LEVEL = \>> versions.vc] \ |
| 724 |
&& [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc] |
| 725 |
!endif |
| 726 |
!endif # _TK_H |
| 727 |
|
| 728 |
!include versions.vc |
| 729 |
|
| 730 |
TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION) |
| 731 |
TCL_DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) |
| 732 |
!if [nmakehlp -f $(TCL_PATCH_LEVEL) "a"] |
| 733 |
TCL_PATCH_LETTER = a |
| 734 |
!elseif [nmakehlp -f $(TCL_PATCH_LEVEL) "b"] |
| 735 |
TCL_PATCH_LETTER = b |
| 736 |
!else |
| 737 |
TCL_PATCH_LETTER = . |
| 738 |
!endif |
| 739 |
|
| 740 |
!if defined(_TK_H) |
| 741 |
|
| 742 |
TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION) |
| 743 |
TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION) |
| 744 |
!if [nmakehlp -f $(TK_PATCH_LEVEL) "a"] |
| 745 |
TK_PATCH_LETTER = a |
| 746 |
!elseif [nmakehlp -f $(TK_PATCH_LEVEL) "b"] |
| 747 |
TK_PATCH_LETTER = b |
| 748 |
!else |
| 749 |
TK_PATCH_LETTER = . |
| 750 |
!endif |
| 751 |
|
| 752 |
!endif |
| 753 |
|
| 754 |
# Set DOTVERSION and VERSION |
| 755 |
!if $(DOING_TCL) |
| 756 |
|
| 757 |
DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) |
| 758 |
VERSION = $(TCL_VERSION) |
| 759 |
|
| 760 |
!elseif $(DOING_TK) |
| 761 |
|
| 762 |
DOTVERSION = $(TK_DOTVERSION) |
| 763 |
VERSION = $(TK_VERSION) |
| 764 |
|
| 765 |
!else # Doing a non-Tk extension |
| 766 |
|
| 767 |
# If parent makefile has not defined DOTVERSION, try to get it from TEA |
| 768 |
# first from a configure.in file, and then from configure.ac |
| 769 |
!ifndef DOTVERSION |
| 770 |
!if [echo DOTVERSION = \> versions.vc] \ |
| 771 |
|| [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc] |
| 772 |
!if [echo DOTVERSION = \> versions.vc] \ |
| 773 |
|| [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc] |
| 774 |
!error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc. |
| 775 |
!endif |
| 776 |
!endif |
| 777 |
!include versions.vc |
| 778 |
!endif # DOTVERSION |
| 779 |
VERSION = $(DOTVERSION:.=) |
| 780 |
|
| 781 |
!endif # $(DOING_TCL) ... etc. |
| 782 |
|
| 783 |
# Windows RC files have 3 version components. Ensure this irrespective |
| 784 |
# of how many components the package has specified. Basically, ensure |
| 785 |
# minimum 4 components by appending 4 0's and then pick out the first 4. |
| 786 |
# Also take care of the fact that DOTVERSION may have "a" or "b" instead |
| 787 |
# of "." separating the version components. |
| 788 |
DOTSEPARATED=$(DOTVERSION:a=.) |
| 789 |
DOTSEPARATED=$(DOTSEPARATED:b=.) |
| 790 |
!if [echo RCCOMMAVERSION = \> versions.vc] \ |
| 791 |
|| [for /f "tokens=1,2,3,4,5* delims=." %a in ("$(DOTSEPARATED).0.0.0.0") do echo %a,%b,%c,%d >> versions.vc] |
| 792 |
!error *** Could not generate RCCOMMAVERSION *** |
| 793 |
!endif |
| 794 |
!include versions.vc |
| 795 |
|
| 796 |
######################################################################## |
| 797 |
# 7. Parse the OPTS macro to work out the requested build configuration. |
| 798 |
# Based on this, we will construct the actual switches to be passed to the |
| 799 |
# compiler and linker using the macros defined in the previous section. |
| 800 |
# The following macros are defined by this section based on OPTS |
| 801 |
# STATIC_BUILD - 0 -> Tcl is to be built as a shared library |
| 802 |
# 1 -> build as a static library and shell |
| 803 |
# TCL_THREADS - legacy but always 1 on Windows since winsock requires it. |
| 804 |
# DEBUG - 1 -> debug build, 0 -> release builds |
| 805 |
# SYMBOLS - 1 -> generate PDB's, 0 -> no PDB's |
| 806 |
# PROFILE - 1 -> generate profiling info, 0 -> no profiling |
| 807 |
# PGO - 1 -> profile based optimization, 0 -> no |
| 808 |
# MSVCRT - 1 -> link to dynamic C runtime even when building static Tcl build |
| 809 |
# 0 -> link to static C runtime for static Tcl build. |
| 810 |
# Does not impact shared Tcl builds (STATIC_BUILD == 0) |
| 811 |
# Default: 1 for Tcl 9.0 and up, 0 otherwise. |
| 812 |
# TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions |
| 813 |
# in the Tcl and Wish shell. 0 -> keep them as shared libraries. Does |
| 814 |
# not impact shared Tcl builds. Implied by STATIC_BUILD since Tcl 9.0. |
| 815 |
# USE_THREAD_ALLOC - 1 -> Use a shared global free pool for allocation. |
| 816 |
# 0 -> Use the non-thread allocator. |
| 817 |
# UNCHECKED - 1 -> when doing a debug build with symbols, use the release |
| 818 |
# C runtime, 0 -> use the debug C runtime. |
| 819 |
# USE_STUBS - 1 -> compile to use stubs interfaces, 0 -> direct linking |
| 820 |
# CONFIG_CHECK - 1 -> check current build configuration against Tcl |
| 821 |
# configuration (ignored for Tcl itself) |
| 822 |
# _USE_64BIT_TIME_T - forces a build using 64-bit time_t for 32-bit build |
| 823 |
# (CRT library should support this, not needed for Tcl 9.x) |
| 824 |
# Further, LINKERFLAGS are modified based on above. |
| 825 |
|
| 826 |
# Default values for all the above |
| 827 |
STATIC_BUILD = 0 |
| 828 |
TCL_THREADS = 1 |
| 829 |
DEBUG = 0 |
| 830 |
SYMBOLS = 0 |
| 831 |
PROFILE = 0 |
| 832 |
PGO = 0 |
| 833 |
MSVCRT = 1 |
| 834 |
TCL_USE_STATIC_PACKAGES = 0 |
| 835 |
USE_THREAD_ALLOC = 1 |
| 836 |
UNCHECKED = 0 |
| 837 |
CONFIG_CHECK = 1 |
| 838 |
!if $(DOING_TCL) |
| 839 |
USE_STUBS = 0 |
| 840 |
!else |
| 841 |
USE_STUBS = 1 |
| 842 |
!endif |
| 843 |
|
| 844 |
# If OPTS is not empty AND does not contain "none" which turns off all OPTS |
| 845 |
# set the above macros based on OPTS content |
| 846 |
!if "$(OPTS)" != "" && ![nmakehlp -f "$(OPTS)" "none"] |
| 847 |
|
| 848 |
# OPTS are specified, parse them |
| 849 |
|
| 850 |
!if [nmakehlp -f $(OPTS) "static"] |
| 851 |
!message *** Doing static |
| 852 |
STATIC_BUILD = 1 |
| 853 |
!endif |
| 854 |
|
| 855 |
!if [nmakehlp -f $(OPTS) "nostubs"] |
| 856 |
!message *** Not using stubs |
| 857 |
USE_STUBS = 0 |
| 858 |
!endif |
| 859 |
|
| 860 |
!if [nmakehlp -f $(OPTS) "nomsvcrt"] |
| 861 |
!message *** Doing nomsvcrt |
| 862 |
MSVCRT = 0 |
| 863 |
!else |
| 864 |
!if [nmakehlp -f $(OPTS) "msvcrt"] |
| 865 |
!message *** Doing msvcrt |
| 866 |
!else |
| 867 |
!if $(TCL_MAJOR_VERSION) == 8 && $(TCL_MINOR_VERSION) < 7 && $(STATIC_BUILD) |
| 868 |
MSVCRT = 0 |
| 869 |
!endif |
| 870 |
!endif |
| 871 |
!endif # [nmakehlp -f $(OPTS) "nomsvcrt"] |
| 872 |
|
| 873 |
!if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD) |
| 874 |
!message *** Doing staticpkg |
| 875 |
TCL_USE_STATIC_PACKAGES = 1 |
| 876 |
!endif |
| 877 |
|
| 878 |
!if [nmakehlp -f $(OPTS) "nothreads"] |
| 879 |
!message *** Compile explicitly for non-threaded tcl |
| 880 |
TCL_THREADS = 0 |
| 881 |
USE_THREAD_ALLOC= 0 |
| 882 |
!endif |
| 883 |
|
| 884 |
!if $(TCL_MAJOR_VERSION) == 8 |
| 885 |
!if [nmakehlp -f $(OPTS) "time64bit"] |
| 886 |
!message *** Force 64-bit time_t |
| 887 |
_USE_64BIT_TIME_T = 1 |
| 888 |
!endif |
| 889 |
!endif |
| 890 |
|
| 891 |
# Yes, it's weird that the "symbols" option controls DEBUG and |
| 892 |
# the "pdbs" option controls SYMBOLS. That's historical. |
| 893 |
!if [nmakehlp -f $(OPTS) "symbols"] |
| 894 |
!message *** Doing symbols |
| 895 |
DEBUG = 1 |
| 896 |
!else |
| 897 |
DEBUG = 0 |
| 898 |
!endif |
| 899 |
|
| 900 |
!if [nmakehlp -f $(OPTS) "pdbs"] |
| 901 |
!message *** Doing pdbs |
| 902 |
SYMBOLS = 1 |
| 903 |
!else |
| 904 |
SYMBOLS = 0 |
| 905 |
!endif |
| 906 |
|
| 907 |
!if [nmakehlp -f $(OPTS) "profile"] |
| 908 |
!message *** Doing profile |
| 909 |
PROFILE = 1 |
| 910 |
!else |
| 911 |
PROFILE = 0 |
| 912 |
!endif |
| 913 |
|
| 914 |
!if [nmakehlp -f $(OPTS) "pgi"] |
| 915 |
!message *** Doing profile guided optimization instrumentation |
| 916 |
PGO = 1 |
| 917 |
!elseif [nmakehlp -f $(OPTS) "pgo"] |
| 918 |
!message *** Doing profile guided optimization |
| 919 |
PGO = 2 |
| 920 |
!else |
| 921 |
PGO = 0 |
| 922 |
!endif |
| 923 |
|
| 924 |
!if [nmakehlp -f $(OPTS) "loimpact"] |
| 925 |
!message *** Warning: ignoring option "loimpact" - deprecated on modern Windows. |
| 926 |
!endif |
| 927 |
|
| 928 |
# TBD - should get rid of this option |
| 929 |
!if [nmakehlp -f $(OPTS) "thrdalloc"] |
| 930 |
!message *** Doing thrdalloc |
| 931 |
USE_THREAD_ALLOC = 1 |
| 932 |
!endif |
| 933 |
|
| 934 |
!if [nmakehlp -f $(OPTS) "tclalloc"] |
| 935 |
USE_THREAD_ALLOC = 0 |
| 936 |
!endif |
| 937 |
|
| 938 |
!if [nmakehlp -f $(OPTS) "unchecked"] |
| 939 |
!message *** Doing unchecked |
| 940 |
UNCHECKED = 1 |
| 941 |
!else |
| 942 |
UNCHECKED = 0 |
| 943 |
!endif |
| 944 |
|
| 945 |
!if [nmakehlp -f $(OPTS) "noconfigcheck"] |
| 946 |
CONFIG_CHECK = 1 |
| 947 |
!else |
| 948 |
CONFIG_CHECK = 0 |
| 949 |
!endif |
| 950 |
|
| 951 |
!endif # "$(OPTS)" != "" && ... parsing of OPTS |
| 952 |
|
| 953 |
# Set linker flags based on above |
| 954 |
|
| 955 |
!if $(PGO) > 1 |
| 956 |
!if [nmakehlp -l -ltcg:pgoptimize $(LINKER_TESTFLAGS)] |
| 957 |
LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize |
| 958 |
!else |
| 959 |
MSG=^ |
| 960 |
This compiler does not support profile guided optimization. |
| 961 |
!error $(MSG) |
| 962 |
!endif |
| 963 |
!elseif $(PGO) > 0 |
| 964 |
!if [nmakehlp -l -ltcg:pginstrument $(LINKER_TESTFLAGS)] |
| 965 |
LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument |
| 966 |
!else |
| 967 |
MSG=^ |
| 968 |
This compiler does not support profile guided optimization. |
| 969 |
!error $(MSG) |
| 970 |
!endif |
| 971 |
!endif |
| 972 |
|
| 973 |
################################################################ |
| 974 |
# 8. Parse the STATS macro to configure code instrumentation |
| 975 |
# The following macros are set by this section: |
| 976 |
# TCL_MEM_DEBUG - 1 -> enables memory allocation instrumentation |
| 977 |
# 0 -> disables |
| 978 |
# TCL_COMPILE_DEBUG - 1 -> enables byte compiler logging |
| 979 |
# 0 -> disables |
| 980 |
|
| 981 |
# Default both are off |
| 982 |
TCL_MEM_DEBUG = 0 |
| 983 |
TCL_COMPILE_DEBUG = 0 |
| 984 |
|
| 985 |
!if "$(STATS)" != "" && ![nmakehlp -f "$(STATS)" "none"] |
| 986 |
|
| 987 |
!if [nmakehlp -f $(STATS) "memdbg"] |
| 988 |
!message *** Doing memdbg |
| 989 |
TCL_MEM_DEBUG = 1 |
| 990 |
!else |
| 991 |
TCL_MEM_DEBUG = 0 |
| 992 |
!endif |
| 993 |
|
| 994 |
!if [nmakehlp -f $(STATS) "compdbg"] |
| 995 |
!message *** Doing compdbg |
| 996 |
TCL_COMPILE_DEBUG = 1 |
| 997 |
!else |
| 998 |
TCL_COMPILE_DEBUG = 0 |
| 999 |
!endif |
| 1000 |
|
| 1001 |
!endif |
| 1002 |
|
| 1003 |
#################################################################### |
| 1004 |
# 9. Parse the CHECKS macro to configure additional compiler checks |
| 1005 |
# The following macros are set by this section: |
| 1006 |
# WARNINGS - compiler switches that control the warnings level |
| 1007 |
# TCL_NO_DEPRECATED - 1 -> disable support for deprecated functions |
| 1008 |
# 0 -> enable deprecated functions |
| 1009 |
|
| 1010 |
# Defaults - Permit deprecated functions and warning level 3 |
| 1011 |
TCL_NO_DEPRECATED = 0 |
| 1012 |
WARNINGS = -W3 |
| 1013 |
|
| 1014 |
!if "$(CHECKS)" != "" && ![nmakehlp -f "$(CHECKS)" "none"] |
| 1015 |
|
| 1016 |
!if [nmakehlp -f $(CHECKS) "nodep"] |
| 1017 |
!message *** Doing nodep check |
| 1018 |
TCL_NO_DEPRECATED = 1 |
| 1019 |
!endif |
| 1020 |
|
| 1021 |
!if [nmakehlp -f $(CHECKS) "fullwarn"] |
| 1022 |
!message *** Doing full warnings check |
| 1023 |
WARNINGS = -W4 |
| 1024 |
!if [nmakehlp -l -warn:3 $(LINKER_TESTFLAGS)] |
| 1025 |
LINKERFLAGS = $(LINKERFLAGS) -warn:3 |
| 1026 |
!endif |
| 1027 |
!endif |
| 1028 |
|
| 1029 |
!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64] |
| 1030 |
!message *** Doing 64bit portability warnings |
| 1031 |
WARNINGS = $(WARNINGS) -Wp64 |
| 1032 |
!endif |
| 1033 |
|
| 1034 |
!endif |
| 1035 |
|
| 1036 |
|
| 1037 |
################################################################ |
| 1038 |
# 10. Construct output directory and file paths |
| 1039 |
# Figure-out how to name our intermediate and output directories. |
| 1040 |
# In order to avoid inadvertent mixing of object files built using |
| 1041 |
# different compilers, build configurations etc., |
| 1042 |
# |
| 1043 |
# Naming convention (suffixes): |
| 1044 |
# t = full thread support. (Not used for Tcl >= 9.0) |
| 1045 |
# s = static library (as opposed to an import library) |
| 1046 |
# g = linked to the debug enabled C run-time. |
| 1047 |
# x = special static build when it links to the dynamic C run-time. |
| 1048 |
# |
| 1049 |
# The following macros are set in this section: |
| 1050 |
# SUFX - the suffix to use for binaries based on above naming convention |
| 1051 |
# BUILDDIRTOP - the toplevel default output directory |
| 1052 |
# is of the form {Release,Debug}[_AMD64][_COMPILERVERSION] |
| 1053 |
# TMP_DIR - directory where object files are created |
| 1054 |
# OUT_DIR - directory where output executables are created |
| 1055 |
# Both TMP_DIR and OUT_DIR are defaulted only if not defined by the |
| 1056 |
# parent makefile (or command line). The default values are |
| 1057 |
# based on BUILDDIRTOP. |
| 1058 |
# STUBPREFIX - name of the stubs library for this project |
| 1059 |
# PRJIMPLIB - output path of the generated project import library |
| 1060 |
# PRJLIBNAME - name of generated project library |
| 1061 |
# PRJLIB - output path of generated project library |
| 1062 |
# PRJSTUBLIBNAME - name of the generated project stubs library |
| 1063 |
# PRJSTUBLIB - output path of the generated project stubs library |
| 1064 |
# RESFILE - output resource file (only if not static build) |
| 1065 |
|
| 1066 |
SUFX = tsgx |
| 1067 |
|
| 1068 |
!if $(DEBUG) |
| 1069 |
BUILDDIRTOP = Debug |
| 1070 |
!else |
| 1071 |
BUILDDIRTOP = Release |
| 1072 |
!endif |
| 1073 |
|
| 1074 |
!if "$(MACHINE)" != "IX86" |
| 1075 |
BUILDDIRTOP =$(BUILDDIRTOP)_$(MACHINE) |
| 1076 |
!endif |
| 1077 |
!if $(VCVER) > 6 |
| 1078 |
BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER) |
| 1079 |
!endif |
| 1080 |
|
| 1081 |
!if !$(DEBUG) || $(TCL_VERSION) > 86 || $(DEBUG) && $(UNCHECKED) |
| 1082 |
SUFX = $(SUFX:g=) |
| 1083 |
!endif |
| 1084 |
|
| 1085 |
TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX |
| 1086 |
|
| 1087 |
!if !$(STATIC_BUILD) |
| 1088 |
TMP_DIRFULL = $(TMP_DIRFULL:Static=) |
| 1089 |
SUFX = $(SUFX:s=) |
| 1090 |
EXT = dll |
| 1091 |
TMP_DIRFULL = $(TMP_DIRFULL:X=) |
| 1092 |
SUFX = $(SUFX:x=) |
| 1093 |
!else |
| 1094 |
TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=) |
| 1095 |
EXT = lib |
| 1096 |
!if !$(MSVCRT) |
| 1097 |
TMP_DIRFULL = $(TMP_DIRFULL:X=) |
| 1098 |
SUFX = $(SUFX:x=) |
| 1099 |
!endif |
| 1100 |
!endif |
| 1101 |
|
| 1102 |
!if !$(TCL_THREADS) || $(TCL_VERSION) > 86 |
| 1103 |
TMP_DIRFULL = $(TMP_DIRFULL:Threaded=) |
| 1104 |
SUFX = $(SUFX:t=) |
| 1105 |
!endif |
| 1106 |
|
| 1107 |
!ifndef TMP_DIR |
| 1108 |
TMP_DIR = $(TMP_DIRFULL) |
| 1109 |
!ifndef OUT_DIR |
| 1110 |
OUT_DIR = .\$(BUILDDIRTOP) |
| 1111 |
!endif |
| 1112 |
!else |
| 1113 |
!ifndef OUT_DIR |
| 1114 |
OUT_DIR = $(TMP_DIR) |
| 1115 |
!endif |
| 1116 |
!endif |
| 1117 |
|
| 1118 |
# Relative paths -> absolute |
| 1119 |
!if [echo OUT_DIR = \> nmakehlp.out] \ |
| 1120 |
|| [nmakehlp -Q "$(OUT_DIR)" >> nmakehlp.out] |
| 1121 |
!error *** Could not fully qualify path OUT_DIR=$(OUT_DIR) |
| 1122 |
!endif |
| 1123 |
!if [echo TMP_DIR = \>> nmakehlp.out] \ |
| 1124 |
|| [nmakehlp -Q "$(TMP_DIR)" >> nmakehlp.out] |
| 1125 |
!error *** Could not fully qualify path TMP_DIR=$(TMP_DIR) |
| 1126 |
!endif |
| 1127 |
!include nmakehlp.out |
| 1128 |
|
| 1129 |
# The name of the stubs library for the project being built |
| 1130 |
STUBPREFIX = $(PROJECT)stub |
| 1131 |
|
| 1132 |
# |
| 1133 |
# Set up paths to various Tcl executables and libraries needed by extensions |
| 1134 |
# |
| 1135 |
|
| 1136 |
# TIP 430. Unused for 8.6 but no harm defining it to allow a common rules.vc |
| 1137 |
TCLSCRIPTZIPNAME = libtcl$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)$(TCL_PATCH_LETTER)$(TCL_RELEASE_SERIAL).zip |
| 1138 |
TKSCRIPTZIPNAME = libtk$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)$(TK_PATCH_LETTER)$(TK_RELEASE_SERIAL).zip |
| 1139 |
|
| 1140 |
!if $(DOING_TCL) |
| 1141 |
TCLSHNAME = $(PROJECT)sh$(VERSION)$(SUFX).exe |
| 1142 |
TCLSH = $(OUT_DIR)\$(TCLSHNAME) |
| 1143 |
TCLIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib |
| 1144 |
TCLLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT) |
| 1145 |
TCLLIB = $(OUT_DIR)\$(TCLLIBNAME) |
| 1146 |
TCLSCRIPTZIP = $(OUT_DIR)\$(TCLSCRIPTZIPNAME) |
| 1147 |
|
| 1148 |
TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib |
| 1149 |
TCLSTUBLIB = $(OUT_DIR)\$(TCLSTUBLIBNAME) |
| 1150 |
TCL_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)" |
| 1151 |
|
| 1152 |
!else # !$(DOING_TCL) |
| 1153 |
|
| 1154 |
!if $(TCLINSTALL) # Building against an installed Tcl |
| 1155 |
|
| 1156 |
# When building extensions, we need to locate tclsh. Depending on version |
| 1157 |
# of Tcl we are building against, this may or may not have a "t" suffix. |
| 1158 |
# Try various possibilities in turn. |
| 1159 |
TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX:t=).exe |
| 1160 |
!if !exist("$(TCLSH)") |
| 1161 |
TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX:t=).exe |
| 1162 |
!endif |
| 1163 |
|
| 1164 |
TCLSTUBLIB = $(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib |
| 1165 |
TCLIMPLIB = $(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX:t=).lib |
| 1166 |
# When building extensions, may be linking against Tcl that does not add |
| 1167 |
# "t" suffix (e.g. 8.6). If lib not found check for that possibility. |
| 1168 |
!if !exist("$(TCLIMPLIB)") |
| 1169 |
TCLIMPLIB = $(_TCLDIR)\lib\tcl$(TCL_VERSION)t$(SUFX:t=).lib |
| 1170 |
!endif |
| 1171 |
TCL_LIBRARY = $(_TCLDIR)\lib |
| 1172 |
TCLREGLIB = $(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib |
| 1173 |
TCLDDELIB = $(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib |
| 1174 |
TCLSCRIPTZIP = $(_TCLDIR)\lib\$(TCLSCRIPTZIPNAME) |
| 1175 |
TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target |
| 1176 |
TCL_INCLUDES = -I"$(_TCLDIR)\include" |
| 1177 |
|
| 1178 |
!else # Building against Tcl sources |
| 1179 |
|
| 1180 |
TCLSH = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX:t=).exe |
| 1181 |
!if !exist($(TCLSH)) |
| 1182 |
TCLSH = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX:t=).exe |
| 1183 |
!endif |
| 1184 |
TCLSTUBLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib |
| 1185 |
TCLIMPLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX:t=).lib |
| 1186 |
# When building extensions, may be linking against Tcl that does not add |
| 1187 |
# "t" suffix (e.g. 8.6). If lib not found check for that possibility. |
| 1188 |
!if !exist("$(TCLIMPLIB)") |
| 1189 |
TCLIMPLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)t$(SUFX:t=).lib |
| 1190 |
!endif |
| 1191 |
TCL_LIBRARY = $(_TCLDIR)\library |
| 1192 |
TCLREGLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib |
| 1193 |
TCLDDELIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib |
| 1194 |
TCLSCRIPTZIP = $(_TCLDIR)\win\$(BUILDDIRTOP)\$(TCLSCRIPTZIPNAME) |
| 1195 |
TCLTOOLSDIR = $(_TCLDIR)\tools |
| 1196 |
TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win" |
| 1197 |
|
| 1198 |
!endif # TCLINSTALL |
| 1199 |
|
| 1200 |
tcllibs = "$(TCLSTUBLIB)" "$(TCLIMPLIB)" |
| 1201 |
|
| 1202 |
!endif # $(DOING_TCL) |
| 1203 |
|
| 1204 |
# We need a tclsh that will run on the host machine as part of the build. |
| 1205 |
# IX86 runs on all architectures. |
| 1206 |
!ifndef TCLSH_NATIVE |
| 1207 |
!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)" |
| 1208 |
TCLSH_NATIVE = $(TCLSH) |
| 1209 |
!else |
| 1210 |
!error You must explicitly set TCLSH_NATIVE for cross-compilation |
| 1211 |
!endif |
| 1212 |
!endif |
| 1213 |
|
| 1214 |
# Do the same for Tk and Tk extensions that require the Tk libraries |
| 1215 |
!if $(DOING_TK) || $(NEED_TK) |
| 1216 |
WISHNAMEPREFIX = wish |
| 1217 |
WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe |
| 1218 |
TKLIBNAME8 = tk$(TK_VERSION)$(SUFX).$(EXT) |
| 1219 |
TKLIBNAME9 = tcl9tk$(TK_VERSION)$(SUFX).$(EXT) |
| 1220 |
!if $(TCL_MAJOR_VERSION) == 8 |
| 1221 |
TKLIBNAME = tk$(TK_VERSION)$(SUFX).$(EXT) |
| 1222 |
TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX).lib |
| 1223 |
!else |
| 1224 |
TKLIBNAME = tcl9tk$(TK_VERSION)$(SUFX).$(EXT) |
| 1225 |
TKIMPLIBNAME = tcl9tk$(TK_VERSION)$(SUFX).lib |
| 1226 |
!endif |
| 1227 |
TKSTUBLIBNAME = tkstub$(TK_VERSION).lib |
| 1228 |
|
| 1229 |
!if $(DOING_TK) |
| 1230 |
WISH = $(OUT_DIR)\$(WISHNAME) |
| 1231 |
TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME) |
| 1232 |
TKIMPLIB = $(OUT_DIR)\$(TKIMPLIBNAME) |
| 1233 |
TKLIB = $(OUT_DIR)\$(TKLIBNAME) |
| 1234 |
TK_INCLUDES = -I"$(WIN_DIR)" -I"$(GENERICDIR)" |
| 1235 |
TKSCRIPTZIP = $(OUT_DIR)\$(TKSCRIPTZIPNAME) |
| 1236 |
|
| 1237 |
!else # effectively NEED_TK |
| 1238 |
|
| 1239 |
!if $(TKINSTALL) # Building against installed Tk |
| 1240 |
WISH = $(_TKDIR)\bin\$(WISHNAME) |
| 1241 |
TKSTUBLIB = $(_TKDIR)\lib\$(TKSTUBLIBNAME) |
| 1242 |
TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME) |
| 1243 |
# When building extensions, may be linking against Tk that does not add |
| 1244 |
# "t" suffix (e.g. 8.6). If lib not found check for that possibility. |
| 1245 |
!if !exist("$(TKIMPLIB)") |
| 1246 |
TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX:t=).lib |
| 1247 |
TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME) |
| 1248 |
!endif |
| 1249 |
TK_INCLUDES = -I"$(_TKDIR)\include" |
| 1250 |
TKSCRIPTZIP = $(_TKDIR)\lib\$(TKSCRIPTZIPNAME) |
| 1251 |
|
| 1252 |
!else # Building against Tk sources |
| 1253 |
|
| 1254 |
WISH = $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME) |
| 1255 |
TKSTUBLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME) |
| 1256 |
TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME) |
| 1257 |
# When building extensions, may be linking against Tk that does not add |
| 1258 |
# "t" suffix (e.g. 8.6). If lib not found check for that possibility. |
| 1259 |
!if !exist("$(TKIMPLIB)") |
| 1260 |
TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX:t=).lib |
| 1261 |
TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME) |
| 1262 |
!endif |
| 1263 |
TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" |
| 1264 |
TKSCRIPTZIP = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSCRIPTZIPNAME) |
| 1265 |
|
| 1266 |
!endif # TKINSTALL |
| 1267 |
|
| 1268 |
tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)" |
| 1269 |
|
| 1270 |
!endif # $(DOING_TK) |
| 1271 |
!endif # $(DOING_TK) || $(NEED_TK) |
| 1272 |
|
| 1273 |
# Various output paths |
| 1274 |
PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib |
| 1275 |
PRJLIBNAME8 = $(PROJECT)$(VERSION)$(SUFX).$(EXT) |
| 1276 |
PRJLIBNAME9 = tcl9$(PROJECT)$(VERSION)$(SUFX).$(EXT) |
| 1277 |
!if $(TCL_MAJOR_VERSION) == 8 |
| 1278 |
PRJLIBNAME = $(PRJLIBNAME8) |
| 1279 |
!else |
| 1280 |
PRJLIBNAME = $(PRJLIBNAME9) |
| 1281 |
!endif |
| 1282 |
PRJLIB = $(OUT_DIR)\$(PRJLIBNAME) |
| 1283 |
|
| 1284 |
PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib |
| 1285 |
PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME) |
| 1286 |
|
| 1287 |
# If extension parent makefile has not defined a resource definition file, |
| 1288 |
# we will generate one from standard template. |
| 1289 |
!if !$(DOING_TCL) && !$(DOING_TK) && !$(STATIC_BUILD) |
| 1290 |
!ifdef RCFILE |
| 1291 |
RESFILE = $(TMP_DIR)\$(RCFILE:.rc=.res) |
| 1292 |
!else |
| 1293 |
RESFILE = $(TMP_DIR)\$(PROJECT).res |
| 1294 |
!endif |
| 1295 |
!endif |
| 1296 |
|
| 1297 |
################################################################### |
| 1298 |
# 11. Construct the paths for the installation directories |
| 1299 |
# The following macros get defined in this section: |
| 1300 |
# LIB_INSTALL_DIR - where libraries should be installed |
| 1301 |
# BIN_INSTALL_DIR - where the executables should be installed |
| 1302 |
# DOC_INSTALL_DIR - where documentation should be installed |
| 1303 |
# SCRIPT_INSTALL_DIR - where scripts should be installed |
| 1304 |
# INCLUDE_INSTALL_DIR - where C include files should be installed |
| 1305 |
# DEMO_INSTALL_DIR - where demos should be installed |
| 1306 |
# PRJ_INSTALL_DIR - where package will be installed (not set for Tcl and Tk) |
| 1307 |
|
| 1308 |
!if $(DOING_TCL) || $(DOING_TK) |
| 1309 |
LIB_INSTALL_DIR = $(_INSTALLDIR)\lib |
| 1310 |
BIN_INSTALL_DIR = $(_INSTALLDIR)\bin |
| 1311 |
DOC_INSTALL_DIR = $(_INSTALLDIR)\doc |
| 1312 |
!if $(DOING_TCL) |
| 1313 |
SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION) |
| 1314 |
MODULE_INSTALL_DIR = $(_INSTALLDIR)\lib\tcl$(TCL_MAJOR_VERSION) |
| 1315 |
!else # DOING_TK |
| 1316 |
SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION) |
| 1317 |
!endif |
| 1318 |
DEMO_INSTALL_DIR = $(SCRIPT_INSTALL_DIR)\demos |
| 1319 |
INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\include |
| 1320 |
|
| 1321 |
!else # extension other than Tk |
| 1322 |
|
| 1323 |
PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION) |
| 1324 |
!if $(MULTIPLATFORM_INSTALL) |
| 1325 |
LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)\$(PLATFORM_IDENTIFY) |
| 1326 |
BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)\$(PLATFORM_IDENTIFY) |
| 1327 |
!else |
| 1328 |
LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR) |
| 1329 |
BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR) |
| 1330 |
!endif |
| 1331 |
DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR) |
| 1332 |
SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR) |
| 1333 |
DEMO_INSTALL_DIR = $(PRJ_INSTALL_DIR)\demos |
| 1334 |
INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\..\include |
| 1335 |
|
| 1336 |
!endif |
| 1337 |
|
| 1338 |
################################################################### |
| 1339 |
# 12. Set up actual options to be passed to the compiler and linker |
| 1340 |
# Now we have all the information we need, set up the actual flags and |
| 1341 |
# options that we will pass to the compiler and linker. The main |
| 1342 |
# makefile should use these in combination with whatever other flags |
| 1343 |
# and switches are specific to it. |
| 1344 |
# The following macros are defined, names are for historical compatibility: |
| 1345 |
# OPTDEFINES - /Dxxx C macro flags based on user-specified OPTS |
| 1346 |
# COMPILERFLAGS - /Dxxx C macro flags independent of any configuration options |
| 1347 |
# crt - Compiler switch that selects the appropriate C runtime |
| 1348 |
# cdebug - Compiler switches related to debug AND optimizations |
| 1349 |
# cwarn - Compiler switches that set warning levels |
| 1350 |
# cflags - complete compiler switches (subsumes cdebug and cwarn) |
| 1351 |
# ldebug - Linker switches controlling debug information and optimization |
| 1352 |
# lflags - complete linker switches (subsumes ldebug) except subsystem type |
| 1353 |
# dlllflags - complete linker switches to build DLLs (subsumes lflags) |
| 1354 |
# conlflags - complete linker switches for console program (subsumes lflags) |
| 1355 |
# guilflags - complete linker switches for GUI program (subsumes lflags) |
| 1356 |
# baselibs - minimum Windows libraries required. Parent makefile can |
| 1357 |
# define PRJ_LIBS before including rules.rc if additional libs are needed |
| 1358 |
|
| 1359 |
OPTDEFINES = /DSTDC_HEADERS /DUSE_NMAKE=1 |
| 1360 |
!if $(VCVERSION) > 1600 |
| 1361 |
OPTDEFINES = $(OPTDEFINES) /DHAVE_STDINT_H=1 |
| 1362 |
!else |
| 1363 |
OPTDEFINES = $(OPTDEFINES) /DMP_NO_STDINT=1 |
| 1364 |
!endif |
| 1365 |
!if $(VCVERSION) >= 1800 |
| 1366 |
OPTDEFINES = $(OPTDEFINES) /DHAVE_INTTYPES_H=1 /DHAVE_STDBOOL_H=1 |
| 1367 |
!endif |
| 1368 |
|
| 1369 |
!if $(TCL_MEM_DEBUG) |
| 1370 |
OPTDEFINES = $(OPTDEFINES) /DTCL_MEM_DEBUG |
| 1371 |
!endif |
| 1372 |
!if $(TCL_COMPILE_DEBUG) |
| 1373 |
OPTDEFINES = $(OPTDEFINES) /DTCL_COMPILE_DEBUG /DTCL_COMPILE_STATS |
| 1374 |
!endif |
| 1375 |
!if $(TCL_THREADS) && $(TCL_VERSION) < 87 |
| 1376 |
OPTDEFINES = $(OPTDEFINES) /DTCL_THREADS=1 |
| 1377 |
!if $(USE_THREAD_ALLOC) && $(TCL_VERSION) < 87 |
| 1378 |
OPTDEFINES = $(OPTDEFINES) /DUSE_THREAD_ALLOC=1 |
| 1379 |
!endif |
| 1380 |
!endif |
| 1381 |
!if $(STATIC_BUILD) |
| 1382 |
OPTDEFINES = $(OPTDEFINES) /DSTATIC_BUILD |
| 1383 |
!elseif $(TCL_VERSION) > 86 |
| 1384 |
OPTDEFINES = $(OPTDEFINES) /DTCL_WITH_EXTERNAL_TOMMATH |
| 1385 |
!if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64" |
| 1386 |
OPTDEFINES = $(OPTDEFINES) /DMP_64BIT |
| 1387 |
!endif |
| 1388 |
!endif |
| 1389 |
!if $(TCL_NO_DEPRECATED) |
| 1390 |
OPTDEFINES = $(OPTDEFINES) /DTCL_NO_DEPRECATED |
| 1391 |
!endif |
| 1392 |
|
| 1393 |
!if $(USE_STUBS) |
| 1394 |
# Note we do not define USE_TCL_STUBS even when building tk since some |
| 1395 |
# test targets in tk do not use stubs |
| 1396 |
!if !$(DOING_TCL) |
| 1397 |
USE_STUBS_DEFS = /DUSE_TCL_STUBS /DUSE_TCLOO_STUBS |
| 1398 |
!if $(NEED_TK) |
| 1399 |
USE_STUBS_DEFS = $(USE_STUBS_DEFS) /DUSE_TK_STUBS |
| 1400 |
!endif |
| 1401 |
!endif |
| 1402 |
!endif # USE_STUBS |
| 1403 |
|
| 1404 |
!if !$(DEBUG) |
| 1405 |
OPTDEFINES = $(OPTDEFINES) /DNDEBUG |
| 1406 |
!if $(OPTIMIZING) |
| 1407 |
OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_OPTIMIZED |
| 1408 |
!endif |
| 1409 |
!endif |
| 1410 |
!if $(PROFILE) |
| 1411 |
OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_PROFILED |
| 1412 |
!endif |
| 1413 |
!if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64" |
| 1414 |
OPTDEFINES = $(OPTDEFINES) /DTCL_CFG_DO64BIT |
| 1415 |
!endif |
| 1416 |
!if $(VCVERSION) < 1300 |
| 1417 |
OPTDEFINES = $(OPTDEFINES) /DNO_STRTOI64=1 |
| 1418 |
!endif |
| 1419 |
|
| 1420 |
!if $(TCL_MAJOR_VERSION) == 8 |
| 1421 |
!if "$(_USE_64BIT_TIME_T)" == "1" |
| 1422 |
OPTDEFINES = $(OPTDEFINES) /D_USE_64BIT_TIME_T=1 |
| 1423 |
!endif |
| 1424 |
|
| 1425 |
# _ATL_XP_TARGETING - Newer SDK's need this to build for XP |
| 1426 |
COMPILERFLAGS = /D_ATL_XP_TARGETING |
| 1427 |
!endif |
| 1428 |
|
| 1429 |
# Like the TEA system only set this non empty for non-Tk extensions |
| 1430 |
# Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME |
| 1431 |
# so we pass both |
| 1432 |
!if !$(DOING_TCL) && !$(DOING_TK) |
| 1433 |
PKGNAMEFLAGS = /DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \ |
| 1434 |
/DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \ |
| 1435 |
/DPACKAGE_VERSION="\"$(DOTVERSION)\"" \ |
| 1436 |
/DMODULE_SCOPE=extern |
| 1437 |
!endif |
| 1438 |
|
| 1439 |
# crt picks the C run time based on selected OPTS |
| 1440 |
!if $(MSVCRT) |
| 1441 |
!if $(DEBUG) && !$(UNCHECKED) |
| 1442 |
crt = -MDd |
| 1443 |
!else |
| 1444 |
crt = -MD |
| 1445 |
!endif |
| 1446 |
!else |
| 1447 |
!if $(DEBUG) && !$(UNCHECKED) |
| 1448 |
crt = -MTd |
| 1449 |
!else |
| 1450 |
crt = -MT |
| 1451 |
!endif |
| 1452 |
!endif |
| 1453 |
|
| 1454 |
# cdebug includes compiler options for debugging as well as optimization. |
| 1455 |
!if $(DEBUG) |
| 1456 |
|
| 1457 |
# In debugging mode, optimizations need to be disabled |
| 1458 |
cdebug = -Zi -Od $(DEBUGFLAGS) |
| 1459 |
|
| 1460 |
!else |
| 1461 |
|
| 1462 |
cdebug = $(OPTIMIZATIONS) |
| 1463 |
!if $(SYMBOLS) |
| 1464 |
cdebug = $(cdebug) -Zi |
| 1465 |
!endif |
| 1466 |
|
| 1467 |
!endif # $(DEBUG) |
| 1468 |
|
| 1469 |
# cwarn includes default warning levels, also C4090 (buggy) and C4146 is useless. |
| 1470 |
cwarn = $(WARNINGS) -wd4090 -wd4146 |
| 1471 |
|
| 1472 |
!if "$(MACHINE)" == "AMD64" || "$(MACHINE)" == "ARM64" |
| 1473 |
# Disable pointer<->int warnings related to cast between different sizes |
| 1474 |
# There are a gadzillion of these due to use of ClientData and |
| 1475 |
# clutter up compiler |
| 1476 |
# output increasing chance of a real warning getting lost. So disable them. |
| 1477 |
# Eventually some day, Tcl will be 64-bit clean. |
| 1478 |
cwarn = $(cwarn) -wd4311 -wd4312 |
| 1479 |
!endif |
| 1480 |
|
| 1481 |
### Common compiler options that are architecture specific |
| 1482 |
!if "$(MACHINE)" == "ARM" |
| 1483 |
carch = /D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE |
| 1484 |
!else |
| 1485 |
carch = |
| 1486 |
!endif |
| 1487 |
|
| 1488 |
# cpuid is only available on intel machines |
| 1489 |
!if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "AMD64" |
| 1490 |
carch = $(carch) /DHAVE_CPUID=1 |
| 1491 |
!endif |
| 1492 |
|
| 1493 |
!if $(DEBUG) |
| 1494 |
# Turn warnings into errors |
| 1495 |
cwarn = $(cwarn) -WX |
| 1496 |
!endif |
| 1497 |
|
| 1498 |
INCLUDES = $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES) |
| 1499 |
!if !$(DOING_TCL) && !$(DOING_TK) |
| 1500 |
INCLUDES = $(INCLUDES) -I"$(GENERICDIR)" -I"$(WIN_DIR)" -I"$(COMPATDIR)" |
| 1501 |
!endif |
| 1502 |
|
| 1503 |
# These flags are defined roughly in the order of the pre-reform |
| 1504 |
# rules.vc/makefile.vc to help visually compare that the pre- and |
| 1505 |
# post-reform build logs |
| 1506 |
|
| 1507 |
# cflags contains generic flags used for building practically all object files |
| 1508 |
cflags = -nologo -c $(COMPILERFLAGS) $(carch) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug) |
| 1509 |
|
| 1510 |
# appcflags contains $(cflags) and flags for building the application |
| 1511 |
# object files (e.g. tclsh, or wish) pkgcflags contains $(cflags) plus |
| 1512 |
# flags used for building shared object files The two differ in the |
| 1513 |
# BUILD_$(PROJECT) macro which should be defined only for the shared |
| 1514 |
# library *implementation* and not for its caller interface |
| 1515 |
|
| 1516 |
appcflags_nostubs = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) |
| 1517 |
appcflags = $(appcflags_nostubs) $(USE_STUBS_DEFS) |
| 1518 |
pkgcflags = $(appcflags) $(PKGNAMEFLAGS) /DBUILD_$(PROJECT) |
| 1519 |
pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) /DBUILD_$(PROJECT) |
| 1520 |
|
| 1521 |
# stubscflags contains $(cflags) plus flags used for building a stubs |
| 1522 |
# library for the package. Note: /DSTATIC_BUILD is defined in |
| 1523 |
# $(OPTDEFINES) only if the OPTS configuration indicates a static |
| 1524 |
# library. However the stubs library is ALWAYS static hence included |
| 1525 |
# here irrespective of the OPTS setting. |
| 1526 |
# |
| 1527 |
# TBD - tclvfs has a comment that stubs libs should not be compiled with -GL |
| 1528 |
# without stating why. Tcl itself compiled stubs libs with this flag. |
| 1529 |
# so we do not remove it from cflags. -GL may prevent extensions |
| 1530 |
# compiled with one VC version to fail to link against stubs library |
| 1531 |
# compiled with another VC version. Check for this and fix accordingly. |
| 1532 |
stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) /Zl /GL- /DSTATIC_BUILD $(INCLUDES) $(USE_STUBS_DEFS) |
| 1533 |
|
| 1534 |
# Link flags |
| 1535 |
|
| 1536 |
!if $(DEBUG) |
| 1537 |
ldebug = -debug -debugtype:cv |
| 1538 |
!else |
| 1539 |
ldebug = -release -opt:ref -opt:icf,3 |
| 1540 |
!if $(SYMBOLS) |
| 1541 |
ldebug = $(ldebug) -debug -debugtype:cv |
| 1542 |
!endif |
| 1543 |
!endif |
| 1544 |
|
| 1545 |
# Note: Profiling is currently only possible with the Visual Studio Enterprise |
| 1546 |
!if $(PROFILE) |
| 1547 |
ldebug= $(ldebug) -profile |
| 1548 |
!endif |
| 1549 |
|
| 1550 |
### Declarations common to all linker versions |
| 1551 |
lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug) |
| 1552 |
|
| 1553 |
!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 |
| 1554 |
lflags = $(lflags) -nodefaultlib:ucrt.lib |
| 1555 |
!endif |
| 1556 |
|
| 1557 |
dlllflags = $(lflags) -dll |
| 1558 |
conlflags = $(lflags) -subsystem:console |
| 1559 |
guilflags = $(lflags) -subsystem:windows |
| 1560 |
|
| 1561 |
# Libraries that are required for every image. |
| 1562 |
# Extensions should define any additional libraries with $(PRJ_LIBS) |
| 1563 |
winlibs = kernel32.lib advapi32.lib |
| 1564 |
|
| 1565 |
!if $(NEED_TK) |
| 1566 |
winlibs = $(winlibs) gdi32.lib user32.lib uxtheme.lib |
| 1567 |
!endif |
| 1568 |
|
| 1569 |
# Avoid 'unresolved external symbol __security_cookie' errors. |
| 1570 |
# c.f. http://support.microsoft.com/?id=894573 |
| 1571 |
!if "$(MACHINE)" == "AMD64" |
| 1572 |
!if $(VCVERSION) > 1399 && $(VCVERSION) < 1500 |
| 1573 |
winlibs = $(winlibs) bufferoverflowU.lib |
| 1574 |
!endif |
| 1575 |
!endif |
| 1576 |
|
| 1577 |
baselibs = $(winlibs) $(PRJ_LIBS) |
| 1578 |
|
| 1579 |
!if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900 |
| 1580 |
baselibs = $(baselibs) ucrt.lib |
| 1581 |
!endif |
| 1582 |
|
| 1583 |
################################################################ |
| 1584 |
# 13. Define standard commands, common make targets and implicit rules |
| 1585 |
|
| 1586 |
CCPKGCMD = $(cc32) $(pkgcflags) -Fo$(TMP_DIR)^\ |
| 1587 |
CCAPPCMD = $(cc32) $(appcflags) -Fo$(TMP_DIR)^\ |
| 1588 |
CCSTUBSCMD = $(cc32) $(stubscflags) -Fo$(TMP_DIR)^\ |
| 1589 |
|
| 1590 |
LIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@ |
| 1591 |
DLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) |
| 1592 |
|
| 1593 |
CONEXECMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) |
| 1594 |
GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs) |
| 1595 |
RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \ |
| 1596 |
$(TCL_INCLUDES) /DSTATIC_BUILD=$(STATIC_BUILD) \ |
| 1597 |
/DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \ |
| 1598 |
/DCOMMAVERSION=$(RCCOMMAVERSION) \ |
| 1599 |
/DDOTVERSION=\"$(DOTVERSION)\" \ |
| 1600 |
/DVERSION=\"$(VERSION)\" \ |
| 1601 |
/DSUFX=\"$(SUFX)\" \ |
| 1602 |
/DPROJECT=\"$(PROJECT)\" \ |
| 1603 |
/DPRJLIBNAME=\"$(PRJLIBNAME)\" |
| 1604 |
|
| 1605 |
!ifndef DEFAULT_BUILD_TARGET |
| 1606 |
DEFAULT_BUILD_TARGET = $(PROJECT) |
| 1607 |
!endif |
| 1608 |
|
| 1609 |
default-target: $(DEFAULT_BUILD_TARGET) |
| 1610 |
|
| 1611 |
!if $(MULTIPLATFORM_INSTALL) |
| 1612 |
default-pkgindex: |
| 1613 |
@echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl |
| 1614 |
@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \ |
| 1615 |
[list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME9)]] >> $(OUT_DIR)\pkgIndex.tcl |
| 1616 |
@echo } else { >> $(OUT_DIR)\pkgIndex.tcl |
| 1617 |
@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \ |
| 1618 |
[list load [file join $$dir $(PLATFORM_IDENTIFY) $(PRJLIBNAME8)]] >> $(OUT_DIR)\pkgIndex.tcl |
| 1619 |
@echo } >> $(OUT_DIR)\pkgIndex.tcl |
| 1620 |
!else |
| 1621 |
default-pkgindex: |
| 1622 |
@echo if {[package vsatisfies [package provide Tcl] 9.0-]} { > $(OUT_DIR)\pkgIndex.tcl |
| 1623 |
@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \ |
| 1624 |
[list load [file join $$dir $(PRJLIBNAME9)]] >> $(OUT_DIR)\pkgIndex.tcl |
| 1625 |
@echo } else { >> $(OUT_DIR)\pkgIndex.tcl |
| 1626 |
@echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \ |
| 1627 |
[list load [file join $$dir $(PRJLIBNAME8)]] >> $(OUT_DIR)\pkgIndex.tcl |
| 1628 |
@echo } >> $(OUT_DIR)\pkgIndex.tcl |
| 1629 |
!endif |
| 1630 |
|
| 1631 |
default-pkgindex-tea: |
| 1632 |
@if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl |
| 1633 |
@PACKAGE_VERSION@ $(DOTVERSION) |
| 1634 |
@PACKAGE_NAME@ $(PRJ_PACKAGE_TCLNAME) |
| 1635 |
@PACKAGE_TCLNAME@ $(PRJ_PACKAGE_TCLNAME) |
| 1636 |
@PKG_LIB_FILE@ $(PRJLIBNAME) |
| 1637 |
@PKG_LIB_FILE8@ $(PRJLIBNAME8) |
| 1638 |
@PKG_LIB_FILE9@ $(PRJLIBNAME9) |
| 1639 |
<< |
| 1640 |
|
| 1641 |
default-install: default-install-binaries default-install-libraries |
| 1642 |
!if $(SYMBOLS) |
| 1643 |
default-install: default-install-pdbs |
| 1644 |
!endif |
| 1645 |
|
| 1646 |
# Again to deal with historical brokenness, there is some confusion |
| 1647 |
# in terminlogy. For extensions, the "install-binaries" was used to |
| 1648 |
# locate target directory for *binary shared libraries* and thus |
| 1649 |
# the appropriate macro is LIB_INSTALL_DIR since BIN_INSTALL_DIR is |
| 1650 |
# for executables (exes). On the other hand the "install-libraries" |
| 1651 |
# target is for *scripts* and should have been called "install-scripts". |
| 1652 |
default-install-binaries: $(PRJLIB) |
| 1653 |
@echo Installing binaries to '$(LIB_INSTALL_DIR)' |
| 1654 |
@if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)" |
| 1655 |
@$(CPY) $(PRJLIB) "$(LIB_INSTALL_DIR)" >NUL |
| 1656 |
|
| 1657 |
# Alias for default-install-scripts |
| 1658 |
default-install-libraries: default-install-scripts |
| 1659 |
|
| 1660 |
default-install-scripts: $(OUT_DIR)\pkgIndex.tcl |
| 1661 |
@echo Installing libraries to '$(SCRIPT_INSTALL_DIR)' |
| 1662 |
@if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)" |
| 1663 |
@echo Installing package index in '$(SCRIPT_INSTALL_DIR)' |
| 1664 |
@$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR) |
| 1665 |
|
| 1666 |
default-install-stubs: |
| 1667 |
@echo Installing stubs library to '$(SCRIPT_INSTALL_DIR)' |
| 1668 |
@if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)" |
| 1669 |
@$(CPY) $(PRJSTUBLIB) "$(SCRIPT_INSTALL_DIR)" >NUL |
| 1670 |
|
| 1671 |
default-install-pdbs: |
| 1672 |
@echo Installing PDBs to '$(LIB_INSTALL_DIR)' |
| 1673 |
@if not exist "$(LIB_INSTALL_DIR)" mkdir "$(LIB_INSTALL_DIR)" |
| 1674 |
@$(CPY) "$(OUT_DIR)\*.pdb" "$(LIB_INSTALL_DIR)\" |
| 1675 |
|
| 1676 |
# "emacs font-lock highlighting fix |
| 1677 |
|
| 1678 |
default-install-docs-html: |
| 1679 |
@echo Installing documentation files to '$(DOC_INSTALL_DIR)' |
| 1680 |
@if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)" |
| 1681 |
@if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css" "$(DOCDIR)\*.png") do @$(COPY) %f "$(DOC_INSTALL_DIR)" |
| 1682 |
|
| 1683 |
default-install-docs-n: |
| 1684 |
@echo Installing documentation files to '$(DOC_INSTALL_DIR)' |
| 1685 |
@if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)" |
| 1686 |
@if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.n") do @$(COPY) %f "$(DOC_INSTALL_DIR)" |
| 1687 |
|
| 1688 |
default-install-demos: |
| 1689 |
@echo Installing demos to '$(DEMO_INSTALL_DIR)' |
| 1690 |
@if not exist "$(DEMO_INSTALL_DIR)" mkdir "$(DEMO_INSTALL_DIR)" |
| 1691 |
@if exist $(DEMODIR) $(CPYDIR) "$(DEMODIR)" "$(DEMO_INSTALL_DIR)" |
| 1692 |
|
| 1693 |
default-clean: |
| 1694 |
@echo Cleaning $(TMP_DIR)\* ... |
| 1695 |
@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR) |
| 1696 |
@echo Cleaning $(WIN_DIR)\nmakehlp.obj, nmakehlp.exe ... |
| 1697 |
@if exist $(WIN_DIR)\nmakehlp.obj del $(WIN_DIR)\nmakehlp.obj |
| 1698 |
@if exist $(WIN_DIR)\nmakehlp.exe del $(WIN_DIR)\nmakehlp.exe |
| 1699 |
@if exist $(WIN_DIR)\nmakehlp.out del $(WIN_DIR)\nmakehlp.out |
| 1700 |
@echo Cleaning $(WIN_DIR)\nmhlp-out.txt ... |
| 1701 |
@if exist $(WIN_DIR)\nmhlp-out.txt del $(WIN_DIR)\nmhlp-out.txt |
| 1702 |
@echo Cleaning $(WIN_DIR)\_junk.pch ... |
| 1703 |
@if exist $(WIN_DIR)\_junk.pch del $(WIN_DIR)\_junk.pch |
| 1704 |
@echo Cleaning $(WIN_DIR)\vercl.x, vercl.i ... |
| 1705 |
@if exist $(WIN_DIR)\vercl.x del $(WIN_DIR)\vercl.x |
| 1706 |
@if exist $(WIN_DIR)\vercl.i del $(WIN_DIR)\vercl.i |
| 1707 |
@echo Cleaning $(WIN_DIR)\versions.vc, version.vc ... |
| 1708 |
@if exist $(WIN_DIR)\versions.vc del $(WIN_DIR)\versions.vc |
| 1709 |
@if exist $(WIN_DIR)\version.vc del $(WIN_DIR)\version.vc |
| 1710 |
|
| 1711 |
default-hose: default-clean |
| 1712 |
@echo Hosing $(OUT_DIR)\* ... |
| 1713 |
@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR) |
| 1714 |
|
| 1715 |
# Only for backward compatibility |
| 1716 |
default-distclean: default-hose |
| 1717 |
|
| 1718 |
default-setup: |
| 1719 |
@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) |
| 1720 |
@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) |
| 1721 |
|
| 1722 |
!if "$(TESTPAT)" != "" |
| 1723 |
TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT) |
| 1724 |
!endif |
| 1725 |
|
| 1726 |
default-test: default-setup $(PROJECT) |
| 1727 |
@set TCLLIBPATH=$(OUT_DIR:\=/) |
| 1728 |
@if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)" |
| 1729 |
cd "$(TESTDIR)" && $(DEBUGGER) $(TCLSH) all.tcl $(TESTFLAGS) |
| 1730 |
|
| 1731 |
default-shell: default-setup $(PROJECT) |
| 1732 |
@set TCLLIBPATH=$(OUT_DIR:\=/) |
| 1733 |
@if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)" |
| 1734 |
$(DEBUGGER) $(TCLSH) |
| 1735 |
|
| 1736 |
# Generation of Windows version resource |
| 1737 |
!ifdef RCFILE |
| 1738 |
|
| 1739 |
# Note: don't use $** in below rule because there may be other dependencies |
| 1740 |
# and only the "main" rc must be passed to the resource compiler |
| 1741 |
$(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc |
| 1742 |
$(RESCMD) $(RCDIR)\$(PROJECT).rc |
| 1743 |
|
| 1744 |
!else |
| 1745 |
|
| 1746 |
# If parent makefile has not defined a resource definition file, |
| 1747 |
# we will generate one from standard template. |
| 1748 |
$(TMP_DIR)\$(PROJECT).res: $(TMP_DIR)\$(PROJECT).rc |
| 1749 |
|
| 1750 |
$(TMP_DIR)\$(PROJECT).rc: |
| 1751 |
@$(COPY) << $(TMP_DIR)\$(PROJECT).rc |
| 1752 |
#include <winver.h> |
| 1753 |
|
| 1754 |
VS_VERSION_INFO VERSIONINFO |
| 1755 |
FILEVERSION COMMAVERSION |
| 1756 |
PRODUCTVERSION COMMAVERSION |
| 1757 |
FILEFLAGSMASK 0x3fL |
| 1758 |
#ifdef DEBUG |
| 1759 |
FILEFLAGS VS_FF_DEBUG |
| 1760 |
#else |
| 1761 |
FILEFLAGS 0x0L |
| 1762 |
#endif |
| 1763 |
FILEOS VOS_NT_WINDOWS32 |
| 1764 |
FILETYPE VFT_DLL |
| 1765 |
FILESUBTYPE 0x0L |
| 1766 |
BEGIN |
| 1767 |
BLOCK "StringFileInfo" |
| 1768 |
BEGIN |
| 1769 |
BLOCK "040904b0" |
| 1770 |
BEGIN |
| 1771 |
VALUE "FileDescription", "Tcl extension " PROJECT |
| 1772 |
VALUE "OriginalFilename", PRJLIBNAME |
| 1773 |
VALUE "FileVersion", DOTVERSION |
| 1774 |
VALUE "ProductName", "Package " PROJECT " for Tcl" |
| 1775 |
VALUE "ProductVersion", DOTVERSION |
| 1776 |
END |
| 1777 |
END |
| 1778 |
BLOCK "VarFileInfo" |
| 1779 |
BEGIN |
| 1780 |
VALUE "Translation", 0x409, 1200 |
| 1781 |
END |
| 1782 |
END |
| 1783 |
|
| 1784 |
<< |
| 1785 |
|
| 1786 |
!endif # ifdef RCFILE |
| 1787 |
|
| 1788 |
!ifndef DISABLE_IMPLICIT_RULES |
| 1789 |
DISABLE_IMPLICIT_RULES = 0 |
| 1790 |
!endif |
| 1791 |
|
| 1792 |
!if !$(DISABLE_IMPLICIT_RULES) |
| 1793 |
# Implicit rule definitions - only for building library objects. For stubs and |
| 1794 |
# main application, the makefile should define explicit rules. |
| 1795 |
|
| 1796 |
{$(ROOT)}.c{$(TMP_DIR)}.obj:: |
| 1797 |
$(CCPKGCMD) @<< |
| 1798 |
$< |
| 1799 |
<< |
| 1800 |
|
| 1801 |
{$(WIN_DIR)}.c{$(TMP_DIR)}.obj:: |
| 1802 |
$(CCPKGCMD) @<< |
| 1803 |
$< |
| 1804 |
<< |
| 1805 |
|
| 1806 |
{$(GENERICDIR)}.c{$(TMP_DIR)}.obj:: |
| 1807 |
$(CCPKGCMD) @<< |
| 1808 |
$< |
| 1809 |
<< |
| 1810 |
|
| 1811 |
{$(COMPATDIR)}.c{$(TMP_DIR)}.obj:: |
| 1812 |
$(CCPKGCMD) @<< |
| 1813 |
$< |
| 1814 |
<< |
| 1815 |
|
| 1816 |
{$(RCDIR)}.rc{$(TMP_DIR)}.res: |
| 1817 |
$(RESCMD) $< |
| 1818 |
|
| 1819 |
{$(WIN_DIR)}.rc{$(TMP_DIR)}.res: |
| 1820 |
$(RESCMD) $< |
| 1821 |
|
| 1822 |
{$(TMP_DIR)}.rc{$(TMP_DIR)}.res: |
| 1823 |
$(RESCMD) $< |
| 1824 |
|
| 1825 |
.SUFFIXES: |
| 1826 |
.SUFFIXES:.c .rc |
| 1827 |
|
| 1828 |
!endif |
| 1829 |
|
| 1830 |
################################################################ |
| 1831 |
# 14. Sanity check selected options against Tcl build options |
| 1832 |
# When building an extension, certain configuration options should |
| 1833 |
# match the ones used when Tcl was built. Here we check and |
| 1834 |
# warn on a mismatch. |
| 1835 |
!if !$(DOING_TCL) |
| 1836 |
|
| 1837 |
!if $(TCLINSTALL) # Building against an installed Tcl |
| 1838 |
!if exist("$(_TCLDIR)\lib\nmake\tcl.nmake") |
| 1839 |
TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake" |
| 1840 |
!endif |
| 1841 |
!else # !$(TCLINSTALL) - building against Tcl source |
| 1842 |
!if exist("$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl.nmake") |
| 1843 |
TCLNMAKECONFIG = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl.nmake" |
| 1844 |
!endif |
| 1845 |
!endif # TCLINSTALL |
| 1846 |
|
| 1847 |
!if $(CONFIG_CHECK) |
| 1848 |
!ifdef TCLNMAKECONFIG |
| 1849 |
!include $(TCLNMAKECONFIG) |
| 1850 |
|
| 1851 |
!if defined(CORE_MACHINE) && "$(CORE_MACHINE)" != "$(MACHINE)" |
| 1852 |
!error ERROR: Build target ($(MACHINE)) does not match the Tcl library architecture ($(CORE_MACHINE)). |
| 1853 |
!endif |
| 1854 |
!if $(TCL_VERSION) < 87 && defined(CORE_USE_THREAD_ALLOC) && $(CORE_USE_THREAD_ALLOC) != $(USE_THREAD_ALLOC) |
| 1855 |
!message WARNING: Value of USE_THREAD_ALLOC ($(USE_THREAD_ALLOC)) does not match its Tcl core value ($(CORE_USE_THREAD_ALLOC)). |
| 1856 |
!endif |
| 1857 |
!if defined(CORE_DEBUG) && $(CORE_DEBUG) != $(DEBUG) |
| 1858 |
!message WARNING: Value of DEBUG ($(DEBUG)) does not match its Tcl library configuration ($(DEBUG)). |
| 1859 |
!endif |
| 1860 |
!endif |
| 1861 |
|
| 1862 |
!endif # TCLNMAKECONFIG |
| 1863 |
|
| 1864 |
!endif # !$(DOING_TCL) |
| 1865 |
|
| 1866 |
|
| 1867 |
#---------------------------------------------------------- |
| 1868 |
# Display stats being used. |
| 1869 |
#---------------------------------------------------------- |
| 1870 |
|
| 1871 |
!if !$(DOING_TCL) |
| 1872 |
!message *** Building against Tcl at '$(_TCLDIR)' |
| 1873 |
!endif |
| 1874 |
!if !$(DOING_TK) && $(NEED_TK) |
| 1875 |
!message *** Building against Tk at '$(_TKDIR)' |
| 1876 |
!endif |
| 1877 |
!message *** Intermediate directory will be '$(TMP_DIR)' |
| 1878 |
!message *** Output directory will be '$(OUT_DIR)' |
| 1879 |
!message *** Installation, if selected, will be in '$(_INSTALLDIR)' |
| 1880 |
!message *** Suffix for binaries will be '$(SUFX)' |
| 1881 |
!message *** Compiler version $(VCVER). Target $(MACHINE), host $(NATIVE_ARCH). |
| 1882 |
|
| 1883 |
!endif # ifdef _RULES_VC |