1#------------------------------------------------------------------------------
2# makefile.vc --
3#
4#	Microsoft Visual C++ makefile for use with nmake.exe v1.62+ (VC++ 5.0+)
5#
6# See the file "license.terms" for information on usage and redistribution
7# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8# 
9# Copyright (c) 1995-1996 Sun Microsystems, Inc.
10# Copyright (c) 1998-2000 Ajuba Solutions.
11# Copyright (c) 2001-2005 ActiveState Corporation.
12# Copyright (c) 2001-2002 David Gravereaux.
13#
14#------------------------------------------------------------------------------
15# RCS: @(#) $Id: makefile.vc,v 1.100.2.10 2007/09/11 00:10:48 patthoyts Exp $
16#------------------------------------------------------------------------------
17
18# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
19# or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define
20# VCINSTALLDIR instead.
21!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) && !defined(VCINSTALLDIR)
22MSG = ^
23You need to run vcvars32.bat from Developer Studio or setenv.bat from the^
24Platform SDK first to setup the environment.  Jump to this line to read^
25the build instructions.
26!error $(MSG)
27!endif
28
29#------------------------------------------------------------------------------
30# HOW TO USE this makefile:
31#
32# 1)  It is now necessary to have MSVCDir, MSDevDir or MSSDK set in the
33#     environment.  This is used as a check to see if vcvars32.bat had been
34#     run prior to running nmake or during the installation of Microsoft
35#     Visual C++, MSVCDir had been set globally and the PATH adjusted.
36#     Either way is valid.
37#
38#     You'll need to run vcvars32.bat contained in the MsDev's vc(98)/bin
39#     directory to setup the proper environment, if needed, for your
40#     current setup.  This is a needed bootstrap requirement and allows the
41#     swapping of different environments to be easier.
42#
43# 2)  To use the Platform SDK (not expressly needed), run setenv.bat after
44#     vcvars32.bat according to the instructions for it.  This can also
45#     turn on the 64-bit compiler, if your SDK has it.
46#
47# 3)  Targets are:
48#	release  -- Builds the core, the shell and the dlls. (default)
49#	dlls     -- Just builds the windows extensions and the 16-bit DOS
50#		    pipe/thunk helper app.
51#	shell    -- Just builds the shell and the core.
52#	core     -- Only builds the core [tclXX.(dll|lib)].
53#	all      -- Builds everything.
54#	test     -- Builds and runs the test suite.
55#	tcltest  -- Just builds the test shell.
56#	install  -- Installs the built binaries and libraries to $(INSTALLDIR)
57#		    as the root of the install tree.
58#	tidy/clean/hose -- varying levels of cleaning.
59#	genstubs -- Rebuilds the Stubs table and support files (dev only).
60#	depend   -- Generates an accurate set of source dependancies for this
61#		    makefile.  Helpful to avoid problems when the sources are
62#		    refreshed and you rebuild, but can "overbuild" when common
63#		    headers like tclInt.h just get small changes.
64#	winhelp  -- Builds the windows .hlp file for Tcl from the troff man
65#		    files found in $(ROOT)\doc .
66#
67# 4)  Macros usable on the commandline:
68#	INSTALLDIR=<path>
69#		Sets where to install Tcl from the built binaries.
70#		C:\Progra~1\Tcl is assumed when not specified.
71#
72#	OPTS=static,msvcrt,staticpkg,threads,symbols,profile,loimpact,none
73#		Sets special options for the core.  The default is for none.
74#		Any combination of the above may be used (comma separated).
75#		'none' will over-ride everything to nothing.
76#
77#		static  =  Builds a static library of the core instead of a
78#			   dll.  The shell will be static (and large), as well.
79#		msvcrt  =  Effects the static option only to switch it from
80#			   using libcmt(d) as the C runtime [by default] to
81#			   msvcrt(d). This is useful for static embedding
82#			   support.
83#		staticpkg = Effects the static option only to switch
84#			   tclshXX.exe to have the dde and reg extension linked
85#			   inside it.
86#		threads =  Turns on full multithreading support.
87#		thrdalloc = Use the thread allocator (shared global free pool).
88#		symbols =  Adds symbols for step debugging.
89#		profile =  Adds profiling hooks.  Map file is assumed.
90#		loimpact =  Adds a flag for how NT treats the heap to keep memory
91#			   in use, low.  This is said to impact alloc performance.
92#
93#	STATS=memdbg,compdbg,none
94#		Sets optional memory and bytecode compiler debugging code added
95#		to the core.  The default is for none.  Any combination of the
96#		above may be used (comma separated).  'none' will over-ride
97#		everything to nothing.
98#
99#		memdbg   = Enables the debugging memory allocator.
100#		compdbg  = Enables byte compilation logging.
101#
102#	MACHINE=(IX86|IA64|AMD64|ALPHA)
103#		Set the machine type used for the compiler, linker, and
104#		resource compiler.  This hook is needed to tell the tools
105#		when alternate platforms are requested.  IX86 is the default
106#		when not specified.
107#
108#	TMP_DIR=<path>
109#	OUT_DIR=<path>
110#		Hooks to allow the intermediate and output directories to be
111#		changed.  $(OUT_DIR) is assumed to be 
112#		$(BINROOT)\(Release|Debug) based on if symbols are requested.
113#		$(TMP_DIR) will de $(OUT_DIR)\<buildtype> by default.
114#
115#	TESTPAT=<file>
116#		Reads the tests requested to be run from this file.
117#
118# 5)  Examples:
119#
120#	Basic syntax of calling nmake looks like this:
121#	nmake [-nologo] -f makefile.vc [target|macrodef [target|macrodef] [...]]
122#
123#                        Standard (no frills)
124#       c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
125#       Setting environment for using Microsoft Visual C++ tools.
126#       c:\tcl_src\win\>nmake -f makefile.vc release
127#       c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl
128#
129#                         Building for Win64
130#       c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
131#       Setting environment for using Microsoft Visual C++ tools.
132#       c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /pre64 /RETAIL
133#       Targeting Windows pre64 RETAIL
134#       c:\tcl_src\win\>nmake -f makefile.vc MACHINE=IA64
135#
136#------------------------------------------------------------------------------
137#==============================================================================
138###############################################################################
139
140
141#    //==================================================================\\
142#   >>[               -> Do not modify below this line. <-               ]<<
143#   >>[  Please, use the commandline macros to modify how Tcl is built.  ]<<
144#   >>[  If you need more features, send us a patch for more macros.     ]<<
145#    \\==================================================================//
146
147
148###############################################################################
149#==============================================================================
150#------------------------------------------------------------------------------
151
152!if !exist("makefile.vc")
153MSG = ^
154You must run this makefile only from the directory it is in.^
155Please `cd` to its location first.
156!error $(MSG)
157!endif
158
159PROJECT	= tcl
160!include "rules.vc"
161
162STUBPREFIX = $(PROJECT)stub
163DOTVERSION = 8.4
164VERSION = $(DOTVERSION:.=)
165
166DDEDOTVERSION = 1.2
167DDEVERSION = $(DDEDOTVERSION:.=)
168
169REGDOTVERSION = 1.1
170REGVERSION = $(REGDOTVERSION:.=)
171
172BINROOT		= .
173ROOT		= ..
174
175TCLIMPLIB	= $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
176TCLLIBNAME	= $(PROJECT)$(VERSION)$(SUFX).$(EXT)
177TCLLIB		= $(OUT_DIR)\$(TCLLIBNAME)
178
179TCLSTUBLIBNAME	= $(STUBPREFIX)$(VERSION).lib
180TCLSTUBLIB	= $(OUT_DIR)\$(TCLSTUBLIBNAME)
181
182TCLSHNAME	= $(PROJECT)sh$(VERSION)$(SUFX).exe
183TCLSH		= $(OUT_DIR)\$(TCLSHNAME)
184TCLPIPEDLLNAME	= $(PROJECT)pip$(VERSION)$(SUFX:t=).dll
185TCLPIPEDLL	= $(OUT_DIR)\$(TCLPIPEDLLNAME)
186
187TCLREGLIBNAME	= $(PROJECT)reg$(REGVERSION)$(SUFX:t=).$(EXT)
188TCLREGLIB	= $(OUT_DIR)\$(TCLREGLIBNAME)
189
190TCLDDELIBNAME	= $(PROJECT)dde$(DDEVERSION)$(SUFX:t=).$(EXT)
191TCLDDELIB	= $(OUT_DIR)\$(TCLDDELIBNAME)
192
193TCLTEST		= $(OUT_DIR)\$(PROJECT)test.exe
194CAT32		= $(OUT_DIR)\cat32.exe
195
196### Make sure we use backslash only.
197LIB_INSTALL_DIR		= $(_INSTALLDIR)\lib
198BIN_INSTALL_DIR		= $(_INSTALLDIR)\bin
199DOC_INSTALL_DIR		= $(_INSTALLDIR)\doc
200SCRIPT_INSTALL_DIR	= $(_INSTALLDIR)\lib\tcl$(DOTVERSION)
201INCLUDE_INSTALL_DIR	= $(_INSTALLDIR)\include
202
203TCLSHOBJS = \
204	$(TMP_DIR)\tclAppInit.obj \
205!if $(TCL_USE_STATIC_PACKAGES)
206	$(TMP_DIR)\tclWinReg.obj \
207	$(TMP_DIR)\tclWinDde.obj \
208!endif
209	$(TMP_DIR)\tclsh.res
210
211TCLTESTOBJS = \
212	$(TMP_DIR)\tclTest.obj \
213	$(TMP_DIR)\tclTestObj.obj \
214	$(TMP_DIR)\tclTestProcBodyObj.obj \
215	$(TMP_DIR)\tclThreadTest.obj \
216	$(TMP_DIR)\tclWinTest.obj \
217!if $(TCL_USE_STATIC_PACKAGES)
218	$(TMP_DIR)\tclWinReg.obj \
219	$(TMP_DIR)\tclWinDde.obj \
220!endif
221	$(TMP_DIR)\testMain.obj
222
223TCLOBJS = \
224	$(TMP_DIR)\regcomp.obj \
225	$(TMP_DIR)\regerror.obj \
226	$(TMP_DIR)\regexec.obj \
227	$(TMP_DIR)\regfree.obj \
228	$(TMP_DIR)\strftime.obj \
229	$(TMP_DIR)\strtoll.obj \
230	$(TMP_DIR)\strtoull.obj \
231	$(TMP_DIR)\tclAlloc.obj \
232	$(TMP_DIR)\tclAsync.obj \
233	$(TMP_DIR)\tclBasic.obj \
234	$(TMP_DIR)\tclBinary.obj \
235	$(TMP_DIR)\tclCkalloc.obj \
236	$(TMP_DIR)\tclClock.obj \
237	$(TMP_DIR)\tclCmdAH.obj \
238	$(TMP_DIR)\tclCmdIL.obj \
239	$(TMP_DIR)\tclCmdMZ.obj \
240	$(TMP_DIR)\tclCompCmds.obj \
241	$(TMP_DIR)\tclCompExpr.obj \
242	$(TMP_DIR)\tclCompile.obj \
243	$(TMP_DIR)\tclDate.obj \
244	$(TMP_DIR)\tclEncoding.obj \
245	$(TMP_DIR)\tclEnv.obj \
246	$(TMP_DIR)\tclEvent.obj \
247	$(TMP_DIR)\tclExecute.obj \
248	$(TMP_DIR)\tclFCmd.obj \
249	$(TMP_DIR)\tclFileName.obj \
250	$(TMP_DIR)\tclGet.obj \
251	$(TMP_DIR)\tclHash.obj \
252	$(TMP_DIR)\tclHistory.obj \
253	$(TMP_DIR)\tclIndexObj.obj \
254	$(TMP_DIR)\tclInterp.obj \
255	$(TMP_DIR)\tclIO.obj \
256	$(TMP_DIR)\tclIOCmd.obj \
257	$(TMP_DIR)\tclIOGT.obj \
258	$(TMP_DIR)\tclIOSock.obj \
259	$(TMP_DIR)\tclIOUtil.obj \
260	$(TMP_DIR)\tclLink.obj \
261	$(TMP_DIR)\tclListObj.obj \
262	$(TMP_DIR)\tclLiteral.obj \
263	$(TMP_DIR)\tclLoad.obj \
264	$(TMP_DIR)\tclMain.obj \
265	$(TMP_DIR)\tclNamesp.obj \
266	$(TMP_DIR)\tclNotify.obj \
267	$(TMP_DIR)\tclObj.obj \
268	$(TMP_DIR)\tclPanic.obj \
269	$(TMP_DIR)\tclParse.obj \
270	$(TMP_DIR)\tclParseExpr.obj \
271	$(TMP_DIR)\tclPipe.obj \
272	$(TMP_DIR)\tclPkg.obj \
273	$(TMP_DIR)\tclPosixStr.obj \
274	$(TMP_DIR)\tclPreserve.obj \
275	$(TMP_DIR)\tclProc.obj \
276	$(TMP_DIR)\tclRegexp.obj \
277	$(TMP_DIR)\tclResolve.obj \
278	$(TMP_DIR)\tclResult.obj \
279	$(TMP_DIR)\tclScan.obj \
280	$(TMP_DIR)\tclStringObj.obj \
281	$(TMP_DIR)\tclStubInit.obj \
282	$(TMP_DIR)\tclStubLib.obj \
283	$(TMP_DIR)\tclThread.obj \
284	$(TMP_DIR)\tclThreadAlloc.obj \
285	$(TMP_DIR)\tclThreadJoin.obj \
286	$(TMP_DIR)\tclTimer.obj \
287	$(TMP_DIR)\tclUtf.obj \
288	$(TMP_DIR)\tclUtil.obj \
289	$(TMP_DIR)\tclVar.obj \
290	$(TMP_DIR)\tclWin32Dll.obj \
291	$(TMP_DIR)\tclWinChan.obj \
292	$(TMP_DIR)\tclWinConsole.obj \
293	$(TMP_DIR)\tclWinSerial.obj \
294	$(TMP_DIR)\tclWinError.obj \
295	$(TMP_DIR)\tclWinFCmd.obj \
296	$(TMP_DIR)\tclWinFile.obj \
297	$(TMP_DIR)\tclWinInit.obj \
298	$(TMP_DIR)\tclWinLoad.obj \
299	$(TMP_DIR)\tclWinMtherr.obj \
300	$(TMP_DIR)\tclWinNotify.obj \
301	$(TMP_DIR)\tclWinPipe.obj \
302	$(TMP_DIR)\tclWinSock.obj \
303	$(TMP_DIR)\tclWinThrd.obj \
304	$(TMP_DIR)\tclWinTime.obj \
305!if !$(STATIC_BUILD)
306	$(TMP_DIR)\tcl.res
307!endif
308
309TCLSTUBOBJS = $(TMP_DIR)\tclStubLib.obj
310
311### The following paths CANNOT have spaces in them.
312COMPATDIR	= $(ROOT)\compat
313DOCDIR		= $(ROOT)\doc
314GENERICDIR	= $(ROOT)\generic
315TOOLSDIR	= $(ROOT)\tools
316WINDIR		= $(ROOT)\win
317
318
319#---------------------------------------------------------------------
320# Compile flags
321#---------------------------------------------------------------------
322
323!if !$(DEBUG)
324!if $(OPTIMIZING)
325### This cranks the optimization level to maximize speed
326cdebug	= -O2 $(OPTIMIZATIONS)
327!else
328cdebug	=
329!endif
330!else if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
331### Warnings are too many, can't support warnings into errors.
332cdebug	= -Zi -Od $(DEBUGFLAGS)
333!else
334cdebug	= -Zi -WX $(DEBUGFLAGS)
335!endif
336
337### Declarations common to all compiler options
338cwarn = -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE
339cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\
340
341!if $(FULLWARNINGS)
342cflags = $(cflags) -W4
343!else
344cflags = $(cflags) -W3
345!endif
346
347!if $(MSVCRT)
348!if "$(DBGX)" == ""
349crt = -MD
350!else
351crt = -MDd
352!endif
353!else
354!if "$(DBGX)" == ""
355crt = -MT
356!else
357crt = -MTd
358!endif
359!endif
360
361TCL_INCLUDES	= -I"$(WINDIR)" -I"$(GENERICDIR)"
362BASE_CFLAGS	= $(cflags) $(cdebug) $(crt) $(TCL_INCLUDES) \
363			-DTCL_PIPE_DLL=\"$(TCLPIPEDLLNAME)\"
364CON_CFLAGS	= $(cflags) $(cdebug) $(crt) -DCONSOLE
365TCL_CFLAGS	= $(BASE_CFLAGS) $(OPTDEFINES)
366
367
368#---------------------------------------------------------------------
369# Link flags
370#---------------------------------------------------------------------
371
372!if $(DEBUG)
373ldebug	= -debug:full -debugtype:cv
374!else
375ldebug	= -release -opt:ref -opt:icf,3
376!endif
377
378### Declarations common to all linker options
379lflags	= -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
380
381!if $(FULLWARNINGS)
382lflags = $(lflags) -warn:3
383!endif
384
385!if $(PROFILE)
386lflags	= $(lflags) -profile
387!endif
388
389!if $(ALIGN98_HACK) && !$(STATIC_BUILD)
390### Align sections for PE size savings.
391lflags	= $(lflags) -opt:nowin98
392!else if !$(ALIGN98_HACK) && $(STATIC_BUILD)
393### Align sections for speed in loading by choosing the virtual page size.
394lflags	= $(lflags) -align:4096
395!endif
396
397!if $(LOIMPACT)
398lflags	= $(lflags) -ws:aggressive
399!endif
400
401dlllflags = $(lflags) -dll
402conlflags = $(lflags) -subsystem:console
403guilflags = $(lflags) -subsystem:windows
404
405baselibs  = kernel32.lib advapi32.lib user32.lib
406# Avoid 'unresolved external symbol __security_cookie' errors.
407# c.f. http://support.microsoft.com/?id=894573
408!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
409baselibs   = $(baselibs) bufferoverflowU.lib
410!endif
411
412#---------------------------------------------------------------------
413# TclTest flags
414#---------------------------------------------------------------------
415
416!if "$(TESTPAT)" != ""
417TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
418!endif
419
420
421#---------------------------------------------------------------------
422# Project specific targets
423#---------------------------------------------------------------------
424
425release:    setup $(TCLSH) $(TCLSTUBLIB) dlls
426core:	    setup $(TCLLIB) $(TCLSTUBLIB)
427shell:	    setup $(TCLSH)
428dlls:	    setup $(TCLPIPEDLL) $(TCLREGLIB) $(TCLDDELIB)
429all:	    setup $(TCLSH) $(TCLSTUBLIB) dlls $(CAT32) 
430tcltest:    setup $(TCLTEST) dlls $(CAT32)
431install:    install-binaries install-libraries install-docs
432
433
434test: setup $(TCLTEST) dlls $(CAT32)
435	set TCL_LIBRARY=$(ROOT)/library
436!if "$(OS)" == "Windows_NT"  || "$(MSVCDIR)" == "IDE"
437	$(TCLTEST) "$(ROOT)/tests/all.tcl" $(TESTFLAGS)
438!else
439	$(TCLTEST) "$(ROOT)/tests/all.tcl" $(TESTFLAGS) > tests.log
440	type tests.log | more
441!endif
442
443runtest: setup $(TCLTEST) dlls $(CAT32)
444	set TCL_LIBRARY=$(ROOT)/library
445	$(TCLTEST)
446
447setup:
448	@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
449	@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
450
451!if !$(STATIC_BUILD)
452$(TCLIMPLIB): $(TCLLIB)
453!endif
454
455$(TCLLIB): $(TCLOBJS)
456!if $(STATIC_BUILD)
457	$(lib32) -nologo -out:$@ @<<
458$**
459<<
460!else
461	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcl -out:$@ \
462		$(baselibs) @<<
463$**
464<<
465	$(_VC_MANIFEST_EMBED_DLL)
466	-@del $*.exp
467!endif
468
469$(TCLSTUBLIB): $(TCLSTUBOBJS)
470	$(lib32) -nologo -out:$@ $(TCLSTUBOBJS)
471
472$(TCLSH): $(TCLSHOBJS) $(TCLIMPLIB)
473	$(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $**
474	$(_VC_MANIFEST_EMBED_EXE)
475
476$(TCLTEST): $(TCLTESTOBJS) $(TCLIMPLIB)
477	$(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $**
478	$(_VC_MANIFEST_EMBED_EXE)
479
480$(TCLPIPEDLL): $(WINDIR)\stub16.c
481	$(cc32) $(CON_CFLAGS) -Fo$(TMP_DIR)\ $(WINDIR)\stub16.c
482	$(link32) $(conlflags) -out:$@ $(TMP_DIR)\stub16.obj $(baselibs)
483	$(_VC_MANIFEST_EMBED_DLL)
484
485!if $(STATIC_BUILD)
486$(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj
487	$(lib32) -nologo -out:$@ $(TMP_DIR)\tclWinDde.obj
488!else
489$(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB)
490	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcldde -out:$@ \
491		$** $(baselibs)
492	$(_VC_MANIFEST_EMBED_DLL)
493	-@del $*.exp
494	-@del $*.lib
495!endif
496
497!if $(STATIC_BUILD)
498$(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj
499	$(lib32) -nologo -out:$@ $(TMP_DIR)\tclWinReg.obj
500!else
501$(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLSTUBLIB)
502	$(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tclreg -out:$@ \
503		$** $(baselibs)
504	$(_VC_MANIFEST_EMBED_DLL)
505	-@del $*.exp
506	-@del $*.lib
507!endif
508
509$(CAT32): $(WINDIR)\cat.c
510	$(cc32) $(CON_CFLAGS) -Fo$(TMP_DIR)\ $?
511	$(link32) $(conlflags) -out:$@ -stack:16384 $(TMP_DIR)\cat.obj \
512		$(baselibs)
513	$(_VC_MANIFEST_EMBED_EXE)
514
515#---------------------------------------------------------------------
516# Regenerate the stubs files.  [Development use only]
517#---------------------------------------------------------------------
518
519genstubs:
520!if !exist($(TCLSH))
521	@echo Build tclsh first!
522!else
523	$(TCLSH) $(TOOLSDIR:\=/)\genStubs.tcl $(GENERICDIR:\=/) \
524		$(GENERICDIR:\=/)/tcl.decls $(GENERICDIR:\=/)/tclInt.decls
525!endif
526
527
528#---------------------------------------------------------------------
529# Generate the makefile depedancies.
530#---------------------------------------------------------------------
531
532depend:
533!if !exist($(TCLSH))
534	@echo Build tclsh first!
535!else
536	$(TCLSH) $(TOOLSDIR:\=/)/mkdepend.tcl -vc32 -out:"$(OUT_DIR)\depend.mk" \
537		-passthru:"-DBUILD_tcl $(TCL_INCLUDES:"="")" $(GENERICDIR) \
538		$(COMPATDIR) $(WINDIR) @<<
539$(TCLOBJS)
540<<
541!endif
542
543
544#---------------------------------------------------------------------
545# Build the windows help file.
546#---------------------------------------------------------------------
547
548TCLHLPBASE	= $(PROJECT)$(VERSION)
549HELPFILE	= $(OUT_DIR)\$(TCLHLPBASE).hlp
550HELPCNT		= $(OUT_DIR)\$(TCLHLPBASE).cnt
551DOCTMP_DIR	= $(OUT_DIR)\$(PROJECT)_docs
552HELPRTF		= $(DOCTMP_DIR)\$(PROJECT).rtf
553MAN2HELP	= $(DOCTMP_DIR)\man2help.tcl
554MAN2HELP2	= $(DOCTMP_DIR)\man2help2.tcl
555INDEX		= $(DOCTMP_DIR)\index.tcl
556BMP		= $(DOCTMP_DIR)\feather.bmp
557BMP_NOPATH	= feather.bmp
558MAN2TCL		= $(DOCTMP_DIR)\man2tcl.exe
559
560winhelp: docsetup $(HELPFILE)
561
562docsetup:
563	@if not exist $(DOCTMP_DIR)\nul mkdir $(DOCTMP_DIR)
564
565$(MAN2HELP) $(MAN2HELP2) $(INDEX) $(BMP): $(TOOLSDIR)\$$(@F)
566	@$(CPY) $(TOOLSDIR)\$(@F) $(@D)
567
568$(HELPFILE): $(HELPRTF) $(BMP)
569	cd $(DOCTMP_DIR)
570	start /wait hcrtf.exe -x <<$(PROJECT).hpj
571[OPTIONS]
572COMPRESS=12 Hall Zeck
573LCID=0x409 0x0 0x0 ; English (United States)
574TITLE=Tcl/Tk Reference Manual
575BMROOT=.
576CNT=$(@B).cnt
577HLP=$(@B).hlp
578
579[FILES]
580$(PROJECT).rtf
581
582[WINDOWS]
583main="Tcl/Tk Reference Manual",,27648,(r15263976),(r65535)
584
585[CONFIG]
586BrowseButtons()
587CreateButton(1, "Web", ExecFile("http://www.tcl.tk"))
588CreateButton(2, "SF", ExecFile("http://sf.net/projects/tcl"))
589CreateButton(3, "Wiki", ExecFile("http://wiki.tcl.tk"))
590CreateButton(4, "FAQ", ExecFile("http://www.purl.org/NET/Tcl-FAQ/"))
591<<
592	cd $(MAKEDIR)
593	@$(CPY) "$(DOCTMP_DIR)\$(@B).hlp" "$(OUT_DIR)"
594	@$(CPY) "$(DOCTMP_DIR)\$(@B).cnt" "$(OUT_DIR)"
595
596$(MAN2TCL): $(TOOLSDIR)\$$(@B).c
597	$(cc32) $(TCL_CFLAGS) -Fo$(@D)\ $(TOOLSDIR)\$(@B).c
598	$(link32) $(conlflags) -out:$@ -stack:16384 $(@D)\man2tcl.obj
599	$(_VC_MANIFEST_EMBED_EXE)
600
601$(HELPRTF): $(MAN2TCL) $(MAN2HELP) $(MAN2HELP2) $(INDEX) $(DOCDIR)\*
602	$(TCLSH) $(MAN2HELP) -bitmap $(BMP_NOPATH) $(PROJECT) $(VERSION) $(DOCDIR:\=/)
603
604install-docs:
605!if exist($(HELPFILE))
606	@$(CPY) "$(HELPFILE)" "$(DOC_INSTALL_DIR)\"
607	@$(CPY) "$(HELPCNT)" "$(DOC_INSTALL_DIR)\"
608!endif
609
610
611#---------------------------------------------------------------------
612# Special case object file targets
613#---------------------------------------------------------------------
614
615$(TMP_DIR)\testMain.obj: $(WINDIR)\tclAppInit.c
616!if $(TCL_USE_STATIC_PACKAGES)
617	$(cc32) $(TCL_CFLAGS) -DTCL_TEST -DTCL_USE_STATIC_PACKAGES -Fo$@ $?
618!else
619	$(cc32) $(TCL_CFLAGS) -DTCL_TEST -Fo$@ $?
620!endif
621
622$(TMP_DIR)\tclTest.obj: $(GENERICDIR)\tclTest.c
623	$(cc32) $(TCL_CFLAGS) -Fo$@ $?
624
625$(TMP_DIR)\tclTestObj.obj: $(GENERICDIR)\tclTestObj.c
626	$(cc32) $(TCL_CFLAGS) -Fo$@ $?
627
628$(TMP_DIR)\tclWinTest.obj: $(WINDIR)\tclWinTest.c
629	$(cc32) $(TCL_CFLAGS) -Fo$@ $?
630
631$(TMP_DIR)\tclAppInit.obj: $(WINDIR)\tclAppInit.c
632!if $(TCL_USE_STATIC_PACKAGES)
633	$(cc32) $(TCL_CFLAGS) -DTCL_USE_STATIC_PACKAGES -Fo$@ $?
634!else
635	$(cc32) $(TCL_CFLAGS) -Fo$@ $?
636!endif
637
638### The following objects should be built using the stub interfaces
639### *ALL* extensions need to built with -DTCL_THREADS=1
640
641$(TMP_DIR)\tclWinReg.obj: $(WINDIR)\tclWinReg.c
642!if $(STATIC_BUILD)
643	$(cc32) $(BASE_CFLAGS) -DTCL_THREADS=1 -DSTATIC_BUILD -Fo$@ $?
644!else
645	$(cc32) $(BASE_CFLAGS) -DTCL_THREADS=1 -DUSE_TCL_STUBS -Fo$@ $?
646!endif
647
648
649$(TMP_DIR)\tclWinDde.obj: $(WINDIR)\tclWinDde.c
650!if $(STATIC_BUILD)
651	$(cc32) $(BASE_CFLAGS) -DTCL_THREADS=1 -DSTATIC_BUILD -Fo$@ $?
652!else
653	$(cc32) $(BASE_CFLAGS) -DTCL_THREADS=1 -DUSE_TCL_STUBS -Fo$@ $?
654!endif
655
656
657### The following objects are part of the stub library and should not
658### be built as DLL objects.  -Zl is used to avoid a dependancy on any
659### specific C run-time.
660
661$(TMP_DIR)\tclStubLib.obj: $(GENERICDIR)\tclStubLib.c
662	$(cc32) $(cdebug) $(cflags) -Zl -DSTATIC_BUILD $(TCL_INCLUDES) -Fo$@ $?
663
664
665#---------------------------------------------------------------------
666# Dedependency rules
667#---------------------------------------------------------------------
668
669$(GENERICDIR)\regcomp.c: \
670	$(GENERICDIR)\regguts.h \
671	$(GENERICDIR)\regc_lex.c \
672	$(GENERICDIR)\regc_color.c \
673	$(GENERICDIR)\regc_nfa.c \
674	$(GENERICDIR)\regc_cvec.c \
675	$(GENERICDIR)\regc_locale.c
676$(GENERICDIR)\regcustom.h: \
677	$(GENERICDIR)\tclInt.h \
678	$(GENERICDIR)\tclPort.h \
679	$(GENERICDIR)\regex.h
680$(GENERICDIR)\regexec.c: \
681	$(GENERICDIR)\rege_dfa.c \
682	$(GENERICDIR)\regguts.h
683$(GENERICDIR)\regerror.c: $(GENERICDIR)\regguts.h
684$(GENERICDIR)\regfree.c: $(GENERICDIR)\regguts.h
685$(GENERICDIR)\regfronts.c: $(GENERICDIR)\regguts.h
686$(GENERICDIR)\regguts.h: $(GENERICDIR)\regcustom.h
687
688!if exist("$(OUT_DIR)\depend.mk")
689!include "$(OUT_DIR)\depend.mk"
690!message *** Dependency rules in effect.
691!else
692!message *** Dependency rules are not being used.
693!endif
694
695### add a spacer in the output
696!message
697
698
699#---------------------------------------------------------------------
700# Implicit rules
701#---------------------------------------------------------------------
702
703{$(WINDIR)}.c{$(TMP_DIR)}.obj::
704    $(cc32) $(TCL_CFLAGS) -DBUILD_tcl -Fo$(TMP_DIR)\ @<<
705$<
706<<
707
708{$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
709    $(cc32) $(TCL_CFLAGS) -DBUILD_tcl -Fo$(TMP_DIR)\ @<<
710$<
711<<
712
713{$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
714    $(cc32) $(TCL_CFLAGS) -DBUILD_tcl -Fo$(TMP_DIR)\ @<<
715$<
716<<
717
718{$(WINDIR)}.rc{$(TMP_DIR)}.res:
719	$(rc32) -fo $@ -r -i "$(GENERICDIR)" -D__WIN32__ \
720!if $(DEBUG)
721	-d DEBUG \
722!endif
723!if $(TCL_THREADS)
724	-d TCL_THREADS \
725!endif
726!if $(STATIC_BUILD)
727	-d STATIC_BUILD \
728!endif
729	$<
730
731.SUFFIXES:
732.SUFFIXES:.c .rc
733
734
735#---------------------------------------------------------------------
736# Installation.
737#---------------------------------------------------------------------
738
739install-binaries:
740	@echo Installing to '$(_INSTALLDIR)'
741	@echo installing $(TCLLIBNAME)
742!if "$(TCLLIB)" != "$(TCLIMPLIB)"
743	@$(CPY) "$(TCLLIB)" "$(BIN_INSTALL_DIR)\"
744!endif
745	@$(CPY) "$(TCLIMPLIB)" "$(LIB_INSTALL_DIR)\"
746!if exist($(TCLSH))
747	@echo installing $(TCLSHNAME)
748	@$(CPY) "$(TCLSH)" "$(BIN_INSTALL_DIR)\"
749!endif
750!if exist($(TCLPIPEDLL))
751	@echo installing $(TCLPIPEDLLNAME)
752	@$(CPY) "$(TCLPIPEDLL)" "$(BIN_INSTALL_DIR)\"
753!endif
754	@echo installing $(TCLSTUBLIBNAME)
755	@$(CPY) "$(TCLSTUBLIB)" "$(LIB_INSTALL_DIR)\"
756
757install-libraries:
758	@echo installing http1.0
759	@$(CPY) "$(ROOT)\library\http1.0\*.tcl" \
760		"$(SCRIPT_INSTALL_DIR)\http1.0\"
761	@echo installing http2.5
762	@$(CPY) "$(ROOT)\library\http\*.tcl" \
763		"$(SCRIPT_INSTALL_DIR)\http2.5\"
764	@echo installing opt0.4
765	@$(CPY) "$(ROOT)\library\opt\*.tcl" \
766		"$(SCRIPT_INSTALL_DIR)\opt0.4\"
767	@echo installing msgcat1.3
768	@$(CPY) "$(ROOT)\library\msgcat\*.tcl" \
769	    "$(SCRIPT_INSTALL_DIR)\msgcat1.3\"
770	@echo installing tcltest2.2 
771	@$(CPY) "$(ROOT)\library\tcltest\*.tcl" \
772	    "$(SCRIPT_INSTALL_DIR)\tcltest2.2\"
773	@echo installing $(TCLDDELIBNAME)
774!if $(STATIC_BUILD)
775	@$(CPY) "$(TCLDDELIB)" "$(LIB_INSTALL_DIR)\"
776!else
777	@$(CPY) "$(TCLDDELIB)" "$(LIB_INSTALL_DIR)\dde$(DDEDOTVERSION)\"
778	@$(CPY) "$(ROOT)\library\dde\pkgIndex.tcl" \
779	    "$(LIB_INSTALL_DIR)\dde$(DDEDOTVERSION)\"
780!endif
781	@echo installing $(TCLREGLIBNAME)
782!if $(STATIC_BUILD)
783	@$(CPY) "$(TCLREGLIB)" "$(LIB_INSTALL_DIR)\"
784!else
785	@$(CPY) "$(TCLREGLIB)" "$(LIB_INSTALL_DIR)\reg$(REGDOTVERSION)\"
786	@$(CPY) "$(ROOT)\library\reg\pkgIndex.tcl" \
787	    "$(LIB_INSTALL_DIR)\reg$(REGDOTVERSION)\"
788!endif
789	@echo installing encoding files
790	@$(CPY) "$(ROOT)\library\encoding\*.enc" \
791		"$(SCRIPT_INSTALL_DIR)\encoding\"
792	@echo installing library files
793	@$(CPY) "$(GENERICDIR)\tcl.h"          "$(INCLUDE_INSTALL_DIR)\"
794	@$(CPY) "$(GENERICDIR)\tclDecls.h"     "$(INCLUDE_INSTALL_DIR)\"
795	@$(CPY) "$(GENERICDIR)\tclPlatDecls.h" "$(INCLUDE_INSTALL_DIR)\"
796	@$(CPY) "$(ROOT)\library\history.tcl"  "$(SCRIPT_INSTALL_DIR)\"
797	@$(CPY) "$(ROOT)\library\init.tcl"     "$(SCRIPT_INSTALL_DIR)\"
798	@$(CPY) "$(ROOT)\library\ldAout.tcl"   "$(SCRIPT_INSTALL_DIR)\"
799	@$(CPY) "$(ROOT)\library\parray.tcl"   "$(SCRIPT_INSTALL_DIR)\"
800	@$(CPY) "$(ROOT)\library\safe.tcl"     "$(SCRIPT_INSTALL_DIR)\"
801	@$(CPY) "$(ROOT)\library\tclIndex"     "$(SCRIPT_INSTALL_DIR)\"
802	@$(CPY) "$(ROOT)\library\package.tcl"  "$(SCRIPT_INSTALL_DIR)\"
803	@$(CPY) "$(ROOT)\library\word.tcl"     "$(SCRIPT_INSTALL_DIR)\"
804	@$(CPY) "$(ROOT)\library\auto.tcl"     "$(SCRIPT_INSTALL_DIR)\"
805
806
807#---------------------------------------------------------------------
808# Clean up
809#---------------------------------------------------------------------
810
811tidy:
812	@echo Removing $(TCLLIB) ...
813	@if exist $(TCLLIB) del $(TCLLIB)
814	@echo Removing $(TCLSH) ...
815	@if exist $(TCLSH) del $(TCLSH)
816	@echo Removing $(TCLTEST) ...
817	@if exist $(TCLTEST) del $(TCLTEST)
818	@echo Removing $(TCLDDELIB) ...
819	@if exist $(TCLDDELIB) del $(TCLDDELIB)
820	@echo Removing $(TCLREGLIB) ...
821	@if exist $(TCLREGLIB) del $(TCLREGLIB)
822
823clean:
824	@echo Cleaning $(TMP_DIR)\* ...
825	@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
826
827hose:
828	@echo Hosing $(OUT_DIR)\* ...
829	@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
830
831