comparison mupdf-source/thirdparty/zint/backend_tcl/win/rules.vc @ 2:b50eed0cc0ef upstream

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