rules.vc 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752
  1. #------------------------------------------------------------- -*- makefile -*-
  2. # rules.vc --
  3. #
  4. # Part of the nmake based build system for Tcl and its extensions.
  5. # This file does all the hard work in terms of parsing build options,
  6. # compiler switches, defining common targets and macros. The Tcl makefile
  7. # directly includes this. Extensions include it via "rules-ext.vc".
  8. #
  9. # See TIP 477 (https://core.tcl.tk/tips/doc/trunk/tip/477.md) for
  10. # detailed documentation.
  11. #
  12. # See the file "license.terms" for information on usage and redistribution
  13. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  14. #
  15. # Copyright (c) 2001-2003 David Gravereaux.
  16. # Copyright (c) 2003-2008 Patrick Thoyts
  17. # Copyright (c) 2017 Ashok P. Nadkarni
  18. #------------------------------------------------------------------------------
  19. !ifndef _RULES_VC
  20. _RULES_VC = 1
  21. # The following macros define the version of the rules.vc nmake build system
  22. # For modifications that are not backward-compatible, you *must* change
  23. # the major version.
  24. RULES_VERSION_MAJOR = 1
  25. RULES_VERSION_MINOR = 2
  26. # The PROJECT macro must be defined by parent makefile.
  27. !if "$(PROJECT)" == ""
  28. !error *** Error: Macro PROJECT not defined! Please define it before including rules.vc
  29. !endif
  30. !if "$(PRJ_PACKAGE_TCLNAME)" == ""
  31. PRJ_PACKAGE_TCLNAME = $(PROJECT)
  32. !endif
  33. # Also special case Tcl and Tk to save some typing later
  34. DOING_TCL = 0
  35. DOING_TK = 0
  36. !if "$(PROJECT)" == "tcl"
  37. DOING_TCL = 1
  38. !elseif "$(PROJECT)" == "tk"
  39. DOING_TK = 1
  40. !endif
  41. !ifndef NEED_TK
  42. # Backwards compatibility
  43. !ifdef PROJECT_REQUIRES_TK
  44. NEED_TK = $(PROJECT_REQUIRES_TK)
  45. !else
  46. NEED_TK = 0
  47. !endif
  48. !endif
  49. !ifndef NEED_TCL_SOURCE
  50. NEED_TCL_SOURCE = 0
  51. !endif
  52. !ifdef NEED_TK_SOURCE
  53. !if $(NEED_TK_SOURCE)
  54. NEED_TK = 1
  55. !endif
  56. !else
  57. NEED_TK_SOURCE = 0
  58. !endif
  59. ################################################################
  60. # Nmake is a pretty weak environment in syntax and capabilities
  61. # so this file is necessarily verbose. It's broken down into
  62. # the following parts.
  63. #
  64. # 0. Sanity check that compiler environment is set up and initialize
  65. # any built-in settings from the parent makefile
  66. # 1. First define the external tools used for compiling, copying etc.
  67. # as this is independent of everything else.
  68. # 2. Figure out our build structure in terms of the directory, whether
  69. # we are building Tcl or an extension, etc.
  70. # 3. Determine the compiler and linker versions
  71. # 4. Build the nmakehlp helper application
  72. # 5. Determine the supported compiler options and features
  73. # 6. Parse the OPTS macro value for user-specified build configuration
  74. # 7. Parse the STATS macro value for statistics instrumentation
  75. # 8. Parse the CHECKS macro for additional compilation checks
  76. # 9. Extract Tcl, and possibly Tk, version numbers from the headers
  77. # 10. Based on this selected configuration, construct the output
  78. # directory and file paths
  79. # 11. Construct the paths where the package is to be installed
  80. # 12. Set up the actual options passed to compiler and linker based
  81. # on the information gathered above.
  82. # 13. Define some standard build targets and implicit rules. These may
  83. # be optionally disabled by the parent makefile.
  84. # 14. (For extensions only.) Compare the configuration of the target
  85. # Tcl and the extensions and warn against discrepancies.
  86. #
  87. # One final note about the macro names used. They are as they are
  88. # for historical reasons. We would like legacy extensions to
  89. # continue to work with this make include file so be wary of
  90. # changing them for consistency or clarity.
  91. # 0. Sanity check compiler environment
  92. # Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or
  93. # VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir)
  94. !if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR)
  95. MSG = ^
  96. Visual C++ compiler environment not initialized.
  97. !error $(MSG)
  98. !endif
  99. # We need to run from the directory the parent makefile is located in.
  100. # nmake does not tell us what makefile was used to invoke it so parent
  101. # makefile has to set the MAKEFILEVC macro or we just make a guess and
  102. # warn if we think that is not the case.
  103. !if "$(MAKEFILEVC)" == ""
  104. !if exist("$(PROJECT).vc")
  105. MAKEFILEVC = $(PROJECT).vc
  106. !elseif exist("makefile.vc")
  107. MAKEFILEVC = makefile.vc
  108. !endif
  109. !endif # "$(MAKEFILEVC)" == ""
  110. !if !exist("$(MAKEFILEVC)")
  111. MSG = ^
  112. You must run nmake from the directory containing the project makefile.^
  113. If you are doing that and getting this message, set the MAKEFILEVC^
  114. macro to the name of the project makefile.
  115. !message WARNING: $(MSG)
  116. !endif
  117. ################################################################
  118. # 1. Define external programs being used
  119. #----------------------------------------------------------
  120. # Set the proper copy method to avoid overwrite questions
  121. # to the user when copying files and selecting the right
  122. # "delete all" method.
  123. #----------------------------------------------------------
  124. RMDIR = rmdir /S /Q
  125. CPY = xcopy /i /y >NUL
  126. CPYDIR = xcopy /e /i /y >NUL
  127. COPY = copy /y >NUL
  128. MKDIR = mkdir
  129. ######################################################################
  130. # 2. Figure out our build environment in terms of what we're building.
  131. #
  132. # (a) Tcl itself
  133. # (b) Tk
  134. # (c) a Tcl extension using libraries/includes from an *installed* Tcl
  135. # (d) a Tcl extension using libraries/includes from Tcl source directory
  136. #
  137. # This last is needed because some extensions still need
  138. # some Tcl interfaces that are not publicly exposed.
  139. #
  140. # The fragment will set the following macros:
  141. # ROOT - root of this module sources
  142. # COMPATDIR - source directory that holds compatibility sources
  143. # DOCDIR - source directory containing documentation files
  144. # GENERICDIR - platform-independent source directory
  145. # WINDIR - Windows-specific source directory
  146. # TESTDIR - directory containing test files
  147. # TOOLSDIR - directory containing build tools
  148. # _TCLDIR - root of the Tcl installation OR the Tcl sources. Not set
  149. # when building Tcl itself.
  150. # _INSTALLDIR - native form of the installation path. For Tcl
  151. # this will be the root of the Tcl installation. For extensions
  152. # this will be the lib directory under the root.
  153. # TCLINSTALL - set to 1 if _TCLDIR refers to
  154. # headers and libraries from an installed Tcl, and 0 if built against
  155. # Tcl sources. Not set when building Tcl itself. Yes, not very well
  156. # named.
  157. # _TCL_H - native path to the tcl.h file
  158. #
  159. # If Tk is involved, also sets the following
  160. # _TKDIR - native form Tk installation OR Tk source. Not set if building
  161. # Tk itself.
  162. # TKINSTALL - set 1 if _TKDIR refers to installed Tk and 0 if Tk sources
  163. # _TK_H - native path to the tk.h file
  164. # Root directory for sources and assumed subdirectories
  165. ROOT = $(MAKEDIR)\..
  166. # The following paths CANNOT have spaces in them as they appear on the
  167. # left side of implicit rules.
  168. !ifndef COMPATDIR
  169. COMPATDIR = $(ROOT)\compat
  170. !endif
  171. !ifndef DOCDIR
  172. DOCDIR = $(ROOT)\doc
  173. !endif
  174. !ifndef GENERICDIR
  175. GENERICDIR = $(ROOT)\generic
  176. !endif
  177. !ifndef TOOLSDIR
  178. TOOLSDIR = $(ROOT)\tools
  179. !endif
  180. !ifndef TESTDIR
  181. TESTDIR = $(ROOT)\tests
  182. !endif
  183. !ifndef LIBDIR
  184. !if exist("$(ROOT)\library")
  185. LIBDIR = $(ROOT)\library
  186. !else
  187. LIBDIR = $(ROOT)\lib
  188. !endif
  189. !endif
  190. !ifndef DEMODIR
  191. !if exist("$(LIBDIR)\demos")
  192. DEMODIR = $(LIBDIR)\demos
  193. !else
  194. DEMODIR = $(ROOT)\demos
  195. !endif
  196. !endif # ifndef DEMODIR
  197. # Do NOT enclose WINDIR in a !ifndef because Windows always defines
  198. # WINDIR env var to point to c:\windows!
  199. # TBD - This is a potentially dangerous conflict, rename WINDIR to
  200. # something else
  201. WINDIR = $(ROOT)\win
  202. !ifndef RCDIR
  203. !if exist("$(WINDIR)\rc")
  204. RCDIR = $(WINDIR)\rc
  205. !else
  206. RCDIR = $(WINDIR)
  207. !endif
  208. !endif
  209. RCDIR = $(RCDIR:/=\)
  210. # The target directory where the built packages and binaries will be installed.
  211. # INSTALLDIR is the (optional) path specified by the user.
  212. # _INSTALLDIR is INSTALLDIR using the backslash separator syntax
  213. !ifdef INSTALLDIR
  214. ### Fix the path separators.
  215. _INSTALLDIR = $(INSTALLDIR:/=\)
  216. !else
  217. ### Assume the normal default.
  218. _INSTALLDIR = $(HOMEDRIVE)\Tcl
  219. !endif
  220. !if $(DOING_TCL)
  221. # BEGIN Case 2(a) - Building Tcl itself
  222. # Only need to define _TCL_H
  223. _TCL_H = ..\generic\tcl.h
  224. # END Case 2(a) - Building Tcl itself
  225. !elseif $(DOING_TK)
  226. # BEGIN Case 2(b) - Building Tk
  227. TCLINSTALL = 0 # Tk always builds against Tcl source, not an installed Tcl
  228. !if "$(TCLDIR)" == ""
  229. !if [echo TCLDIR = \> nmakehlp.out] \
  230. || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
  231. !error *** Could not locate Tcl source directory.
  232. !endif
  233. !include nmakehlp.out
  234. !endif # TCLDIR == ""
  235. _TCLDIR = $(TCLDIR:/=\)
  236. _TCL_H = $(_TCLDIR)\generic\tcl.h
  237. !if !exist("$(_TCL_H)")
  238. !error Could not locate tcl.h. Please set the TCLDIR macro to point to the Tcl *source* directory.
  239. !endif
  240. _TK_H = ..\generic\tk.h
  241. # END Case 2(b) - Building Tk
  242. !else
  243. # BEGIN Case 2(c) or (d) - Building an extension other than Tk
  244. # If command line has specified Tcl location through TCLDIR, use it
  245. # else default to the INSTALLDIR setting
  246. !if "$(TCLDIR)" != ""
  247. _TCLDIR = $(TCLDIR:/=\)
  248. !if exist("$(_TCLDIR)\include\tcl.h") # Case 2(c) with TCLDIR defined
  249. TCLINSTALL = 1
  250. _TCL_H = $(_TCLDIR)\include\tcl.h
  251. !elseif exist("$(_TCLDIR)\generic\tcl.h") # Case 2(d) with TCLDIR defined
  252. TCLINSTALL = 0
  253. _TCL_H = $(_TCLDIR)\generic\tcl.h
  254. !endif
  255. !else # # Case 2(c) for extensions with TCLDIR undefined
  256. # Need to locate Tcl depending on whether it needs Tcl source or not.
  257. # If we don't, check the INSTALLDIR for an installed Tcl first
  258. !if exist("$(_INSTALLDIR)\include\tcl.h") && !$(NEED_TCL_SOURCE)
  259. TCLINSTALL = 1
  260. TCLDIR = $(_INSTALLDIR)\..
  261. # NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions
  262. # later so the \.. accounts for the /lib
  263. _TCLDIR = $(_INSTALLDIR)\..
  264. _TCL_H = $(_TCLDIR)\include\tcl.h
  265. !else # exist(...) && ! $(NEED_TCL_SOURCE)
  266. !if [echo _TCLDIR = \> nmakehlp.out] \
  267. || [nmakehlp -L generic\tcl.h >> nmakehlp.out]
  268. !error *** Could not locate Tcl source directory.
  269. !endif
  270. !include nmakehlp.out
  271. TCLINSTALL = 0
  272. TCLDIR = $(_TCLDIR)
  273. _TCL_H = $(_TCLDIR)\generic\tcl.h
  274. !endif # exist(...) && ! $(NEED_TCL_SOURCE)
  275. !endif # TCLDIR
  276. !ifndef _TCL_H
  277. MSG =^
  278. Failed to find tcl.h. The TCLDIR macro is set incorrectly or is not set and default path does not contain tcl.h.
  279. !error $(MSG)
  280. !endif
  281. # Now do the same to locate Tk headers and libs if project requires Tk
  282. !if $(NEED_TK)
  283. !if "$(TKDIR)" != ""
  284. _TKDIR = $(TKDIR:/=\)
  285. !if exist("$(_TKDIR)\include\tk.h")
  286. TKINSTALL = 1
  287. _TK_H = $(_TKDIR)\include\tk.h
  288. !elseif exist("$(_TKDIR)\generic\tk.h")
  289. TKINSTALL = 0
  290. _TK_H = $(_TKDIR)\generic\tk.h
  291. !endif
  292. !else # TKDIR not defined
  293. # Need to locate Tcl depending on whether it needs Tcl source or not.
  294. # If we don't, check the INSTALLDIR for an installed Tcl first
  295. !if exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE)
  296. TKINSTALL = 1
  297. # NOTE: we will be resetting _INSTALLDIR to _INSTALLDIR/lib for extensions
  298. # later so the \.. accounts for the /lib
  299. _TKDIR = $(_INSTALLDIR)\..
  300. _TK_H = $(_TKDIR)\include\tk.h
  301. TKDIR = $(_TKDIR)
  302. !else # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE)
  303. !if [echo _TKDIR = \> nmakehlp.out] \
  304. || [nmakehlp -L generic\tk.h >> nmakehlp.out]
  305. !error *** Could not locate Tk source directory.
  306. !endif
  307. !include nmakehlp.out
  308. TKINSTALL = 0
  309. TKDIR = $(_TKDIR)
  310. _TK_H = $(_TKDIR)\generic\tk.h
  311. !endif # exist("$(_INSTALLDIR)\include\tk.h") && !$(NEED_TK_SOURCE)
  312. !endif # TKDIR
  313. !ifndef _TK_H
  314. MSG =^
  315. Failed to find tk.h. The TKDIR macro is set incorrectly or is not set and default path does not contain tk.h.
  316. !error $(MSG)
  317. !endif
  318. !endif # NEED_TK
  319. !if $(NEED_TCL_SOURCE) && $(TCLINSTALL)
  320. MSG = ^
  321. *** Warning: This extension requires the source distribution of Tcl.^
  322. *** Please set the TCLDIR macro to point to the Tcl sources.
  323. !error $(MSG)
  324. !endif
  325. !if $(NEED_TK_SOURCE)
  326. !if $(TKINSTALL)
  327. MSG = ^
  328. *** Warning: This extension requires the source distribution of Tk.^
  329. *** Please set the TKDIR macro to point to the Tk sources.
  330. !error $(MSG)
  331. !endif
  332. !endif
  333. # If INSTALLDIR set to Tcl installation root dir then reset to the
  334. # lib dir for installing extensions
  335. !if exist("$(_INSTALLDIR)\include\tcl.h")
  336. _INSTALLDIR=$(_INSTALLDIR)\lib
  337. !endif
  338. # END Case 2(c) or (d) - Building an extension
  339. !endif # if $(DOING_TCL)
  340. ################################################################
  341. # 3. Determine compiler version and architecture
  342. # In this section, we figure out the compiler version and the
  343. # architecture for which we are building. This sets the
  344. # following macros:
  345. # VCVERSION - the internal compiler version as 1200, 1400, 1910 etc.
  346. # This is also printed by the compiler in dotted form 19.10 etc.
  347. # VCVER - the "marketing version", for example Visual C++ 6 for internal
  348. # compiler version 1200. This is kept only for legacy reasons as it
  349. # does not make sense for recent Microsoft compilers. Only used for
  350. # output directory names.
  351. # ARCH - set to IX86 or AMD64 depending on 32- or 64-bit target
  352. # NATIVE_ARCH - set to IX86 or AMD64 for the host machine
  353. # MACHINE - same as $(ARCH) - legacy
  354. # _VC_MANIFEST_EMBED_{DLL,EXE} - commands for embedding a manifest if needed
  355. # CFG_ENCODING - set to an character encoding.
  356. # TBD - this is passed to compiler as TCL_CFGVAL_ENCODING but can't
  357. # see where it is used
  358. cc32 = $(CC) # built-in default.
  359. link32 = link
  360. lib32 = lib
  361. rc32 = $(RC) # built-in default.
  362. #----------------------------------------------------------------
  363. # Figure out the compiler architecture and version by writing
  364. # the C macros to a file, preprocessing them with the C
  365. # preprocessor and reading back the created file
  366. _HASH=^#
  367. _VC_MANIFEST_EMBED_EXE=
  368. _VC_MANIFEST_EMBED_DLL=
  369. VCVER=0
  370. !if ![echo VCVERSION=_MSC_VER > vercl.x] \
  371. && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
  372. && ![echo ARCH=IX86 >> vercl.x] \
  373. && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
  374. && ![echo ARCH=AMD64 >> vercl.x] \
  375. && ![echo $(_HASH)endif >> vercl.x] \
  376. && ![$(cc32) -nologo -TC -P vercl.x 2>NUL]
  377. !include vercl.i
  378. !if $(VCVERSION) < 1900
  379. !if ![echo VCVER= ^\> vercl.vc] \
  380. && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
  381. !include vercl.vc
  382. !endif
  383. !else
  384. # The simple calculation above does not apply to new Visual Studio releases
  385. # Keep the compiler version in its native form.
  386. VCVER = $(VCVERSION)
  387. !endif
  388. !endif
  389. !if ![del 2>NUL /q/f vercl.x vercl.i vercl.vc]
  390. !endif
  391. #----------------------------------------------------------------
  392. # The MACHINE macro is used by legacy makefiles so set it as well
  393. !ifdef MACHINE
  394. !if "$(MACHINE)" == "x86"
  395. !undef MACHINE
  396. MACHINE = IX86
  397. !elseif "$(MACHINE)" == "x64"
  398. !undef MACHINE
  399. MACHINE = AMD64
  400. !endif
  401. !if "$(MACHINE)" != "$(ARCH)"
  402. !error Specified MACHINE macro $(MACHINE) does not match detected target architecture $(ARCH).
  403. !endif
  404. !else
  405. MACHINE=$(ARCH)
  406. !endif
  407. #------------------------------------------------------------
  408. # Figure out the *host* architecture by reading the registry
  409. !if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
  410. NATIVE_ARCH=IX86
  411. !else
  412. NATIVE_ARCH=AMD64
  413. !endif
  414. # Since MSVC8 we must deal with manifest resources.
  415. !if $(VCVERSION) >= 1400
  416. _VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1
  417. _VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2
  418. !endif
  419. !ifndef CFG_ENCODING
  420. CFG_ENCODING = \"cp1252\"
  421. !endif
  422. ################################################################
  423. # 4. Build the nmakehlp program
  424. # This is a helper app we need to overcome nmake's limiting
  425. # environment. We will call out to it to get various bits of
  426. # information about supported compiler options etc.
  427. #
  428. # Tcl itself will always use the nmakehlp.c program which is
  429. # in its own source. This is the "master" copy and kept updated.
  430. #
  431. # Extensions built against an installed Tcl will use the installed
  432. # copy of Tcl's nmakehlp.c if there is one and their own version
  433. # otherwise. In the latter case, they would also be using their own
  434. # rules.vc. Note that older versions of Tcl do not install nmakehlp.c
  435. # or rules.vc.
  436. #
  437. # Extensions built against Tcl sources will use the one from the Tcl source.
  438. #
  439. # When building an extension using a sufficiently new version of Tcl,
  440. # rules-ext.vc will define NMAKEHLPC appropriately to point to the
  441. # copy of nmakehlp.c to be used.
  442. !ifndef NMAKEHLPC
  443. # Default to the one in the current directory (the extension's own nmakehlp.c)
  444. NMAKEHLPC = nmakehlp.c
  445. !if !$(DOING_TCL)
  446. !if $(TCLINSTALL)
  447. !if exist("$(_TCLDIR)\lib\nmake\nmakehlp.c")
  448. NMAKEHLPC = $(_TCLDIR)\lib\nmake\nmakehlp.c
  449. !endif
  450. !else # ! $(TCLINSTALL)
  451. !if exist("$(_TCLDIR)\win\nmakehlp.c")
  452. NMAKEHLPC = $(_TCLDIR)\win\nmakehlp.c
  453. !endif
  454. !endif # $(TCLINSTALL)
  455. !endif # !$(DOING_TCL)
  456. !endif # NMAKEHLPC
  457. # We always build nmakehlp even if it exists since we do not know
  458. # what source it was built from.
  459. !if [$(cc32) -nologo "$(NMAKEHLPC)" -link -subsystem:console > nul]
  460. !endif
  461. ################################################################
  462. # 5. Test for compiler features
  463. # Visual C++ compiler options have changed over the years. Check
  464. # which options are supported by the compiler in use.
  465. #
  466. # The following macros are set:
  467. # OPTIMIZATIONS - the compiler flags to be used for optimized builds
  468. # DEBUGFLAGS - the compiler flags to be used for debug builds
  469. # LINKERFLAGS - Flags passed to the linker
  470. #
  471. # Note that these are the compiler settings *available*, not those
  472. # that will be *used*. The latter depends on the OPTS macro settings
  473. # which we have not yet parsed.
  474. #
  475. # Also note that some of the flags in OPTIMIZATIONS are not really
  476. # related to optimization. They are placed there only for legacy reasons
  477. # as some extensions expect them to be included in that macro.
  478. # -Op improves float consistency. Note only needed for older compilers
  479. # Newer compilers do not need or support this option.
  480. !if [nmakehlp -c -Op]
  481. FPOPTS = -Op
  482. !endif
  483. # Strict floating point semantics - present in newer compilers in lieu of -Op
  484. !if [nmakehlp -c -fp:strict]
  485. FPOPTS = $(FPOPTS) -fp:strict
  486. !endif
  487. !if "$(MACHINE)" == "IX86"
  488. ### test for pentium errata
  489. !if [nmakehlp -c -QI0f]
  490. !message *** Compiler has 'Pentium 0x0f fix'
  491. FPOPTS = $(FPOPTS) -QI0f
  492. !else
  493. !message *** Compiler does not have 'Pentium 0x0f fix'
  494. !endif
  495. !endif
  496. ### test for optimizations
  497. # /O2 optimization includes /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy as per
  498. # documentation. Note we do NOT want /Gs as that inserts a _chkstk
  499. # stack probe at *every* function entry, not just those with more than
  500. # a page of stack allocation resulting in a performance hit. However,
  501. # /O2 documentation is misleading as its stack probes are simply the
  502. # default page size locals allocation probes and not what is implied
  503. # by an explicit /Gs option.
  504. OPTIMIZATIONS = $(FPOPTS)
  505. !if [nmakehlp -c -O2]
  506. OPTIMIZING = 1
  507. OPTIMIZATIONS = $(OPTIMIZATIONS) -O2
  508. !else
  509. # Legacy, really. All modern compilers support this
  510. !message *** Compiler does not have 'Optimizations'
  511. OPTIMIZING = 0
  512. !endif
  513. # Checks for buffer overflows in local arrays
  514. !if [nmakehlp -c -GS]
  515. OPTIMIZATIONS = $(OPTIMIZATIONS) -GS
  516. !endif
  517. # Link time optimization. Note that this option (potentially) makes
  518. # generated libraries only usable by the specific VC++ version that
  519. # created it. Requires /LTCG linker option
  520. !if [nmakehlp -c -GL]
  521. OPTIMIZATIONS = $(OPTIMIZATIONS) -GL
  522. CC_GL_OPT_ENABLED = 1
  523. !else
  524. # In newer compilers -GL and -YX are incompatible.
  525. !if [nmakehlp -c -YX]
  526. OPTIMIZATIONS = $(OPTIMIZATIONS) -YX
  527. !endif
  528. !endif # [nmakehlp -c -GL]
  529. DEBUGFLAGS = $(FPOPTS)
  530. # Run time error checks. Not available or valid in a release, non-debug build
  531. # RTC is for modern compilers, -GZ is legacy
  532. !if [nmakehlp -c -RTC1]
  533. DEBUGFLAGS = $(DEBUGFLAGS) -RTC1
  534. !elseif [nmakehlp -c -GZ]
  535. DEBUGFLAGS = $(DEBUGFLAGS) -GZ
  536. !endif
  537. #----------------------------------------------------------------
  538. # Linker flags
  539. # LINKER_TESTFLAGS are for internal use when we call nmakehlp to test
  540. # if the linker supports a specific option. Without these flags link will
  541. # return "LNK1561: entry point must be defined" error compiling from VS-IDE:
  542. # They are not passed through to the actual application / extension
  543. # link rules.
  544. !ifndef LINKER_TESTFLAGS
  545. LINKER_TESTFLAGS = /DLL /NOENTRY /OUT:nmakehlp.out
  546. !endif
  547. LINKERFLAGS =
  548. # If compiler has enabled link time optimization, linker must too with -ltcg
  549. !ifdef CC_GL_OPT_ENABLED
  550. !if [nmakehlp -l -ltcg $(LINKER_TESTFLAGS)]
  551. LINKERFLAGS = $(LINKERFLAGS) -ltcg
  552. !endif
  553. !endif
  554. ########################################################################
  555. # 6. Parse the OPTS macro to work out the requested build configuration.
  556. # Based on this, we will construct the actual switches to be passed to the
  557. # compiler and linker using the macros defined in the previous section.
  558. # The following macros are defined by this section based on OPTS
  559. # STATIC_BUILD - 0 -> Tcl is to be built as a shared library
  560. # 1 -> build as a static library and shell
  561. # TCL_THREADS - legacy but always 1 on Windows since winsock requires it.
  562. # DEBUG - 1 -> debug build, 0 -> release builds
  563. # SYMBOLS - 1 -> generate PDB's, 0 -> no PDB's
  564. # PROFILE - 1 -> generate profiling info, 0 -> no profiling
  565. # PGO - 1 -> profile based optimization, 0 -> no
  566. # MSVCRT - 1 -> link to dynamic C runtime even when building static Tcl build
  567. # 0 -> link to static C runtime for static Tcl build.
  568. # Does not impact shared Tcl builds (STATIC_BUILD == 0)
  569. # TCL_USE_STATIC_PACKAGES - 1 -> statically link the registry and dde extensions
  570. # in the Tcl shell. 0 -> keep them as shared libraries
  571. # Does not impact shared Tcl builds.
  572. # USE_THREAD_ALLOC - 1 -> Use a shared global free pool for allocation.
  573. # 0 -> Use the non-thread allocator.
  574. # UNCHECKED - 1 -> when doing a debug build with symbols, use the release
  575. # C runtime, 0 -> use the debug C runtime.
  576. # USE_STUBS - 1 -> compile to use stubs interfaces, 0 -> direct linking
  577. # CONFIG_CHECK - 1 -> check current build configuration against Tcl
  578. # configuration (ignored for Tcl itself)
  579. # Further, LINKERFLAGS are modified based on above.
  580. # Default values for all the above
  581. STATIC_BUILD = 0
  582. TCL_THREADS = 1
  583. DEBUG = 0
  584. SYMBOLS = 0
  585. PROFILE = 0
  586. PGO = 0
  587. MSVCRT = 1
  588. TCL_USE_STATIC_PACKAGES = 0
  589. USE_THREAD_ALLOC = 1
  590. UNCHECKED = 0
  591. CONFIG_CHECK = 1
  592. !if $(DOING_TCL)
  593. USE_STUBS = 0
  594. !else
  595. USE_STUBS = 1
  596. !endif
  597. # If OPTS is not empty AND does not contain "none" which turns off all OPTS
  598. # set the above macros based on OPTS content
  599. !if "$(OPTS)" != "" && ![nmakehlp -f "$(OPTS)" "none"]
  600. # OPTS are specified, parse them
  601. !if [nmakehlp -f $(OPTS) "static"]
  602. !message *** Doing static
  603. STATIC_BUILD = 1
  604. !endif
  605. !if [nmakehlp -f $(OPTS) "nostubs"]
  606. !message *** Not using stubs
  607. USE_STUBS = 0
  608. !endif
  609. !if [nmakehlp -f $(OPTS) "nomsvcrt"]
  610. !message *** Doing nomsvcrt
  611. MSVCRT = 0
  612. !else
  613. !if [nmakehlp -f $(OPTS) "msvcrt"]
  614. !message *** Doing msvcrt
  615. MSVCRT = 1
  616. !else
  617. !if !$(STATIC_BUILD)
  618. MSVCRT = 1
  619. !else
  620. MSVCRT = 0
  621. !endif
  622. !endif
  623. !endif # [nmakehlp -f $(OPTS) "nomsvcrt"]
  624. !if [nmakehlp -f $(OPTS) "staticpkg"] && $(STATIC_BUILD)
  625. !message *** Doing staticpkg
  626. TCL_USE_STATIC_PACKAGES = 1
  627. !else
  628. TCL_USE_STATIC_PACKAGES = 0
  629. !endif
  630. !if [nmakehlp -f $(OPTS) "nothreads"]
  631. !message *** Compile explicitly for non-threaded tcl
  632. TCL_THREADS = 0
  633. USE_THREAD_ALLOC= 0
  634. !else
  635. TCL_THREADS = 1
  636. USE_THREAD_ALLOC= 1
  637. !endif
  638. !if [nmakehlp -f $(OPTS) "symbols"]
  639. !message *** Doing symbols
  640. DEBUG = 1
  641. !else
  642. DEBUG = 0
  643. !endif
  644. !if [nmakehlp -f $(OPTS) "pdbs"]
  645. !message *** Doing pdbs
  646. SYMBOLS = 1
  647. !else
  648. SYMBOLS = 0
  649. !endif
  650. !if [nmakehlp -f $(OPTS) "profile"]
  651. !message *** Doing profile
  652. PROFILE = 1
  653. !else
  654. PROFILE = 0
  655. !endif
  656. !if [nmakehlp -f $(OPTS) "pgi"]
  657. !message *** Doing profile guided optimization instrumentation
  658. PGO = 1
  659. !elseif [nmakehlp -f $(OPTS) "pgo"]
  660. !message *** Doing profile guided optimization
  661. PGO = 2
  662. !else
  663. PGO = 0
  664. !endif
  665. !if [nmakehlp -f $(OPTS) "loimpact"]
  666. !message *** Warning: ignoring option "loimpact" - deprecated on modern Windows.
  667. !endif
  668. # TBD - should get rid of this option
  669. !if [nmakehlp -f $(OPTS) "thrdalloc"]
  670. !message *** Doing thrdalloc
  671. USE_THREAD_ALLOC = 1
  672. !endif
  673. !if [nmakehlp -f $(OPTS) "tclalloc"]
  674. USE_THREAD_ALLOC = 0
  675. !endif
  676. !if [nmakehlp -f $(OPTS) "unchecked"]
  677. !message *** Doing unchecked
  678. UNCHECKED = 1
  679. !else
  680. UNCHECKED = 0
  681. !endif
  682. !if [nmakehlp -f $(OPTS) "noconfigcheck"]
  683. CONFIG_CHECK = 1
  684. !else
  685. CONFIG_CHECK = 0
  686. !endif
  687. !endif # "$(OPTS)" != "" && ... parsing of OPTS
  688. # Set linker flags based on above
  689. !if $(PGO) > 1
  690. !if [nmakehlp -l -ltcg:pgoptimize $(LINKER_TESTFLAGS)]
  691. LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize
  692. !else
  693. MSG=^
  694. This compiler does not support profile guided optimization.
  695. !error $(MSG)
  696. !endif
  697. !elseif $(PGO) > 0
  698. !if [nmakehlp -l -ltcg:pginstrument $(LINKER_TESTFLAGS)]
  699. LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument
  700. !else
  701. MSG=^
  702. This compiler does not support profile guided optimization.
  703. !error $(MSG)
  704. !endif
  705. !endif
  706. ################################################################
  707. # 7. Parse the STATS macro to configure code instrumentation
  708. # The following macros are set by this section:
  709. # TCL_MEM_DEBUG - 1 -> enables memory allocation instrumentation
  710. # 0 -> disables
  711. # TCL_COMPILE_DEBUG - 1 -> enables byte compiler logging
  712. # 0 -> disables
  713. # Default both are off
  714. TCL_MEM_DEBUG = 0
  715. TCL_COMPILE_DEBUG = 0
  716. !if "$(STATS)" != "" && ![nmakehlp -f "$(STATS)" "none"]
  717. !if [nmakehlp -f $(STATS) "memdbg"]
  718. !message *** Doing memdbg
  719. TCL_MEM_DEBUG = 1
  720. !else
  721. TCL_MEM_DEBUG = 0
  722. !endif
  723. !if [nmakehlp -f $(STATS) "compdbg"]
  724. !message *** Doing compdbg
  725. TCL_COMPILE_DEBUG = 1
  726. !else
  727. TCL_COMPILE_DEBUG = 0
  728. !endif
  729. !endif
  730. ####################################################################
  731. # 8. Parse the CHECKS macro to configure additional compiler checks
  732. # The following macros are set by this section:
  733. # WARNINGS - compiler switches that control the warnings level
  734. # TCL_NO_DEPRECATED - 1 -> disable support for deprecated functions
  735. # 0 -> enable deprecated functions
  736. # Defaults - Permit deprecated functions and warning level 3
  737. TCL_NO_DEPRECATED = 0
  738. WARNINGS = -W3
  739. !if "$(CHECKS)" != "" && ![nmakehlp -f "$(CHECKS)" "none"]
  740. !if [nmakehlp -f $(CHECKS) "nodep"]
  741. !message *** Doing nodep check
  742. TCL_NO_DEPRECATED = 1
  743. !endif
  744. !if [nmakehlp -f $(CHECKS) "fullwarn"]
  745. !message *** Doing full warnings check
  746. WARNINGS = -W4
  747. !if [nmakehlp -l -warn:3 $(LINKER_TESTFLAGS)]
  748. LINKERFLAGS = $(LINKERFLAGS) -warn:3
  749. !endif
  750. !endif
  751. !if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
  752. !message *** Doing 64bit portability warnings
  753. WARNINGS = $(WARNINGS) -Wp64
  754. !endif
  755. !endif
  756. ################################################################
  757. # 9. Extract various version numbers
  758. # For Tcl and Tk, version numbers are extracted from tcl.h and tk.h
  759. # respectively. For extensions, versions are extracted from the
  760. # configure.in or configure.ac from the TEA configuration if it
  761. # exists, and unset otherwise.
  762. # Sets the following macros:
  763. # TCL_MAJOR_VERSION
  764. # TCL_MINOR_VERSION
  765. # TCL_PATCH_LEVEL
  766. # TCL_VERSION
  767. # TK_MAJOR_VERSION
  768. # TK_MINOR_VERSION
  769. # TK_PATCH_LEVEL
  770. # TK_VERSION
  771. # DOTVERSION - set as (for example) 2.5
  772. # VERSION - set as (for example 25)
  773. #--------------------------------------------------------------
  774. !if [echo REM = This file is generated from rules.vc > versions.vc]
  775. !endif
  776. !if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
  777. && [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
  778. !endif
  779. !if [echo TCL_MINOR_VERSION = \>> versions.vc] \
  780. && [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
  781. !endif
  782. !if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
  783. && [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
  784. !endif
  785. !if defined(_TK_H)
  786. !if [echo TK_MAJOR_VERSION = \>> versions.vc] \
  787. && [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
  788. !endif
  789. !if [echo TK_MINOR_VERSION = \>> versions.vc] \
  790. && [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
  791. !endif
  792. !if [echo TK_PATCH_LEVEL = \>> versions.vc] \
  793. && [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
  794. !endif
  795. !endif # _TK_H
  796. !include versions.vc
  797. TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
  798. TCL_DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
  799. !if defined(_TK_H)
  800. TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
  801. TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
  802. !endif
  803. # Set DOTVERSION and VERSION
  804. !if $(DOING_TCL)
  805. DOTVERSION = $(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
  806. VERSION = $(TCL_VERSION)
  807. !elseif $(DOING_TK)
  808. DOTVERSION = $(TK_DOTVERSION)
  809. VERSION = $(TK_VERSION)
  810. !else # Doing a non-Tk extension
  811. # If parent makefile has not defined DOTVERSION, try to get it from TEA
  812. # first from a configure.in file, and then from configure.ac
  813. !ifndef DOTVERSION
  814. !if [echo DOTVERSION = \> versions.vc] \
  815. || [nmakehlp -V $(ROOT)\configure.in ^[$(PROJECT)^] >> versions.vc]
  816. !if [echo DOTVERSION = \> versions.vc] \
  817. || [nmakehlp -V $(ROOT)\configure.ac ^[$(PROJECT)^] >> versions.vc]
  818. !error *** Could not figure out extension version. Please define DOTVERSION in parent makefile before including rules.vc.
  819. !endif
  820. !endif
  821. !include versions.vc
  822. !endif # DOTVERSION
  823. VERSION = $(DOTVERSION:.=)
  824. !endif # $(DOING_TCL) ... etc.
  825. ################################################################
  826. # 10. Construct output directory and file paths
  827. # Figure-out how to name our intermediate and output directories.
  828. # In order to avoid inadvertent mixing of object files built using
  829. # different compilers, build configurations etc.,
  830. #
  831. # Naming convention (suffixes):
  832. # t = full thread support.
  833. # s = static library (as opposed to an import library)
  834. # g = linked to the debug enabled C run-time.
  835. # x = special static build when it links to the dynamic C run-time.
  836. #
  837. # The following macros are set in this section:
  838. # SUFX - the suffix to use for binaries based on above naming convention
  839. # BUILDDIRTOP - the toplevel default output directory
  840. # is of the form {Release,Debug}[_AMD64][_COMPILERVERSION]
  841. # TMP_DIR - directory where object files are created
  842. # OUT_DIR - directory where output executables are created
  843. # Both TMP_DIR and OUT_DIR are defaulted only if not defined by the
  844. # parent makefile (or command line). The default values are
  845. # based on BUILDDIRTOP.
  846. # STUBPREFIX - name of the stubs library for this project
  847. # PRJIMPLIB - output path of the generated project import library
  848. # PRJLIBNAME - name of generated project library
  849. # PRJLIB - output path of generated project library
  850. # PRJSTUBLIBNAME - name of the generated project stubs library
  851. # PRJSTUBLIB - output path of the generated project stubs library
  852. # RESFILE - output resource file (only if not static build)
  853. SUFX = tsgx
  854. !if $(DEBUG)
  855. BUILDDIRTOP = Debug
  856. !else
  857. BUILDDIRTOP = Release
  858. !endif
  859. !if "$(MACHINE)" != "IX86"
  860. BUILDDIRTOP =$(BUILDDIRTOP)_$(MACHINE)
  861. !endif
  862. !if $(VCVER) > 6
  863. BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER)
  864. !endif
  865. !if !$(DEBUG) || $(DEBUG) && $(UNCHECKED)
  866. SUFX = $(SUFX:g=)
  867. !endif
  868. TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX
  869. !if !$(STATIC_BUILD)
  870. TMP_DIRFULL = $(TMP_DIRFULL:Static=)
  871. SUFX = $(SUFX:s=)
  872. EXT = dll
  873. TMP_DIRFULL = $(TMP_DIRFULL:X=)
  874. SUFX = $(SUFX:x=)
  875. !else
  876. TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=)
  877. EXT = lib
  878. !if !$(MSVCRT)
  879. TMP_DIRFULL = $(TMP_DIRFULL:X=)
  880. SUFX = $(SUFX:x=)
  881. !endif
  882. !endif
  883. !if !$(TCL_THREADS)
  884. TMP_DIRFULL = $(TMP_DIRFULL:Threaded=)
  885. SUFX = $(SUFX:t=)
  886. !endif
  887. !ifndef TMP_DIR
  888. TMP_DIR = $(TMP_DIRFULL)
  889. !ifndef OUT_DIR
  890. OUT_DIR = .\$(BUILDDIRTOP)
  891. !endif
  892. !else
  893. !ifndef OUT_DIR
  894. OUT_DIR = $(TMP_DIR)
  895. !endif
  896. !endif
  897. # Relative paths -> absolute
  898. !if [echo OUT_DIR = \> nmakehlp.out] \
  899. || [nmakehlp -Q "$(OUT_DIR)" >> nmakehlp.out]
  900. !error *** Could not fully qualify path OUT_DIR=$(OUT_DIR)
  901. !endif
  902. !if [echo TMP_DIR = \>> nmakehlp.out] \
  903. || [nmakehlp -Q "$(TMP_DIR)" >> nmakehlp.out]
  904. !error *** Could not fully qualify path TMP_DIR=$(TMP_DIR)
  905. !endif
  906. !include nmakehlp.out
  907. # The name of the stubs library for the project being built
  908. STUBPREFIX = $(PROJECT)stub
  909. # Set up paths to various Tcl executables and libraries needed by extensions
  910. !if $(DOING_TCL)
  911. TCLSHNAME = $(PROJECT)sh$(TCL_VERSION)$(SUFX).exe
  912. TCLSH = $(OUT_DIR)\$(TCLSHNAME)
  913. TCLIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
  914. TCLLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
  915. TCLLIB = $(OUT_DIR)\$(TCLLIBNAME)
  916. TCLSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
  917. TCLSTUBLIB = $(OUT_DIR)\$(TCLSTUBLIBNAME)
  918. TCL_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)"
  919. !else # ! $(DOING_TCL)
  920. !if $(TCLINSTALL) # Building against an installed Tcl
  921. # When building extensions, we need to locate tclsh. Depending on version
  922. # of Tcl we are building against, this may or may not have a "t" suffix.
  923. # Try various possibilities in turn.
  924. TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe
  925. !if !exist("$(TCLSH)") && $(TCL_THREADS)
  926. TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe
  927. !endif
  928. !if !exist("$(TCLSH)")
  929. TCLSH = $(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX:t=).exe
  930. !endif
  931. TCLSTUBLIB = $(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib
  932. TCLIMPLIB = $(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib
  933. # When building extensions, may be linking against Tcl that does not add
  934. # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
  935. !if !exist("$(TCLIMPLIB)")
  936. TCLIMPLIB = $(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX:t=).lib
  937. !endif
  938. TCL_LIBRARY = $(_TCLDIR)\lib
  939. TCLREGLIB = $(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib
  940. TCLDDELIB = $(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib
  941. TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target
  942. TCL_INCLUDES = -I"$(_TCLDIR)\include"
  943. !else # Building against Tcl sources
  944. TCLSH = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe
  945. !if !exist($(TCLSH)) && $(TCL_THREADS)
  946. TCLSH = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe
  947. !endif
  948. !if !exist($(TCLSH))
  949. TCLSH = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX:t=).exe
  950. !endif
  951. TCLSTUBLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib
  952. TCLIMPLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib
  953. # When building extensions, may be linking against Tcl that does not add
  954. # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
  955. !if !exist("$(TCLIMPLIB)")
  956. TCLIMPLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX:t=).lib
  957. !endif
  958. TCL_LIBRARY = $(_TCLDIR)\library
  959. TCLREGLIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib
  960. TCLDDELIB = $(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib
  961. TCLTOOLSDIR = $(_TCLDIR)\tools
  962. TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
  963. !endif # TCLINSTALL
  964. tcllibs = "$(TCLSTUBLIB)" "$(TCLIMPLIB)"
  965. !endif # $(DOING_TCL)
  966. # We need a tclsh that will run on the host machine as part of the build.
  967. # IX86 runs on all architectures.
  968. !ifndef TCLSH_NATIVE
  969. !if "$(MACHINE)" == "IX86" || "$(MACHINE)" == "$(NATIVE_ARCH)"
  970. TCLSH_NATIVE = $(TCLSH)
  971. !else
  972. !error You must explicitly set TCLSH_NATIVE for cross-compilation
  973. !endif
  974. !endif
  975. # Do the same for Tk and Tk extensions that require the Tk libraries
  976. !if $(DOING_TK) || $(NEED_TK)
  977. WISHNAMEPREFIX = wish
  978. WISHNAME = $(WISHNAMEPREFIX)$(TK_VERSION)$(SUFX).exe
  979. TKLIBNAME = $(PROJECT)$(TK_VERSION)$(SUFX).$(EXT)
  980. TKSTUBLIBNAME = tkstub$(TK_VERSION).lib
  981. TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX).lib
  982. !if $(DOING_TK)
  983. WISH = $(OUT_DIR)\$(WISHNAME)
  984. TKSTUBLIB = $(OUT_DIR)\$(TKSTUBLIBNAME)
  985. TKIMPLIB = $(OUT_DIR)\$(TKIMPLIBNAME)
  986. TKLIB = $(OUT_DIR)\$(TKLIBNAME)
  987. TK_INCLUDES = -I"$(WINDIR)" -I"$(GENERICDIR)"
  988. !else # effectively NEED_TK
  989. !if $(TKINSTALL) # Building against installed Tk
  990. WISH = $(_TKDIR)\bin\$(WISHNAME)
  991. TKSTUBLIB = $(_TKDIR)\lib\$(TKSTUBLIBNAME)
  992. TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME)
  993. # When building extensions, may be linking against Tk that does not add
  994. # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
  995. !if !exist("$(TKIMPLIB)")
  996. TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX:t=).lib
  997. TKIMPLIB = $(_TKDIR)\lib\$(TKIMPLIBNAME)
  998. !endif
  999. TK_INCLUDES = -I"$(_TKDIR)\include"
  1000. !else # Building against Tk sources
  1001. WISH = $(_TKDIR)\win\$(BUILDDIRTOP)\$(WISHNAME)
  1002. TKSTUBLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKSTUBLIBNAME)
  1003. TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
  1004. # When building extensions, may be linking against Tk that does not add
  1005. # "t" suffix (e.g. 8.5 or 8.7). If lib not found check for that possibility.
  1006. !if !exist("$(TKIMPLIB)")
  1007. TKIMPLIBNAME = tk$(TK_VERSION)$(SUFX:t=).lib
  1008. TKIMPLIB = $(_TKDIR)\win\$(BUILDDIRTOP)\$(TKIMPLIBNAME)
  1009. !endif
  1010. TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
  1011. !endif # TKINSTALL
  1012. tklibs = "$(TKSTUBLIB)" "$(TKIMPLIB)"
  1013. !endif # $(DOING_TK)
  1014. !endif # $(DOING_TK) || $(NEED_TK)
  1015. # Various output paths
  1016. PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
  1017. PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
  1018. PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
  1019. PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
  1020. PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME)
  1021. # If extension parent makefile has not defined a resource definition file,
  1022. # we will generate one from standard template.
  1023. !if !$(DOING_TCL) && !$(DOING_TK) && !$(STATIC_BUILD)
  1024. !ifdef RCFILE
  1025. RESFILE = $(TMP_DIR)\$(RCFILE:.rc=.res)
  1026. !else
  1027. RESFILE = $(TMP_DIR)\$(PROJECT).res
  1028. !endif
  1029. !endif
  1030. ###################################################################
  1031. # 11. Construct the paths for the installation directories
  1032. # The following macros get defined in this section:
  1033. # LIB_INSTALL_DIR - where libraries should be installed
  1034. # BIN_INSTALL_DIR - where the executables should be installed
  1035. # DOC_INSTALL_DIR - where documentation should be installed
  1036. # SCRIPT_INSTALL_DIR - where scripts should be installed
  1037. # INCLUDE_INSTALL_DIR - where C include files should be installed
  1038. # DEMO_INSTALL_DIR - where demos should be installed
  1039. # PRJ_INSTALL_DIR - where package will be installed (not set for Tcl and Tk)
  1040. !if $(DOING_TCL) || $(DOING_TK)
  1041. LIB_INSTALL_DIR = $(_INSTALLDIR)\lib
  1042. BIN_INSTALL_DIR = $(_INSTALLDIR)\bin
  1043. DOC_INSTALL_DIR = $(_INSTALLDIR)\doc
  1044. !if $(DOING_TCL)
  1045. SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TCL_MAJOR_VERSION).$(TCL_MINOR_VERSION)
  1046. !else # DOING_TK
  1047. SCRIPT_INSTALL_DIR = $(_INSTALLDIR)\lib\$(PROJECT)$(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
  1048. !endif
  1049. DEMO_INSTALL_DIR = $(SCRIPT_INSTALL_DIR)\demos
  1050. INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\include
  1051. !else # extension other than Tk
  1052. PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
  1053. LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)
  1054. BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)
  1055. DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR)
  1056. SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR)
  1057. DEMO_INSTALL_DIR = $(PRJ_INSTALL_DIR)\demos
  1058. INCLUDE_INSTALL_DIR = $(_INSTALLDIR)\..\include
  1059. !endif
  1060. ###################################################################
  1061. # 12. Set up actual options to be passed to the compiler and linker
  1062. # Now we have all the information we need, set up the actual flags and
  1063. # options that we will pass to the compiler and linker. The main
  1064. # makefile should use these in combination with whatever other flags
  1065. # and switches are specific to it.
  1066. # The following macros are defined, names are for historical compatibility:
  1067. # OPTDEFINES - /Dxxx C macro flags based on user-specified OPTS
  1068. # COMPILERFLAGS - /Dxxx C macro flags independent of any configuration opttions
  1069. # crt - Compiler switch that selects the appropriate C runtime
  1070. # cdebug - Compiler switches related to debug AND optimizations
  1071. # cwarn - Compiler switches that set warning levels
  1072. # cflags - complete compiler switches (subsumes cdebug and cwarn)
  1073. # ldebug - Linker switches controlling debug information and optimization
  1074. # lflags - complete linker switches (subsumes ldebug) except subsystem type
  1075. # dlllflags - complete linker switches to build DLLs (subsumes lflags)
  1076. # conlflags - complete linker switches for console program (subsumes lflags)
  1077. # guilflags - complete linker switches for GUI program (subsumes lflags)
  1078. # baselibs - minimum Windows libraries required. Parent makefile can
  1079. # define PRJ_LIBS before including rules.rc if additional libs are needed
  1080. OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS
  1081. !if $(TCL_MEM_DEBUG)
  1082. OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG
  1083. !endif
  1084. !if $(TCL_COMPILE_DEBUG)
  1085. OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS
  1086. !endif
  1087. !if $(TCL_THREADS)
  1088. OPTDEFINES = $(OPTDEFINES) -DTCL_THREADS=1
  1089. !if $(USE_THREAD_ALLOC)
  1090. OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1
  1091. !endif
  1092. !endif
  1093. !if $(STATIC_BUILD)
  1094. OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD
  1095. !endif
  1096. !if $(TCL_NO_DEPRECATED)
  1097. OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED
  1098. !endif
  1099. !if $(USE_STUBS)
  1100. # Note we do not define USE_TCL_STUBS even when building tk since some
  1101. # test targets in tk do not use stubs
  1102. !if ! $(DOING_TCL)
  1103. USE_STUBS_DEFS = -DUSE_TCL_STUBS -DUSE_TCLOO_STUBS
  1104. !if $(NEED_TK)
  1105. USE_STUBS_DEFS = $(USE_STUBS_DEFS) -DUSE_TK_STUBS
  1106. !endif
  1107. !endif
  1108. !endif # USE_STUBS
  1109. !if !$(DEBUG)
  1110. OPTDEFINES = $(OPTDEFINES) -DNDEBUG
  1111. !if $(OPTIMIZING)
  1112. OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED
  1113. !endif
  1114. !endif
  1115. !if $(PROFILE)
  1116. OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED
  1117. !endif
  1118. !if "$(MACHINE)" == "AMD64"
  1119. OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT
  1120. !endif
  1121. !if $(VCVERSION) < 1300
  1122. OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64
  1123. !endif
  1124. # _ATL_XP_TARGETING - Newer SDK's need this to build for XP
  1125. COMPILERFLAGS = /D_ATL_XP_TARGETING
  1126. # Following is primarily for the benefit of extensions. Tcl 8.5 builds
  1127. # Tcl without /DUNICODE, while 8.6 builds with it defined. When building
  1128. # an extension, it is advisable (but not mandated) to use the same Windows
  1129. # API as the Tcl build. This is accordingly defaulted below. A particular
  1130. # extension can override this by pre-definining USE_WIDECHAR_API.
  1131. !ifndef USE_WIDECHAR_API
  1132. !if $(TCL_VERSION) > 85
  1133. USE_WIDECHAR_API = 1
  1134. !else
  1135. USE_WIDECHAR_API = 0
  1136. !endif
  1137. !endif
  1138. !if $(USE_WIDECHAR_API)
  1139. COMPILERFLAGS = $(COMPILERFLAGS) /DUNICODE /D_UNICODE
  1140. !endif
  1141. # Like the TEA system only set this non empty for non-Tk extensions
  1142. # Note: some extensions use PACKAGE_NAME and others use PACKAGE_TCLNAME
  1143. # so we pass both
  1144. !if !$(DOING_TCL) && !$(DOING_TK)
  1145. PKGNAMEFLAGS = -DPACKAGE_NAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
  1146. -DPACKAGE_TCLNAME="\"$(PRJ_PACKAGE_TCLNAME)\"" \
  1147. -DPACKAGE_VERSION="\"$(DOTVERSION)\"" \
  1148. -DMODULE_SCOPE=extern
  1149. !endif
  1150. # crt picks the C run time based on selected OPTS
  1151. !if $(MSVCRT)
  1152. !if $(DEBUG) && !$(UNCHECKED)
  1153. crt = -MDd
  1154. !else
  1155. crt = -MD
  1156. !endif
  1157. !else
  1158. !if $(DEBUG) && !$(UNCHECKED)
  1159. crt = -MTd
  1160. !else
  1161. crt = -MT
  1162. !endif
  1163. !endif
  1164. # cdebug includes compiler options for debugging as well as optimization.
  1165. !if $(DEBUG)
  1166. # In debugging mode, optimizations need to be disabled
  1167. cdebug = -Zi -Od $(DEBUGFLAGS)
  1168. !else
  1169. cdebug = $(OPTIMIZATIONS)
  1170. !if $(SYMBOLS)
  1171. cdebug = $(cdebug) -Zi
  1172. !endif
  1173. !endif # $(DEBUG)
  1174. # cwarn includes default warning levels.
  1175. cwarn = $(WARNINGS)
  1176. !if "$(MACHINE)" == "AMD64"
  1177. # Disable pointer<->int warnings related to cast between different sizes
  1178. # There are a gadzillion of these due to use of ClientData and
  1179. # clutter up compiler
  1180. # output increasing chance of a real warning getting lost. So disable them.
  1181. # Eventually some day, Tcl will be 64-bit clean.
  1182. cwarn = $(cwarn) -wd4311 -wd4312
  1183. !endif
  1184. ### Common compiler options that are architecture specific
  1185. !if "$(MACHINE)" == "ARM"
  1186. carch = -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
  1187. !else
  1188. carch =
  1189. !endif
  1190. !if $(DEBUG)
  1191. # Turn warnings into errors
  1192. cwarn = $(cwarn) -WX
  1193. !endif
  1194. INCLUDES = $(TCL_INCLUDES) $(TK_INCLUDES) $(PRJ_INCLUDES)
  1195. !if !$(DOING_TCL) && !$(DOING_TK)
  1196. INCLUDES = $(INCLUDES) -I"$(GENERICDIR)" -I"$(WINDIR)" -I"$(COMPATDIR)"
  1197. !endif
  1198. # These flags are defined roughly in the order of the pre-reform
  1199. # rules.vc/makefile.vc to help visually compare that the pre- and
  1200. # post-reform build logs
  1201. # cflags contains generic flags used for building practically all object files
  1202. cflags = -nologo -c $(COMPILERFLAGS) $(carch) $(cwarn) -Fp$(TMP_DIR)^\ $(cdebug)
  1203. # appcflags contains $(cflags) and flags for building the application
  1204. # object files (e.g. tclsh, or wish) pkgcflags contains $(cflags) plus
  1205. # flags used for building shared object files The two differ in the
  1206. # BUILD_$(PROJECT) macro which should be defined only for the shared
  1207. # library *implementation* and not for its caller interface
  1208. appcflags = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES) $(USE_STUBS_DEFS)
  1209. appcflags_nostubs = $(cflags) $(crt) $(INCLUDES) $(TCL_DEFINES) $(PRJ_DEFINES) $(OPTDEFINES)
  1210. pkgcflags = $(appcflags) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
  1211. pkgcflags_nostubs = $(appcflags_nostubs) $(PKGNAMEFLAGS) -DBUILD_$(PROJECT)
  1212. # stubscflags contains $(cflags) plus flags used for building a stubs
  1213. # library for the package. Note: -DSTATIC_BUILD is defined in
  1214. # $(OPTDEFINES) only if the OPTS configuration indicates a static
  1215. # library. However the stubs library is ALWAYS static hence included
  1216. # here irrespective of the OPTS setting.
  1217. #
  1218. # TBD - tclvfs has a comment that stubs libs should not be compiled with -GL
  1219. # without stating why. Tcl itself compiled stubs libs with this flag.
  1220. # so we do not remove it from cflags. -GL may prevent extensions
  1221. # compiled with one VC version to fail to link against stubs library
  1222. # compiled with another VC version. Check for this and fix accordingly.
  1223. stubscflags = $(cflags) $(PKGNAMEFLAGS) $(PRJ_DEFINES) $(OPTDEFINES) -Zl -DSTATIC_BUILD $(INCLUDES)
  1224. # Link flags
  1225. !if $(DEBUG)
  1226. ldebug = -debug -debugtype:cv
  1227. !else
  1228. ldebug = -release -opt:ref -opt:icf,3
  1229. !if $(SYMBOLS)
  1230. ldebug = $(ldebug) -debug -debugtype:cv
  1231. !endif
  1232. !endif
  1233. # Note: Profiling is currently only possible with the Visual Studio Enterprise
  1234. !if $(PROFILE)
  1235. ldebug= $(ldebug) -profile
  1236. !endif
  1237. ### Declarations common to all linker versions
  1238. lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug)
  1239. !if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900
  1240. lflags = $(lflags) -nodefaultlib:libucrt.lib
  1241. !endif
  1242. # Old linkers (Visual C++ 6 in particular) will link for fast loading
  1243. # on Win98. Since we do not support Win98 any more, we specify nowin98
  1244. # as recommended for NT and later. However, this is only required by
  1245. # IX86 on older compilers and only needed if we are not doing a static build.
  1246. !if "$(MACHINE)" == "IX86" && !$(STATIC_BUILD)
  1247. !if [nmakehlp -l -opt:nowin98 $(LINKER_TESTFLAGS)]
  1248. # Align sections for PE size savings.
  1249. lflags = $(lflags) -opt:nowin98
  1250. !endif
  1251. !endif
  1252. dlllflags = $(lflags) -dll
  1253. conlflags = $(lflags) -subsystem:console
  1254. guilflags = $(lflags) -subsystem:windows
  1255. # Libraries that are required for every image.
  1256. # Extensions should define any additional libraries with $(PRJ_LIBS)
  1257. winlibs = kernel32.lib advapi32.lib
  1258. !if $(NEED_TK)
  1259. winlibs = $(winlibs) gdi32.lib user32.lib uxtheme.lib
  1260. !endif
  1261. # Avoid 'unresolved external symbol __security_cookie' errors.
  1262. # c.f. http://support.microsoft.com/?id=894573
  1263. !if "$(MACHINE)" == "AMD64"
  1264. !if $(VCVERSION) > 1399 && $(VCVERSION) < 1500
  1265. winlibs = $(winlibs) bufferoverflowU.lib
  1266. !endif
  1267. !endif
  1268. baselibs = $(winlibs) $(PRJ_LIBS)
  1269. !if $(MSVCRT) && !($(DEBUG) && !$(UNCHECKED)) && $(VCVERSION) >= 1900
  1270. baselibs = $(baselibs) ucrt.lib
  1271. !endif
  1272. ################################################################
  1273. # 13. Define standard commands, common make targets and implicit rules
  1274. CCPKGCMD = $(cc32) $(pkgcflags) -Fo$(TMP_DIR)^\
  1275. CCAPPCMD = $(cc32) $(appcflags) -Fo$(TMP_DIR)^\
  1276. CCSTUBSCMD = $(cc32) $(stubscflags) -Fo$(TMP_DIR)^\
  1277. LIBCMD = $(lib32) -nologo $(LINKERFLAGS) -out:$@
  1278. DLLCMD = $(link32) $(dlllflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
  1279. CONEXECMD = $(link32) $(conlflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
  1280. GUIEXECMD = $(link32) $(guilflags) -out:$@ $(baselibs) $(tcllibs) $(tklibs)
  1281. RESCMD = $(rc32) -fo $@ -r -i "$(GENERICDIR)" -i "$(TMP_DIR)" \
  1282. $(TCL_INCLUDES) \
  1283. -DDEBUG=$(DEBUG) -d UNCHECKED=$(UNCHECKED) \
  1284. -DCOMMAVERSION=$(DOTVERSION:.=,),0 \
  1285. -DDOTVERSION=\"$(DOTVERSION)\" \
  1286. -DVERSION=\"$(VERSION)\" \
  1287. -DSUFX=\"$(SUFX)\" \
  1288. -DPROJECT=\"$(PROJECT)\" \
  1289. -DPRJLIBNAME=\"$(PRJLIBNAME)\"
  1290. !ifndef DEFAULT_BUILD_TARGET
  1291. DEFAULT_BUILD_TARGET = $(PROJECT)
  1292. !endif
  1293. default-target: $(DEFAULT_BUILD_TARGET)
  1294. default-pkgindex:
  1295. @echo package ifneeded $(PRJ_PACKAGE_TCLNAME) $(DOTVERSION) \
  1296. [list load [file join $$dir $(PRJLIBNAME)]] > $(OUT_DIR)\pkgIndex.tcl
  1297. default-pkgindex-tea:
  1298. @if exist $(ROOT)\pkgIndex.tcl.in nmakehlp -s << $(ROOT)\pkgIndex.tcl.in > $(OUT_DIR)\pkgIndex.tcl
  1299. @PACKAGE_VERSION@ $(DOTVERSION)
  1300. @PACKAGE_NAME@ $(PRJ_PACKAGE_TCLNAME)
  1301. @PACKAGE_TCLNAME@ $(PRJ_PACKAGE_TCLNAME)
  1302. @PKG_LIB_FILE@ $(PRJLIBNAME)
  1303. <<
  1304. default-install: default-install-binaries default-install-libraries
  1305. default-install-binaries: $(PRJLIB)
  1306. @echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
  1307. @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
  1308. @$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
  1309. default-install-libraries: $(OUT_DIR)\pkgIndex.tcl
  1310. @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
  1311. @if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
  1312. @echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
  1313. @$(CPY) $(OUT_DIR)\pkgIndex.tcl $(SCRIPT_INSTALL_DIR)
  1314. default-install-stubs:
  1315. @echo Installing stubs library to '$(SCRIPT_INSTALL_DIR)'
  1316. @if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
  1317. @$(CPY) $(PRJSTUBLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
  1318. default-install-docs-html:
  1319. @echo Installing documentation files to '$(DOC_INSTALL_DIR)'
  1320. @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
  1321. @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.html" "$(DOCDIR)\*.css" "$(DOCDIR)\*.png") do @$(COPY) %f "$(DOC_INSTALL_DIR)"
  1322. default-install-docs-n:
  1323. @echo Installing documentation files to '$(DOC_INSTALL_DIR)'
  1324. @if not exist "$(DOC_INSTALL_DIR)" mkdir "$(DOC_INSTALL_DIR)"
  1325. @if exist $(DOCDIR) for %f in ("$(DOCDIR)\*.n") do @$(COPY) %f "$(DOC_INSTALL_DIR)"
  1326. default-install-demos:
  1327. @echo Installing demos to '$(DEMO_INSTALL_DIR)'
  1328. @if not exist "$(DEMO_INSTALL_DIR)" mkdir "$(DEMO_INSTALL_DIR)"
  1329. @if exist $(DEMODIR) $(CPYDIR) "$(DEMODIR)" "$(DEMO_INSTALL_DIR)"
  1330. default-clean:
  1331. @echo Cleaning $(TMP_DIR)\* ...
  1332. @if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
  1333. @echo Cleaning $(WINDIR)\nmakehlp.obj, nmakehlp.exe ...
  1334. @if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
  1335. @if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
  1336. @if exist $(WINDIR)\nmakehlp.out del $(WINDIR)\nmakehlp.out
  1337. @echo Cleaning $(WINDIR)\nmhlp-out.txt ...
  1338. @if exist $(WINDIR)\nmhlp-out.txt del $(WINDIR)\nmhlp-out.txt
  1339. @echo Cleaning $(WINDIR)\_junk.pch ...
  1340. @if exist $(WINDIR)\_junk.pch del $(WINDIR)\_junk.pch
  1341. @echo Cleaning $(WINDIR)\vercl.x, vercl.i ...
  1342. @if exist $(WINDIR)\vercl.x del $(WINDIR)\vercl.x
  1343. @if exist $(WINDIR)\vercl.i del $(WINDIR)\vercl.i
  1344. @echo Cleaning $(WINDIR)\versions.vc, version.vc ...
  1345. @if exist $(WINDIR)\versions.vc del $(WINDIR)\versions.vc
  1346. @if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
  1347. default-hose: default-clean
  1348. @echo Hosing $(OUT_DIR)\* ...
  1349. @if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
  1350. # Only for backward compatibility
  1351. default-distclean: default-hose
  1352. default-setup:
  1353. @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
  1354. @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
  1355. !if "$(TESTPAT)" != ""
  1356. TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
  1357. !endif
  1358. default-test: default-setup $(PROJECT)
  1359. @set TCLLIBPATH=$(OUT_DIR:\=/)
  1360. @if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)"
  1361. cd "$(TESTDIR)" && $(DEBUGGER) $(TCLSH) all.tcl $(TESTFLAGS)
  1362. default-shell: default-setup $(PROJECT)
  1363. @set TCLLIBPATH=$(OUT_DIR:\=/)
  1364. @if exist $(LIBDIR) for %f in ("$(LIBDIR)\*.tcl") do @$(COPY) %f "$(OUT_DIR)"
  1365. $(DEBUGGER) $(TCLSH)
  1366. # Generation of Windows version resource
  1367. !ifdef RCFILE
  1368. # Note: don't use $** in below rule because there may be other dependencies
  1369. # and only the "master" rc must be passed to the resource compiler
  1370. $(TMP_DIR)\$(PROJECT).res: $(RCDIR)\$(PROJECT).rc
  1371. $(RESCMD) $(RCDIR)\$(PROJECT).rc
  1372. !else
  1373. # If parent makefile has not defined a resource definition file,
  1374. # we will generate one from standard template.
  1375. $(TMP_DIR)\$(PROJECT).res: $(TMP_DIR)\$(PROJECT).rc
  1376. $(TMP_DIR)\$(PROJECT).rc:
  1377. @$(COPY) << $(TMP_DIR)\$(PROJECT).rc
  1378. #include <winver.h>
  1379. VS_VERSION_INFO VERSIONINFO
  1380. FILEVERSION COMMAVERSION
  1381. PRODUCTVERSION COMMAVERSION
  1382. FILEFLAGSMASK 0x3fL
  1383. #ifdef DEBUG
  1384. FILEFLAGS VS_FF_DEBUG
  1385. #else
  1386. FILEFLAGS 0x0L
  1387. #endif
  1388. FILEOS VOS_NT_WINDOWS32
  1389. FILETYPE VFT_DLL
  1390. FILESUBTYPE 0x0L
  1391. BEGIN
  1392. BLOCK "StringFileInfo"
  1393. BEGIN
  1394. BLOCK "040904b0"
  1395. BEGIN
  1396. VALUE "FileDescription", "Tcl extension " PROJECT
  1397. VALUE "OriginalFilename", PRJLIBNAME
  1398. VALUE "FileVersion", DOTVERSION
  1399. VALUE "ProductName", "Package " PROJECT " for Tcl"
  1400. VALUE "ProductVersion", DOTVERSION
  1401. END
  1402. END
  1403. BLOCK "VarFileInfo"
  1404. BEGIN
  1405. VALUE "Translation", 0x409, 1200
  1406. END
  1407. END
  1408. <<
  1409. !endif # ifdef RCFILE
  1410. !ifndef DISABLE_IMPLICIT_RULES
  1411. DISABLE_IMPLICIT_RULES = 0
  1412. !endif
  1413. !if !$(DISABLE_IMPLICIT_RULES)
  1414. # Implicit rule definitions - only for building library objects. For stubs and
  1415. # main application, the master makefile should define explicit rules.
  1416. {$(ROOT)}.c{$(TMP_DIR)}.obj::
  1417. $(CCPKGCMD) @<<
  1418. $<
  1419. <<
  1420. {$(WINDIR)}.c{$(TMP_DIR)}.obj::
  1421. $(CCPKGCMD) @<<
  1422. $<
  1423. <<
  1424. {$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
  1425. $(CCPKGCMD) @<<
  1426. $<
  1427. <<
  1428. {$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
  1429. $(CCPKGCMD) @<<
  1430. $<
  1431. <<
  1432. {$(RCDIR)}.rc{$(TMP_DIR)}.res:
  1433. $(RESCMD) $<
  1434. {$(WINDIR)}.rc{$(TMP_DIR)}.res:
  1435. $(RESCMD) $<
  1436. {$(TMP_DIR)}.rc{$(TMP_DIR)}.res:
  1437. $(RESCMD) $<
  1438. .SUFFIXES:
  1439. .SUFFIXES:.c .rc
  1440. !endif
  1441. ################################################################
  1442. # 14. Sanity check selected options against Tcl build options
  1443. # When building an extension, certain configuration options should
  1444. # match the ones used when Tcl was built. Here we check and
  1445. # warn on a mismatch.
  1446. !if ! $(DOING_TCL)
  1447. !if $(TCLINSTALL) # Building against an installed Tcl
  1448. !if exist("$(_TCLDIR)\lib\nmake\tcl.nmake")
  1449. TCLNMAKECONFIG = "$(_TCLDIR)\lib\nmake\tcl.nmake"
  1450. !endif
  1451. !else # ! $(TCLINSTALL) - building against Tcl source
  1452. !if exist("$(OUT_DIR)\tcl.nmake")
  1453. TCLNMAKECONFIG = "$(OUT_DIR)\tcl.nmake"
  1454. !endif
  1455. !endif # TCLINSTALL
  1456. !if $(CONFIG_CHECK)
  1457. !ifdef TCLNMAKECONFIG
  1458. !include $(TCLNMAKECONFIG)
  1459. !if defined(CORE_MACHINE) && "$(CORE_MACHINE)" != "$(MACHINE)"
  1460. !error ERROR: Build target ($(MACHINE)) does not match the Tcl library architecture ($(CORE_MACHINE)).
  1461. !endif
  1462. !if defined(CORE_USE_THREAD_ALLOC) && $(CORE_USE_THREAD_ALLOC) != $(USE_THREAD_ALLOC)
  1463. !message WARNING: Value of USE_THREAD_ALLOC ($(USE_THREAD_ALLOC)) does not match its Tcl core value ($(CORE_USE_THREAD_ALLOC)).
  1464. !endif
  1465. !if defined(CORE_DEBUG) && $(CORE_DEBUG) != $(DEBUG)
  1466. !message WARNING: Value of DEBUG ($(DEBUG)) does not match its Tcl library configuration ($(DEBUG)).
  1467. !endif
  1468. !endif
  1469. !endif # TCLNMAKECONFIG
  1470. !endif # ! $(DOING_TCL)
  1471. #----------------------------------------------------------
  1472. # Display stats being used.
  1473. #----------------------------------------------------------
  1474. !if !$(DOING_TCL)
  1475. !message *** Building against Tcl at '$(_TCLDIR)'
  1476. !endif
  1477. !if !$(DOING_TK) && $(NEED_TK)
  1478. !message *** Building against Tk at '$(_TKDIR)'
  1479. !endif
  1480. !message *** Intermediate directory will be '$(TMP_DIR)'
  1481. !message *** Output directory will be '$(OUT_DIR)'
  1482. !message *** Installation, if selected, will be in '$(_INSTALLDIR)'
  1483. !message *** Suffix for binaries will be '$(SUFX)'
  1484. !message *** Compiler version $(VCVER). Target $(MACHINE), host $(NATIVE_ARCH).
  1485. !endif # ifdef _RULES_VC