makefile.wat 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 07 Aug 2005.
  3. # Makes Zip.exe, ZipNote.exe, ZipCloak.exe, and ZipSplit.exe.
  4. #
  5. # Invoke from Zip source dir with "WMAKE -F MSDOS\MAKEFILE.WAT [targets]"
  6. # To build with debug info use "WMAKE DEBUG=1 ..."
  7. # To build with no assembly modules use "WMAKE NOASM=1 ..."
  8. # To make the PMODE/W version use "WMAKE PM=1 ..."
  9. # To make the DOS/4GW version use "WMAKE GW=1 ..." (overrides PM=1)
  10. # Note: specifying PM or GW without NOASM requires that the win32 source
  11. # directory be present, so it can access the 32 bit assembly sources.
  12. # PMODE/W is recommended over DOS/4GW for best performance.
  13. # To create a low memory usage version of Zip, use "WMAKE WSIZE=8192 ..."
  14. # (or whatever power of two less than 32768 you wish) -- this also causes
  15. # SMALL_MEM to be defined. Compression performance will be reduced.
  16. # This currently is not supported with PM=1 or GW=1.
  17. #
  18. # Other options to be fed to the compiler and assembler can be specified in
  19. # an environment variable called LOCAL_ZIP.
  20. variation = $(%LOCAL_ZIP)
  21. # Stifle annoying "Delete this file?" questions when errors occur:
  22. .ERASE
  23. .EXTENSIONS:
  24. .EXTENSIONS: .exe .obj .c .h .asm
  25. # We maintain multiple sets of object files in different directories so that
  26. # we can compile msdos, dos/4gw or pmode/w, and win32 versions of Zip without
  27. # their object files interacting. The following var must be a directory name
  28. # ending with a backslash. All object file names must include this macro
  29. # at the beginning, for example "$(O)foo.obj".
  30. !ifdef GW
  31. PM = 1 # both protected mode formats use the same object files
  32. !endif
  33. !ifdef DEBUG
  34. ! ifdef PM
  35. OBDIR = od32d
  36. ! else
  37. ! ifdef WSIZE
  38. OBDIR = od16l
  39. size = -DWSIZE=$(WSIZE) -DSMALL_MEM
  40. ! else
  41. OBDIR = od16d
  42. size = -DMEDIUM_MEM
  43. ! endif
  44. ! endif
  45. !else
  46. ! ifdef PM
  47. OBDIR = ob32d
  48. ! else
  49. ! ifdef WSIZE
  50. OBDIR = ob16l
  51. size = -DWSIZE=$(WSIZE) -DSMALL_MEM
  52. ! else
  53. OBDIR = ob16d
  54. size = -DMEDIUM_MEM
  55. ! endif
  56. ! endif
  57. !endif
  58. O = $(OBDIR)\ # comment here so backslash won't continue the line
  59. # The assembly hot-spot code in crc_i[3]86.asm and match[32].asm is
  60. # optional. This section controls its usage.
  61. !ifdef NOASM
  62. # C source
  63. asmob =
  64. cvars = $+$(cvars)$- -DDYN_ALLOC -DNO_ASM # or ASM_CRC might default on!
  65. # "$+$(foo)$-" means expand foo as it has been defined up to now; normally,
  66. # this make defers inner expansion until the outer macro is expanded.
  67. !else # !NOASM
  68. asmob = $(O)crc.obj $(O)match.obj
  69. ! ifdef PM
  70. cvars = $+$(cvars)$- -DASM_CRC -DASMV # no DYN_ALLOC with match32.asm
  71. crc_s = win32\crc_i386.asm # requires that the win32 directory be present
  72. mat_s = win32\match32.asm # ditto
  73. ! else
  74. cvars = $+$(cvars)$- -DDYN_ALLOC -DASM_CRC -DASMV
  75. avars = $+$(avars)$- -DDYN_ALLOC
  76. crc_s = msdos\crc_i86.asm
  77. mat_s = msdos\match.asm
  78. ! endif
  79. !endif
  80. # Now we have to pick out the proper compiler and options for it. This gets
  81. # pretty complicated with the PM, GW, DEBUG, and NOASM options...
  82. link = wlink
  83. asm = wasm
  84. !ifdef PM
  85. cc = wcc386
  86. # Use Pentium Pro timings, register args, static strings in code:
  87. cflags = -bt=DOS -mf -6r -zt -zq
  88. aflags = -bt=DOS -mf -3 -zq
  89. cvars = $+$(cvars)$- -DDOS $(variation)
  90. avars = $+$(avars)$- -DWATCOM_DSEG $(variation)
  91. ! ifdef GW
  92. lflags = sys DOS4G
  93. ! else
  94. # THIS REQUIRES THAT PMODEW.EXE BE FINDABLE IN THE COMMAND PATH.
  95. # It does NOT require you to add a pmodew entry to wlink.lnk or wlsystem.lnk.
  96. defaultlibs = libpath %WATCOM%\lib386 libpath %WATCOM%\lib386\dos
  97. lflags = format os2 le op osname='PMODE/W' op stub=pmodew.exe $(defaultlibs)
  98. ! endif
  99. !else # plain 16-bit DOS:
  100. cc = wcc
  101. # Use plain 8086 instructions, large memory model, static strings in code:
  102. cflags = -bt=DOS -ml -0 -zt -zq
  103. aflags = -bt=DOS -ml -0 -zq
  104. cvars = $+$(cvars)$- -DDOS $(size) $(variation)
  105. avars = $+$(avars)$- $(size) $(variation)
  106. lflags = sys DOS
  107. !endif # !PM
  108. # Specify optimizations, or a nonoptimized debugging version:
  109. !ifdef DEBUG
  110. cdebug = -od -d2
  111. ldebug = d w all op symf
  112. !else
  113. ! ifdef PM
  114. cdebug = -s -obhikl+rt -oe=100 -zp8
  115. # -oa helps slightly but might be dangerous.
  116. ! else
  117. cdebug = -s -oehiklrt
  118. ! endif
  119. ldebug = op el
  120. !endif
  121. # How to compile most sources:
  122. .c.obj:
  123. $(cc) $(cdebug) $(cflags) $(cvars) $[@ -fo=$@
  124. # Our object files. OBJZ is for Zip, OBJC is for ZipCloak, OBJN is for
  125. # ZipNote, and OBJS is for ZipSplit:
  126. OBJZ2 = $(O)zip.obj $(O)crypt.obj $(O)ttyio.obj $(O)zipfile.obj $(O)zipup.obj
  127. OBJZA = $(OBJZ2) $(O)util.obj $(O)fileio.obj $(O)deflate.obj
  128. OBJZB = $(O)trees.obj $(O)globals.obj $(O)crc32.obj $(asmob) $(O)msdos.obj
  129. OBJU2 = $(O)zipfile_.obj $(O)fileio_.obj $(O)util_.obj $(O)globals.obj
  130. OBJ_U = $(OBJU2) $(O)msdos_.obj
  131. OBJC = $(O)zipcloak.obj $(O)crc32_.obj $(O)crypt_.obj $(O)ttyio.obj $(OBJ_U)
  132. OBJN = $(O)zipnote.obj $(OBJ_U)
  133. OBJS = $(O)zipsplit.obj $(OBJ_U)
  134. # Common header files included by all C sources:
  135. ZIP_H = zip.h ziperr.h tailor.h msdos\osdep.h
  136. # HERE WE GO! By default, make all targets:
  137. all: Zip.exe ZipNote.exe ZipCloak.exe ZipSplit.exe
  138. # Convenient shorthand options for single targets:
  139. z: Zip.exe .SYMBOLIC
  140. n: ZipNote.exe .SYMBOLIC
  141. c: ZipCloak.exe .SYMBOLIC
  142. s: ZipSplit.exe .SYMBOLIC
  143. Zip.exe: $(OBDIR) $(OBJZA) $(OBJZB) $(OBJV)
  144. set WLK_VA=file {$(OBJZA)}
  145. set WLK_VB=file {$(OBJZB) $(OBJV)}
  146. $(link) $(lflags) $(ldebug) name $@ @WLK_VA @WLK_VB
  147. set WLK_VA=
  148. set WLK_VB=
  149. # We use WLK_VA and WLK_VB to keep the size of each command under 256 chars.
  150. ZipNote.exe: $(OBDIR) $(OBJN)
  151. set WLK_VAR=file {$(OBJN)}
  152. $(link) $(lflags) $(ldebug) name $@ @WLK_VAR
  153. set WLK_VAR=
  154. ZipCloak.exe: $(OBDIR) $(OBJC)
  155. set WLK_VAR=file {$(OBJC)}
  156. $(link) $(lflags) $(ldebug) name $@ @WLK_VAR
  157. set WLK_VAR=
  158. ZipSplit.exe: $(OBDIR) $(OBJS)
  159. set WLK_VAR=file {$(OBJS)}
  160. $(link) $(lflags) $(ldebug) name $@ @WLK_VAR
  161. set WLK_VAR=
  162. # Source dependencies:
  163. $(O)crc32.obj: crc32.c $(ZIP_H) crc32.h
  164. $(O)crypt.obj: crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h
  165. $(O)deflate.obj: deflate.c $(ZIP_H)
  166. $(O)fileio.obj: fileio.c $(ZIP_H) crc32.h
  167. $(O)globals.obj: globals.c $(ZIP_H)
  168. $(O)trees.obj: trees.c $(ZIP_H)
  169. $(O)ttyio.obj: ttyio.c $(ZIP_H) crypt.h ttyio.h
  170. $(O)util.obj: util.c $(ZIP_H)
  171. $(O)zip.obj: zip.c $(ZIP_H) crc32.h crypt.h revision.h ttyio.h
  172. $(O)zipfile.obj: zipfile.c $(ZIP_H) crc32.h
  173. $(O)zipup.obj: zipup.c $(ZIP_H) revision.h crc32.h crypt.h msdos\zipup.h
  174. $(O)zipnote.obj: zipnote.c $(ZIP_H) revision.h
  175. $(O)zipcloak.obj: zipcloak.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h
  176. $(O)zipsplit.obj: zipsplit.c $(ZIP_H) revision.h
  177. # Special case object files:
  178. $(O)msdos.obj: msdos\msdos.c $(ZIP_H)
  179. $(cc) $(cdebug) $(cflags) $(cvars) msdos\msdos.c -fo=$@
  180. $(O)match.obj: $(mat_s)
  181. $(asm) $(aflags) $(avars) $(mat_s) -fo=$@
  182. $(O)crc.obj: $(crc_s)
  183. $(asm) $(aflags) $(avars) $(crc_s) -fo=$@
  184. # Variant object files for ZipNote, ZipCloak, and ZipSplit:
  185. $(O)zipfile_.obj: zipfile.c $(ZIP_H) crc32.h
  186. $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL zipfile.c -fo=$@
  187. $(O)fileio_.obj: fileio.c $(ZIP_H) crc32.h
  188. $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL fileio.c -fo=$@
  189. $(O)util_.obj: util.c $(ZIP_H)
  190. $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL util.c -fo=$@
  191. $(O)crc32_.obj: crc32.c $(ZIP_H) crc32.h
  192. $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL crc32.c -fo=$@
  193. $(O)crypt_.obj: crypt.c $(ZIP_H) crc32.h crypt.h ttyio.h
  194. $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL crypt.c -fo=$@
  195. $(O)msdos_.obj: msdos\msdos.c $(ZIP_H)
  196. $(cc) $(cdebug) $(cflags) $(cvars) -DUTIL msdos\msdos.c -fo=$@
  197. # Creation of subdirectory for intermediate files
  198. $(OBDIR):
  199. -mkdir $@
  200. # Unwanted file removal:
  201. clean: .SYMBOLIC
  202. del $(O)*.obj
  203. cleaner: clean .SYMBOLIC
  204. del Zip.exe
  205. del ZipNote.exe
  206. del ZipCloak.exe
  207. del ZipSplit.exe