home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK10 / MFC / SRC / MAKEFILE.$ / makefile
Encoding:
Makefile  |  1992-03-13  |  7.5 KB  |  299 lines

  1. # Makefile : Builds a Foundation class library variant.
  2. #
  3. # Usage: NMAKE CLEAN        (removes all intermediary files)
  4. #    or: NMAKE options      (builds one library variant (see below))
  5. # Note that an NMAKE CLEAN should be performed before building a new variant.
  6. #
  7. # 'Options' are one of each of:
  8. #   "MODEL=M"            (defaults to M)
  9. #           Any of the following models are accepted: S (small), M (medium),
  10. #           C (compact), or L (large).
  11. #   "TARGET=W"           (defaults to W)
  12. #           Any of the following platforms are accepted: R (real-mode DOS),
  13. #           W (windows).
  14. #   "DLL"              (defaults to 0)
  15. #           If this item is 1, a DLL version of the library is generated.
  16. #           If this item is 0, then a normal library is generated.
  17. #           Only Large model versions of DLLs are supported.
  18. #   "DEBUG"             (defaults to 1)
  19. #           If this item is 1, debugging support is compiled into
  20. #           the library.  If this item is 0, then debugging support
  21. #           is disabled.  Debug support does not include CodeView information.
  22. #   "CODEVIEW=0"           (defaults to 2, always)
  23. #           If this item is 1 CodeView information is compiled into
  24. #           the library.  You must use the /CODEVIEW link option
  25. #           in addition, when linking your executable.  If this item
  26. #           is 2, then only selected modules will be compiled with
  27. #           CodeView information.  You must use the link option /CODEVIEW.
  28. #           A value of 0 indicates that no CodeView information is to be
  29. #           generated.
  30. #   "OBJ=.\obj"          (defaults to '$$(MODEL)$(TARGET)$(DEBUG)'
  31. #           This optional specification specifies where temporary OBJ files
  32. #           are stored during the build process.  The directory is created or
  33. #           removed as necessary.
  34. #   "OPT="               (no default value)
  35. #           This allows additional compiler options to be added to the build.
  36. #           If more than one switch is desired, put double-quotes around the
  37. #           whole OPT= argument, e.g., "OPT=/J /W3".
  38. #   "NO_PCH=1" 
  39. #           Set this item to override the default use of precompiled headers
  40. #
  41. #   The default is to build MODEL=M TARGET=W DEBUG=1
  42. #
  43. #
  44. #############################################################################
  45. # Standard tools
  46.  
  47. CPP=cl
  48. CC=cl
  49.  
  50. #############################################################################
  51. # Parse these options:
  52.  
  53. !ifndef MODEL
  54. MODEL=M
  55. !endif
  56.  
  57. !ifndef DEBUG
  58. DEBUG=1
  59. !endif
  60.  
  61. !ifndef DLL
  62. DLL=0
  63. !else
  64. # DLL must be large model
  65. MODEL=l
  66. !endif
  67.  
  68. !ifndef TARGET
  69. TARGET=W
  70. !endif
  71.  
  72. !ifndef CODEVIEW
  73. CODEVIEW=2
  74. !endif
  75.  
  76. !if "$(DEBUG)" != "0"
  77. DEBUGSUF=D
  78. DEBDEFS=/D_DEBUG
  79. DEBOPTS=/Odr /f
  80. !else
  81. DEBUGSUF=
  82. DEBDEFS=
  83. DEBOPTS=/Oxt
  84. !endif
  85.  
  86. !if "$(CODEVIEW)" == "1"
  87. DEBOPTS=$(DEBOPTS) /Zi
  88. !endif
  89.  
  90. # CVEXTRA used for select CodeView information (main files only)
  91. !if "$(CODEVIEW)" == "2"
  92. CVEXTRA=/Zi
  93. !endif
  94.  
  95. !if "$(MODEL)"=="s" || "$(MODEL)"=="S" || "$(MODEL)"==""
  96. CL_MODEL=/AS
  97. !else
  98. !if "$(MODEL)"=="m" || "$(MODEL)"=="M"
  99. CL_MODEL=/AM
  100. !else
  101. !if "$(MODEL)"=="c" || "$(MODEL)"=="C"
  102. CL_MODEL=/AC
  103. !else
  104. !if "$(MODEL)"=="l" || "$(MODEL)"=="L"
  105. CL_MODEL=/AL
  106. !else
  107. !error MODEL must be one of S, M, C, L.
  108. !endif
  109. !endif
  110. !endif
  111. !endif
  112.  
  113. !if "$(TARGET)"=="r" || "$(TARGET)"=="R"
  114. TARGDEFS=/D_DOS
  115. TARGOPTS=
  116. EXPFLAG=
  117. !else
  118. !if "$(TARGET)"=="w" || "$(TARGET)"=="W"
  119. TARGDEFS=/D_WINDOWS
  120. TARGOPTS=/GA /GEs /G2
  121. MKWIN=1
  122. EXPFLAG=/GEe
  123. !else
  124.  
  125.  
  126.  
  127. !error TARGET must be one of W, R.
  128.  
  129. !endif
  130. !endif
  131.  
  132.  
  133. !if "$(OBJ)" == ""
  134. D=$$$(MODEL)$(TARGET)$(DEBUGSUF)
  135. !if "$(DLL)" != "0"
  136. D=$D.dll
  137. !endif
  138. !else
  139. D=$(OBJ)
  140. !endif
  141.  
  142. DEFS=$(DEBDEFS) $(TARGDEFS)
  143. CL_OPT=/W3 /Zp $(DEBOPTS) $(TARGOPTS) $(OPT)
  144.  
  145. !if "$(DLL)" == "0"
  146. # Normal library
  147. GOAL=$(MODEL)afxc$(TARGET)$(DEBUGSUF)
  148. !else
  149. # DLL library (SS!=DS) - only Large model supported (compact model is possible)
  150. GOAL=$(MODEL)afxd$(TARGET)$(DEBUGSUF)
  151. CL_MODEL=$(CL_MODEL)w
  152. TARGOPTS=/GD /G2
  153. # /GD will define _WINDLL
  154. !endif
  155.  
  156. #############################################################################
  157. # Library Components
  158.  
  159. OBJECT=$D\object.obj $D\except.obj $D\dumpcont.obj $D\abort.obj \
  160.     $D\assert.obj $D\archive.obj $D\archivex.obj $D\memory.obj \
  161.     $D\validadd.obj $D\dumpinit.obj $D\version.obj
  162.  
  163. FILES=$D\file.obj $D\filetxt.obj $D\filemem.obj $D\filex.obj
  164.  
  165. COLLECTIONS=$D\array_b.obj $D\array_d.obj $D\array_o.obj $D\array_p.obj \
  166.     $D\array_s.obj $D\array_w.obj $D\list_o.obj $D\list_p.obj \
  167.     $D\list_s.obj $D\map_pp.obj $D\map_pw.obj $D\map_so.obj \
  168.     $D\map_sp.obj $D\map_ss.obj $D\map_wo.obj $D\map_wp.obj $D\plex.obj
  169.  
  170. MISC=$D\string.obj $D\stringex.obj $D\time.obj
  171.  
  172. WINDOWS=$D\window.obj $D\wingdi.obj $D\winctrl.obj $D\winstr.obj \
  173.     $D\winapp.obj $D\winmain.obj $D\winmenu.obj $D\winmdi.obj $D\trace.obj
  174.  
  175. WINEXTRAS=$D\penctrl.obj $D\winbtn.obj $D\windlgs.obj
  176.  
  177. !if "$(DLL)" == "0"
  178. OLE= $D\olemisc.obj $D\olefile.obj $D\olecli.obj $D\oleui.obj $D\oleui2.obj \
  179.     $D\olesvr.obj
  180. !else
  181. OLE= # OLE not supported for DLLs
  182. !endif
  183.  
  184. OBJS=$(OBJS) $(OBJECT) $(FILES) $(COLLECTIONS) $(MISC)
  185.  
  186. !ifdef MKWIN
  187. OBJS=$(OBJS) $(WINDOWS) $(WINEXTRAS) $(OLE)
  188. !endif
  189.  
  190.  
  191.  
  192.  
  193. #############################################################################
  194. # Set CPPFLAGS for use with .cpp.obj and .c.obj rules
  195. # Define rule for use with OBJ directory
  196. # C++ uses a PCH file
  197.  
  198. CPPFLAGS=$(CPPFLAGS) $(CL_STANDARD) $(CL_MODEL) $(CL_OPT) $(DEFS) 
  199.  
  200. !ifndef NO_PCH
  201. PCH_FILE=$D\afxpch.pch
  202. CPPFLAGS=$(CPPFLAGS) /Yu /Fp$(PCH_FILE)
  203. !else
  204. PCH_FILE=
  205. !endif
  206.  
  207. CFLAGS=$(CFLAGS) $(CL_STANDARD) $(CL_MODEL) $(CL_OPT) $(DEFS) 
  208.  
  209. .cpp{$D}.obj:
  210.     $(CPP) @<<
  211. $(CPPFLAGS) /c /Fo$@ $<
  212. <<
  213.  
  214. .c{$D}.obj:
  215.     $(CC) @<<
  216. $(CFLAGS) /c /Fo$@ $<
  217. <<
  218.  
  219.  
  220. #############################################################################
  221. # Goal to build
  222.  
  223. goal: $D ..\lib\$(GOAL).lib
  224.  
  225. $D:
  226.     mkdir $D
  227.  
  228. clean:
  229.     -erase $D\*.obj
  230.     -erase $D\*.pch
  231.     -rmdir $D
  232.  
  233.  
  234. #############################################################################
  235. # Precompiled header file
  236.  
  237. !ifndef NO_PCH
  238. INC_DIR=..\include
  239. HDRS=$(INC_DIR)\afx.h $(INC_DIR)\afx.inl $(INC_DIR)\afxcoll.h \
  240.         $(INC_DIR)\afxwin.h $(INC_DIR)\afxwin.inl $(INC_DIR)\afxmsg.h \
  241.         $(INC_DIR)\afxres.h \
  242.         $(INC_DIR)\afxole.h $(INC_DIR)\afxoleui.h
  243.  
  244. $D\object.obj $(PCH_FILE): object.cpp $(HDRS)
  245.     $(CPP) @<<
  246. /c /Yc /Fp$(PCH_FILE) $(CL_STANDARD) $(CL_MODEL) $(CL_OPT)
  247.         $(DEFS) $(CVEXTRA) /c /Fo$D\object.obj object.cpp
  248. <<
  249. !endif
  250.  
  251. ############################################################################
  252. # CodeView for select files
  253. !if "$(CODEVIEW)"=="2"
  254. $D\memory.obj : memory.cpp
  255.     $(CPP) @<<
  256. $(CPPFLAGS) $(CVEXTRA) /c /Fo$D\memory.obj memory.cpp
  257. <<
  258.  
  259. !ifdef MKWIN
  260. $D\winmain.obj : winmain.cpp
  261.     $(CPP) @<<
  262. $(CPPFLAGS) $(CVEXTRA) /c /Fo$D\winmain.obj winmain.cpp
  263. <<
  264.  
  265. $D\window.obj : window.cpp
  266.     $(CPP) @<<
  267. $(CPPFLAGS) $(CVEXTRA) /c /Fo$D\window.obj window.cpp
  268. <<
  269.  
  270. $D\winapp.obj : winapp.cpp
  271.     $(CPP) @<<
  272. $(CPPFLAGS) $(CVEXTRA) /c /Fo$D\winapp.obj winapp.cpp
  273. <<
  274. !endif
  275. !endif
  276.  
  277. #############################################################################
  278. # Windows 3.0 loader export/version number
  279. $D\version.obj : version.cpp
  280.     $(CPP) @<<
  281. $(CPPFLAGS) $(EXPFLAG) /c /Fo$D\version.obj version.cpp
  282. <<
  283.  
  284.  
  285. #############################################################################
  286. # Library results
  287.  
  288. ..\lib\$(GOAL).lib: $D $(OBJS)
  289.     -erase $@
  290.     lib /PAGESIZE:128 @<<
  291. ..\lib\$(GOAL)
  292. y
  293. $(OBJS)
  294. nul
  295. ;
  296. <<
  297.  
  298. #############################################################################
  299.