source: trunk/kitgen/8.x/blt/win/makefile.vc

Last change on this file was 175, checked in by demin, 12 years ago

initial commit

File size: 15.1 KB
Line 
1# makefile.vc -- -*- Makefile -*-
2#
3# Microsoft Visual C++ makefile for use with nmake.exe v1.62+ (VC++ 5.0+)
4#
5# This makefile is based upon the Tcl 8.4 Makefile.vc and modified to
6# make it suitable as a general package makefile. Look for the word EDIT
7# which marks sections that may need modification. As a minumum you will
8# need to change the PROJECT, DOTVERSION and DLLOBJS variables to values
9# relevant to your package.
10#
11# See the file "license.terms" for information on usage and redistribution
12# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13#
14# Copyright (c) 1995-1996 Sun Microsystems, Inc.
15# Copyright (c) 1998-2000 Ajuba Solutions.
16# Copyright (c) 2001 ActiveState Corporation.
17# Copyright (c) 2001-2002 David Gravereaux.
18# Copyright (c) 2003-2006 Pat Thoyts
19#
20#-------------------------------------------------------------------------
21# RCS: @(#)$Id: makefile.vc,v 1.10 2008/06/18 11:01:39 patthoyts Exp $
22#-------------------------------------------------------------------------
23
24# Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR)
25# or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define
26# VCINSTALLDIR instead. The MSVC Toolkit release defines yet another.
27!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) && !defined(VCINSTALLDIR) && !defined(VCToolkitInstallDir)
28MSG = ^
29You need to run vcvars32.bat from Developer Studio or setenv.bat from the^
30Platform SDK first to setup the environment. Jump to this line to read^
31the build instructions.
32!error $(MSG)
33!endif
34
35#------------------------------------------------------------------------------
36# HOW TO USE this makefile:
37#
38# 1) It is now necessary to have %MSVCDir% set in the environment. This is
39# used as a check to see if vcvars32.bat had been run prior to running
40# nmake or during the installation of Microsoft Visual C++, MSVCDir had
41# been set globally and the PATH adjusted. Either way is valid.
42#
43# You'll need to run vcvars32.bat contained in the MsDev's vc(98)/bin
44# directory to setup the proper environment, if needed, for your current
45# setup. This is a needed bootstrap requirement and allows the swapping of
46# different environments to be easier.
47#
48# 2) To use the Platform SDK (not expressly needed), run setenv.bat after
49# vcvars32.bat according to the instructions for it. This can also turn on
50# the 64-bit compiler, if your SDK has it.
51#
52# 3) Targets are:
53# all -- Builds everything.
54# <project> -- Builds the project (eg: nmake sample)
55# test -- Builds and runs the test suite.
56# install -- Installs the built binaries and libraries to $(INSTALLDIR)
57# in an appropriate subdirectory.
58# clean/realclean/distclean -- varying levels of cleaning.
59#
60# 4) Macros usable on the commandline:
61# INSTALLDIR=<path>
62# Sets where to install Tcl from the built binaries.
63# C:\Progra~1\Tcl is assumed when not specified.
64#
65# OPTS=static,msvcrt,staticpkg,threads,symbols,profile,loimpact,none
66# Sets special options for the core. The default is for none.
67# Any combination of the above may be used (comma separated).
68# 'none' will over-ride everything to nothing.
69#
70# static = Builds a static library of the core instead of a
71# dll. The shell will be static (and large), as well.
72# msvcrt = Effects the static option only to switch it from
73# using libcmt(d) as the C runtime [by default] to
74# msvcrt(d). This is useful for static embedding
75# support.
76# staticpkg = Effects the static option only to switch
77# tclshXX.exe to have the dde and reg extension linked
78# inside it.
79# nothreads = Turns off multithreading support (not recommended)
80# thrdalloc = Use the thread allocator (shared global free pool).
81# symbols = Adds symbols for step debugging.
82# profile = Adds profiling hooks. Map file is assumed.
83# loimpact = Adds a flag for how NT treats the heap to keep memory
84# in use, low. This is said to impact alloc performance.
85#
86# STATS=memdbg,compdbg,none
87# Sets optional memory and bytecode compiler debugging code added
88# to the core. The default is for none. Any combination of the
89# above may be used (comma separated). 'none' will over-ride
90# everything to nothing.
91#
92# memdbg = Enables the debugging memory allocator.
93# compdbg = Enables byte compilation logging.
94#
95# MACHINE=(IX86|IA64|ALPHA|AMD64)
96# Set the machine type used for the compiler, linker, and
97# resource compiler. This hook is needed to tell the tools
98# when alternate platforms are requested. IX86 is the default
99# when not specified. If the CPU environment variable has been
100# set (ie: recent Platform SDK) then MACHINE is set from CPU.
101#
102# TMP_DIR=<path>
103# OUT_DIR=<path>
104# Hooks to allow the intermediate and output directories to be
105# changed. $(OUT_DIR) is assumed to be
106# $(BINROOT)\(Release|Debug) based on if symbols are requested.
107# $(TMP_DIR) will de $(OUT_DIR)\<buildtype> by default.
108#
109# TESTPAT=<file>
110# Reads the tests requested to be run from this file.
111#
112# CFG_ENCODING=encoding
113# name of encoding for configuration information. Defaults
114# to cp1252
115#
116# 5) Examples:
117#
118# Basic syntax of calling nmake looks like this:
119# nmake [-nologo] -f makefile.vc [target|macrodef [target|macrodef] [...]]
120#
121# Standard (no frills)
122# c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
123# Setting environment for using Microsoft Visual C++ tools.
124# c:\tcl_src\win\>nmake -f makefile.vc all
125# c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl
126#
127# Building for Win64
128# c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
129# Setting environment for using Microsoft Visual C++ tools.
130# c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /pre64 /RETAIL
131# Targeting Windows pre64 RETAIL
132# c:\tcl_src\win\>nmake -f makefile.vc MACHINE=IA64
133#
134#------------------------------------------------------------------------------
135#==============================================================================
136###############################################################################
137#------------------------------------------------------------------------------
138
139!if !exist("makefile.vc")
140MSG = ^
141You must run this makefile only from the directory it is in.^
142Please `cd` to its location first.
143!error $(MSG)
144!endif
145
146#-------------------------------------------------------------------------
147# Project specific information (EDIT)
148#
149# You should edit this with the name and version of your project. This
150# information is used to generate the name of the package library and
151# it's install location.
152#
153# For example, the sample extension is going to build sample04.dll and
154# would install it into $(INSTALLDIR)\lib\sample04
155#
156# You need to specify the object files that need to be linked into your
157# binary here.
158#
159#-------------------------------------------------------------------------
160
161PROJECT = sample
162
163# Uncomment the following line if this is a Tk extension.
164#PROJECT_REQUIRES_TK=1
165!include "rules.vc"
166
167DOTVERSION = 0.5
168VERSION = $(DOTVERSION:.=)
169STUBPREFIX = $(PROJECT)stub
170
171DLLOBJS = \
172 $(TMP_DIR)\tclsample.obj \
173 $(TMP_DIR)\sample.obj \
174!if !$(STATIC_BUILD)
175 $(TMP_DIR)\sample.res
176!endif
177
178#-------------------------------------------------------------------------
179# Target names and paths ( shouldn't need changing )
180#-------------------------------------------------------------------------
181
182BINROOT = .
183ROOT = ..
184
185PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
186PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
187PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
188
189PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
190PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME)
191
192### Make sure we use backslash only.
193PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
194LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)
195BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)
196DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR)
197SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR)
198INCLUDE_INSTALL_DIR = $(_TCLDIR)\include
199
200### The following paths CANNOT have spaces in them.
201GENERICDIR = $(ROOT)\generic
202WINDIR = $(ROOT)\win
203LIBDIR = $(ROOT)\library
204DOCDIR = $(ROOT)\doc
205TOOLSDIR = $(ROOT)\tools
206COMPATDIR = $(ROOT)\compat
207
208#---------------------------------------------------------------------
209# Compile flags
210#---------------------------------------------------------------------
211
212!if !$(DEBUG)
213!if $(OPTIMIZING)
214### This cranks the optimization level to maximize speed
215cdebug = $(OPTIMIZATIONS)
216!else
217cdebug =
218!endif
219!else if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
220### Warnings are too many, can't support warnings into errors.
221cdebug = -Zi -Od $(DEBUGFLAGS)
222!else
223cdebug = -Zi -WX $(DEBUGFLAGS)
224!endif
225
226### Declarations common to all compiler options
227cwarn = $(WARNINGS) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE
228cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\
229
230!if $(MSVCRT)
231!if $(DEBUG) && !$(UNCHECKED)
232crt = -MDd
233!else
234crt = -MD
235!endif
236!else
237!if $(DEBUG) && !$(UNCHECKED)
238crt = -MTd
239!else
240crt = -MT
241!endif
242!endif
243
244!if !$(STATIC_BUILD)
245cflags = $(cflags) -DUSE_TCL_STUBS
246!if defined(TKSTUBLIB)
247cflags = $(cflags) -DUSE_TK_STUBS
248!endif
249!endif
250
251INCLUDES = $(TCL_INCLUDES) -I"$(WINDIR)" -I"$(GENERICDIR)"
252BASE_CFLAGS = $(cflags) $(cdebug) $(crt) $(INCLUDES)
253CON_CFLAGS = $(cflags) $(cdebug) $(crt) -DCONSOLE
254TCL_CFLAGS = -DPACKAGE_NAME="\"$(PROJECT)\"" \
255 -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
256 -DBUILD_$(PROJECT) \
257 $(BASE_CFLAGS) $(OPTDEFINES)
258
259#---------------------------------------------------------------------
260# Link flags
261#---------------------------------------------------------------------
262
263!if $(DEBUG)
264ldebug = -debug:full -debugtype:cv
265!if $(MSVCRT)
266ldebug = $(ldebug) -nodefaultlib:msvcrt
267!endif
268!else
269ldebug = -release -opt:ref -opt:icf,3
270!endif
271
272### Declarations common to all linker options
273lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
274
275!if $(PROFILE)
276lflags = $(lflags) -profile
277!endif
278
279!if $(ALIGN98_HACK) && !$(STATIC_BUILD)
280### Align sections for PE size savings.
281lflags = $(lflags) -opt:nowin98
282!else if !$(ALIGN98_HACK) && $(STATIC_BUILD)
283### Align sections for speed in loading by choosing the virtual page size.
284lflags = $(lflags) -align:4096
285!endif
286
287!if $(LOIMPACT)
288lflags = $(lflags) -ws:aggressive
289!endif
290
291dlllflags = $(lflags) -dll
292conlflags = $(lflags) -subsystem:console
293guilflags = $(lflags) -subsystem:windows
294!if !$(STATIC_BUILD)
295baselibs = $(TCLSTUBLIB)
296!if defined(TKSTUBLIB)
297baselibs = $(baselibs) $(TKSTUBLIB)
298!endif
299!endif
300
301# Avoid 'unresolved external symbol __security_cookie' errors.
302# c.f. http://support.microsoft.com/?id=894573
303!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
304!if $(VCVERSION) >= 1400 && $(VCVERSION) < 1500
305baselibs = $(baselibs) bufferoverflowU.lib
306!endif
307!endif
308
309baselibs = $(baselibs) user32.lib gdi32.lib
310
311#---------------------------------------------------------------------
312# TclTest flags
313#---------------------------------------------------------------------
314
315!IF "$(TESTPAT)" != ""
316TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
317!ENDIF
318
319#---------------------------------------------------------------------
320# Project specific targets (EDIT)
321#---------------------------------------------------------------------
322
323all: setup $(PROJECT)
324$(PROJECT): setup pkgIndex $(PRJLIB)
325install: install-binaries install-libraries install-docs
326pkgIndex: $(OUT_DIR)\pkgIndex.tcl
327
328test: setup $(PROJECT)
329 @set TCL_LIBRARY=$(TCL_LIBRARY:\=/)
330 @set TCLLIBPATH=$(OUT_DIR_PATH:\=/)
331!if $(TCLINSTALL)
332 @set PATH=$(_TCLDIR)\bin;$(PATH)
333!else
334 @set PATH=$(_TCLDIR)\win\$(BUILDDIRTOP);$(PATH)
335!endif
336!if "$(OS)" == "Windows_NT" || "$(MSVCDIR)" == "IDE"
337 $(DEBUGGER) $(TCLSH) "$(ROOT)/tests/all.tcl" $(TESTFLAGS)
338!else
339 @echo Please wait while the tests are collected...
340 $(DEBUGGER) $(TCLSH) "$(ROOT)/tests/all.tcl" $(TESTFLAGS) > tests.log
341 type tests.log | more
342!endif
343
344shell: setup $(PROJECT)
345 @set VLERQ_LIBRARY=$(LIBDIR:\=/)
346 @set TCL_LIBRARY=$(TCL_LIBRARY:\=/)
347 @set TCLLIBPATH=$(OUT_DIR_PATH:\=/)
348!if $(TCLINSTALL)
349 @set PATH=$(_TCLDIR)\bin;$(PATH)
350!else
351 @set PATH=$(_TCLDIR)\win\$(BUILDDIRTOP);$(PATH)
352!endif
353 $(DEBUGGER) $(TCLSH) $(SCRIPT)
354
355setup:
356 @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
357 @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
358
359# See <tcl>/win/coffbase.txt for extension base addresses.
360$(PRJLIB): $(DLLOBJS)
361!if $(STATIC_BUILD)
362 $(lib32) -nologo -out:$@ @<<
363$**
364<<
365!else
366 $(link32) $(dlllflags) -base:0x10000000 -out:$@ $(baselibs) @<<
367$**
368<<
369 $(_VC_MANIFEST_EMBED_DLL)
370 -@del $*.exp
371!endif
372
373$(PRJSTUBLIB): $(PRJSTUBOBJS)
374 $(lib32) -nologo -out:$@ $(PRJSTUBOBJS)
375
376#---------------------------------------------------------------------
377# Implicit rules
378#---------------------------------------------------------------------
379
380{$(WINDIR)}.c{$(TMP_DIR)}.obj::
381 $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
382$<
383<<
384
385{$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
386 $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
387$<
388<<
389
390{$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
391 $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
392$<
393<<
394
395{$(WINDIR)}.rc{$(TMP_DIR)}.res:
396 $(rc32) -fo $@ -r -i "$(GENERICDIR)" -D__WIN32__ \
397 -DCOMMAVERSION=$(DOTVERSION:.=,),0,0 \
398 -DDOTVERSION=\"$(DOTVERSION)\" \
399 -DVERSION=\"$(VERSION)$(SUFX)\" \
400!if $(DEBUG)
401 -d DEBUG \
402!endif
403!if $(TCL_THREADS)
404 -d TCL_THREADS \
405!endif
406!if $(STATIC_BUILD)
407 -d STATIC_BUILD \
408!endif
409 $<
410
411.SUFFIXES:
412.SUFFIXES:.c .rc
413
414#-------------------------------------------------------------------------
415# Explicit dependency rules
416#
417#-------------------------------------------------------------------------
418
419$(OUT_DIR)\pkgIndex.tcl: $(ROOT)\pkgIndex.tcl.in
420 @nmakehlp -s << $** > $@
421@PACKAGE_VERSION@ $(DOTVERSION)
422@PACKAGE_NAME@ $(PROJECT)
423@PKG_LIB_FILE@ $(PRJLIBNAME)
424<<
425
426#---------------------------------------------------------------------
427# Installation. (EDIT)
428#
429# You may need to modify this section to reflect the final distribution
430# of your files and possibly to generate documentation.
431#
432#---------------------------------------------------------------------
433
434install-binaries:
435 @echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
436 @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
437 @$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
438
439install-libraries: $(OUT_DIR)\pkgIndex.tcl
440 @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
441 @if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
442 @echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
443 @$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR)
444
445install-docs:
446 @echo Installing documentation files to '$(DOC_INSTALL_DIR)'
447 @if exist $(DOCDIR) $(CPY) $(DOCDIR)\*.n "$(DOC_INSTALL_DIR)"
448
449#---------------------------------------------------------------------
450# Clean up
451#---------------------------------------------------------------------
452
453clean:
454 @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
455 @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
456 @if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
457 @if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
458 @if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
459
460realclean: clean
461 @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
462
463distclean: realclean
464 @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
465 @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
Note: See TracBrowser for help on using the repository browser.