home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 20.ddi / CLASSSRC.PAK / MAKEFILE < prev    next >
Encoding:
Text File  |  1993-12-02  |  17.1 KB  |  523 lines

  1. #--------------------------------------------------------------------------#
  2. #                                                                          #
  3. #   MAKEFILE for Class Libraries                                           #
  4. #                                                                          #
  5. #   Copyright (c) Borland International 1991, 1993                         #
  6. #   All Rights Reserved                                                    #
  7. #                                                                          #
  8. #   Usage:                                                                 #
  9. #                                                                          #
  10. #       maker options                                                      #
  11. #                                                                          #
  12. #   Options:                                                               #
  13. #                                                                          #
  14. #       -DDOS, -DWIN32, -DOS2   Specifies target system                    #
  15. #                                                                          #
  16. #       -DMODEL=x               Specifies memory model for DOS library.    #
  17. #                               Required when building DOS library.        #
  18. #                               Must be s, c, m, l, or h.                  #
  19. #                                                                          #
  20. #       -DNAME=xxx              Base name of the target library or DLL     #
  21. #                               Always required.                           #
  22. #                                                                          #
  23. #       -DDLL                   Build a DLL.                               #
  24. #                                                                          #
  25. #       -DDBG                   Build the debugging version of the target. #
  26. #                                                                          #
  27. #       -DOBJECTS               Also build the object-based containers     #
  28. #                                                                          #
  29. #--------------------------------------------------------------------------#
  30.  
  31. .autodepend
  32. .swap
  33.  
  34. !if !$d(DOS) && !$d(WIN32) && !$d(OS2)
  35. !error Must specify target system DOS, WIN32, or OS2
  36. !endif
  37.  
  38. !if $d(DOS) && !($d(MODEL) || $d(DLL))
  39. !error When building DOS libraries, must specify MODEL or DLL
  40. !endif
  41.  
  42. !if $d(MODEL) && ($d(OS2) || $d(WIN32))
  43. !error When building OS2 or WIN32 libraries, cannot specify MODEL
  44. !endif
  45.  
  46. !if $d(DLL) && !$d(NAME)
  47. !error Must specify a NAME for a DLL.
  48. !endif
  49.  
  50. !if $d(MODEL)
  51. !if $(MODEL)!=s && $(MODEL)!=c && $(MODEL)!=m && $(MODEL)!=l && $(MODEL)!=h
  52. !Error MODEL must be s, c, m, l, or h
  53. !endif
  54. !endif
  55.  
  56. #--------------------------------------------------------------------#
  57. #                                                                    #
  58. # Set up the names of the tools to be used. If these macros have     #
  59. #   already been defined in the environment, use those definitions.  #
  60. #                                                                    #
  61. #   BCC is the compiler.                                             #
  62. #   MAKE is make.                                                    #
  63. #   TLIB is the librarian.                                           #
  64. #   TLINK is the linker.                                             #
  65. #                                                                    #
  66. #--------------------------------------------------------------------#
  67.  
  68.  
  69. !if !$d(BCC)
  70. !if $d(WIN32)
  71. BCC = bcc32 +turboc.cfg -v- -x
  72. !elif $d(OS2)
  73. BCC = bcc
  74. !else
  75. BCC = bcc -2- -x
  76. !endif
  77. !endif
  78.  
  79. !if !$d(MAKE)
  80. !if $d(WIN32)
  81. MAKE = maker
  82. !else
  83. MAKE = make
  84. !endif
  85. !endif
  86.  
  87. !if !$d(TLIB)
  88. !if $d(WIN32)
  89. TLIB = tlib /C/E
  90. !else
  91. TLIB = tlib /C/E
  92. !endif
  93. !endif
  94.  
  95. !if !$d(TLINK)
  96. !if $d(WIN32)
  97. TLINK = tlink32
  98. !else
  99. TLINK = tlink
  100. !endif
  101. !endif
  102.  
  103. !if !$d(BRCC)
  104. !if $d(WIN32)
  105. BRCC = brcc32 -dWIN32
  106. !else
  107. BRCC = brcc
  108. !endif
  109. !endif
  110.  
  111. #--------------------------------------------------------------------#
  112. #                                                                    #
  113. # Set up options for the various tools                               #
  114. #                                                                    #
  115. #   WFLAG does some magic to produce a library that works for both   #
  116. #   DOS and Windows.                                                 #
  117. #                                                                    #
  118. #   DFLAG contains the debugging switches that will be passed to the #
  119. #   compiler through the .CFG file.                                  #
  120. #                                                                    #
  121. #   LFLAG contains the switches that will be passed to TLIB on the   #
  122. #   command line.                                                    #
  123. #                                                                    #
  124. #   XFLAG handles _RTLDLL, which is passed to the compiler in the    #
  125. #   .CFG file and determines whether classes are to be exported.     #
  126. #                                                                    #
  127. #   LINKOPTS is the list of options for the linker.                  #
  128. #                                                                    #
  129. #--------------------------------------------------------------------#
  130.  
  131. !if $d(DOS) && $d(DLL)
  132. WFLAG = -WDE
  133. !elif $d(DOS) && ($(MODEL) == s || $(MODEL) == c )
  134. WFLAG = -WE
  135. !elif $d(DOS) && ($(MODEL) == m || $(MODEL) == l)
  136. WFLAG = -Y
  137. !endif
  138.  
  139. !if $d(DBG)
  140. DFLAG = -v- -D__DEBUG=2 -D__WARN -D__TRACE
  141. LFLAG = /0
  142. !else
  143. DFLAG = -v- -D__DEBUG=0
  144. LFLAG = /0
  145. !endif
  146.  
  147. !if $d(DLL)
  148. XFLAG = -D_RTLDLL -D_BUILDBIDSDLL
  149. !endif
  150.  
  151. !if $d(DOS)
  152. !if $d(DLL)
  153. MFLAG = -ml
  154. !else
  155. MFLAG = -m$(MODEL)
  156. !endif
  157. !endif
  158.  
  159. !if $d(DOS)
  160. LINKOPTS = /C/c/s/Twd
  161. !elif $d(OS2)
  162. LINKOPTS = /c/s/Tod
  163. !elif $d(WIN32)
  164. LINKOPTS = /c/s/Tpd
  165. !endif
  166.  
  167. !if $d(DLL)
  168. DEFFILE=deffile
  169. !endif
  170.  
  171. #--------------------------------------------------------------------#
  172. #                                                                    #
  173. # Build the macros to provide the startup code and library names     #
  174. # for building DLLs.                                                 #
  175. #                                                                    #
  176. #   STARTUP is the startup code.                                     #
  177. #                                                                    #
  178. #   LINKLIBS is the list of libraries.                               #
  179. #                                                                    #
  180. #--------------------------------------------------------------------#
  181.  
  182. !if !$d(DLL)
  183.  
  184. TARGETLIB = $(NAME)
  185.  
  186. !else
  187.  
  188. VER = 40
  189.  
  190. TARGETFILE = $(NAME)$(VER)$(SUFFIX)
  191. TARGETLIB  = $(NAME)$(SUFFIX)i.lib
  192.  
  193. !if $d(DOS)
  194.  
  195. STARTUP = $(LIB)\c0dl.obj
  196. LINKLIBS = $(LIB)\import.lib $(LIB)\crtldll.lib
  197.  
  198. !elif $d(OS2)
  199.  
  200. STARTUP = $(LIB)\c02d.obj
  201. LINKLIBS = $(LIB)\c2.lib $(LIB)\os2.lib
  202.  
  203. !else
  204.  
  205. STARTUP = $(LIB)\c0d32.obj
  206. LINKLIBS = $(LIB)\cw32i.lib $(LIB)\import32.lib
  207.  
  208. !endif
  209.  
  210. !endif
  211.  
  212. #--------------------------------------------------------------------#
  213. #                                                                    #
  214. # OBJDIRLIST is the list of subdirectories under the OBJ directory   #
  215. #                                                                    #
  216. #   This is used by dirs to be sure all the subdirectories are       #
  217. #   present and by clean to remove all OBJ files                     #
  218. #                                                                    #
  219. #--------------------------------------------------------------------#
  220.  
  221. !if $d(DOS)
  222. OBJDIRLIST = s ds c dc m dm l dl h dh i di
  223. !endif
  224.  
  225. !if $d(WIN32)
  226. OBJDIRLIST = 32 d32 i32 di32
  227. !endif
  228.  
  229. !if $d(OS2)
  230. OBJDIRLIST = 2 d2 i2 di2
  231. !endif
  232.  
  233. #--------------------------------------------------------------------#
  234. #                                                                    #
  235. # Set up the paths that will be needed later.                        #
  236. #                                                                    #
  237. #   INCLUDE is the full path to the compiler's include files and     #
  238. #   to the classlib's include files.  If it is not defined in the    #
  239. #   environment, it is assumed to be under the directory where the   #
  240. #   compiler was installed in the subdirectory INCLUDE.              #
  241. #                                                                    #
  242. #   LIB is the full path to the compiler's libraries.  If it is not  #
  243. #   defined in the environment, it is assumed to be under the        #
  244. #   directory where the compiler was installed in the subdirectory   #
  245. #   LIB.                                                             #
  246. #                                                                    #
  247. #   SOURCEDIR is the full path to the source code.  If it is not     #
  248. #   defined in the environment, it is assumed to be under the        #
  249. #   directory where the compiler was installed in the subdirectory   #
  250. #   SOURCE\CLASSLIB.                                                 #
  251. #                                                                    #
  252. #   ROOTDIR is the full path to the directory in which the makefile  #
  253. #   is located.  If it is not defined in the environment, it is      #
  254. #   assumed to be the same as SOURCEDIR.                             #
  255. #                                                                    #
  256. #   LIBDIR is the full path to the directory in which the libraries  #
  257. #   should be placed when they are built.  If it is not defined in   #
  258. #   the environment, it is assumed to be the same as the directory   #
  259. #   specified by LIB.                                                #
  260. #                                                                    #
  261. #--------------------------------------------------------------------#
  262.  
  263. !if !$d(BCROOT)
  264. !include $(MAKEDIR)\bcroot.inc
  265. !endif
  266.  
  267. !if !$d(INCLUDE)
  268. INCLUDE = $(BCROOT)\include
  269. !endif
  270.  
  271. !if !$d(RCINCLUDE)
  272. RCINCLUDE = $(BCROOT)\include
  273. !endif
  274.  
  275. !if !$d(LIB)
  276. LIB = $(BCROOT)\lib
  277. !endif
  278.  
  279. !if !$d(SOURCEDIR)
  280. SOURCEDIR = $(BCROOT)\source\classlib
  281. !endif
  282.  
  283. !if !$d(LIBDIR)
  284. LIBDIR = $(LIB)
  285. !endif
  286.  
  287. !if !$d(ROOTDIR)
  288. ROOTDIR = $(SOURCEDIR)
  289. !endif
  290.  
  291. #--------------------------------------------------------------------#
  292. #                                                                    #
  293. # Set up the various paths that MAKE will use                        #
  294. #                                                                    #
  295. #   OBJDIR will only have been defined when we've decide on a target #
  296. #   platform and a set of options. Since .PATH.obj isn't used in any #
  297. #   context in which DBG and SUFFIX haven't been defined, it's ok    #
  298. #   to use DBG and SUFFIX to define it.                              #
  299. #                                                                    #
  300. #--------------------------------------------------------------------#
  301.  
  302. .PATH.cpp = $(SOURCEDIR)
  303. .PATH.cpo = $(SOURCEDIR)\obsolete
  304.  
  305. .PATH.lib = $(LIBDIR)
  306.  
  307. .PATH.rc = $(SOURCEDIR)
  308.  
  309. !if $d(DOS)
  310. OBJDIR=$(MODEL)
  311. !elif $d(OS2)
  312. OBJDIR=2
  313. !else
  314. OBJDIR=32
  315. !endif
  316.  
  317. !if $d(DLL)
  318. OBJDIR=i$(OBJDIR)
  319. !endif
  320.  
  321. !if $d(DBG)
  322. .PATH.obj = $(SOURCEDIR)\d$(OBJDIR)
  323. !else
  324. .PATH.obj = $(SOURCEDIR)\$(OBJDIR)
  325. !endif
  326.  
  327. #--------------------------------------------------------------------#
  328. #                                                                    #
  329. # Build the various file lists needed for dependency checking,       #
  330. # and LIBing.                                                        #
  331. #                                                                    #
  332. #   OBJS is the main list, conditionalized for the various targets   #
  333. #       and options.                                                 #
  334. #                                                                    #
  335. #   DEPOBJS is the list of object files for dependency checking      #
  336. #                                                                    #
  337. #   LIBOBJS is the list of object files for building the library     #
  338. #                                                                    #
  339. #--------------------------------------------------------------------#
  340.  
  341. !if $d(OBJECTS)
  342. OBJS =              \
  343.     PFXassoc.obj    \
  344.     PFXbtree.obj    \
  345.     PFXbtreeinn.obj \
  346.     PFXbtreelfn.obj \
  347.     PFXcollect.obj  \
  348.     PFXcontain.obj  \
  349.     PFXdbllist.obj  \
  350.     PFXhashtbl.obj  \
  351.     PFXldate.obj    \
  352.     PFXlist.obj     \
  353.     PFXltime.obj    \
  354.     PFXobject.obj
  355. !endif
  356.  
  357. OBJS = $(OBJS)      \
  358.     PFXbinimp.obj   \
  359.     PFXcastable.obj \
  360.     PFXdate.obj     \
  361.     PFXdateio.obj   \
  362.     PFXdatep.obj    \
  363.     PFXfile.obj     \
  364.     PFXheapsel.obj  \
  365.     PFXobjstrm.obj  \
  366.     PFXtime.obj     \
  367.     PFXtimep.obj    \
  368.     PFXtimeio.obj   \
  369.     PFXversion.obj
  370.  
  371. !if $d(DOS) && !$d(DLL)
  372. OBJS = $(OBJS) PFXtimer.obj
  373. !endif
  374.  
  375. !if $d(WIN32)
  376. OBJS = $(OBJS) PFXthread.obj
  377. !endif
  378.  
  379. !if $d(OBJECTS)
  380. !if $d(TEMPLATES)
  381. OBJS = $(OBJS)      \
  382.     PFXbabstary.obj \
  383.     PFXbdict.obj    \
  384.     PFXbsortary.obj
  385. !else
  386. OBJS = $(OBJS)      \
  387.     PFXabstarry.obj \
  388.     PFXarray.obj    \
  389.     PFXdeque.obj    \
  390.     PFXdict.obj     \
  391.     PFXsortarry.obj \
  392.     PFXstack.obj
  393. !endif
  394. !endif
  395.  
  396. !if $d(DLL) && $(DOS)
  397. OBJS = $(OBJS) PFXclasmain.obj
  398. !endif
  399.  
  400. !if $d(DLL) && $d(OBJECTS)
  401.  
  402. !if $d(TEMPLATES)
  403. OBJS = $(OBJS) PFXtmpl2.obj
  404. !else
  405. OBJS = $(OBJS) PFXtmpl1.obj
  406. !endif
  407.  
  408. !endif
  409.  
  410. !if $d(DLL) && !$d(OBJECTS)
  411. RESFILE = version.res
  412. !endif
  413.  
  414. PFXOBJS = $(OBJS:SFX=)
  415. SFXOBJS = $(OBJS:PFX=)
  416.  
  417. DEPOBJS = $(PFXOBJS:PFX=)
  418. LIBOBJS = $(PFXOBJS:PFX= -+)
  419. LINKOBJS = $(PFXOBJS:PFX=)
  420.  
  421. #--------------------------------------------------------------------#
  422. #                                                                    #
  423. # These are the targets that we can make.                            #
  424. #                                                                    #
  425. #   target: builds the target file                                   #
  426. #                                                                    #
  427. #   dirs:   makes sure all the necessary subdirectories are present  #
  428. #                                                                    #
  429. #   clean:  deletes the .OBJ files                                   #
  430. #                                                                    #
  431. #   config: builds a .CFG file with the correct flags                #
  432. #                                                                    #
  433. #--------------------------------------------------------------------#
  434.  
  435. target: config $(DEFFILE) $(DEPOBJS) $(RESFILE)
  436. !if !$d(DLL)
  437.     cd $(.PATH.obj)
  438.     $(TLIB) $(LFLAG) $(.PATH.lib)\$(TARGETLIB) @&&!
  439. $(LIBOBJS)
  440. !
  441.     cd $(ROOTDIR)
  442. !else
  443.     cd $(.PATH.obj)
  444.     $(TLINK) @&&!
  445. $(STARTUP)+
  446. $(LINKOBJS)
  447. $(TARGETFILE).dll
  448. $(LINKOPTS) $(.PATH.lib)\$(TARGETFILE).map
  449. $(LINKLIBS)
  450. temp.def
  451. $(RESFILE)
  452. !
  453. !if $(TARGET) == DOS
  454.     rc -30 $(TARGETFILE)
  455. !endif
  456.     implib $(TARGETLIB) $(TARGETFILE).dll
  457.     tlib /E $(TARGETLIB)
  458.     cd $(ROOTDIR)
  459.     copy $(.PATH.obj)\$(TARGETFILE).dll $(.PATH.lib)
  460.     del $(.PATH.obj)\$(TARGETFILE).dll
  461.     copy $(.PATH.obj)\$(TARGETLIB) $(.PATH.lib)
  462.     del $(.PATH.obj)\$(TARGETLIB)
  463.  
  464. !endif
  465.  
  466.  
  467. dirs:
  468.     -for %d in ($(OBJDIRLIST)) do md $(SOURCEDIR)\%d
  469.  
  470. clean:
  471.     -for %d in ($(OBJDIRLIST)) do del $(SOURCEDIR)\%d\*.obj
  472.  
  473. config:
  474.     @-if not exist $(.PATH.obj)\..\NUL md $(.PATH.obj)\..
  475.     @-if not exist $(.PATH.obj)\NUL md $(.PATH.obj)
  476.     @type &&!
  477. -c -n$(.PATH.obj) -I$(INCLUDE) $(DFLAG) $(XFLAG) $(MFLAG) $(TFLAG)
  478. ! >turboc.cfg
  479.  
  480. deffile:
  481.     @echo >$(.PATH.obj)\temp.def LIBRARY     $(TARGETFILE)
  482.     @echo >>$(.PATH.obj)\temp.def DESCRIPTION 'Parametrized Class Library for BC++'
  483. !if $d(DOS)
  484.     @echo >>$(.PATH.obj)\temp.def EXETYPE     WINDOWS
  485.     @echo >>$(.PATH.obj)\temp.def CODE        PRELOAD MOVEABLE DISCARDABLE
  486.     @echo >>$(.PATH.obj)\temp.def DATA        PRELOAD MOVEABLE SINGLE
  487. !else
  488.     @echo >>$(.PATH.obj)\temp.def DATA        MULTIPLE NONSHARED
  489. !endif
  490.     @echo >>$(.PATH.obj)\temp.def HEAPSIZE    4096
  491.  
  492.  
  493. #--------------------------------------------------------------------#
  494. #                                                                    #
  495. # We need an implicit rule for building .OBJ files, and a few        #
  496. # explicit rules for special cases.                                  #
  497. #                                                                    #
  498. #   TIMER.OBJ is never built for windows, so doesn't need the        #
  499. #       windows flags.                                               #
  500. #                                                                    #
  501. #--------------------------------------------------------------------#
  502.  
  503. timer.obj: timer.cpp
  504.     $(BCC) $(SOURCEDIR)\timer
  505.  
  506. tmpl1.obj: tmplinst.cpp
  507.     $(BCC) -o$(.PATH.obj)\tmpl1.obj $(WFLAG) $(.PATH.cpp)\tmplinst
  508.  
  509. tmpl2.obj: tmplinst.cpp
  510.     $(BCC) -o$(.PATH.obj)\tmpl2.obj -DTEMPLATES $(WFLAG) $(.PATH.cpp)\tmplinst
  511.  
  512. .cpo.obj:
  513.     $(BCC) $(WFLAG) -P {$< }
  514.  
  515. .cpp.obj:
  516.     $(BCC) $(WFLAG) {$* }
  517.  
  518. .rc.res:
  519.     $(BRCC) -i$(RCINCLUDE) $*.rc
  520.     copy $*.res $(.PATH.obj)
  521.     del $*.res
  522.  
  523.