sl@0: #------------------------------------------------------------------------------ sl@0: # rules.vc -- sl@0: # sl@0: # Microsoft Visual C++ makefile include for decoding the commandline sl@0: # macros. This file does not need editing to build Tcl. sl@0: # sl@0: # See the file "license.terms" for information on usage and redistribution sl@0: # of this file, and for a DISCLAIMER OF ALL WARRANTIES. sl@0: # sl@0: # Copyright (c) 2001-2003 David Gravereaux. sl@0: # Copyright (c) 2003-2006 Patrick Thoyts sl@0: # sl@0: #------------------------------------------------------------------------------ sl@0: # RCS: @(#) $Id: rules.vc,v 1.11.2.6 2006/10/31 15:17:20 patthoyts Exp $ sl@0: #------------------------------------------------------------------------------ sl@0: sl@0: !ifndef _RULES_VC sl@0: _RULES_VC = 1 sl@0: sl@0: cc32 = $(CC) # built-in default. sl@0: link32 = link sl@0: lib32 = lib sl@0: rc32 = $(RC) # built-in default. sl@0: sl@0: !ifndef INSTALLDIR sl@0: ### Assume the normal default. sl@0: _INSTALLDIR = C:\Program Files\Tcl sl@0: !else sl@0: ### Fix the path separators. sl@0: _INSTALLDIR = $(INSTALLDIR:/=\) sl@0: !endif sl@0: sl@0: !ifndef MACHINE sl@0: !if "$(CPU)" == "" || "$(CPU)" == "i386" sl@0: MACHINE = IX86 sl@0: !else sl@0: MACHINE = $(CPU) sl@0: !endif sl@0: !endif sl@0: sl@0: !ifndef CFG_ENCODING sl@0: CFG_ENCODING = \"cp1252\" sl@0: !endif sl@0: sl@0: #---------------------------------------------------------- sl@0: # Set the proper copy method to avoid overwrite questions sl@0: # to the user when copying files and selecting the right sl@0: # "delete all" method. sl@0: #---------------------------------------------------------- sl@0: sl@0: !if "$(OS)" == "Windows_NT" sl@0: RMDIR = rmdir /S /Q sl@0: !if ![ver | find "4.0" > nul] sl@0: CPY = echo y | xcopy /i sl@0: !else sl@0: CPY = xcopy /i /y >NUL sl@0: !endif sl@0: !else sl@0: CPY = xcopy /i sl@0: RMDIR = deltree /Y sl@0: !endif sl@0: MKDIR = mkdir sl@0: COPY = copy /y >NUL sl@0: sl@0: !message =============================================================================== sl@0: sl@0: #---------------------------------------------------------- sl@0: # build the helper app we need to overcome nmake's limiting sl@0: # environment. sl@0: #---------------------------------------------------------- sl@0: sl@0: !if !exist(nmakehlp.exe) sl@0: !if [$(cc32) -nologo nmakehlp.c -link -subsystem:console > nul] sl@0: !endif sl@0: !endif sl@0: sl@0: #---------------------------------------------------------- sl@0: # Test for compiler features sl@0: #---------------------------------------------------------- sl@0: sl@0: ### test for optimizations sl@0: !if [nmakehlp -c -Ot] sl@0: !message *** Compiler has 'Optimizations' sl@0: OPTIMIZING = 1 sl@0: !else sl@0: !message *** Compiler doesn't have 'Optimizations' sl@0: OPTIMIZING = 0 sl@0: !endif sl@0: sl@0: OPTIMIZATIONS = sl@0: sl@0: !if [nmakehlp -c -Ot] sl@0: OPTIMIZATIONS = $(OPTIMIZATIONS) -Ot sl@0: !endif sl@0: sl@0: !if [nmakehlp -c -Oi] sl@0: OPTIMIZATIONS = $(OPTIMIZATIONS) -Oi sl@0: !endif sl@0: sl@0: !if [nmakehlp -c -Op] sl@0: OPTIMIZATIONS = $(OPTIMIZATIONS) -Op sl@0: !endif sl@0: sl@0: !if [nmakehlp -c -fp:strict] sl@0: OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict sl@0: !endif sl@0: sl@0: !if [nmakehlp -c -Gs] sl@0: OPTIMIZATIONS = $(OPTIMIZATIONS) -Gs sl@0: !endif sl@0: sl@0: !if [nmakehlp -c -GS] sl@0: OPTIMIZATIONS = $(OPTIMIZATIONS) -GS sl@0: !endif sl@0: sl@0: !if [nmakehlp -c -GL] sl@0: OPTIMIZATIONS = $(OPTIMIZATIONS) -GL sl@0: !endif sl@0: sl@0: DEBUGFLAGS = sl@0: sl@0: !if [nmakehlp -c -RTC1] sl@0: DEBUGFLAGS = $(DEBUGFLAGS) -RTC1 sl@0: !elseif [nmakehlp -c -GZ] sl@0: DEBUGFLAGS = $(DEBUGFLAGS) -GZ sl@0: !endif sl@0: sl@0: COMPILERFLAGS =-W3 sl@0: sl@0: # In v13 -GL and -YX are incompatible. sl@0: !if [nmakehlp -c -YX] sl@0: !if ![nmakehlp -c -GL] sl@0: OPTIMIZATIONS = $(OPTIMIZATIONS) -YX sl@0: !endif sl@0: !endif sl@0: sl@0: !if "$(MACHINE)" == "IX86" sl@0: ### test for pentium errata sl@0: !if [nmakehlp -c -QI0f] sl@0: !message *** Compiler has 'Pentium 0x0f fix' sl@0: COMPILERFLAGS = $(COMPILERFLAGSS) -QI0f sl@0: !else sl@0: !message *** Compiler doesn't have 'Pentium 0x0f fix' sl@0: !endif sl@0: !endif sl@0: sl@0: !if "$(MACHINE)" == "IA64" sl@0: ### test for Itanium errata sl@0: !if [nmakehlp -c -QIA64_Bx] sl@0: !message *** Compiler has 'B-stepping errata workarounds' sl@0: COMPILERFLAGS = $(COMPILERFLAGS) -QIA64_Bx sl@0: !else sl@0: !message *** Compiler does not have 'B-stepping errata workarounds' sl@0: !endif sl@0: !endif sl@0: sl@0: !if "$(MACHINE)" == "IX86" sl@0: ### test for -align:4096, when align:512 will do. sl@0: !if [nmakehlp -l -opt:nowin98] sl@0: !message *** Linker has 'Win98 alignment problem' sl@0: ALIGN98_HACK = 1 sl@0: !else sl@0: !message *** Linker doesn't have 'Win98 alignment problem' sl@0: ALIGN98_HACK = 0 sl@0: !endif sl@0: !else sl@0: ALIGN98_HACK = 0 sl@0: !endif sl@0: sl@0: LINKERFLAGS = sl@0: sl@0: !if [nmakehlp -l -ltcg] sl@0: LINKERFLAGS =-ltcg sl@0: !endif sl@0: sl@0: #---------------------------------------------------------- sl@0: # MSVC8 (ships with Visual Studio 2005) generates a manifest sl@0: # file that we should link into the binaries. This is how. sl@0: #---------------------------------------------------------- sl@0: sl@0: _VC_MANIFEST_EMBED_EXE= sl@0: _VC_MANIFEST_EMBED_DLL= sl@0: !if ![cl /Zs /Tc NUL 2>&1 | find "Version 12" > NUL] sl@0: VCVER=6 sl@0: !elseif ![cl /Zs /Tc NUL 2>&1 | find "Version 13" > NUL] sl@0: VCVER=7 sl@0: !elseif ![cl /Zs /Tc NUL 2>&1 | find "Version 14" > NUL] sl@0: VCVER=8 sl@0: _VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1 sl@0: _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 sl@0: !else sl@0: VCVER=0 sl@0: !endif sl@0: sl@0: #---------------------------------------------------------- sl@0: # Decode the options requested. sl@0: #---------------------------------------------------------- sl@0: sl@0: !if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"] sl@0: STATIC_BUILD = 0 sl@0: TCL_THREADS = 0 sl@0: DEBUG = 0 sl@0: PROFILE = 0 sl@0: MSVCRT = 0 sl@0: LOIMPACT = 0 sl@0: TCL_USE_STATIC_PACKAGES = 0 sl@0: USE_THREAD_ALLOC = 0 sl@0: UNCHECKED = 0 sl@0: !else sl@0: !if [nmakehlp -f $(OPTS) "static"] sl@0: !message *** Doing static sl@0: STATIC_BUILD = 1 sl@0: !else sl@0: STATIC_BUILD = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(OPTS) "msvcrt"] sl@0: !message *** Doing msvcrt sl@0: MSVCRT = 1 sl@0: !else sl@0: MSVCRT = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(OPTS) "staticpkg"] sl@0: !message *** Doing staticpkg sl@0: TCL_USE_STATIC_PACKAGES = 1 sl@0: !else sl@0: TCL_USE_STATIC_PACKAGES = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(OPTS) "threads"] sl@0: !message *** Doing threads sl@0: TCL_THREADS = 1 sl@0: !else sl@0: TCL_THREADS = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(OPTS) "symbols"] sl@0: !message *** Doing symbols sl@0: DEBUG = 1 sl@0: !else sl@0: DEBUG = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(OPTS) "profile"] sl@0: !message *** Doing profile sl@0: PROFILE = 1 sl@0: !else sl@0: PROFILE = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(OPTS) "loimpact"] sl@0: !message *** Doing loimpact sl@0: LOIMPACT = 1 sl@0: !else sl@0: LOIMPACT = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(OPTS) "thrdalloc"] sl@0: !message *** Doing thrdalloc sl@0: USE_THREAD_ALLOC = 1 sl@0: !else sl@0: USE_THREAD_ALLOC = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(OPTS) "unchecked"] sl@0: !message *** Doing unchecked sl@0: UNCHECKED = 1 sl@0: !else sl@0: UNCHECKED = 0 sl@0: !endif sl@0: !endif sl@0: sl@0: sl@0: !if !$(STATIC_BUILD) sl@0: # Make sure we don't build overly fat DLLs. sl@0: MSVCRT = 1 sl@0: # We shouldn't statically put the extensions inside the shell when dynamic. sl@0: TCL_USE_STATIC_PACKAGES = 0 sl@0: !endif sl@0: sl@0: sl@0: #---------------------------------------------------------- sl@0: # Figure-out how to name our intermediate and output directories. sl@0: # We wouldn't want different builds to use the same .obj files sl@0: # by accident. sl@0: #---------------------------------------------------------- sl@0: sl@0: #---------------------------------------- sl@0: # Naming convention: sl@0: # t = full thread support. sl@0: # s = static library (as opposed to an sl@0: # import library) sl@0: # g = linked to the debug enabled C sl@0: # run-time. sl@0: # x = special static build when it sl@0: # links to the dynamic C run-time. sl@0: #---------------------------------------- sl@0: SUFX = tsgx sl@0: sl@0: !if $(DEBUG) sl@0: BUILDDIRTOP = Debug sl@0: DBGX = g sl@0: !else sl@0: BUILDDIRTOP = Release sl@0: DBGX = sl@0: SUFX = $(SUFX:g=) sl@0: !endif sl@0: sl@0: !if "$(MACHINE)" != "IX86" sl@0: BUILDDIRTOP =$(BUILDDIRTOP)_$(MACHINE) sl@0: !endif sl@0: !if $(VCVER) > 6 sl@0: BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER) sl@0: !endif sl@0: sl@0: TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX sl@0: sl@0: !if !$(STATIC_BUILD) sl@0: TMP_DIRFULL = $(TMP_DIRFULL:Static=) sl@0: SUFX = $(SUFX:s=) sl@0: EXT = dll sl@0: !if $(MSVCRT) sl@0: TMP_DIRFULL = $(TMP_DIRFULL:X=) sl@0: SUFX = $(SUFX:x=) sl@0: !endif sl@0: !else sl@0: TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=) sl@0: EXT = lib sl@0: !if !$(MSVCRT) sl@0: TMP_DIRFULL = $(TMP_DIRFULL:X=) sl@0: SUFX = $(SUFX:x=) sl@0: !endif sl@0: !endif sl@0: sl@0: !if !$(TCL_THREADS) sl@0: TMP_DIRFULL = $(TMP_DIRFULL:Threaded=) sl@0: SUFX = $(SUFX:t=) sl@0: !endif sl@0: sl@0: !ifndef TMP_DIR sl@0: TMP_DIR = $(TMP_DIRFULL) sl@0: !ifndef OUT_DIR sl@0: OUT_DIR = .\$(BUILDDIRTOP) sl@0: !endif sl@0: !else sl@0: !ifndef OUT_DIR sl@0: OUT_DIR = $(TMP_DIR) sl@0: !endif sl@0: !endif sl@0: sl@0: sl@0: #---------------------------------------------------------- sl@0: # Decode the statistics requested. sl@0: #---------------------------------------------------------- sl@0: sl@0: !if "$(STATS)" == "" || [nmakehlp -f "$(STATS)" "none"] sl@0: TCL_MEM_DEBUG = 0 sl@0: TCL_COMPILE_DEBUG = 0 sl@0: !else sl@0: !if [nmakehlp -f $(STATS) "memdbg"] sl@0: !message *** Doing memdbg sl@0: TCL_MEM_DEBUG = 1 sl@0: !else sl@0: TCL_MEM_DEBUG = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(STATS) "compdbg"] sl@0: !message *** Doing compdbg sl@0: TCL_COMPILE_DEBUG = 1 sl@0: !else sl@0: TCL_COMPILE_DEBUG = 0 sl@0: !endif sl@0: !endif sl@0: sl@0: #---------------------------------------------------------- sl@0: # Decode the checks requested. sl@0: #---------------------------------------------------------- sl@0: sl@0: !if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"] sl@0: TCL_NO_DEPRECATED = 0 sl@0: FULLWARNINGS = 0 sl@0: !else sl@0: !if [nmakehlp -f $(CHECKS) "nodep"] sl@0: !message *** Doing nodep check sl@0: TCL_NO_DEPRECATED = 1 sl@0: !else sl@0: TCL_NO_DEPRECATED = 0 sl@0: !endif sl@0: !if [nmakehlp -f $(CHECKS) "fullwarn"] sl@0: !message *** Doing full warnings check sl@0: FULLWARNINGS = 1 sl@0: !else sl@0: FULLWARNINGS = 0 sl@0: !endif sl@0: !endif sl@0: sl@0: sl@0: #---------------------------------------------------------- sl@0: # Set our defines now armed with our options. sl@0: #---------------------------------------------------------- sl@0: sl@0: OPTDEFINES = sl@0: !if $(TCL_MEM_DEBUG) sl@0: OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG sl@0: !endif sl@0: !if $(TCL_COMPILE_DEBUG) sl@0: OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS sl@0: !endif sl@0: !if $(TCL_THREADS) sl@0: OPTDEFINES = $(OPTDEFINES) -DTCL_THREADS=1 sl@0: !if $(USE_THREAD_ALLOC) sl@0: OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1 sl@0: !endif sl@0: !endif sl@0: !if $(STATIC_BUILD) sl@0: OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD sl@0: !endif sl@0: sl@0: !if $(DEBUG) sl@0: OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DEBUG sl@0: !elseif $(OPTIMIZING) sl@0: OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED sl@0: !endif sl@0: !if $(PROFILE) sl@0: OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED sl@0: !endif sl@0: !if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64" sl@0: OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT sl@0: !endif sl@0: sl@0: sl@0: #---------------------------------------------------------- sl@0: # Get common info used when building extensions. sl@0: #---------------------------------------------------------- sl@0: sl@0: !if "$(PROJECT)" != "tcl" sl@0: sl@0: !if !defined(TCLDIR) sl@0: !if exist("$(_INSTALLDIR)\include\tcl.h") sl@0: TCLH = "$(_INSTALLDIR)\include\tcl.h" sl@0: TCLINSTALL = 1 sl@0: _TCLDIR = $(_INSTALLDIR) sl@0: !else sl@0: MSG=^ sl@0: Failed to find tcl.h. Set the TCLDIR macro. sl@0: !error $(MSG) sl@0: !endif sl@0: !else sl@0: _TCLDIR = $(TCLDIR:/=\) sl@0: !if exist("$(_TCLDIR)\include\tcl.h") sl@0: TCLH = "$(_TCLDIR)\include\tcl.h" sl@0: TCLINSTALL = 1 sl@0: !elseif exist("$(_TCLDIR)\generic\tcl.h") sl@0: TCLH = "$(_TCLDIR)\generic\tcl.h" sl@0: TCLINSTALL = 0 sl@0: !else sl@0: MSG =^ sl@0: Failed to find tcl.h. The TCLDIR macro does not appear correct. sl@0: !error $(MSG) sl@0: !endif sl@0: !endif sl@0: sl@0: ### TODO: add a command to nmakehlp.c to grep for Tcl's version from tcl.h. sl@0: ### Because nmake can't return a string, we'll need to play games with return sl@0: ### codes. It might look something like this: sl@0: #!if [nmakehlp -g $(TCL.H)] == 81 sl@0: #TCL_DOTVERSION = 8.1 sl@0: #!elseif [nmakehlp -g $(TCL.H)] == 82 sl@0: #TCL_DOTVERSION = 8.2 sl@0: #... sl@0: #!endif sl@0: sl@0: TCL_DOTVERSION = 8.4 sl@0: TCL_VERSION = $(TCL_DOTVERSION:.=) sl@0: sl@0: !if $(TCLINSTALL) sl@0: TCLSH = "$(_INSTALLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe" sl@0: TCLSTUBLIB = "$(_INSTALLDIR)\lib\tclstub$(TCL_VERSION).lib" sl@0: TCLIMPLIB = "$(_INSTALLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib" sl@0: TCL_LIBRARY = $(_INSTALLDIR)\lib sl@0: TCLREGLIB = "$(_INSTALLDIR)\lib\tclreg11$(SUFX:t=).lib" sl@0: TCLDDELIB = "$(_INSTALLDIR)\lib\tcldde12$(SUFX:t=).lib" sl@0: COFFBASE = \must\have\tcl\sources\to\build\this\target sl@0: TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target sl@0: !else sl@0: TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe" sl@0: TCLSTUBLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib" sl@0: TCLIMPLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib" sl@0: TCL_LIBRARY = $(_TCLDIR)\library sl@0: TCLREGLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg11$(SUFX:t=).lib" sl@0: TCLDDELIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde12$(SUFX:t=).lib" sl@0: COFFBASE = "$(_TCLDIR)\win\coffbase.txt" sl@0: TCLTOOLSDIR = $(_TCLDIR)\tools sl@0: !endif sl@0: sl@0: !endif sl@0: sl@0: sl@0: #---------------------------------------------------------- sl@0: # Display stats being used. sl@0: #---------------------------------------------------------- sl@0: sl@0: !message *** Intermediate directory will be '$(TMP_DIR)' sl@0: !message *** Output directory will be '$(OUT_DIR)' sl@0: !message *** Suffix for binaries will be '$(SUFX)' sl@0: !message *** Optional defines are '$(OPTDEFINES)' sl@0: !message *** Compiler version $(VCVER) sl@0: !message *** Compiler options '$(OPTIMIZATIONS) $(DEBUGFLAGS)' sl@0: !message *** Link options '$(LINKERFLAGS)' sl@0: sl@0: !endif sl@0: