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