home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / MFCINC.PAK / MFCSAMPS.MAK < prev    next >
Encoding:
Text File  |  1997-05-06  |  8.0 KB  |  391 lines

  1. # This is a part of the Microsoft Foundation Classes C++ library.
  2. # Copyright (C) 1992-1995 Microsoft Corporation
  3. # All rights reserved.
  4. #
  5. # This source code is only intended as a supplement to the
  6. # Microsoft Foundation Classes Reference and related
  7. # electronic documentation provided with the library.
  8. # See these sources for detailed information regarding the
  9. # Microsoft Foundation Classes product.
  10.  
  11. # Common include for building MFC Sample programs
  12. #
  13. #  typical usage
  14. #       PROJ=foo
  15. #       OBJS=foo.obj bar.obj ...
  16. #       !INCLUDE ..\..\SAMPLE_.MAK
  17. #
  18. #  ROOT specifies the location of the msdev\samples\mfc directory,
  19. #  relative to the project directory. Because the MFC tutorial samples
  20. #  have an intermediate STEP<n> subdirectory, they use
  21. #       ROOT=..\..\..
  22. #  instead of the default
  23. #       ROOT=..\..
  24. #
  25. # Options to NMAKE:
  26. #     "DEBUG=0"     use retail (default debug)
  27. #     "CODEVIEW=1"  include codeview info (even for retail builds)
  28. #         "AFXDLL=1"    to use shared DLL version of MFC
  29. #         "USRDLL=1"    to build a DLL that uses static MFC
  30. #############################################################################
  31. #  Borland specific options:
  32. #
  33. #  "USRSTARTUP=xxx" used to link with a specific startup code .OBJ
  34. #                   (by default it uses the correct one for the specified
  35. #                    target).
  36. #
  37. #  "DBGINFO=1"      is used to include source debugging information.
  38. #
  39. #  "NO_RESOURCE=1"  is set to not attempt to bind in resources.
  40. #
  41. #  "NO_PCH=1"       is set to prevent the use of pre-compiled headers
  42. #                   (default is to use them)
  43. #
  44. #  "NO_CLEAN_PCH"   To prevent deleting an existing PCH (.csm) file
  45. #
  46. #  LINKFLAGS and CFLAGS can be set to contain additional or overriding option
  47. #  for the linker or compiler
  48. #
  49. #
  50.  
  51. !ifndef PROJ
  52. !ERROR You forgot to define 'PROJ' symbol!!
  53. !endif
  54.  
  55. ROOT=.
  56.  
  57. !ifndef OBJS
  58. !ERROR You forgot to define 'OBJS' symbol!!
  59. !endif
  60.  
  61. !ifndef DEBUG
  62. DEBUG=1
  63. !endif
  64.  
  65. !ifndef DBGINFO
  66. DBGINFO=0
  67. !endif
  68.  
  69. !ifdef CODEVIEW
  70. DBGINFO=$(CODEVIEW)
  71. !endif
  72.  
  73. !ifndef AFXDLL
  74. AFXDLL=0
  75. !endif
  76.  
  77. !ifndef UNICODE
  78. UNICODE=0
  79. !endif
  80.  
  81. !ifndef USRDLL
  82. USRDLL=0
  83. !endif
  84.  
  85. !ifdef USRSTARTUP
  86. STARTUP=$(USRSTARTUP)
  87. !endif
  88.  
  89. !ifndef NO_RESOURCE
  90. NO_RESOURCE=0
  91. !endif
  92.  
  93. !ifndef NO_PCH
  94. NO_PCH=0
  95. !endif
  96.  
  97. !ifndef NO_CLEAN_PCH
  98. NO_CLEAN_PCH=0
  99. !endif
  100.  
  101. !if "$(SIMPLE_APP)" == "1"
  102.   NO_RESOURCE=1
  103. !endif
  104.  
  105. !ifndef USES_OLE
  106. USES_OLE=0
  107. !endif
  108.  
  109. !ifndef USES_DB
  110. USES_DB=0
  111. !endif
  112.  
  113. !ifndef CONSOLE
  114. CONSOLE=0
  115. !endif
  116.  
  117. #
  118. # Set BASE=W, M, or P depending on platform
  119. #
  120. BASE=W
  121.  
  122. !if "$(UNICODE)" == "0"
  123. !if "$(AFXDLL)" == "0"
  124. !if "$(USRDLL)" != "1"
  125. STDAFX=stdafx
  126. !else
  127. STDAFX=stdusr
  128. !endif
  129. !else
  130. STDAFX=stddll
  131. !endif
  132. !endif
  133.  
  134. !if "$(UNICODE)" == "1"
  135. !if "$(AFXDLL)" == "0"
  136. !if "$(USRDLL)" != "1"
  137. STDAFX=uniafx
  138. !else
  139. STDAFX=uniusr
  140. !endif
  141. !else
  142. STDAFX=unidll
  143. !endif
  144. !endif
  145.  
  146. !if "$(DEBUG)" == "1"
  147. STDAFX=$(STDAFX)d
  148. !endif
  149.  
  150. !if "$(DEBUG)" == "1"
  151. DEBUG_SUFFIX=d
  152. !endif
  153.  
  154. !if "$(DEBUG)" != "0"
  155. DEBUGFLAGS=/Od
  156. MFCDEFS=$(MFCDEFS) /D_DEBUG
  157.  
  158.  
  159. !endif
  160.  
  161. !if "$(DEBUG)" == "0"
  162. DEBUGFLAGS=/O1
  163. !endif # DEBUG == 0
  164.  
  165. !if "$(DBGINFO)" == "1"
  166. DEBUGFLAGS=$(DEBUGFLAGS) -v -vi
  167. LINKDEBUG=/v
  168. !endif
  169.  
  170. !if "$(UNICODE)" == "1"
  171. DLL_SUFFIX=u
  172. !endif
  173.  
  174. !if "$(AFXDLL)" == "1"
  175. MFCDEFS=$(MFCDEFS) /D_RTLDLL;_AFXDLL;_X86_;_WINDOWS;_MSC_VER=900;_AFX_PORTABLE;_AFX_NOFORCE_LIBS;_CRT_PORTABLE;_AFX_NO_DEBUG_CRT;
  176. !else
  177. MFCDEFS=$(MFCDEFS) /D_X86_;_WINDOWS;_MSC_VER=900;_AFX_PORTABLE;_AFX_NOFORCE_LIBS;_CRT_PORTABLE;_AFX_NO_DEBUG_CRT;
  178. !endif
  179.  
  180. !if "$(USRDLL)" == "1"
  181. MFCDEFS=$(MFCDEFS) /D_USRDLL /D_WINDLL
  182. !if "$(CONSOLE)" == "1"
  183. MFCFLAGS=$(MFCFLAGS) -tWCD
  184. !else
  185. MFCFLAGS=$(MFCFLAGS) -tWD
  186. !endif
  187. !else
  188. !if "$(CONSOLE)" == "1"
  189. MFCFLAGS=$(MFCFLAGS) -tWC
  190. !else
  191. MFCFLAGS=$(MFCFLAGS) -tWE
  192. !endif
  193. !endif
  194.  
  195. !if "$(UNICODE)" == "1"
  196. MFCDEFS=$(MFCDEFS) /D_UNICODE
  197. !endif
  198.  
  199. CPP=bcc32
  200. BORINCL=$(MAKEDIR)\..\include
  201. CFLAGS=-X -c -g0 -j1 -w-hid -w-par -w-aus -w-inl -VF -Vd -tWM -I$(BORINCL);$(BORINCL)\mfc $(DEBUGFLAGS) $(MFCFLAGS) $(MFCDEFS) $(CFLAGS)
  202. CPPMAIN_FLAGS=$(CFLAGS)
  203.  
  204. !if "$(NO_PCH)" == "1"
  205. CPPFLAGS=$(CPPMAIN_FLAGS)
  206. !else
  207. PCHDIR=.
  208. PCH_FILE=$(PCHDIR)\$(STDAFX).csm
  209. CPPFLAGS=$(CPPMAIN_FLAGS) -H -Hc -H=$(PCH_FILE)
  210. !endif
  211.  
  212. BORLIB=$(MAKEDIR)\..\lib
  213. LINKFLAGS=/n /m /s /w-inq $(LINKDEBUG) /L$(BORLIB);$(OTHERLIBPATH) $(LINKFLAGS) 
  214. LINKCMD=tlink32
  215. !if "$(USES_OLE)" == "1"
  216.   OTHERLIBS=ole2w32.lib $(OTHERLIBS)
  217. !endif
  218.  
  219. !if "$(USES_DB)" == "1"
  220.   OTHERLIBS=odbc32.lib $(OTHERLIBS)
  221. !endif
  222.  
  223. !if "$(AFXDLL)" == "1"
  224. !if "$(DEBUG)" == "1"
  225. LIBRARIES=BFC40D.lib BFCS40D.lib bfcd40d.lib bfco40d.lib bfcn40d.lib $(OTHERLIBS) cw32mti.lib import32.lib
  226. !else
  227. LIBRARIES=BFC40.lib BFCS40.lib $(OTHERLIBS) cw32mti.lib import32.lib
  228. !endif
  229. !else
  230. LIBRARIES=nafxcw$(DEBUG_SUFFIX).lib $(OTHERLIBS) cw32mt.lib import32.lib
  231. !endif
  232. RC=brc32
  233.  
  234. # link flags - must be specified after $(LINKCMD)
  235. #
  236. # conflags : creating a character based console application
  237. # guiflags : creating a GUI based "Windows" application
  238.  
  239. #CONFLAGS=/subsystem:console
  240. #GUIFLAGS=/subsystem:windows
  241. CONFLAGS=/ap
  242. GUIFLAGS=/aa
  243.  
  244. BORRSP=bor.rsp
  245.  
  246. #.SUFFIXES:
  247. .SUFFIXES: .c .cpp .rc
  248.  
  249. .cpp.obj:
  250.     $(CPP) @$(BORRSP) { $< }
  251.  
  252. .c.obj:
  253.     $(CPP) @$(BORRSP) { $< }
  254.  
  255. .rc.res:
  256.     $(RC) -I$(BORINCL);$(BORINCL)\mfc -r @&&~
  257. $(MFCDEFS) /fo $@ $<
  258. ~
  259. #############################################################################
  260.  
  261. LINK_OBJS=$(OBJS)
  262.  
  263. !if "$(CONSOLE)" == "1"
  264. LINKFLAGS=$(LINKFLAGS) $(CONFLAGS)
  265. !ifndef USRSTARTUP
  266. STARTUP=$(BORLIB)\c0x32.obj
  267. !endif
  268. !else
  269. LINKFLAGS=$(LINKFLAGS) $(GUIFLAGS)
  270. !ifndef USRSTARTUP
  271. STARTUP=$(BORLIB)\c0w32.obj
  272. !endif
  273. !endif
  274.  
  275. !if "$(USRDLL)" == "1"
  276. !ifndef USRSTARTUP
  277. STARTUP=$(BORLIB)\c0d32.obj
  278. !endif
  279. TARGET=$(PROJ).DLL
  280. !else
  281. TARGET=$(PROJ).EXE
  282. !endif
  283.  
  284. MainRule: create.rsp build.pch $(TARGET)
  285.  
  286. create.rsp:
  287. !if "$(NO_PCH)" != "1"
  288. !if "$(NO_CLEAN_PCH)" == "0"
  289. !ifdef PCH_FILE
  290.      @-if exist $(PCH_FILE) echo Erasing PCH file: $(PCH_FILE) for a fresh build
  291.      @-if exist $(PCH_FILE) erase $(PCH_FILE) > nul
  292. !endif
  293. !endif
  294. !endif
  295.      @-if exist $(BORRSP) erase $(BORRSP) > nul
  296.      copy &&|
  297. $(CPPFLAGS)
  298. | $(BORRSP)
  299.  
  300. build.pch:
  301. !if "$(NO_PCH)" != "1"
  302.     @-echo Checking / building precompiled headers:
  303.     @-if exist stdafx.cpp if not exist $(PCH_FILE) $(CPP) @$(BORRSP) stdafx.cpp
  304. !else
  305.     @-echo NOT using Precompiled Headers.
  306. !endif
  307.  
  308. !if "$(SIMPLE_APP)" == "1"
  309. $(TARGET): $(LINK_OBJS)
  310.     $(LINKCMD) /Tpe @&&~
  311. $(LINKFLAGS) +
  312. $(STARTUP) $(LINK_OBJS)
  313. $(TARGET)
  314. $(PROJ).map
  315. $(EXTRA_LIBS) $(LIBRARIES)
  316.  
  317. ~
  318. !else
  319.  
  320. !if "$(USRDLL)" == "0"
  321. !if "$(NO_RESOURCE)" == "1"
  322. $(TARGET): $(LINK_OBJS)
  323. !else
  324. $(TARGET): $(LINK_OBJS) $(PROJ).res
  325. !endif
  326.     $(LINKCMD) /Tpe @&&~
  327. $(LINKFLAGS) +
  328. $(STARTUP) $(LINK_OBJS)
  329. $(TARGET)
  330. $(PROJ).map
  331. $(EXTRA_LIBS) $(LIBRARIES)
  332.  
  333. !if "$(NO_RESOURCE)" != "1"
  334. $(PROJ).res
  335. !endif
  336. ~
  337. !else
  338. !if "$(NO_RESOURCE)" == "1"
  339. $(TARGET): $(LINK_OBJS)
  340. !else
  341. $(TARGET): $(LINK_OBJS) $(PROJ).res
  342. !endif
  343.     $(LINKCMD) /Tpd @&&~
  344. $(LINKFLAGS) +
  345. $(STARTUP) $(LINK_OBJS)
  346. $(TARGET)
  347. $(PROJ).map
  348. $(EXTRA_LIBS) $(LIBRARIES)
  349. $(PROJ).def
  350. !if "$(NO_RESOURCE)" != "1"
  351. $(PROJ).res
  352. !endif
  353. ~
  354.  
  355. !endif # userdll
  356. !endif # simple_app
  357.  
  358. #  This rule is for testing.
  359. #  Useage:
  360. #  MAKE {put any make options here} printdebuginfo
  361. #
  362. printdebuginfo:
  363.         @-echo List of macros:
  364.         @-type &&~
  365.   USRDLL    = $(USRDLL)
  366.   AFXDLL    = $(AFXDLL)
  367.   CONSOLE   = $(CONSOLE)
  368.   PROJ      = $(PROJ)
  369.   STARTUP   = $(STARTUP)
  370.   LIBRARIES = $(LIBRARIES)
  371.   LIBDIR    = $(BORLIB)
  372.   INCLDIR   = $(BORINCL)
  373.   LINKFLAGS = $(LINKFLAGS)
  374.   CFLAGS    = $(CFLAGS)
  375. ~
  376.  
  377.  
  378. clean::
  379.     @if exist $(PROJ).exe erase $(PROJ).exe
  380.     @if exist $(PROJ).dll erase $(PROJ).dll
  381.     @if exist *.csm erase *.csm
  382.     @if exist *.map erase *.map
  383.     @if exist *.obj erase *.obj
  384.     @if exist *.exp erase *.exp
  385.     @if exist *.map erase *.map
  386.     @if exist *.lib erase *.lib
  387.     @if exist *.res erase *.res
  388.     @if exist $(BORRSP) erase $(BORRSP)
  389.  
  390. #############################################################################
  391.