1 #------------------------------------------------------------------------------
4 # Microsoft Visual C++ makefile include for decoding the commandline
5 # macros. This file does not need editing to build Tcl.
7 # See the file "license.terms" for information on usage and redistribution
8 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 # Copyright (c) 2001-2003 David Gravereaux.
11 # Copyright (c) 2003-2008 Patrick Thoyts
12 #------------------------------------------------------------------------------
17 cc32 = $(CC) # built-in default.
20 rc32 = $(RC) # built-in default.
23 ### Assume the normal default.
24 _INSTALLDIR = C:\Program Files\Tcl
26 ### Fix the path separators.
27 _INSTALLDIR = $(INSTALLDIR:/=\)
30 #----------------------------------------------------------
31 # Set the proper copy method to avoid overwrite questions
32 # to the user when copying files and selecting the right
33 # "delete all" method.
34 #----------------------------------------------------------
36 !if "$(OS)" == "Windows_NT"
39 !if ![ver | find "4.0" > nul]
40 CPY = echo y | xcopy /i >NUL
43 CPY = xcopy /i /y >NUL
46 !else # "$(OS)" != "Windows_NT"
47 CPY = xcopy /i >_JUNK.OUT # On Win98 NUL does not work here.
48 COPY = copy >_JUNK.OUT # On Win98 NUL does not work here.
50 NULL = \NUL # Used in testing directory existence
51 ERRNULL = >NUL # Win9x shell cannot redirect stderr
55 #------------------------------------------------------------------------------
56 # Determine the host and target architectures and compiler version.
57 #------------------------------------------------------------------------------
60 _VC_MANIFEST_EMBED_EXE=
61 _VC_MANIFEST_EMBED_DLL=
63 !if ![echo VCVERSION=_MSC_VER > vercl.x] \
64 && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
65 && ![echo ARCH=IX86 >> vercl.x] \
66 && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
67 && ![echo ARCH=AMD64 >> vercl.x] \
68 && ![echo $(_HASH)endif >> vercl.x] \
69 && ![cl -nologo -TC -P vercl.x $(ERRNULL)]
71 !if ![echo VCVER= ^\> vercl.vc] \
72 && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
76 !if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc]
79 !if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
85 # Since MSVC8 we must deal with manifest resources.
86 !if $(VCVERSION) >= 1400
87 _VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1
88 _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2
96 CFG_ENCODING = \"cp1252\"
99 !message ===============================================================================
101 #----------------------------------------------------------
102 # build the helper app we need to overcome nmake's limiting
104 #----------------------------------------------------------
106 !if !exist(nmakehlp.exe)
107 !if [$(cc32) -nologo nmakehlp.c -link -subsystem:console > nul]
111 #----------------------------------------------------------
112 # Test for compiler features
113 #----------------------------------------------------------
115 ### test for optimizations
116 !if [nmakehlp -c -Ot]
117 !message *** Compiler has 'Optimizations'
120 !message *** Compiler does not have 'Optimizations'
126 !if [nmakehlp -c -Ot]
127 OPTIMIZATIONS = $(OPTIMIZATIONS) -Ot
130 !if [nmakehlp -c -Oi]
131 OPTIMIZATIONS = $(OPTIMIZATIONS) -Oi
134 !if [nmakehlp -c -Op]
135 OPTIMIZATIONS = $(OPTIMIZATIONS) -Op
138 !if [nmakehlp -c -fp:strict]
139 OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict
142 !if [nmakehlp -c -Gs]
143 OPTIMIZATIONS = $(OPTIMIZATIONS) -Gs
146 !if [nmakehlp -c -GS]
147 OPTIMIZATIONS = $(OPTIMIZATIONS) -GS
150 !if [nmakehlp -c -GL]
151 OPTIMIZATIONS = $(OPTIMIZATIONS) -GL
156 !if [nmakehlp -c -RTC1]
157 DEBUGFLAGS = $(DEBUGFLAGS) -RTC1
158 !elseif [nmakehlp -c -GZ]
159 DEBUGFLAGS = $(DEBUGFLAGS) -GZ
162 COMPILERFLAGS =-W3 -DUNICODE -D_UNICODE
164 # In v13 -GL and -YX are incompatible.
165 !if [nmakehlp -c -YX]
166 !if ![nmakehlp -c -GL]
167 OPTIMIZATIONS = $(OPTIMIZATIONS) -YX
171 !if "$(MACHINE)" == "IX86"
172 ### test for pentium errata
173 !if [nmakehlp -c -QI0f]
174 !message *** Compiler has 'Pentium 0x0f fix'
175 COMPILERFLAGS = $(COMPILERFLAGS) -QI0f
177 !message *** Compiler does not have 'Pentium 0x0f fix'
181 !if "$(MACHINE)" == "IA64"
182 ### test for Itanium errata
183 !if [nmakehlp -c -QIA64_Bx]
184 !message *** Compiler has 'B-stepping errata workarounds'
185 COMPILERFLAGS = $(COMPILERFLAGS) -QIA64_Bx
187 !message *** Compiler does not have 'B-stepping errata workarounds'
191 !if "$(MACHINE)" == "IX86"
192 ### test for -align:4096, when align:512 will do.
193 !if [nmakehlp -l -opt:nowin98]
194 !message *** Linker has 'Win98 alignment problem'
197 !message *** Linker does not have 'Win98 alignment problem'
206 !if [nmakehlp -l -ltcg]
210 #----------------------------------------------------------
211 # Decode the options requested.
212 #----------------------------------------------------------
214 !if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"]
223 TCL_USE_STATIC_PACKAGES = 0
227 !if [nmakehlp -f $(OPTS) "static"]
228 !message *** Doing static
233 !if [nmakehlp -f $(OPTS) "msvcrt"]
234 !message *** Doing msvcrt
239 !if [nmakehlp -f $(OPTS) "staticpkg"]
240 !message *** Doing staticpkg
241 TCL_USE_STATIC_PACKAGES = 1
243 TCL_USE_STATIC_PACKAGES = 0
245 !if [nmakehlp -f $(OPTS) "nothreads"]
246 !message *** Compile explicitly for non-threaded tcl
252 !if [nmakehlp -f $(OPTS) "symbols"]
253 !message *** Doing symbols
258 !if [nmakehlp -f $(OPTS) "pdbs"]
259 !message *** Doing pdbs
264 !if [nmakehlp -f $(OPTS) "profile"]
265 !message *** Doing profile
270 !if [nmakehlp -f $(OPTS) "pgi"]
271 !message *** Doing profile guided optimization instrumentation
273 !elseif [nmakehlp -f $(OPTS) "pgo"]
274 !message *** Doing profile guided optimization
279 !if [nmakehlp -f $(OPTS) "loimpact"]
280 !message *** Doing loimpact
285 !if [nmakehlp -f $(OPTS) "thrdalloc"]
286 !message *** Doing thrdalloc
289 !if [nmakehlp -f $(OPTS) "tclalloc"]
290 !message *** Doing tclalloc
293 !if [nmakehlp -f $(OPTS) "unchecked"]
294 !message *** Doing unchecked
303 # Make sure we don't build overly fat DLLs.
305 # We shouldn't statically put the extensions inside the shell when dynamic.
306 TCL_USE_STATIC_PACKAGES = 0
310 #----------------------------------------------------------
311 # Figure-out how to name our intermediate and output directories.
312 # We wouldn't want different builds to use the same .obj files
314 #----------------------------------------------------------
316 #----------------------------------------
318 # t = full thread support.
319 # s = static library (as opposed to an
321 # g = linked to the debug enabled C
323 # x = special static build when it
324 # links to the dynamic C run-time.
325 #----------------------------------------
331 BUILDDIRTOP = Release
334 !if "$(MACHINE)" != "IX86"
335 BUILDDIRTOP =$(BUILDDIRTOP)_$(MACHINE)
338 BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER)
341 !if !$(DEBUG) || $(DEBUG) && $(UNCHECKED)
345 TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX
348 TMP_DIRFULL = $(TMP_DIRFULL:Static=)
352 TMP_DIRFULL = $(TMP_DIRFULL:X=)
356 TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=)
359 TMP_DIRFULL = $(TMP_DIRFULL:X=)
365 TMP_DIRFULL = $(TMP_DIRFULL:Threaded=)
370 TMP_DIR = $(TMP_DIRFULL)
372 OUT_DIR = .\$(BUILDDIRTOP)
381 #----------------------------------------------------------
382 # Decode the statistics requested.
383 #----------------------------------------------------------
385 !if "$(STATS)" == "" || [nmakehlp -f "$(STATS)" "none"]
387 TCL_COMPILE_DEBUG = 0
389 !if [nmakehlp -f $(STATS) "memdbg"]
390 !message *** Doing memdbg
395 !if [nmakehlp -f $(STATS) "compdbg"]
396 !message *** Doing compdbg
397 TCL_COMPILE_DEBUG = 1
399 TCL_COMPILE_DEBUG = 0
404 #----------------------------------------------------------
405 # Decode the checks requested.
406 #----------------------------------------------------------
408 !if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"]
409 TCL_NO_DEPRECATED = 0
412 !if [nmakehlp -f $(CHECKS) "nodep"]
413 !message *** Doing nodep check
414 TCL_NO_DEPRECATED = 1
416 TCL_NO_DEPRECATED = 0
418 !if [nmakehlp -f $(CHECKS) "fullwarn"]
419 !message *** Doing full warnings check
421 !if [nmakehlp -l -warn:3]
422 LINKERFLAGS = $(LINKERFLAGS) -warn:3
427 !if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
428 !message *** Doing 64bit portability warnings
429 WARNINGS = $(WARNINGS) -Wp64
434 !if [nmakehlp -l -ltcg:pgoptimize]
435 LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize
438 This compiler does not support profile guided optimization.
442 !if [nmakehlp -l -ltcg:pginstrument]
443 LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument
446 This compiler does not support profile guided optimization.
451 #----------------------------------------------------------
452 # Set our defines now armed with our options.
453 #----------------------------------------------------------
455 OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS
458 OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG
460 !if $(TCL_COMPILE_DEBUG)
461 OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS
464 OPTDEFINES = $(OPTDEFINES) -DTCL_THREADS=1
465 !if $(USE_THREAD_ALLOC)
466 OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1
470 OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD
472 !if $(TCL_NO_DEPRECATED)
473 OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED
477 OPTDEFINES = $(OPTDEFINES) -DNDEBUG
479 OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED
483 OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED
485 !if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
486 OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT
488 !if $(VCVERSION) < 1300
489 OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64
492 #----------------------------------------------------------
493 # Locate the Tcl headers to build against
494 #----------------------------------------------------------
496 !if "$(PROJECT)" == "tcl"
498 _TCL_H = ..\generic\tcl.h
502 # If INSTALLDIR set to tcl root dir then reset to the lib dir.
503 !if exist("$(_INSTALLDIR)\include\tcl.h")
504 _INSTALLDIR=$(_INSTALLDIR)\lib
508 !if exist("$(_INSTALLDIR)\..\include\tcl.h")
510 _TCLDIR = $(_INSTALLDIR)\..
511 _TCL_H = $(_INSTALLDIR)\..\include\tcl.h
512 TCLDIR = $(_INSTALLDIR)\..
515 Failed to find tcl.h. Set the TCLDIR macro.
519 _TCLDIR = $(TCLDIR:/=\)
520 !if exist("$(_TCLDIR)\include\tcl.h")
522 _TCL_H = $(_TCLDIR)\include\tcl.h
523 !elseif exist("$(_TCLDIR)\generic\tcl.h")
525 _TCL_H = $(_TCLDIR)\generic\tcl.h
528 Failed to find tcl.h. The TCLDIR macro does not appear correct.
534 #--------------------------------------------------------------
535 # Extract various version numbers from tcl headers
536 # The generated file is then included in the makefile.
537 #--------------------------------------------------------------
539 !if [echo REM = This file is generated from rules.vc > versions.vc]
541 !if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
542 && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
544 !if [echo TCL_MINOR_VERSION = \>> versions.vc] \
545 && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
547 !if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
548 && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
551 # If building the tcl core then we need additional package versions
552 !if "$(PROJECT)" == "tcl"
553 !if [echo PKG_HTTP_VER = \>> versions.vc] \
554 && [nmakehlp -V ..\library\http\pkgIndex.tcl http >> versions.vc]
556 !if [echo PKG_TCLTEST_VER = \>> versions.vc] \
557 && [nmakehlp -V ..\library\tcltest\pkgIndex.tcl tcltest >> versions.vc]
559 !if [echo PKG_MSGCAT_VER = \>> versions.vc] \
560 && [nmakehlp -V ..\library\msgcat\pkgIndex.tcl msgcat >> versions.vc]
562 !if [echo PKG_PLATFORM_VER = \>> versions.vc] \
563 && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform " >> versions.vc]
565 !if [echo PKG_SHELL_VER = \>> versions.vc] \
566 && [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform::shell" >> versions.vc]
568 !if [echo PKG_DDE_VER = \>> versions.vc] \
569 && [nmakehlp -V ..\library\dde\pkgIndex.tcl "dde " >> versions.vc]
571 !if [echo PKG_REG_VER =\>> versions.vc] \
572 && [nmakehlp -V ..\library\reg\pkgIndex.tcl registry >> versions.vc]
578 #--------------------------------------------------------------
579 # Setup tcl version dependent stuff headers
580 #--------------------------------------------------------------
582 !if "$(PROJECT)" != "tcl"
584 TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
586 !if $(TCL_VERSION) < 81
593 TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe"
594 !if !exist($(TCLSH)) && $(TCL_THREADS)
595 TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe"
597 TCLSTUBLIB = "$(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib"
598 TCLIMPLIB = "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib"
599 TCL_LIBRARY = $(_TCLDIR)\lib
600 TCLREGLIB = "$(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib"
601 TCLDDELIB = "$(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib"
602 COFFBASE = \must\have\tcl\sources\to\build\this\target
603 TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target
604 TCL_INCLUDES = -I"$(_TCLDIR)\include"
606 TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe"
607 !if !exist($(TCLSH)) && $(TCL_THREADS)
608 TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe"
610 TCLSTUBLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib"
611 TCLIMPLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib"
612 TCL_LIBRARY = $(_TCLDIR)\library
613 TCLREGLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib"
614 TCLDDELIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib"
615 COFFBASE = "$(_TCLDIR)\win\coffbase.txt"
616 TCLTOOLSDIR = $(_TCLDIR)\tools
617 TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
622 #-------------------------------------------------------------------------
623 # Locate the Tk headers to build against
624 #-------------------------------------------------------------------------
626 !if "$(PROJECT)" == "tk"
627 _TK_H = ..\generic\tk.h
628 _INSTALLDIR = $(_INSTALLDIR)\..
631 !ifdef PROJECT_REQUIRES_TK
633 !if exist("$(_INSTALLDIR)\..\include\tk.h")
635 _TKDIR = $(_INSTALLDIR)\..
636 _TK_H = $(_TKDIR)\include\tk.h
638 !elseif exist("$(_TCLDIR)\include\tk.h")
641 _TK_H = $(_TKDIR)\include\tk.h
645 _TKDIR = $(TKDIR:/=\)
646 !if exist("$(_TKDIR)\include\tk.h")
648 _TK_H = $(_TKDIR)\include\tk.h
649 !elseif exist("$(_TKDIR)\generic\tk.h")
651 _TK_H = $(_TKDIR)\generic\tk.h
654 Failed to find tk.h. The TKDIR macro does not appear correct.
660 #-------------------------------------------------------------------------
661 # Extract Tk version numbers
662 #-------------------------------------------------------------------------
664 !if defined(PROJECT_REQUIRES_TK) || "$(PROJECT)" == "tk"
666 !if [echo TK_MAJOR_VERSION = \>> versions.vc] \
667 && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
669 !if [echo TK_MINOR_VERSION = \>> versions.vc] \
670 && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
672 !if [echo TK_PATCH_LEVEL = \>> versions.vc] \
673 && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
678 TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
679 TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
681 !if "$(PROJECT)" != "tk"
683 WISH = "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe"
684 TKSTUBLIB = "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib"
685 TKIMPLIB = "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib"
686 TK_INCLUDES = -I"$(_TKDIR)\include"
688 WISH = "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe"
689 TKSTUBLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib"
690 TKIMPLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib"
691 TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
697 #----------------------------------------------------------
698 # Display stats being used.
699 #----------------------------------------------------------
701 !message *** Intermediate directory will be '$(TMP_DIR)'
702 !message *** Output directory will be '$(OUT_DIR)'
703 !message *** Suffix for binaries will be '$(SUFX)'
704 !message *** Optional defines are '$(OPTDEFINES)'
705 !message *** Compiler version $(VCVER). Target machine is $(MACHINE)
706 !message *** Host architecture is $(NATIVE_ARCH)
707 !message *** Compiler options '$(COMPILERFLAGS) $(OPTIMIZATIONS) $(DEBUGFLAGS) $(WARNINGS)'
708 !message *** Link options '$(LINKERFLAGS)'