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

  1. #-----------------------------------------------------------------------------
  2. # (C) Copyright 1993 by Borland International
  3. #  $(BCEXAMPLEDIR)\makefile.gen
  4. #  Common makefile generator for example makefiles
  5. #
  6. #  Usage for each makefile using this include, specify system and model:
  7. #    SYSTEM=WIN16 is implied unless MODEL=f, in which case WIN32 is implied
  8. #
  9. #    make SYSTEM=WIN16 MODEL=s  builds 16bit Windows small model static
  10. #    make SYSTEM=WIN16 MODEL=m  builds 16bit Windows medium model static
  11. #    make SYSTEM=WIN16 MODEL=c  builds 16bit Windows compact model static
  12. #    make SYSTEM=WIN16 MODEL=l  builds 16bit Windows large model static
  13. #    make SYSTEM=WIN16 MODEL=d  builds 16bit Windows large model DLL
  14. #    make SYSTEM=WIN32 MODEL=f  builds 32bit Windows static version
  15. #    make SYSTEM=WIN32 MODEL=d  builds 32bit Windows DLL version
  16. #    make SYSTEM=DOS16 MODEL=s  builds 16bit DOS small model static
  17. #    make SYSTEM=DOS16 MODEL=m  builds 16bit DOS medium model static
  18. #    make SYSTEM=DOS16 MODEL=c  builds 16bit DOS compact model static
  19. #    make SYSTEM=DOS16 MODEL=l  builds 16bit DOS large model static
  20. #    make SYSTEM=CON32 MODEL=f  builds 32bit static console app     
  21. #    make SYSTEM=CON32 MODEL=d  builds 32bit DLL console app     
  22. #         -DDEBUG <or> DEBUG=1    add to enable debug info for TDW & TD32
  23. #         -DDIAGS <or> DIAGS=1    add to enable runtime diagnostics
  24. #         MAKEARGS=           make command args for running generated makefile
  25. #
  26. #   For backward compatibility, SYSTEM may also be specied by -D, e.g. -DWIN32
  27. #
  28. # A specific makefile for the requested model will be generated as required.
  29. # Then the generated makefile will be run to produce the target executables.
  30. #
  31. # BCEXAMPLEDIR must be defined as the directory of this file and other *.gen
  32. # BCEXAMPLEDIR is defined by default to $(MAKEDIR)\..\EXAMPLES in BUILTINS.MAK
  33. # This may be redefined as an environment variable or on the MAKE command line
  34. #
  35. #  Define one or more of the following macros for automatic targeting:
  36. #    EXE=     Base name of .exe for app with no .rc file
  37. #    EXERES=  Base name of .exe for app with .rc -> .res file of same name
  38. #    RESEXE=  .res file(s) for EXE (define RESEXE_ also if more dependencies)
  39. #    RESEXE_= Dependent files for $(RESEXE), other than the corresponding .RC
  40. #    DEFEXE=  .def file for EXE, otherwise temp one will be generated
  41. #    OBJEXE=  Object file names, needed only if other than $(EXE).obj
  42. #    LIBEXE=  Library file names for extra libs if needed
  43. #    MAPEXE(=)Name for map file, else none will be generated
  44. #    CCFEXE=  Additional compiler flags for EXE, added after standard options
  45. #    EXEBIN=  Name with extension of executable if not $(EXE).exe
  46. #    EXE_=    Additional dependencies for EXE, other than RESEXE and OBJEXE
  47. #
  48. #    DLL=     Base name of .dll for dynamic library with no .rc file
  49. #    DLLRES=  Base name of .dll for with .rc file with same base name
  50. #    OBJDLL=  Explicit list of .obj files for DLL, if other than $(DLL).obj
  51. #    LIBDLL=  Library file names for extra libs if needed for DLL
  52. #    RESDLL=  .res file(s) for DLL (use dependency line if >1 RC file)
  53. #    RESDLL_= Dependent files for $(RESDLL), other than the corresponding .RC
  54. #    DEFDLL=  .def file for DLL, otherwise generates one based on DLL
  55. #    MAPDLL(=)Name for map file, else none will be generated
  56. #    CCFDLL=  Additional compiler flags for EXE, added after standard options
  57. #    DLLBIN=  Name with extension of dynamic library if not $(DLL).dll
  58. #
  59. #    HLP=     Helpfile base name, assumes .hlp made from .hpj
  60. #    HLP_=    Optional dependency files for helpfile, if more than $(HLP).hpj
  61. #
  62. #    LIBBIN=  Static library to build (with extension), requires OBJLIB=
  63. #    OBJLIB=  Required list of object files for building static library LIBBIN
  64. #
  65. #    TARGETS= Additional targets to build, rules must be defined in RULES
  66. #
  67. #    RULES=   Additional rules and dependencies to be included in the makefile
  68. #             Lines before the final line must be terminated with a caret (^)
  69. #
  70. #    MODELS=  Optional list of supported models, else all valid models allowed
  71. #    SYSTEMS= Optional list of supported systems, else all platforms supported
  72. #
  73. # For generating makefiles with multiple similar .exe targets:
  74. #  Generate a template EXE target rule using the EXE options for a sample EXE
  75. #  Then define rules for each EXE by substituting text within a previous rule
  76. #  $(EXERULE) is the automatically generated rule for the sample EXE target
  77. #  The following macros must be defined to override automatic EXE targeting
  78. #     EXEALL=  The list of all .exe targets, including extensions
  79. #     EXEMAKE= The list of all rules for the targets in EXEALL (may be macros)
  80. # Similarly, for generating makefiles with multiple similar .dll targets:
  81. #  Substitute text in $(DLLRULE), $(DLLRULE:old=new), and define the following
  82. #     DLLALL=  The list of all .exe targets, including extensions
  83. #     DLLMAKE= The list of all rules for the targets in DLLALL (may be macros)
  84. # To build a single target when multiple EXE or DLL targets are generated:
  85. #     TARGET=  The single target to make, with extension, e.g. step10.exe
  86. #
  87. #-----------------------------------------------------------------------------
  88.  
  89. #-----------------------------------------------------------------------------
  90. # the following defaults set compiler and link options for machine targeting
  91. # they may be modified below or overridden by environment or command line
  92. #-----------------------------------------------------------------------------
  93.  
  94. !ifndef CPUOPT
  95. CPUOPT = 3   # =2 for 286, =3 for 386, =4 for 486, =5 for pentium
  96. !endif
  97.  
  98. !ifndef MATHOPT
  99. MATHOPT = 1  # =0 for no math libs, =1 for emulation, =2 for math coprocessor
  100. !endif
  101.  
  102. #-----------------------------------------------------------------------------
  103.  
  104. .swap
  105.  
  106. # macros enclosed with underbars are for internal use only, i.e. _MODEL_
  107. # other macros defined outside this file will not be altered unless incorrect
  108.  
  109. #-----------------------------------------------------------------------------
  110. # directory & search paths
  111. #-----------------------------------------------------------------------------
  112.  
  113. !ifndef BCBINDIR
  114. ! ifdef BCROOT
  115. BCBINDIR      = $(BCROOT)\bin
  116. ! else
  117. BCBINDIR      = $(MAKEDIR)
  118. ! endif
  119. !endif
  120.  
  121. !ifndef BCROOT
  122. BCROOT = $(MAKEDIR)\..
  123. !endif
  124.  
  125. !ifndef BCINCDIR
  126. BCINCDIR      = $(BCROOT)\include
  127. !endif
  128. !ifndef BCLIBDIR
  129. BCLIBDIR      = $(BCROOT)\lib
  130. !endif
  131. LIBPATH       = $(BCLIBDIR)
  132. INCLUDEPATH   = $(BCINCDIR)
  133.  
  134. #----------------------------------------------------------------------------
  135. # validate or select target operating system
  136. #----------------------------------------------------------------------------
  137.  
  138. !ifndef SYSTEMS
  139. SYSTEMS = WIN16 DOS16 WIN32 CON32
  140. !endif
  141.  
  142. !ifndef SYSTEM
  143. ! if $d(WIN32) || "$(MODEL)"=="f"
  144. SYSTEM  = WIN32
  145. ! elif $d(CON32)
  146. SYSTEM  = CON32
  147. ! elif $d(WIN16)
  148. SYSTEM  = WIN16
  149. ! elif $d(DOS16)
  150. SYSTEM  = DOS16
  151. ! else #default
  152. SYSTEM  = WIN16
  153. ! endif
  154. !endif
  155.  
  156. _SYSTEMS_ = " $(SYSTEMS) "
  157. _SYSTEMX_ = |$(SYSTEM)|
  158. _SYSTEM_  = $(_SYSTEMX_:|= )
  159. !if $(_SYSTEMS_:$(_SYSTEM_)=)==$(_SYSTEMS_)
  160. ! error $(SYSTEM) system not supported
  161. !endif
  162.  
  163. # generate boolean flags for use in platform testing
  164. #
  165. !if $(SYSTEM:32=)!=$(SYSTEM)
  166. _32BIT_=1
  167. !else
  168. _32BIT_=0
  169. !endif
  170. !if $(SYSTEM:WIN=)!=$(SYSTEM)
  171. _GUI_=1
  172. !else
  173. _GUI_=0
  174. !endif
  175.  
  176. #----------------------------------------------------------------------------
  177. # validate or select compiler/library model
  178. #----------------------------------------------------------------------------
  179.  
  180. # set allowable models for each platform
  181. #
  182. !if   $(_32BIT_)
  183. _MODELS_ = dfx
  184. !elif $(_GUI_)
  185. _MODELS_ = smcldx
  186. !else #DOS16
  187. _MODELS_ = smclh
  188. !endif
  189.  
  190. !ifndef MODELS
  191. MODELS = $(_MODELS_:x=)
  192. !endif
  193.  
  194. # validate model if defined, else get default model
  195. #
  196. !ifndef MODEL
  197. ! if   $(_32BIT_)
  198. !  if  $(_GUI_)
  199. MODEL = f  #WIN32
  200. !  else
  201. MODEL = f  #CON32
  202. !  endif
  203. ! elif $(_GUI_)
  204. MODEL = d  #WIN16
  205. ! else
  206. MODEL = s  #DOS16
  207. ! endif
  208. !endif
  209.  
  210. # If model is not valid for this example, display error message and exit
  211. #
  212. !if ("$(MODELS:$(MODEL)=)"=="$(MODELS)")||("$(_MODELS_:$(MODEL)=)"=="$(_MODELS_)")
  213.  
  214. # Convert MODEL to English
  215. ! if $(MODEL)==s 
  216. ERRSTR=Small
  217. ! elif $(MODEL)==m
  218. ERRSTR=Medium
  219. ! elif $(MODEL)==c
  220. ERRSTR=Compact
  221. ! elif $(MODEL)==l
  222. ERRSTR=Large
  223. ! elif $(MODEL)==h
  224. ERRSTR=Huge
  225. ! elif $(MODEL)==d
  226. ERRSTR=DLL
  227. ! elif $(MODEL)==f
  228. ERRSTR=Static
  229. ! elif $(MODEL)==x
  230. ERRSTR=ExternalDLL
  231. !endif
  232.  
  233. # Use message to get everything on one line without path interfering
  234. ! message !! $(ERRSTR) model, $(SYSTEM) is not supported for this program
  235. ! message !! Use MODEL = ?, where ? is a supported model ($(MODELS))
  236. ! error USAGE ERROR
  237. !endif
  238.  
  239. # set internal model for compiler and link libraries
  240. #
  241. !if $(MODEL) == d || $(MODEL) == x
  242. USEDLL = 1
  243. !endif
  244. _MODEL_ = $(MODEL)
  245. !if $(_32BIT_)
  246. _MODEL_ = f
  247. !else
  248. ! ifdef USEDLL
  249. _MODEL_ = l
  250. ! endif
  251. DMODEL = l
  252. !endif
  253.  
  254. # set parameters for .DEF file
  255. #
  256. !ifndef STACKSIZE  #used for 16-bit only
  257. STACKSIZE = 8192
  258. !endif
  259.  
  260. !ifndef HEAPSIZE   #used for 16-bit only
  261. ! ifdef USEDLL
  262. HEAPSIZE = 1024
  263. ! else
  264. HEAPSIZE = 4096
  265. ! endif
  266. !endif
  267.  
  268. #----------------------------------------------------------------------------
  269. # check target options and dependencies, setup defaults
  270. #----------------------------------------------------------------------------
  271.  
  272. # set .RES file if one implied by xxxRES, set target file names
  273. #
  274. !ifdef EXERES
  275. EXE = $(EXERES)
  276. RESEXE = $(EXE).res
  277. !endif
  278. !ifdef EXE
  279. ! ifndef EXEBIN
  280. EXEBIN = $(EXE).exe
  281. ! endif
  282. ! ifndef CFGEXE
  283. CFGEXE = cfgexe
  284. ! endif
  285. !endif
  286.  
  287. !if $(SYSTEM)==DOS16
  288. ! undef RESEXE
  289. ! undef DLL
  290. ! undef DLLRES
  291. ! undef DLLBIN
  292. !endif
  293.  
  294. !ifdef DLLRES
  295. DLL = $(DLLRES)
  296. RESDLL = $(DLL).res
  297. !endif
  298. !ifdef DLL
  299. ! ifndef CFGDLL
  300. CFGDLL = cfgdll
  301. ! endif
  302. ! ifndef DLLBIN
  303. DLLBIN = $(DLL).dll
  304. ! endif
  305. !endif
  306.  
  307. !ifdef HLP
  308. HLPBIN = $(HLP).hlp
  309. !endif
  310.  
  311. #----------------------------------------------------------------------------
  312. # debug & diagnostic flags
  313. #----------------------------------------------------------------------------
  314. !if $(DEBUG) != 0
  315. DEBUG = 1
  316. CDBG = -v -k -Od
  317. ! if $(_32BIT_)
  318. LDBG = -v
  319. ! else
  320. LDBG = -v -Vt
  321. ! endif
  322. !else
  323. DEBUG = 0
  324. !endif
  325.  
  326. !if $(DIAGS) != 0          # default diags use precondition, check, trace & warn
  327. DIAGS = 1
  328. __DEBUG=2
  329. __TRACE=1
  330. __WARN=1
  331. !else
  332. DIAGS = 0
  333. !endif
  334.  
  335. !ifdef __DEBUG
  336. CDIAG = -D__DEBUG=$(__DEBUG)
  337. !endif
  338. !ifdef __TRACE
  339. CDIAG = $(CDIAG) -D__TRACE
  340. !endif
  341. !ifdef __WARN
  342. CDIAG = $(CDIAG) -D__WARN
  343. !endif
  344.  
  345. #----------------------------------------------------------------------------
  346. # library names
  347. #   STDLIBS  - RTL libs for use by current model
  348. #   STDDLIBS - RTL libs for use by DLLs
  349. #   C0       - Startup code for current model
  350. #   C0D      - Startup code for DLLs
  351. #----------------------------------------------------------------------------
  352. !if $(_32BIT_)
  353. STDDLIBS = $(BCLIBDIR)\import32 $(BCLIBDIR)\cw32i
  354. C0D      = $(BCLIBDIR)\c0d32
  355. ! if $(_GUI_)
  356. _SYSCODE_ = n
  357. C0       = $(BCLIBDIR)\c0w32
  358. ! else #CON32
  359. C0       = $(BCLIBDIR)\c0x32
  360. _SYSCODE_ = c
  361. ! endif
  362.  
  363. ! ifdef USEDLL
  364. STDLIBS  = $(STDDLIBS)
  365. ! else
  366. STDLIBS  = $(BCLIBDIR)\import32 $(BCLIBDIR)\cw32
  367. ! endif
  368.  
  369. !elif $(_GUI_) #WIN16
  370. C0       = $(BCLIBDIR)\c0w$(_MODEL_)
  371. C0D      = $(BCLIBDIR)\c0d$(DMODEL)
  372. STDDLIBS=$(BCLIBDIR)\import $(BCLIBDIR)\crtldll
  373. ! ifdef USEDLL
  374. STDLIBS  = $(STDDLIBS)
  375. ! else
  376. STDLIBS =$(BCLIBDIR)\import $(BCLIBDIR)\mathw$(_MODEL_) $(BCLIBDIR)\cw$(_MODEL_)
  377. ! endif
  378. ! if $d(FASTTHIS)
  379. SYSTEM = WIN16F
  380. _SYSCODE_ = f
  381. ! elif $d(PASCAL)
  382. SYSTEM = WIN16P
  383. _SYSCODE_ = p
  384. !else
  385. SYSTEM = WIN16
  386. _SYSCODE_ = w
  387. ! endif
  388.  
  389. !else  #DOS16
  390. ! if "$(MATHOPT)"=="2"
  391. _MATHLIB_ = $(BCLIBDIR)\fp87 $(BCLIBDIR)\math$(_MODEL_)
  392. ! elif "$(MATHOPT)"=="1"
  393. _MATHLIB_ = $(BCLIBDIR)\emu $(BCLIBDIR)\math$(_MODEL_)
  394. !endif
  395. STDLIBS  = $(_MATHLIB_) $(BCLIBDIR)\c$(_MODEL_)
  396. C0       = $(BCLIBDIR)\c0$(_MODEL_)
  397. SYSTEM = DOS16
  398. _SYSCODE_ = d
  399.  
  400. !endif
  401.  
  402. !ifdef SYSLIBS
  403. _SYSLIBS_ = $(SYSLIBS)+^
  404.  
  405. !endif
  406.  
  407. # set makefile name based on platform, model, debug/diagnostic mode
  408. #
  409. _MODELNAME_ = $(SYSTEM)$(MODEL)$(DIAGS)$(DEBUG)
  410.  
  411. #----------------------------------------------------------------------------
  412. # tools and options for 32bit Windows and console apps
  413. #----------------------------------------------------------------------------
  414. !if $(_32BIT_)
  415. BCC      = $(BCBINDIR)\bcc32.exe
  416. BRCC     = $(BCBINDIR)\brcc32.exe
  417. TLINK    = $(BCBINDIR)\tlink32.exe
  418. #COPTS   = -$(CPUOPT) -d -k- -O1gmpv -vi
  419. COPTS    = -$(CPUOPT) -d -k- -vi
  420. CFGFILE  = bcc32.cfg
  421.  
  422. !ifdef USEDLL
  423. CFLAGS   = -W -D_RTLDLL $(COPTS)
  424. !else                          # using DLL libraries
  425. CFLAGS   = -W $(COPTS)
  426. !endif                         # using static libraries
  427. CFLAGSD  = -WDE $(COPTS)    # building DLL's
  428.  
  429. !if $(_GUI_) #WIN32)
  430. LFLAGS   = $(LDBG) -Tpe -aa -c
  431. LFLAGSD  = $(LDBG) -Tpd -aa -c
  432. !else #CON32
  433. LFLAGS   = $(LDBG) -Tpe -ap -c
  434. LFLAGSD  = $(LDBG) -Tpd -ap -c
  435. !endif
  436.  
  437. #----------------------------------------------------------------------------
  438. # tools and options for 16bit Windows and DOS
  439. #----------------------------------------------------------------------------
  440. !else
  441. BCC      = $(BCBINDIR)\bcc.exe
  442. BRCC     = $(BCBINDIR)\brcc.exe
  443. TLINK    = $(BCBINDIR)\tlink.exe
  444. RLINK    = $(BCBINDIR)\rlink.exe -K
  445. COPTS    = -$(CPUOPT) -d -k- -O1gmpv $(COPTS)
  446. !if $(_MODEL_) != s && $(_MODEL_) != m
  447. COPTS    = $(COPTS) -dc      # -dc shouldn't be used in small & medium models
  448. !endif
  449. CFGFILE  = turboc.cfg
  450.  
  451. !if   $d(FASTTHIS)
  452.   CENTRY = -D_FASTTHIS -p
  453. !elif $d(PASCAL)
  454.   CENTRY = -p
  455. !else
  456.   CENTRY = -p-
  457. !endif
  458.  
  459. !if   $d(USEDLL)                        # using DLL libraries
  460. CFLAGS   = -WS -D_RTLDLL $(COPTS) -m$(_MODEL_) $(CENTRY)
  461. LFLAGS   = $(LDBG) -Tw -c -C -A=16
  462. !elif $(_GUI_)                          # using static libraries
  463. CFLAGS   = -WSE $(COPTS) -m$(_MODEL_) $(CENTRY)
  464. LFLAGS   = $(LDBG) -Tw -c -C -A=16
  465. !else                                   # using 16-bit DOS
  466. CFLAGS   = $(COPTS) -m$(_MODEL_) $(CENTRY)
  467. LFLAGS   = $(LDBG) -c -C -A=16 -E
  468. !endif
  469. CFLAGSD  = -WDE $(COPTS) -m$(DMODEL) $(CENTRY) # building DLLs
  470. LFLAGSD  = $(LDBG) -Twd -c -C -A=16
  471.  
  472. !endif #if/else $(_32BIT_)
  473.  
  474. HC       = $(BCBINDIR)\hc31.exe
  475. IMPLIB   = $(BCBINDIR)\implib.exe -c
  476. TLIB     = $(BCBINDIR)\tlib.exe
  477.  
  478. #----------------------------------------------------------------------------
  479. # configure DLL target
  480. #----------------------------------------------------------------------------
  481.  
  482. !ifdef DLL
  483. ! ifndef OBJDLL   # if no explicit objs, assume one with same base name as DLL
  484. OBJDLL = $(DLL).obj
  485. ! endif
  486. #
  487. # generate default .DEF file if none defined
  488. #
  489. ! ifdef DEFDLL
  490. _DEFDLL_ = $(DEFDLL)
  491. ! elif $(_32BIT_)
  492. _DEFDLL_ = &&|^
  493. LIBRARY $(DLLBIN:.=;)^
  494. EXETYPE WINDOWS^
  495. CODE PRELOAD MOVEABLE DISCARDABLE^
  496. DATA PRELOAD MOVEABLE MULTIPLE^
  497. |
  498. !else
  499. _DEFDLL_ = &&|^
  500. LIBRARY $(DLLBIN:.=;)^
  501. EXETYPE WINDOWS^
  502. CODE PRELOAD MOVEABLE DISCARDABLE^
  503. DATA PRELOAD MOVEABLE SINGLE^
  504. HEAPSIZE $(HEAPSIZE)^
  505. |
  506. ! endif
  507.  
  508. ! ifdef MAPDLL
  509. !  if "$(MAPDLL)"=="1"
  510. MAPDLL=
  511. !  endif
  512. _MAPDLL_ = -m -s $(MAPDLL)
  513. ! else
  514. _MAPDLL_ = -x
  515. ! endif
  516. #
  517. # construct rule for DLL target
  518. #
  519. DLLRULE =^
  520. $(DLLBIN): $(OBJDLL) $(RESDLL) $(DEFDLL) $(LIBDLL)^
  521.   $(TLINK) $(LFLAGSD) @&&|^
  522. $(C0D) $(OBJDLL)^
  523. $(DLLBIN)^
  524. $(_MAPDLL_)^
  525. $(_SYSLIBS_)$(LIBDLL) $(STDLIBS)^
  526. |,$(_DEFDLL_),$(RESDLL)^
  527.   $(IMPLIB) $(DLL) $(DLLBIN)^
  528.  
  529. ! ifndef DLLALL
  530. DLLALL = $(DLLBIN)
  531. ! endif
  532. _DLLALL_ = " $(DLLALL) "
  533. ! ifndef DLLMAKE
  534. DLLMAKE = $(DLLRULE)
  535. ! endif
  536.  
  537. !endif
  538.  
  539. #----------------------------------------------------------------------------
  540. # configure LIBBIN target
  541. #----------------------------------------------------------------------------
  542.  
  543. !ifdef LIBBIN
  544. ! ifndef CFGEXE
  545. CFGEXE = cfgexe
  546. ! endif
  547. _LIBOBJ1_ = .obj $(OBJLIB)
  548. _LIBOBJ2_ = $(_LIBOBJ1_:.obj =+)
  549. _LIBOBJ_  = $(_LIBOBJ2_:.obj=)
  550. !endif
  551.  
  552. #----------------------------------------------------------------------------
  553. # configure EXE target
  554. #----------------------------------------------------------------------------
  555.  
  556. !ifdef EXE
  557. #
  558. # generate default .DEF file if none defined
  559. #
  560. ! if $(SYSTEM)==DOS16
  561. !  undef DEFEXE
  562. ! elif $d(DEFEXE)
  563. _DEFEXE_ = ,$(DEFEXE)
  564. ! elif !$(_32BIT_) #WIN16
  565. _DEFEXE_ = ,&&|^
  566. EXETYPE WINDOWS^
  567. CODE PRELOAD MOVEABLE DISCARDABLE^
  568. DATA PRELOAD MOVEABLE MULTIPLE^
  569. HEAPSIZE $(HEAPSIZE)^
  570. STACKSIZE $(STACKSIZE)^
  571. |
  572. ! elif $(_GUI_)    #WIN32
  573. _DEFEXE_ = ,&&|^
  574. EXETYPE WINDOWS^
  575. CODE PRELOAD MOVEABLE DISCARDABLE^
  576. DATA PRELOAD MOVEABLE MULTIPLE^
  577. |
  578. ! else             #CON32
  579. _DEFEXE_ = ,&&|^
  580. CODE PRELOAD MOVEABLE DISCARDABLE^
  581. DATA PRELOAD MOVEABLE MULTIPLE^
  582. |
  583. ! endif
  584.  
  585. ! ifdef RESEXE     # must remove possible trailing space from macro definition
  586. _RESEXE1_=$(RESEXE)*
  587. _RESEXE2_=$(_RESEXE1_: *=)
  588. _RESEXE3_=$(_RESEXE2_:*=)
  589. !  if !$(_32BIT_) && "$(_RESEXE3_)" != "$(_RESEXE3_: =)" # >1 16-bit .res file
  590. _RESEXE_ = ^
  591.  $(RLINK) @&&|^
  592. -fi$(_RESEXE3_: = -fi)^
  593. $(EXEBIN)^
  594. |
  595. ! else
  596. _RESEXE_ = ,$(RESEXE)
  597. !  endif
  598. ! endif
  599.  
  600. ! ifndef OBJEXE   # if no explicit objs, assume one with same base name as EXE
  601. OBJEXE = $(EXE).obj
  602. ! endif
  603. ! ifdef MAPEXE 
  604. !  if "$(MAPEXE)"=="1"
  605. MAPEXE=
  606. !  endif
  607. _MAPEXE_ = -m -s $(MAPEXE)
  608. ! else
  609. _MAPEXE_ = -x
  610. ! endif
  611. #
  612. # construct rule for EXE target
  613. #
  614. EXERULE =^
  615. $(EXEBIN): $(OBJEXE) $(RESEXE) $(DEFEXE) $(LIBEXE)^
  616.   $(TLINK) @&&|^
  617. $(LFLAGS) $(C0)+^
  618. $(OBJEXE)^
  619. $(EXEBIN)^
  620. $(_MAPEXE_)^
  621. $(_SYSLIBS_)$(LIBEXE) $(STDLIBS)^
  622. |$(_DEFEXE_)$(_RESEXE_)^
  623.  
  624. ! ifndef EXEALL
  625. EXEALL = $(EXEBIN)
  626. ! endif
  627. _EXEALL_ = " $(EXEALL) "
  628. ! ifndef EXEMAKE
  629. EXEMAKE = $(EXERULE)
  630. ! endif
  631.  
  632. !endif
  633.  
  634. #----------------------------------------------------------------------------
  635. # define config file cleanup if any config files generated
  636. #----------------------------------------------------------------------------
  637.  
  638. !if $d(EXE) || $d(LIBBIN) || $d(DLL)
  639. ! ifndef CFGCLN
  640. CFGCLN = cfgcln
  641. ! endif
  642. !else
  643. !undef CFGCLN
  644. !endif
  645.  
  646. #----------------------------------------------------------------------------
  647. # run makefile - dependent upon generated makefile and generated model sentry
  648. #----------------------------------------------------------------------------
  649.  
  650. !ifndef MAKEFILE
  651. MAKEFILE = $(_MODELNAME_).mak
  652. !endif
  653.  
  654. _SENTRY_ = $(_MODELNAME_).mod
  655.  
  656. !ifdef TARGET
  657. _TARGXX_ = |$(TARGET)|
  658. _TARGBB_ = $(_TARGXX_:|= )
  659. ! if   $(_EXEALL_:$(_TARGBB_)=) != $(_EXEALL_)
  660. _TARGET_ = $(CFGEXE) $(TARGET) $(CFGCLN)
  661. ! elif $(_DLLALL_:$(_TARGBB_)=) != $(_DLLALL_)
  662. _TARGET_ = $(CFGDLL) $(TARGET) $(CFGCLN)
  663. ! else
  664. !  error TARGET=$(TARGET)^
  665.    $(TARGET) is not in target list (all: ...) for makefile $(MAKEFILE)
  666. ! endif
  667. !endif
  668.  
  669. all: $(MAKEFILE) $(_SENTRY_)
  670.   @$(MAKEDIR)\$(MAKE) -f$(MAKEFILE) $(_TARGET_) $(MAKEARGS)
  671.  
  672. #----------------------------------------------------------------------------
  673. # generate makefile
  674. #----------------------------------------------------------------------------
  675.  
  676. $(MAKEFILE) :: makefile
  677.   @echo Generating $(MAKEFILE), SYSTEM=$(SYSTEM) MODEL=$(MODEL) DIAGS=$(DIAGS) DEBUG=$(DEBUG)
  678.   @if exist $(MAKEFILE) del $(MAKEFILE)
  679.   @rename &&%
  680. .autodepend
  681.  
  682. all: $(CFGDLL) $(DLLALL) $(CFGEXE) $(LIBBIN) $(EXEALL) $(HLPBIN) $(TARGETS) $(CFGCLN)
  683.   @echo SYSTEM=$(SYSTEM) MODEL=$(MODEL) DIAGS=$(DIAGS) DEBUG=$(DEBUG)
  684.  
  685. # standard implicit rules
  686. #
  687. .rc.res:
  688.   $(BRCC) -r -i$(INCLUDEPATH) $$<
  689. .cpp.obj:
  690.   $(BCC) {$$< }
  691. .c.obj:
  692.   $(BCC) {$$< }
  693. #
  694. # dependencies
  695. #
  696. !ifdef HLP_
  697. .hpj.hlp:
  698.   $(HC) $$<
  699.  
  700. $(HLPBIN) : $(HLP_)
  701. !endif
  702. !ifdef RESEXE_
  703.  
  704. $(RESEXE) : $(RESEXE_)
  705. !endif
  706. #
  707. # DLL target - also makes import library
  708. #
  709. !ifdef DLL
  710. #
  711. # generate compiler configuration file for DLL source files
  712. !if "$(CFGDLL)" == "cfgdll"
  713.  
  714. cfgdll:
  715.   @copy &&|
  716. -I$(INCLUDEPATH)
  717. -c $(CFLAGSD)
  718. -w $(CDBG) $(CDIAG) $(CPCH) $(CCFDLL)
  719. | $(CFGFILE) >NUL
  720. !endif
  721. #
  722. # link DLL and generate import library
  723. #
  724. $(DLLMAKE)
  725. !endif # $d(DLL)
  726. #
  727. # generate compiler configuration file for EXE and LIB source files
  728. #
  729. !if ($d(EXE) || $d(LIBBIN)) && "$(CFGEXE)" == "cfgexe"
  730.  
  731. cfgexe:
  732.   @copy &&|
  733. -I$(INCLUDEPATH)
  734. -c $(CFLAGS)
  735. -w $(CDBG) $(CDIAG) $(CPCH) $(CCFEXE)
  736. | $(CFGFILE) >NUL
  737. !endif
  738. # LIBBIN target
  739. #
  740. !ifdef LIBBIN
  741.  
  742. $(LIBBIN) : $(OBJLIB)
  743.   @if exist $(LIBBIN) del $(LIBBIN)
  744.   $(TLIB) $(LIBBIN) $(_LIBOBJ_)
  745. !endif
  746. #
  747. # EXE target
  748. #
  749. !ifdef EXE
  750. $(EXEMAKE)
  751. !endif
  752. !if "$(CFGCLN)" == "cfgcln"
  753.  
  754. cfgcln:
  755.   @del $(CFGFILE)
  756. !endif
  757. $(RULES)
  758. % $(MAKEFILE)
  759.  
  760. #----------------------------------------------------------------------------
  761. # Generate model sentries, clean files of other models
  762. #----------------------------------------------------------------------------
  763.  
  764. # generate model sentry, name contains model information
  765. #
  766. $(_SENTRY_):
  767.   @if exist *.mod del *.mod
  768.   -@type NUL >$(_SENTRY_) # ignore return code generated by some command shell
  769. !if $(NOCLEAN) != 0
  770.   @echo Created model sentry: $(_SENTRY_), NOT deleting files of other models!
  771. !else
  772.   @echo Created model sentry: $(_SENTRY_), Deleting files of other models...
  773. ! if $d(EXEBIN) && "EXEBIN" != "$(EXE).exe"
  774.   @if exist $(EXEBIN) del $(EXEBIN)  # in case extension not .exe
  775. ! endif
  776. ! ifdef LIBBIN
  777.   @if exist $(LIBBIN) del $(LIBBIN)  # only delete the target .lib
  778. ! endif
  779. ! ifdef DLLBIN
  780.   @if exist $(DLLBIN) del $(DLLBIN)  # only delete the target .dll
  781. ! endif
  782.   @if exist *.obj del *.obj
  783.   @if exist *.res del *.res
  784. !endif
  785.  
  786. #----------------------------------------------------------------------------
  787. # Delete all generated files, leaving only source files and makefiles
  788. #----------------------------------------------------------------------------
  789. clean:
  790.   @if exist *.mod del *.mod
  791.   @if exist *.obj del *.obj
  792.   @if exist *.exe del *.exe
  793.   @if exist *.dll del *.dll
  794.   @if exist *.hlp del *.hlp
  795.   @if exist *.scr del *.scr
  796.   @if exist *.res del *.res
  797.   @if exist *.rws del *.rws
  798.   @if exist *.lib del *.lib
  799.   @if exist *.map del *.map
  800.   @if exist *.csm del *.csm
  801.   @if exist bcwdef.* del bcwdef.*
  802.   @if exist *.dsw del *.dsw
  803.   @if exist turboc.cfg del turboc.cfg
  804.   @if exist bcc32.cfg del bcc32.cfg
  805.   @if exist tlink.cfg del tlink.cfg
  806.   @if exist tlink32.cfg del tlink32.cfg
  807.   @if exist *.tds del *.tds #debugger symbols
  808.   @if exist *.td2 del *.td2 #debugger config
  809.   @if exist *.tdw del *.tdw #debugger config
  810.   @if exist *.td  del *.td  #debugger config
  811.   @if exist *.tr? del *.tr? #debugger config
  812.   @if exist WIN16*.mak del WIN16*.mak
  813.   @if exist WIN32*.mak del WIN32*.mak
  814.   @if exist DOS16*.mak del DOS16*.mak
  815.   @if exist CON32*.mak del CON32*.mak
  816.