Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

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