1 # makefile.vc -- -*- Makefile -*-
3 # Microsoft Visual C++ makefile for use with nmake.exe v1.62+ (VC++ 5.0+)
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.
11 # See the file "license.terms" for information on usage and redistribution
12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
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 Pat Thoyts
20 #-------------------------------------------------------------------------
21 # RCS: @(#)$Id: makefile.vc,v 1.4 2004/07/26 08:22:05 patthoyts Exp $
22 #-------------------------------------------------------------------------
24 !if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR)
26 You will need to run vcvars32.bat from Developer Studio, first, to setup^
27 the environment. Jump to this line to read the new instructions.
31 #------------------------------------------------------------------------------
32 # HOW TO USE this makefile:
34 # 1) It is now necessary to have %MSVCDir% set in the environment. This is
35 # used as a check to see if vcvars32.bat had been run prior to running
36 # nmake or during the installation of Microsoft Visual C++, MSVCDir had
37 # been set globally and the PATH adjusted. Either way is valid.
39 # You'll need to run vcvars32.bat contained in the MsDev's vc(98)/bin
40 # directory to setup the proper environment, if needed, for your current
41 # setup. This is a needed bootstrap requirement and allows the swapping of
42 # different environments to be easier.
44 # 2) To use the Platform SDK (not expressly needed), run setenv.bat after
45 # vcvars32.bat according to the instructions for it. This can also turn on
46 # the 64-bit compiler, if your SDK has it.
49 # all -- Builds everything.
50 # <project> -- Builds the project (eg: nmake sample)
51 # test -- Builds and runs the test suite.
52 # install -- Installs the built binaries and libraries to $(INSTALLDIR)
53 # in an appropriate subdirectory.
54 # clean/realclean/distclean -- varying levels of cleaning.
56 # 4) Macros usable on the commandline:
58 # Sets where to install Tcl from the built binaries.
59 # C:\Progra~1\Tcl is assumed when not specified.
61 # OPTS=static,msvcrt,staticpkg,threads,symbols,profile,loimpact,none
62 # Sets special options for the core. The default is for none.
63 # Any combination of the above may be used (comma separated).
64 # 'none' will over-ride everything to nothing.
66 # static = Builds a static library of the core instead of a
67 # dll. The shell will be static (and large), as well.
68 # msvcrt = Effects the static option only to switch it from
69 # using libcmt(d) as the C runtime [by default] to
70 # msvcrt(d). This is useful for static embedding
72 # staticpkg = Effects the static option only to switch
73 # tclshXX.exe to have the dde and reg extension linked
75 # threads = Turns on full multithreading support.
76 # thrdalloc = Use the thread allocator (shared global free pool).
77 # symbols = Adds symbols for step debugging.
78 # profile = Adds profiling hooks. Map file is assumed.
79 # loimpact = Adds a flag for how NT treats the heap to keep memory
80 # in use, low. This is said to impact alloc performance.
82 # STATS=memdbg,compdbg,none
83 # Sets optional memory and bytecode compiler debugging code added
84 # to the core. The default is for none. Any combination of the
85 # above may be used (comma separated). 'none' will over-ride
86 # everything to nothing.
88 # memdbg = Enables the debugging memory allocator.
89 # compdbg = Enables byte compilation logging.
91 # MACHINE=(IX86|IA64|ALPHA)
92 # Set the machine type used for the compiler, linker, and
93 # resource compiler. This hook is needed to tell the tools
94 # when alternate platforms are requested. IX86 is the default
99 # Hooks to allow the intermediate and output directories to be
100 # changed. $(OUT_DIR) is assumed to be
101 # $(BINROOT)\(Release|Debug) based on if symbols are requested.
102 # $(TMP_DIR) will de $(OUT_DIR)\<buildtype> by default.
105 # Reads the tests requested to be run from this file.
107 # CFG_ENCODING=encoding
108 # name of encoding for configuration information. Defaults
113 # Basic syntax of calling nmake looks like this:
114 # nmake [-nologo] -f makefile.vc [target|macrodef [target|macrodef] [...]]
116 # Standard (no frills)
117 # c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
118 # Setting environment for using Microsoft Visual C++ tools.
119 # c:\tcl_src\win\>nmake -f makefile.vc all
120 # c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl
123 # c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
124 # Setting environment for using Microsoft Visual C++ tools.
125 # c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /pre64 /RETAIL
126 # Targeting Windows pre64 RETAIL
127 # c:\tcl_src\win\>nmake -f makefile.vc MACHINE=IA64
129 #------------------------------------------------------------------------------
130 #==============================================================================
131 ###############################################################################
132 #------------------------------------------------------------------------------
134 !if !exist("makefile.vc")
136 You must run this makefile only from the directory it is in.^
137 Please `cd` to its location first.
141 #-------------------------------------------------------------------------
142 # Project specific information (EDIT)
144 # You should edit this with the name and version of your project. This
145 # information is used to generate the name of the package library and
146 # it's install location.
148 # For example, the sample extension is going to build sample04.dll and
149 # would install it into $(INSTALLDIR)\lib\sample04
151 # You need to specify the object files that need to be linked into your
154 #-------------------------------------------------------------------------
159 # nmakehelp -V <file> <tag> will search the file for tag, skips until a
160 # number and returns all character until a character not in [0-9.ab]
163 !if [echo REM = This file is generated from Makefile.vc > versions.vc]
165 # get project version from row "AC_INIT([sqlite], [3.7.14])"
166 !if [echo DOTVERSION = \>> versions.vc] \
167 && [nmakehlp -V ..\configure.in AC_INIT >> versions.vc]
169 !include "versions.vc"
171 VERSION = $(DOTVERSION:.=)
172 STUBPREFIX = $(PROJECT)stub
175 $(TMP_DIR)\tclsqlite3.obj
177 #-------------------------------------------------------------------------
178 # Target names and paths ( shouldn't need changing )
179 #-------------------------------------------------------------------------
184 PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
185 PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
186 PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
188 PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
189 PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME)
191 ### Make sure we use backslash only.
192 PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
193 LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)
194 BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)
195 DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR)
196 SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR)
197 INCLUDE_INSTALL_DIR = $(_TCLDIR)\include
199 ### The following paths CANNOT have spaces in them.
200 GENERICDIR = $(ROOT)\generic
202 LIBDIR = $(ROOT)\library
204 TOOLSDIR = $(ROOT)\tools
205 COMPATDIR = $(ROOT)\compat
207 #---------------------------------------------------------------------
209 #---------------------------------------------------------------------
213 ### This cranks the optimization level to maximize speed
218 !else if "$(MACHINE)" == "IA64"
219 ### Warnings are too many, can't support warnings into errors.
222 cdebug = -Z7 -WX -Od -GZ
225 ### Declarations common to all compiler options
226 cflags = -nologo -c -W3 -YX -Fp$(TMP_DIR)^\
242 INCLUDES = $(TCL_INCLUDES) -I"$(WINDIR)" -I"$(GENERICDIR)" \
244 BASE_CLFAGS = $(cflags) $(cdebug) $(crt) $(INCLUDES) \
245 -DSQLITE_3_SUFFIX_ONLY=1 -DSQLITE_ENABLE_RTREE=1 \
246 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_OMIT_DEPRECATED=1
247 CON_CFLAGS = $(cflags) $(cdebug) $(crt) -DCONSOLE -DSQLITE_ENABLE_FTS3=1
248 TCL_CFLAGS = -DBUILD_sqlite -DUSE_TCL_STUBS \
249 -DPACKAGE_VERSION="\"$(DOTVERSION)\"" $(BASE_CLFAGS) \
252 #---------------------------------------------------------------------
254 #---------------------------------------------------------------------
257 ldebug = -debug:full -debugtype:cv
259 ldebug = -release -opt:ref -opt:icf,3
262 ### Declarations common to all linker options
263 lflags = -nologo -machine:$(MACHINE) $(ldebug)
266 lflags = $(lflags) -profile
269 !if $(ALIGN98_HACK) && !$(STATIC_BUILD)
270 ### Align sections for PE size savings.
271 lflags = $(lflags) -opt:nowin98
272 !else if !$(ALIGN98_HACK) && $(STATIC_BUILD)
273 ### Align sections for speed in loading by choosing the virtual page size.
274 lflags = $(lflags) -align:4096
278 lflags = $(lflags) -ws:aggressive
281 dlllflags = $(lflags) -dll
282 conlflags = $(lflags) -subsystem:console
283 guilflags = $(lflags) -subsystem:windows
284 baselibs = $(TCLSTUBLIB)
286 #---------------------------------------------------------------------
288 #---------------------------------------------------------------------
290 !IF "$(TESTPAT)" != ""
291 TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
294 #---------------------------------------------------------------------
295 # Project specific targets (EDIT)
296 #---------------------------------------------------------------------
298 all: setup $(PROJECT)
299 $(PROJECT): setup $(PRJLIB)
300 install: install-binaries install-libraries install-docs
302 # Tests need to ensure we load the right dll file we
303 # have to handle the output differently on Win9x.
305 !if "$(OS)" == "Windows_NT" || "$(MSVCDIR)" == "IDE"
306 test: setup $(PROJECT)
307 set TCL_LIBRARY=$(ROOT)/library
311 set argv "$(TESTFLAGS)"
315 test: setup $(PROJECT)
316 echo Please wait while the test results are collected
317 set TCL_LIBRARY=$(ROOT)/library
318 $(TCLSH) << >tests.log
321 set argv "$(TESTFLAGS)"
324 type tests.log | more
328 @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
329 @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
331 $(PRJLIB): $(DLLOBJS)
332 $(link32) $(dlllflags) -out:$@ $(baselibs) @<<
337 $(PRJSTUBLIB): $(PRJSTUBOBJS)
338 $(lib32) -nologo -out:$@ $(PRJSTUBOBJS)
340 #---------------------------------------------------------------------
342 #---------------------------------------------------------------------
344 {$(WINDIR)}.c{$(TMP_DIR)}.obj::
345 $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
349 {$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
350 $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
354 {$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
355 $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
359 {$(WINDIR)}.rc{$(TMP_DIR)}.res:
360 $(rc32) -fo $@ -r -i "$(GENERICDIR)" -D__WIN32__ \
375 #---------------------------------------------------------------------
376 # Installation. (EDIT)
378 # You may need to modify this section to reflect the final distribution
379 # of your files and possibly to generate documentation.
381 #---------------------------------------------------------------------
384 @echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
385 @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
386 @$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
389 @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
390 @if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
391 @echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
392 @type << >"$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
393 package ifneeded $(PROJECT) $(DOTVERSION) \
394 [list load [file join $$dir $(PRJLIBNAME)] sqlite3]
398 @echo Installing documentation files to '$(DOC_INSTALL_DIR)'
399 @if exist $(DOCDIR) $(CPY) $(DOCDIR)\*.n "$(DOC_INSTALL_DIR)"
401 #---------------------------------------------------------------------
403 #---------------------------------------------------------------------
406 @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
407 @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
410 @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
413 @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
414 @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj