makefile.vc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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 Pat Thoyts
  19. #
  20. #-------------------------------------------------------------------------
  21. # RCS: @(#)$Id: makefile.vc,v 1.4 2004/07/26 08:22:05 patthoyts Exp $
  22. #-------------------------------------------------------------------------
  23. !if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR)
  24. MSG = ^
  25. You will need to run vcvars32.bat from Developer Studio, first, to setup^
  26. the environment. Jump to this line to read the new instructions.
  27. !error $(MSG)
  28. !endif
  29. #------------------------------------------------------------------------------
  30. # HOW TO USE this makefile:
  31. #
  32. # 1) It is now necessary to have %MSVCDir% set in the environment. This is
  33. # used as a check to see if vcvars32.bat had been run prior to running
  34. # nmake or during the installation of Microsoft Visual C++, MSVCDir had
  35. # been set globally and the PATH adjusted. Either way is valid.
  36. #
  37. # You'll need to run vcvars32.bat contained in the MsDev's vc(98)/bin
  38. # directory to setup the proper environment, if needed, for your current
  39. # setup. This is a needed bootstrap requirement and allows the swapping of
  40. # different environments to be easier.
  41. #
  42. # 2) To use the Platform SDK (not expressly needed), run setenv.bat after
  43. # vcvars32.bat according to the instructions for it. This can also turn on
  44. # the 64-bit compiler, if your SDK has it.
  45. #
  46. # 3) Targets are:
  47. # all -- Builds everything.
  48. # <project> -- Builds the project (eg: nmake sample)
  49. # test -- Builds and runs the test suite.
  50. # install -- Installs the built binaries and libraries to $(INSTALLDIR)
  51. # in an appropriate subdirectory.
  52. # clean/realclean/distclean -- varying levels of cleaning.
  53. #
  54. # 4) Macros usable on the commandline:
  55. # INSTALLDIR=<path>
  56. # Sets where to install Tcl from the built binaries.
  57. # C:\Progra~1\Tcl is assumed when not specified.
  58. #
  59. # OPTS=static,msvcrt,staticpkg,threads,symbols,profile,loimpact,none
  60. # Sets special options for the core. The default is for none.
  61. # Any combination of the above may be used (comma separated).
  62. # 'none' will over-ride everything to nothing.
  63. #
  64. # static = Builds a static library of the core instead of a
  65. # dll. The shell will be static (and large), as well.
  66. # msvcrt = Effects the static option only to switch it from
  67. # using libcmt(d) as the C runtime [by default] to
  68. # msvcrt(d). This is useful for static embedding
  69. # support.
  70. # staticpkg = Effects the static option only to switch
  71. # tclshXX.exe to have the dde and reg extension linked
  72. # inside it.
  73. # threads = Turns on full multithreading support.
  74. # thrdalloc = Use the thread allocator (shared global free pool).
  75. # symbols = Adds symbols for step debugging.
  76. # profile = Adds profiling hooks. Map file is assumed.
  77. # loimpact = Adds a flag for how NT treats the heap to keep memory
  78. # in use, low. This is said to impact alloc performance.
  79. #
  80. # STATS=memdbg,compdbg,none
  81. # Sets optional memory and bytecode compiler debugging code added
  82. # to the core. The default is for none. Any combination of the
  83. # above may be used (comma separated). 'none' will over-ride
  84. # everything to nothing.
  85. #
  86. # memdbg = Enables the debugging memory allocator.
  87. # compdbg = Enables byte compilation logging.
  88. #
  89. # MACHINE=(IX86|IA64|ALPHA)
  90. # Set the machine type used for the compiler, linker, and
  91. # resource compiler. This hook is needed to tell the tools
  92. # when alternate platforms are requested. IX86 is the default
  93. # when not specified.
  94. #
  95. # TMP_DIR=<path>
  96. # OUT_DIR=<path>
  97. # Hooks to allow the intermediate and output directories to be
  98. # changed. $(OUT_DIR) is assumed to be
  99. # $(BINROOT)\(Release|Debug) based on if symbols are requested.
  100. # $(TMP_DIR) will de $(OUT_DIR)\<buildtype> by default.
  101. #
  102. # TESTPAT=<file>
  103. # Reads the tests requested to be run from this file.
  104. #
  105. # CFG_ENCODING=encoding
  106. # name of encoding for configuration information. Defaults
  107. # to cp1252
  108. #
  109. # 5) Examples:
  110. #
  111. # Basic syntax of calling nmake looks like this:
  112. # nmake [-nologo] -f makefile.vc [target|macrodef [target|macrodef] [...]]
  113. #
  114. # Standard (no frills)
  115. # c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
  116. # Setting environment for using Microsoft Visual C++ tools.
  117. # c:\tcl_src\win\>nmake -f makefile.vc all
  118. # c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl
  119. #
  120. # Building for Win64
  121. # c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
  122. # Setting environment for using Microsoft Visual C++ tools.
  123. # c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /pre64 /RETAIL
  124. # Targeting Windows pre64 RETAIL
  125. # c:\tcl_src\win\>nmake -f makefile.vc MACHINE=IA64
  126. #
  127. #------------------------------------------------------------------------------
  128. #==============================================================================
  129. ###############################################################################
  130. #------------------------------------------------------------------------------
  131. !if !exist("makefile.vc")
  132. MSG = ^
  133. You must run this makefile only from the directory it is in.^
  134. Please `cd` to its location first.
  135. !error $(MSG)
  136. !endif
  137. #-------------------------------------------------------------------------
  138. # Project specific information (EDIT)
  139. #
  140. # You should edit this with the name and version of your project. This
  141. # information is used to generate the name of the package library and
  142. # it's install location.
  143. #
  144. # For example, the sample extension is going to build sample04.dll and
  145. # would install it into $(INSTALLDIR)\lib\sample04
  146. #
  147. # You need to specify the object files that need to be linked into your
  148. # binary here.
  149. #
  150. #-------------------------------------------------------------------------
  151. PROJECT = sqlite3
  152. !include "rules.vc"
  153. # nmakehelp -V <file> <tag> will search the file for tag, skips until a
  154. # number and returns all character until a character not in [0-9.ab]
  155. # is read.
  156. !if [echo REM = This file is generated from Makefile.vc > versions.vc]
  157. !endif
  158. # get project version from row "AC_INIT([sqlite], [3.7.14])"
  159. !if [echo DOTVERSION = \>> versions.vc] \
  160. && [nmakehlp -V ..\configure.in AC_INIT >> versions.vc]
  161. !endif
  162. !include "versions.vc"
  163. VERSION = $(DOTVERSION:.=)
  164. STUBPREFIX = $(PROJECT)stub
  165. DLLOBJS = \
  166. $(TMP_DIR)\tclsqlite3.obj
  167. #-------------------------------------------------------------------------
  168. # Target names and paths ( shouldn't need changing )
  169. #-------------------------------------------------------------------------
  170. BINROOT = .
  171. ROOT = ..
  172. PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
  173. PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
  174. PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
  175. PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
  176. PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME)
  177. ### Make sure we use backslash only.
  178. PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
  179. LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)
  180. BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)
  181. DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR)
  182. SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR)
  183. INCLUDE_INSTALL_DIR = $(_TCLDIR)\include
  184. ### The following paths CANNOT have spaces in them.
  185. GENERICDIR = $(ROOT)\generic
  186. WINDIR = $(ROOT)\win
  187. LIBDIR = $(ROOT)\library
  188. DOCDIR = $(ROOT)\doc
  189. TOOLSDIR = $(ROOT)\tools
  190. COMPATDIR = $(ROOT)\compat
  191. #---------------------------------------------------------------------
  192. # Compile flags
  193. #---------------------------------------------------------------------
  194. !if !$(DEBUG)
  195. !if $(OPTIMIZING)
  196. ### This cranks the optimization level to maximize speed
  197. cdebug = -O2 -Op -Gs
  198. !else
  199. cdebug =
  200. !endif
  201. !else if "$(MACHINE)" == "IA64"
  202. ### Warnings are too many, can't support warnings into errors.
  203. cdebug = -Z7 -Od -GZ
  204. !else
  205. cdebug = -Z7 -WX -Od -GZ
  206. !endif
  207. ### Declarations common to all compiler options
  208. cflags = -nologo -c -W3 -YX -Fp$(TMP_DIR)^\
  209. !if $(MSVCRT)
  210. !if $(DEBUG)
  211. crt = -MDd
  212. !else
  213. crt = -MD
  214. !endif
  215. !else
  216. !if $(DEBUG)
  217. crt = -MTd
  218. !else
  219. crt = -MT
  220. !endif
  221. !endif
  222. INCLUDES = $(TCL_INCLUDES) -I"$(WINDIR)" -I"$(GENERICDIR)" \
  223. -I"$(ROOT)\.."
  224. BASE_CLFAGS = $(cflags) $(cdebug) $(crt) $(INCLUDES) \
  225. -DSQLITE_3_SUFFIX_ONLY=1 -DSQLITE_ENABLE_RTREE=1 \
  226. -DSQLITE_ENABLE_FTS3=1 -DSQLITE_OMIT_DEPRECATED=1
  227. CON_CFLAGS = $(cflags) $(cdebug) $(crt) -DCONSOLE -DSQLITE_ENABLE_FTS3=1
  228. TCL_CFLAGS = -DBUILD_sqlite -DUSE_TCL_STUBS \
  229. -DPACKAGE_VERSION="\"$(DOTVERSION)\"" $(BASE_CLFAGS) \
  230. $(OPTDEFINES)
  231. #---------------------------------------------------------------------
  232. # Link flags
  233. #---------------------------------------------------------------------
  234. !if $(DEBUG)
  235. ldebug = -debug:full -debugtype:cv
  236. !else
  237. ldebug = -release -opt:ref -opt:icf,3
  238. !endif
  239. ### Declarations common to all linker options
  240. lflags = -nologo -machine:$(MACHINE) $(ldebug)
  241. !if $(PROFILE)
  242. lflags = $(lflags) -profile
  243. !endif
  244. !if $(ALIGN98_HACK) && !$(STATIC_BUILD)
  245. ### Align sections for PE size savings.
  246. lflags = $(lflags) -opt:nowin98
  247. !else if !$(ALIGN98_HACK) && $(STATIC_BUILD)
  248. ### Align sections for speed in loading by choosing the virtual page size.
  249. lflags = $(lflags) -align:4096
  250. !endif
  251. !if $(LOIMPACT)
  252. lflags = $(lflags) -ws:aggressive
  253. !endif
  254. dlllflags = $(lflags) -dll
  255. conlflags = $(lflags) -subsystem:console
  256. guilflags = $(lflags) -subsystem:windows
  257. baselibs = $(TCLSTUBLIB)
  258. #---------------------------------------------------------------------
  259. # TclTest flags
  260. #---------------------------------------------------------------------
  261. !IF "$(TESTPAT)" != ""
  262. TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
  263. !ENDIF
  264. #---------------------------------------------------------------------
  265. # Project specific targets (EDIT)
  266. #---------------------------------------------------------------------
  267. all: setup $(PROJECT)
  268. $(PROJECT): setup $(PRJLIB)
  269. install: install-binaries install-libraries install-docs
  270. # Tests need to ensure we load the right dll file we
  271. # have to handle the output differently on Win9x.
  272. #
  273. !if "$(OS)" == "Windows_NT" || "$(MSVCDIR)" == "IDE"
  274. test: setup $(PROJECT)
  275. set TCL_LIBRARY=$(ROOT)/library
  276. $(TCLSH) <<
  277. load $(PRJLIB:\=/)
  278. cd "$(ROOT)/tests"
  279. set argv "$(TESTFLAGS)"
  280. source all.tcl
  281. <<
  282. !else
  283. test: setup $(PROJECT)
  284. echo Please wait while the test results are collected
  285. set TCL_LIBRARY=$(ROOT)/library
  286. $(TCLSH) << >tests.log
  287. load $(PRJLIB:\=/)
  288. cd "$(ROOT)/tests"
  289. set argv "$(TESTFLAGS)"
  290. source all.tcl
  291. <<
  292. type tests.log | more
  293. !endif
  294. setup:
  295. @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
  296. @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
  297. $(PRJLIB): $(DLLOBJS)
  298. $(link32) $(dlllflags) -out:$@ $(baselibs) @<<
  299. $**
  300. <<
  301. -@del $*.exp
  302. $(PRJSTUBLIB): $(PRJSTUBOBJS)
  303. $(lib32) -nologo -out:$@ $(PRJSTUBOBJS)
  304. #---------------------------------------------------------------------
  305. # Implicit rules
  306. #---------------------------------------------------------------------
  307. {$(WINDIR)}.c{$(TMP_DIR)}.obj::
  308. $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
  309. $<
  310. <<
  311. {$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
  312. $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
  313. $<
  314. <<
  315. {$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
  316. $(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
  317. $<
  318. <<
  319. {$(WINDIR)}.rc{$(TMP_DIR)}.res:
  320. $(rc32) -fo $@ -r -i "$(GENERICDIR)" -D__WIN32__ \
  321. !if $(DEBUG)
  322. -d DEBUG \
  323. !endif
  324. !if $(TCL_THREADS)
  325. -d TCL_THREADS \
  326. !endif
  327. !if $(STATIC_BUILD)
  328. -d STATIC_BUILD \
  329. !endif
  330. $<
  331. .SUFFIXES:
  332. .SUFFIXES:.c .rc
  333. #---------------------------------------------------------------------
  334. # Installation. (EDIT)
  335. #
  336. # You may need to modify this section to reflect the final distribution
  337. # of your files and possibly to generate documentation.
  338. #
  339. #---------------------------------------------------------------------
  340. install-binaries:
  341. @echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
  342. @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
  343. @$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
  344. install-libraries:
  345. @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
  346. @if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
  347. @echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
  348. @type << >"$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
  349. package ifneeded $(PROJECT) $(DOTVERSION) \
  350. [list load [file join $$dir $(PRJLIBNAME)] sqlite3]
  351. <<
  352. install-docs:
  353. @echo Installing documentation files to '$(DOC_INSTALL_DIR)'
  354. @if exist $(DOCDIR) $(CPY) $(DOCDIR)\*.n "$(DOC_INSTALL_DIR)"
  355. #---------------------------------------------------------------------
  356. # Clean up
  357. #---------------------------------------------------------------------
  358. clean:
  359. @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
  360. @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
  361. realclean: clean
  362. @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
  363. distclean: realclean
  364. @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
  365. @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj