wc32.mk 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. #############################################################################
  2. #
  3. # SciTech Multi-platform Graphics Library
  4. #
  5. # ========================================================================
  6. #
  7. # The contents of this file are subject to the SciTech MGL Public
  8. # License Version 1.0 (the "License"); you may not use this file
  9. # except in compliance with the License. You may obtain a copy of
  10. # the License at http://www.scitechsoft.com/mgl-license.txt
  11. #
  12. # Software distributed under the License is distributed on an
  13. # "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  14. # implied. See the License for the specific language governing
  15. # rights and limitations under the License.
  16. #
  17. # The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
  18. #
  19. # The Initial Developer of the Original Code is SciTech Software, Inc.
  20. # All Rights Reserved.
  21. #
  22. # ========================================================================
  23. #
  24. # Descripton: Rules makefile definitions, which define the rules used to
  25. # build targets. We include them here at the end of the
  26. # makefile so the generic project makefiles can override
  27. # certain things with macros (such as linking C++ programs
  28. # differently).
  29. #
  30. #############################################################################
  31. # Take out PMLIB if we don't need to link with it
  32. .IF $(NO_PMLIB)
  33. PMLIB :=
  34. .ENDIF
  35. # Use a larger stack during linking if requested, or use a default stack
  36. # of 200k. The usual default stack provided by Watcom C++ is *way* to small
  37. # for real 32 bit code development. We also need a *huge* stack for OpenGL
  38. # software rendering also!
  39. .IF $(USE_QNX4)
  40. # Not necessary for QNX code.
  41. .ELSE
  42. .IF $(STKSIZE)
  43. LDFLAGS += OP STACK=$(STKSIZE)
  44. .ELSE
  45. LDFLAGS += OP STACK=204800
  46. .ENDIF
  47. .ENDIF
  48. # Turn on runtime type information as necessary
  49. .IF $(USE_RTTI)
  50. CPFLAGS += -xr
  51. .ENDIF
  52. # Optionally turn on pre-compiled headers
  53. .IF $(PRECOMP_HDR)
  54. CFLAGS += -fhq
  55. .ENDIF
  56. .IF $(USE_QNX)
  57. # Whether to link in real VBIOS library, or just the stub library
  58. .IF $(USE_BIOS)
  59. VBIOSLIB := vbios.lib,
  60. .ELSE
  61. VBIOSLIB := vbstubs.lib,
  62. .END
  63. # Require special privledges for Nucleus programs (requires root access)
  64. .IF $(USE_NUCLEUS)
  65. LDFLAGS += OP PRIV=1
  66. .ENDIF
  67. .ENDIF
  68. # Implicit generation rules for making object files
  69. .IF $(WC_LIBBASE) == WC10A
  70. %$O: %.c ; $(CC) $(CFLAGS) $(<:s,/,\)
  71. %$O: %$P ; $(CPP) $(CFLAGS) $(<:s,/,\)
  72. .ELSE
  73. %$O: %.c ; $(CC) @$(mktmp $(CFLAGS:s/\/\\)) $(<:s,/,\)
  74. %$O: %$P ; $(CPP) @$(mktmp $(CPFLAGS:s/\/\\) $(CFLAGS:s/\/\\)) $(<:s,/,\)
  75. .ENDIF
  76. .IF $(USE_NASM)
  77. %$O: %$A ; $(AS) @$(mktmp -o $@ $(ASFLAGS:s/\/\\)) $(<:s,/,\)
  78. .ELSE
  79. %$O: %$A ; $(AS) @$(mktmp $(ASFLAGS:s/\/\\)) $(<:s,/,\)
  80. .ENDIF
  81. # Implit rule to compile .S assembler files. The first version
  82. # uses GAS directly and the second uses a pre-processor to
  83. # produce NASM code.
  84. .IF $(USE_GAS)
  85. .IF $(WC_LIBBASE) == WC11
  86. %$O: %$S ; $(GAS) -c @$(mktmp $(GAS_FLAGS:s/\/\\)) $(<:s,/,\)
  87. .ELSE
  88. # Black magic to build asm sources with Watcom 10.6 (requires sed)
  89. %$O: %$S ;
  90. $(GAS) -c @$(mktmp $(GAS_FLAGS:s/\/\\)) $(<:s,/,\)
  91. wdisasm \\ -a $(*:s,/,\).o > $(*:s,/,\).lst
  92. sed -e "s/\.text/_TEXT/; s/\.data/_DATA/; s/\.bss/_BSS/; s/\.386/\.586/; s/lar *ecx,cx/lar ecx,ecx/" $(*:s,/,\).lst > $(*:s,/,\).asm
  93. wasm \\ $(WFLAGS) -zq -fr=nul -fp3 -fo=$@ $(*:s,/,\).asm
  94. $(RM) -S $(mktmp $(*:s,/,\).o)
  95. $(RM) -S $(mktmp $(*:s,/,\).lst)
  96. $(RM) -S $(mktmp $(*:s,/,\).asm)
  97. .ENDIF
  98. .ELSE
  99. %$O: %$S ;
  100. @gcpp -DNASM_ASSEMBLER -D__WATCOMC__ -EP $(<:s,/,\) > $(*:s,/,\).asm
  101. nasm @$(mktmp -f obj -o $@) $(*:s,/,\).asm
  102. @$(RM) -S $(mktmp $(*:s,/,\).asm)
  103. .ENDIF
  104. # Special target to build dllstart.asm using Borland TASM
  105. dllstart.obj: dllstart.asm
  106. $(DLL_TASM) @$(mktmp /t /mx /m /D__FLAT__ /i$(SCITECH)\INCLUDE /q) $(PRIVATE)\src\common\dllstart.asm
  107. # Implicit rule for building resource files
  108. %$R: %.rc ; $(RC) $(RCFLAGS) -r $<
  109. # Implicit rule for building a DLL using a response file
  110. .IF $(IMPORT_DLL)
  111. .ELSE
  112. .IF $(USE_OS232)
  113. %$D: ;
  114. @trimlib $(mktmp $(LDFLAGS) OP quiet SYS os2v2 dll\nN $@\nF $(&:t",\n":s/\/\\)\nLIBR $(EXELIBS:t",")) $*.lnk
  115. rclink $(LD) $(RC) $@ $*.lnk
  116. .IF $(LEAVE_LINKFILE)
  117. .ELSE
  118. @$(RM) -S $(mktmp *.lnk)
  119. .ENDIF
  120. .ELIF $(USE_WIN32)
  121. %$D: ;
  122. @trimlib $(mktmp $(LDFLAGS) OP quiet SYS nt_dll\nN $@\nF $(&:t",\n":s/\/\\)\nLIBR $(PMLIB)$(DEFLIBS)$(EXELIBS:t",")) $*.lnk
  123. rclink $(LD) $(RC) $@ $*.lnk
  124. .IF $(LEAVE_LINKFILE)
  125. .ELSE
  126. @$(RM) -S $(mktmp *.lnk)
  127. .ENDIF
  128. .ELSE
  129. %$D: ;
  130. @trimlib $(mktmp $(LDFLAGS) OP quiet SYS win386\nN $*.rex\nF $(&:t",\n":s/\/\\)\nLIBR $(EXELIBS:t",")) $*.lnk
  131. rclink $(LD) $(RC) $@ $*.lnk
  132. wbind $* -d -q -n
  133. .IF $(LEAVE_LINKFILE)
  134. .ELSE
  135. @$(RM) -S $(mktmp *.lnk)
  136. .ENDIF
  137. .ENDIF
  138. .ENDIF
  139. # Implicit rule for building a library file using response file
  140. .IF $(BUILD_DLL)
  141. %$L: ;
  142. @$(RM) $@
  143. $(ILIB) $(ILIBFLAGS) $@ +$?
  144. .ELIF $(IMPORT_DLL)
  145. %$L: ;
  146. @$(RM) $@
  147. $(ILIB) $(ILIBFLAGS) $@ +$?
  148. .ELSE
  149. %$L: ;
  150. @$(RM) $@
  151. $(LIB) $(LIBFLAGS) $@ @$(mktmp,$*.rsp +$(&:t"\n+":s/\/\\)\n)
  152. .ENDIF
  153. # Implicit rule for building an executable file using response file
  154. .IF $(USE_X32)
  155. %$E: ;
  156. @trimlib $(mktmp OP quiet\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk
  157. $(LD) $(LDFLAGS) @$*.lnk
  158. x32fix $@
  159. .IF $(LEAVE_LINKFILE)
  160. .ELSE
  161. @$(RM) -S $(mktmp *.lnk)
  162. .ENDIF
  163. .ELIF $(USE_OS232)
  164. .IF $(USE_OS2GUI)
  165. %$E: ;
  166. @trimlib $(mktmp $(LDFLAGS) OP quiet SYS os2v2_pm\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk
  167. rclink $(LD) $(RC) $@ $*.lnk
  168. .IF $(LEAVE_LINKFILE)
  169. .ELSE
  170. @$(RM) -S $(mktmp *.lnk)
  171. .ENDIF
  172. .IF $(LXLITE)
  173. lxlite $@
  174. .ENDIF
  175. .ELSE
  176. %$E: ;
  177. @trimlib $(mktmp $(LDFLAGS) OP quiet SYS os2v2\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk
  178. rclink $(LD) $(RC) $@ $*.lnk
  179. .IF $(LEAVE_LINKFILE)
  180. .ELSE
  181. @$(RM) -S $(mktmp *.lnk)
  182. .ENDIF
  183. .IF $(LXLITE)
  184. lxlite $@
  185. .ENDIF
  186. .ENDIF
  187. .ELIF $(USE_SNAP)
  188. %$E: ;
  189. @trimlib $(mktmp $(LDFLAGS) OP quiet SYS nt\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(DEFLIBS)$(EXELIBS:t",")) $*.lnk
  190. rclink $(LD) $(RC) $@ $*.lnk
  191. .IF $(LEAVE_LINKFILE)
  192. .ELSE
  193. @$(RM) -S $(mktmp *.lnk)
  194. .ENDIF
  195. .ELIF $(USE_WIN32)
  196. .IF $(WIN32_GUI)
  197. %$E: ;
  198. @trimlib $(mktmp $(LDFLAGS) OP quiet SYS win95\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(DEFLIBS)$(EXELIBS:t",")) $*.lnk
  199. rclink $(LD) $(RC) $@ $*.lnk
  200. .IF $(LEAVE_LINKFILE)
  201. .ELSE
  202. @$(RM) -S $(mktmp *.lnk)
  203. .ENDIF
  204. .ELSE
  205. %$E: ;
  206. @trimlib $(mktmp $(LDFLAGS) OP quiet SYS nt\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(DEFLIBS)$(EXELIBS:t",")) $*.lnk
  207. rclink $(LD) $(RC) $@ $*.lnk
  208. .IF $(LEAVE_LINKFILE)
  209. .ELSE
  210. @$(RM) -S $(mktmp *.lnk)
  211. .ENDIF
  212. .ENDIF
  213. .ELIF $(USE_WIN386)
  214. %$E: ;
  215. @trimlib $(mktmp $(LDFLAGS) OP quiet SYS win386\nN $*.rex\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk
  216. rclink $(LD) wbind $*.rex $*.lnk
  217. .IF $(LEAVE_LINKFILE)
  218. .ELSE
  219. @$(RM) -S $(mktmp *.lnk)
  220. .ENDIF
  221. .ELIF $(USE_TNT)
  222. %$E: ;
  223. @trimlib $(mktmp $(LDFLAGS) OP quiet\nN $@\nF $(&:t",":s/\/\\)\nLIBR dosx32.lib,tntapi.lib,$(PMLIB)$(EXELIBS:t",")) $*.lnk
  224. $(LD) @$*.lnk
  225. .IF $(LEAVE_LINKFILE)
  226. .ELSE
  227. @$(RM) -S $(mktmp *.lnk)
  228. .ENDIF
  229. .IF $(DOSSTYLE)
  230. @markphar $@
  231. .ENDIF
  232. .ELIF $(USE_QNX4)
  233. %$E: ;
  234. @trimlib $(mktmp $(LDFLAGS) OP quiet\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(VBIOSLIB)$(EXELIBS:t",")) $*.lnk
  235. @+if exist $*.exe attrib -s $*.exe > NUL
  236. $(LD) @$*.lnk
  237. @attrib +s $*.exe
  238. .IF $(LEAVE_LINKFILE)
  239. .ELSE
  240. @$(RM) -S $(mktmp *.lnk)
  241. .ENDIF
  242. .ELSE
  243. %$E: ;
  244. @trimlib $(mktmp $(LDFLAGS) OP quiet\nN $@\nF $(&:t",":s/\/\\)\nLIBR $(PMLIB)$(EXELIBS:t",")) $*.lnk
  245. $(LD) @$*.lnk
  246. .IF $(LEAVE_LINKFILE)
  247. .ELSE
  248. @$(RM) -S $(mktmp *.lnk)
  249. .ENDIF
  250. .ENDIF