makefile.wat 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. # WMAKE makefile for 16 bit MSDOS or 32 bit DOS extender (PMODE/W or DOS/4GW)
  2. # using Watcom C/C++ v11.0+, by Paul Kienitz, last revised 16 Feb 2008.
  3. # Makes UnZip.exe, fUnZip.exe, and UnZipSFX.exe.
  4. #
  5. # Invoke from UnZip source dir with "WMAKE -F MSDOS\MAKEFILE.WAT [targets]".
  6. # To make the PMODE/W version use "WMAKE PM=1 ..."
  7. # To make the DOS/4GW version use "WMAKE GW=1 ..." (overrides PM=1)
  8. # Note: specifying PM or GW without NOASM requires that the win32 source
  9. # directory be present, so it can access the 32 bit assembly source.
  10. # PMODE/W is recommended over DOS/4GW for best performance.
  11. # To build with debug info use "WMAKE DEBUG=1 ..."
  12. # To build with no assembly modules use "WMAKE NOASM=1 ..."
  13. # To omit unshrinking support use "WMAKE NO_LZW=1 ..."
  14. # To support unreducing, get the real unreduce.c and go "WMAKE OFFEND_RMS=1 ..."
  15. # To include support for bzip2 decompression (only for 32-bit), get the bzip2
  16. # source distribution into the bzip2/ subfolder and start compilation
  17. # with "WMAKE PM=1 USEBZ2=1 ..."
  18. #
  19. # Other options to be fed to the compiler can be specified in an environment
  20. # variable called LOCAL_UNZIP.
  21. variation = $(%LOCAL_UNZIP)
  22. # Stifle annoying "Delete this file?" questions when errors occur:
  23. .ERASE
  24. .EXTENSIONS:
  25. .EXTENSIONS: .exe .obj .obx .c .h .asm
  26. # We maintain multiple sets of object files in different directories so that
  27. # we can compile msdos, dos/4gw, and win32 versions of UnZip without their
  28. # object files interacting. The following var must be a directory name
  29. # ending with a backslash. All object file names must include this macro
  30. # at the beginning, for example "$(O)foo.obj".
  31. !ifdef GW
  32. PM = 1 # both protected mode formats use the same object files
  33. !endif
  34. !ifdef DEBUG
  35. ! ifdef PM
  36. OBDIR = od32d
  37. ! else
  38. OBDIR = od16d
  39. ! endif
  40. !else
  41. ! ifdef PM
  42. OBDIR = ob32d
  43. ! else
  44. OBDIR = ob16d
  45. ! endif
  46. !endif
  47. O = $(OBDIR)\ # comment here so backslash won't continue the line
  48. !ifdef NO_LZW
  49. cvars = $+$(cvars)$- -DLZW_CLEAN
  50. avars = $+$(avars)$- -DLZW_CLEAN
  51. # "$+$(foo)$-" means expand foo as it has been defined up to now; normally,
  52. # this Make defers inner expansion until the outer macro is expanded.
  53. !endif
  54. !ifdef OFFEND_RMS
  55. cvars = $+$(cvars)$- -DUSE_SMITH_CODE
  56. avars = $+$(avars)$- -DUSE_SMITH_CODE
  57. !endif
  58. IZ_BZIP2 = bzip2
  59. !ifdef USEBZ2
  60. !ifdef PM
  61. cvars = $+$(cvars)$- -DUSE_BZIP2 -I$(IZ_BZIP2)
  62. bz2errob = $(O)ubz2err.obj
  63. bz2errox = $(O)ubz2err.obj
  64. BZIPLIB = $(IZ_BZIP2)/$(OBDIR)/bz2.lib
  65. BZ2LNKLIB = lib {$(BZIPLIB)}
  66. !else
  67. bz2errob =
  68. bz2errox =
  69. BZIPLIB =
  70. BZ2LNKLIB =
  71. !endif
  72. !else
  73. bz2errob =
  74. bz2errox =
  75. BZIPLIB =
  76. BZ2LNKLIB =
  77. !endif
  78. # The assembly hot-spot code in crc_i[3]86.asm is optional. This section
  79. # controls its usage.
  80. !ifdef NOASM
  81. crcaob =
  82. crcaof =
  83. crcaox =
  84. !else # !NOASM
  85. cvars = $+$(cvars)$- -DASM_CRC
  86. ! ifdef PM
  87. crcaob = $(O)crc_i386.obj
  88. crcaof = $(O)crc_i38f.obj
  89. crcaox = $(O)crc_i386.obx
  90. crc_s = win32\crc_i386.asm # requires that the win32 directory be present
  91. ! else
  92. crcaob = $(O)crc_i86.obj
  93. crcaof = $(O)crc_i8f.obj
  94. crcaox = $(O)crc_i86.obx
  95. crc_s = msdos\crc_i86.asm
  96. ! endif
  97. !endif
  98. # Our object files: OBJ[A-C] is for UnZip, OBJX for UnZipSFX, OBJF for fUnZip:
  99. OBJA1 = $(O)unzip.obj $(O)crc32.obj $(crcaob) $(O)crypt.obj $(O)envargs.obj
  100. OBJA = $(OBJA1) $(O)explode.obj $(O)extract.obj $(O)fileio.obj $(O)globals.obj
  101. OBJB2 = $(O)inflate.obj $(O)list.obj $(O)match.obj $(O)process.obj
  102. OBJB = $(OBJB2) $(O)ttyio.obj $(bz2errob) $(O)unreduce.obj
  103. OBJC = $(O)unshrink.obj $(O)zipinfo.obj $(O)msdos.obj
  104. OBJX2 = $(O)unzip.obx $(O)crc32.obx $(crcaox) $(O)crypt.obx $(O)extract.obx
  105. OBJX1 = $(OBJX2) $(O)fileio.obx $(O)globals.obx $(O)inflate.obx $(O)match.obx
  106. OBJX = $(OBJX1) $(O)process.obx $(bz2errox) $(O)ttyio.obx $(O)msdos.obx
  107. OBJF1 = $(O)funzip.obj $(O)crc32f.obj $(crcaof) $(O)cryptf.obj $(O)globalsf.obj
  108. OBJF = $(OBJF1) $(O)inflatef.obj $(O)ttyiof.obj $(O)msdosf.obj
  109. # Common header files included by all C sources:
  110. UNZIP_H = unzip.h unzpriv.h globals.h msdos\doscfg.h
  111. # Now we have to pick out the proper compiler and options for it. This gets
  112. # pretty complicated with the PM, GW, DEBUG, and NOASM options...
  113. link = wlink
  114. asm = wasm
  115. !ifdef PM
  116. cc = wcc386
  117. # Use Pentium Pro timings, flat memory, static strings in code, max strictness:
  118. cflags = -bt=DOS -mf -6r -zt -zq -wx
  119. aflags = -bt=DOS -mf -3 -zq
  120. cflagf = $(cflags)
  121. aflagf = $(aflags)
  122. cflagx = $(cflags)
  123. aflagx = $(aflags)
  124. ! ifdef GW
  125. lflags = sys DOS4G
  126. ! else
  127. # THIS REQUIRES THAT PMODEW.EXE BE FINDABLE IN THE COMMAND PATH.
  128. # It does NOT require you to add a pmodew entry to wlink.lnk or wlsystem.lnk.
  129. defaultlibs = libpath %WATCOM%\lib386 libpath %WATCOM%\lib386\dos
  130. lflags = format os2 le op osname='PMODE/W' op stub=pmodew.exe $(defaultlibs)
  131. ! endif
  132. !else # plain 16-bit DOS:
  133. cc = wcc
  134. # Use plain 8086 code, large memory, static strings in code, max strictness:
  135. cflags = -bt=DOS -ml -0 -zt -zq -wx
  136. aflags = -bt=DOS -ml -0 -zq
  137. # for fUnZip, Deflate64 support requires the compact memory model:
  138. cflagf = -bt=DOS -mc -0 -zt -zq -wx
  139. aflagf = -bt=DOS -mc -0 -zq
  140. # for UnZipSFX (without Deflate64 support), use the small memory model:
  141. cflagx = -bt=DOS -ms -0 -zt -zq -wx
  142. aflagx = -bt=DOS -ms -0 -zq
  143. lflags = sys DOS
  144. !endif # !PM
  145. cvars = $+$(cvars)$- -DMSDOS $(variation)
  146. avars = $+$(avars)$- $(variation)
  147. # Specify optimizations, or a nonoptimized debugging version:
  148. !ifdef DEBUG
  149. cdebug = -od -d2
  150. cdebux = -od -d2
  151. ldebug = d w all op symf
  152. !else
  153. ! ifdef PM
  154. cdebug = -s -obhikl+rt -oe=100 -zp8
  155. # -oa helps slightly but might be dangerous.
  156. ! else
  157. cdebug = -s -oehiklrt
  158. ! endif
  159. cdebux = -s -obhiklrs
  160. ldebug = op el
  161. !endif
  162. # How to compile sources:
  163. .c.obx:
  164. $(cc) $(cdebux) $(cflagx) $(cvars) -DSFX $[@ -fo=$@
  165. .c.obj:
  166. $(cc) $(cdebug) $(cflags) $(cvars) $[@ -fo=$@
  167. # Here we go! By default, make all targets, except no UnZipSFX for PMODE:
  168. !ifdef PM
  169. all: UnZip.exe fUnZip.exe
  170. !else
  171. all: UnZip.exe fUnZip.exe UnZipSFX.exe
  172. !endif
  173. # Convenient shorthand options for single targets:
  174. u: UnZip.exe .SYMBOLIC
  175. f: fUnZip.exe .SYMBOLIC
  176. x: UnZipSFX.exe .SYMBOLIC
  177. UnZip.exe: $(OBDIR) $(OBJA) $(OBJB) $(OBJC) $(BZIPLIB)
  178. set WLK_VA=file {$(OBJA)}
  179. set WLK_VB=file {$(OBJB)}
  180. set WLK_VC=file {$(OBJC)} $(BZ2LNKLIB)
  181. $(link) $(lflags) $(ldebug) name $@ @WLK_VA @WLK_VB @WLK_VC
  182. set WLK_VA=
  183. set WLK_VB=
  184. set WLK_VC=
  185. # We use WLK_VA/WLK_VB/WLK_VC to keep the size of each command below 256 chars.
  186. UnZipSFX.exe: $(OBDIR) $(OBJX) $(BZIPLIB)
  187. set WLK_VX=file {$(OBJX)}
  188. $(link) $(lflags) $(ldebug) name $@ @WLK_VX
  189. set WLK_VX=
  190. fUnZip.exe: $(OBDIR) $(OBJF)
  191. set WLK_VF=file {$(OBJF)}
  192. $(link) $(lflags) $(ldebug) name $@ @WLK_VF
  193. set WLK_VF=
  194. # Source dependencies:
  195. # for UnZip ...
  196. $(O)crc32.obj: crc32.c $(UNZIP_H) zip.h crc32.h
  197. $(O)crypt.obj: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
  198. $(O)envargs.obj: envargs.c $(UNZIP_H)
  199. $(O)explode.obj: explode.c $(UNZIP_H)
  200. $(O)extract.obj: extract.c $(UNZIP_H) crc32.h crypt.h
  201. $(O)fileio.obj: fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
  202. $(O)globals.obj: globals.c $(UNZIP_H)
  203. $(O)inflate.obj: inflate.c inflate.h $(UNZIP_H)
  204. $(O)list.obj: list.c $(UNZIP_H)
  205. $(O)match.obj: match.c $(UNZIP_H)
  206. $(O)process.obj: process.c $(UNZIP_H) crc32.h
  207. $(O)ttyio.obj: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
  208. $(O)ubz2err.obj: ubz2err.c $(UNZIP_H)
  209. $(O)unreduce.obj: unreduce.c $(UNZIP_H)
  210. $(O)unshrink.obj: unshrink.c $(UNZIP_H)
  211. $(O)unzip.obj: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
  212. $(O)zipinfo.obj: zipinfo.c $(UNZIP_H)
  213. # for UnZipSFX ...
  214. $(O)crc32.obx: crc32.c $(UNZIP_H) zip.h crc32.h
  215. $(O)crypt.obx: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
  216. $(O)extract.obx: extract.c $(UNZIP_H) crc32.h crypt.h
  217. $(O)fileio.obx: fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
  218. $(O)globals.obx: globals.c $(UNZIP_H)
  219. $(O)inflate.obx: inflate.c inflate.h $(UNZIP_H)
  220. $(O)match.obx: match.c $(UNZIP_H)
  221. $(O)process.obx: process.c $(UNZIP_H) crc32.h
  222. $(O)ttyio.obx: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
  223. $(O)ubz2err.obx: ubz2err.c $(UNZIP_H)
  224. $(O)unzip.obx: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
  225. # Special case object files:
  226. $(O)msdos.obj: msdos\msdos.c $(UNZIP_H)
  227. $(cc) $(cdebug) $(cflags) $(cvars) msdos\msdos.c -fo=$@
  228. $(O)msdos.obx: msdos\msdos.c $(UNZIP_H)
  229. $(cc) $(cdebux) $(cflagx) $(cvars) -DSFX msdos\msdos.c -fo=$@
  230. !ifndef NOASM
  231. $(crcaob): $(crc_s)
  232. $(asm) $(aflags) $(avars) $(crc_s) -fo=$@
  233. $(crcaof): $(crc_s)
  234. $(asm) $(aflagf) $(avars) $(crc_s) -fo=$@
  235. $(crcaox): $(crc_s)
  236. $(asm) $(aflagx) $(avars) $(crc_s) -fo=$@
  237. !endif
  238. # Variant object files for fUnZip, using $(cflagf):
  239. $(O)funzip.obj: funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h
  240. $(cc) $(cdebux) $(cflagf) $(cvars) funzip.c -fo=$@
  241. $(O)crc32f.obj: crc32.c $(UNZIP_H) zip.h crc32.h
  242. $(cc) $(cdebux) $(cflagf) $(cvars) -DFUNZIP crc32.c -fo=$@
  243. $(O)cryptf.obj: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
  244. $(cc) $(cdebux) $(cflagf) $(cvars) -DFUNZIP crypt.c -fo=$@
  245. $(O)globalsf.obj: globals.c $(UNZIP_H)
  246. $(cc) $(cdebux) $(cflagf) $(cvars) -DFUNZIP globals.c -fo=$@
  247. $(O)inflatef.obj: inflate.c inflate.h $(UNZIP_H) crypt.h
  248. $(cc) $(cdebux) $(cflagf) $(cvars) -DFUNZIP inflate.c -fo=$@
  249. $(O)ttyiof.obj: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
  250. $(cc) $(cdebux) $(cflagf) $(cvars) -DFUNZIP ttyio.c -fo=$@
  251. $(O)msdosf.obj: msdos\msdos.c $(UNZIP_H)
  252. $(cc) $(cdebux) $(cflagf) $(cvars) -DFUNZIP msdos\msdos.c -fo=$@
  253. # The bzip2 (de)compression library for BZIP2 support:
  254. $(IZ_BZIP2)/$(OBDIR)/bz2.lib : .ALWAYS .RECHECK
  255. $(MAKE) -h -f $(IZ_BZIP2)/makbz2iz.wat CC=$(cc) AR=lib386 &
  256. CFLSYS="$(cdebug) $(cflags)" &
  257. BZROOTDIR=$(IZ_BZIP2) BZOBDIR=$(IZ_BZIP2)/$(OBDIR)
  258. # Creation of subdirectory for intermediate files
  259. $(OBDIR):
  260. -mkdir $@
  261. # Unwanted file removal:
  262. clean_bz2_lib: .SYMBOLIC
  263. $(MAKE) -h -f $(IZ_BZIP2)/makbz2iz.wat &
  264. BZROOTDIR=$(IZ_BZIP2) BZOBDIR=$(IZ_BZIP2)\$(OBDIR) clean
  265. clean: clean_bz2_lib .SYMBOLIC
  266. del $(O)*.ob?
  267. cleaner: clean .SYMBOLIC
  268. del UnZip.exe
  269. del fUnZip.exe
  270. del UnZipSFX.exe