1# WMAKE makefile for Windows 9x and Windows NT (Intel only) 2# using Watcom C/C++ v11.0+, by Paul Kienitz, last revised 18 Jan 2009. 3# Makes UnZip.exe, fUnZip.exe, and UnZipSFX.exe. 4# 5# Invoke from UnZip source dir with "WMAKE -F WIN32\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 omit unshrinking support use "WMAKE NO_LZW=1 ..." 9# To support unreducing, get the real unreduce.c and go "WMAKE OFFEND_RMS=1 ..." 10# To use Info-Zip's generic timezone functions use "WMAKE USE_IZTIMEZONE=1 ..." 11# To include support for bzip2 decompression, get the bzip2 source distribution 12# into the bzip2/ subfolder and start compilation with "WMAKE USEBZ2=1 ..." 13# 14# Other options to be fed to the compiler can be specified in an environment 15# variable called LOCAL_UNZIP. 16 17variation = $(%LOCAL_UNZIP) 18 19# Stifle annoying "Delete this file?" questions when errors occur: 20.ERASE 21 22.EXTENSIONS: 23.EXTENSIONS: .exe .obj .obx .c .h .asm 24 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 UnZip 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 31!ifdef DEBUG 32OBDIR = od32w 33!else 34OBDIR = ob32w 35!endif 36O = $(OBDIR)\ # comment here so backslash won't continue the line 37 38!ifdef NO_LZW 39cvars = $+$(cvars)$- -DLZW_CLEAN 40avars = $+$(avars)$- -DLZW_CLEAN 41# "$+$(foo)$-" means expand foo as it has been defined up to now; normally, 42# this Make defers inner expansion until the outer macro is expanded. 43!endif 44!ifdef OFFEND_RMS 45cvars = $+$(cvars)$- -DUSE_SMITH_CODE 46avars = $+$(avars)$- -DUSE_SMITH_CODE 47!endif 48 49IZ_BZIP2 = bzip2 50!ifdef USEBZ2 51cvars = $+$(cvars)$- -DUSE_BZIP2 -I$(IZ_BZIP2) 52BZIPLIB = $(IZ_BZIP2)/$(OBDIR)/bz2.lib 53BZ2LNKLIB = lib {$(BZIPLIB)} 54!else 55BZIPLIB = 56BZ2LNKLIB = 57!endif 58 59!ifndef USE_IZTIMEZONE 60#default: do not use the IZ timezone replacement 61USE_IZTIMEZONE=0 62!endif 63 64# The assembly hot-spot code in crc_i386.asm is optional. This section 65# controls its usage. 66 67!ifdef NOASM 68crcaob = 69!else # !NOASM 70cvars = $+$(cvars)$- -DASM_CRC 71crcaob = $(O)crc_i386.obj 72!endif 73 74!if $(USE_IZTIMEZONE) != 0 75cvars = $+$(cvars)$- -DW32_USE_IZ_TIMEZONE 76TIMEZONE_OBJU = $(O)timezone.obj 77TIMEZONE_OBJX = $(O)timezone.obx 78TIMEZONE_OBJD = $(O)timezonl.obj 79TIMEZONE_OBLX = $(O)timezolx.obj 80TIMEZONE_OBJB = $(O)timezonb.obj 81!else 82TIMEZONE_OBJU = 83TIMEZONE_OBJX = 84TIMEZONE_OBJD = 85TIMEZONE_OBLX = 86TIMEZONE_OBJB = 87!endif 88 89# Our object files. OBJU is for UnZip, OBJX for UnZipSFX, OBJF for fUnZip: 90 91OBJU1 = $(O)unzip.obj $(O)crc32.obj $(crcaob) $(O)crypt.obj $(O)envargs.obj 92OBJU2 = $(O)explode.obj $(O)extract.obj $(O)fileio.obj $(O)globals.obj 93OBJU3 = $(O)inflate.obj $(O)list.obj $(O)match.obj $(O)process.obj 94OBJU4 = $(O)ubz2err.obj $(O)ttyio.obj $(O)unreduce.obj $(O)unshrink.obj 95OBJU5 = $(O)zipinfo.obj 96OBJUS = $(O)win32.obj $(O)win32i64.obj $(O)nt.obj $(TIMEZONE_OBJU) 97OBJU = $(OBJU1) $(OBJU2) $(OBJU3) $(OBJU4) $(OBJU5) $(OBJUS) 98 99OBJX1 = $(O)unzip.obx $(O)crc32.obx $(crcaob) $(O)crypt.obx $(O)extract.obx 100OBJX2 = $(O)fileio.obx $(O)globals.obx $(O)inflate.obx $(O)match.obx 101OBJX3 = $(O)process.obx $(O)ttyio.obx $(O)ubz2err.obx 102OBJXS = $(O)win32.obx $(O)win32i64.obx $(O)nt.obx $(TIMEZONE_OBJX) 103OBJX = $(OBJX1) $(OBJX2) $(OBJX3) $(OBJXS) 104 105OBJF1 = $(O)funzip.obj $(O)crc32f.obj $(crcaob) $(O)cryptf.obj 106OBJF2 = $(O)globalsf.obj $(O)inflatef.obj $(O)ttyiof.obj 107OBJFS = $(O)win32f.obj $(O)win32i64f.obj 108OBJF = $(OBJF1) $(OBJF2) $(OBJFS) 109 110OBJD1 = $(O)api.obj $(O)crc32l.obj $(crcaob) $(O)cryptl.obj $(O)explodel.obj 111OBJD2 = $(O)extractl.obj $(O)fileiol.obj $(O)globalsl.obj $(O)inflatel.obj 112OBJD3 = $(O)listl.obj $(O)matchl.obj $(O)processl.obj $(O)ubz2errl.obj 113OBJD4 = $(O)unreducl.obj $(O)unshrnkl.obj $(O)zipinfol.obj 114OBJDS = $(O)win32l.obj $(O)win32i64l.obj $(O)ntl.obj $(O)windll.obj $(TIMEZONE_OBJD) 115OBJD = $(OBJD1) $(OBJD2) $(OBJD3) $(OBJD4) $(OBJDS) 116 117UNZIP_H = unzip.h unzpriv.h globals.h win32/w32cfg.h 118WINDLL_H = windll/windll.h windll/decs.h windll/structs.h 119WINDLL_DEF = windll/windll32.def 120WINDLL_IMP_H = windll/decs.h windll/structs.h 121 122# Now we have to pick out the proper compiler and options for it. 123 124cc = wcc386 125link = wlink 126asm = wasm 127rc = wrc 128# Use Pentium Pro timings, register args, static strings in code, high strictness: 129cflags = -bt=NT -6r -zt -zq -wx 130aflags = -bt=NT -mf -3 -zq 131rflags = -bt=NT 132lflags = sys NT 133lflags_dll = sys NT_DLL 134cvars = $+$(cvars)$- -DWIN32 $(variation) 135avars = $+$(avars)$- $(variation) 136 137# Specify optimizations, or a nonoptimized debugging version: 138 139!ifdef DEBUG 140cdebug = -od -d2 141cdebux = -od -d2 142ldebug = d w all op symf 143!else 144cdebug = -s -obhikl+rt -oe=100 -zp8 145cdebux = -s -obhiklrs 146# -oa helps slightly but might be dangerous. 147ldebug = op el 148!endif 149 150CFLAGS_FU = $(cdebug) $(cflags) $(cvars) -DFUNZIP 151CFLAGS_DL = $(cdebug) $(cflags) $(cvars) -bd -bm -DWINDLL -DDLL 152 153# How to compile sources: 154.c.obx: 155 $(cc) $(cdebux) $(cflags) $(cvars) -DSFX $[@ -fo=$@ 156 157.c.obj: 158 $(cc) $(cdebug) $(cflags) $(cvars) $[@ -fo=$@ 159 160# Here we go! By default, make all targets: 161all: UnZip.exe fUnZip.exe UnZipSFX.exe 162 163# Convenient shorthand options for single targets: 164u: UnZip.exe .SYMBOLIC 165f: fUnZip.exe .SYMBOLIC 166x: UnZipSFX.exe .SYMBOLIC 167d: UnZip32.dll .SYMBOLIC 168 169UnZip.exe: $(OBDIR) $(OBJU) $(BZIPLIB) $(O)winapp.res 170 $(link) $(lflags) $(ldebug) name $@ file {$(OBJU)} $(BZ2LNKLIB) 171 172UnZipSFX.exe: $(OBDIR) $(OBJX) $(BZIPLIB) 173 $(link) $(lflags) $(ldebug) name $@ file {$(OBJX)} $(BZ2LNKLIB) 174 175fUnZip.exe: $(OBDIR) $(OBJF) 176 $(link) $(lflags) $(ldebug) name $@ file {$(OBJF)} 177 178UnZip32.dll: $(OBDIR) $(OBJD) $(BZIPLIB) $(O)windll.res 179 $(link) $(lflags_dll) $(ldebug) name $@ file {$(OBJD)} $(BZ2LNKLIB) 180 $(rc) $(rflags) $(O)windll.res $@ 181 182uzexampl.exe: $(OBDIR) $(O)uzexampl.obj 183 $(link) $(lflags) $(ldebug) name $@ file {$(O)uzexampl.obj} lib version.lib 184 185# Source dependencies: 186 187# generic (UnZip, fUnZip): 188 189$(O)crc32.obj: crc32.c $(UNZIP_H) zip.h crc32.h 190$(O)crypt.obj: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h 191$(O)envargs.obj: envargs.c $(UNZIP_H) 192$(O)explode.obj: explode.c $(UNZIP_H) 193$(O)extract.obj: extract.c $(UNZIP_H) crc32.h crypt.h 194$(O)fileio.obj: fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h 195$(O)funzip.obj: funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h 196$(O)globals.obj: globals.c $(UNZIP_H) 197$(O)inflate.obj: inflate.c inflate.h $(UNZIP_H) 198$(O)list.obj: list.c $(UNZIP_H) 199$(O)match.obj: match.c $(UNZIP_H) 200$(O)process.obj: process.c $(UNZIP_H) crc32.h 201$(O)timezone.obj: timezone.c $(UNZIP_H) zip.h timezone.h 202$(O)ttyio.obj: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h 203$(O)ubz2err.obj: ubz2err.c $(UNZIP_H) 204$(O)unreduce.obj: unreduce.c $(UNZIP_H) 205$(O)unshrink.obj: unshrink.c $(UNZIP_H) 206$(O)unzip.obj: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h 207$(O)zipinfo.obj: zipinfo.c $(UNZIP_H) 208 209# UnZipSFX variants: 210 211$(O)crc32.obx: crc32.c $(UNZIP_H) zip.h crc32.h 212$(O)crypt.obx: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h 213$(O)extract.obx: extract.c $(UNZIP_H) crc32.h crypt.h 214$(O)fileio.obx: fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h 215$(O)globals.obx: globals.c $(UNZIP_H) 216$(O)inflate.obx: inflate.c inflate.h $(UNZIP_H) 217$(O)match.obx: match.c $(UNZIP_H) 218$(O)process.obx: process.c $(UNZIP_H) crc32.h 219$(O)timezone.obx: timezone.c $(UNZIP_H) zip.h timezone.h 220$(O)ttyio.obx: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h 221$(O)ubz2err.obx: ubz2err.c $(UNZIP_H) 222$(O)unzip.obx: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h 223 224# Special case object files: 225 226$(O)win32.obj: win32\win32.c $(UNZIP_H) win32\nt.h 227 $(cc) $(cdebug) $(cflags) $(cvars) win32\win32.c -fo=$@ 228 229$(O)win32.obx: win32\win32.c $(UNZIP_H) win32\nt.h 230 $(cc) $(cdebux) $(cflags) $(cvars) -DSFX win32\win32.c -fo=$@ 231 232$(O)win32i64.obj: win32\win32i64.c $(UNZIP_H) 233 $(cc) $(cdebug) $(cflags) $(cvars) win32\win32i64.c -fo=$@ 234 235$(O)win32i64.obx: win32\win32i64.c $(UNZIP_H) 236 $(cc) $(cdebux) $(cflags) $(cvars) -DSFX win32\win32i64.c -fo=$@ 237 238$(O)nt.obj: win32\nt.c $(UNZIP_H) win32\nt.h 239 $(cc) $(cdebug) $(cflags) $(cvars) win32\nt.c -fo=$@ 240 241$(O)nt.obx: win32\nt.c $(UNZIP_H) win32\nt.h 242 $(cc) $(cdebux) $(cflags) $(cvars) -DSFX win32\nt.c -fo=$@ 243 244$(O)crc_i386.obj: win32\crc_i386.asm 245 $(asm) $(aflags) $(avars) win32\crc_i386.asm -fo=$@ 246 247$(O)winapp.res: win32\winapp.rc unzvers.h 248 $(rc) $(rflags) /r /fo=$@ /dWIN32 win32\winapp.rc 249 250# Variant object files for fUnZip: 251 252$(O)crc32f.obj: crc32.c $(UNZIP_H) zip.h crc32.h 253 $(cc) $(CFLAGS_FU) crc32.c -fo=$@ 254 255$(O)cryptf.obj: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h 256 $(cc) $(CFLAGS_FU) crypt.c -fo=$@ 257 258$(O)globalsf.obj: globals.c $(UNZIP_H) 259 $(cc) $(CFLAGS_FU) globals.c -fo=$@ 260 261$(O)inflatef.obj: inflate.c inflate.h $(UNZIP_H) crypt.h 262 $(cc) $(CFLAGS_FU) inflate.c -fo=$@ 263 264$(O)ttyiof.obj: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h 265 $(cc) $(CFLAGS_FU) ttyio.c -fo=$@ 266 267$(O)win32f.obj: win32\win32.c $(UNZIP_H) 268 $(cc) $(CFLAGS_FU) win32\win32.c -fo=$@ 269 270$(O)win32i64f.obj: win32\win32i64.c $(UNZIP_H) 271 $(cc) $(CFLAGS_FU) win32\win32i64.c -fo=$@ 272 273# DLL compilation section 274$(O)api.obj: api.c $(UNZIP_H) $(WINDLL_H) unzvers.h 275 $(cc) $(CFLAGS_DL) api.c -fo=$@ 276$(O)crc32l.obj: crc32.c $(UNZIP_H) zip.h crc32.h 277 $(cc) $(CFLAGS_DL) crc32.c -fo=$@ 278$(O)cryptl.obj: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h 279 $(cc) $(CFLAGS_DL) crypt.c -fo=$@ 280$(O)explodel.obj: explode.c $(UNZIP_H) 281 $(cc) $(CFLAGS_DL) explode.c -fo=$@ 282$(O)extractl.obj: extract.c $(UNZIP_H) $(WINDLL_H) crc32.h crypt.h 283 $(cc) $(CFLAGS_DL) extract.c -fo=$@ 284$(O)fileiol.obj: fileio.c $(UNZIP_H) $(WINDLL_H) crc32.h crypt.h ttyio.h ebcdic.h 285 $(cc) $(CFLAGS_DL) fileio.c -fo=$@ 286$(O)globalsl.obj: globals.c $(UNZIP_H) 287 $(cc) $(CFLAGS_DL) globals.c -fo=$@ 288$(O)inflatel.obj: inflate.c inflate.h $(UNZIP_H) 289 $(cc) $(CFLAGS_DL) inflate.c -fo=$@ 290$(O)listl.obj: list.c $(UNZIP_H) $(WINDLL_H) 291 $(cc) $(CFLAGS_DL) list.c -fo=$@ 292$(O)matchl.obj: match.c $(UNZIP_H) 293 $(cc) $(CFLAGS_DL) match.c -fo=$@ 294$(O)processl.obj: process.c $(UNZIP_H) $(WINDLL_H) crc32.h 295 $(cc) $(CFLAGS_DL) process.c -fo=$@ 296$(O)timezonl.obj: timezone.c $(UNZIP_H) zip.h timezone.h 297 $(cc) $(CFLAGS_DL) timezone.c -fo=$@ 298$(O)ubz2errl.obj: ubz2err.c $(UNZIP_H) 299 $(cc) $(CFLAGS_DL) ubz2err.c -fo=$@ 300$(O)unreducl.obj: unreduce.c $(UNZIP_H) 301 $(cc) $(CFLAGS_DL) unreduce.c -fo=$@ 302$(O)unshrnkl.obj: unshrink.c $(UNZIP_H) 303 $(cc) $(CFLAGS_DL) unshrink.c -fo=$@ 304$(O)zipinfol.obj: zipinfo.c $(UNZIP_H) 305 $(cc) $(CFLAGS_DL) zipinfo.c -fo=$@ 306 307$(O)win32l.obj: win32\win32.c $(UNZIP_H) win32\nt.h 308 $(cc) $(CFLAGS_DL) -I. win32\win32.c -fo=$@ 309 310$(O)win32i64l.obj: win32\win32i64.c $(UNZIP_H) 311 $(cc) $(CFLAGS_DL) -I. win32\win32i64.c -fo=$@ 312 313$(O)ntl.obj: win32\nt.c $(UNZIP_H) win32\nt.h 314 $(cc) $(CFLAGS_DL) -I. win32\nt.c -fo=$@ 315 316$(O)windll.obj: windll\windll.c $(UNZIP_H) $(WINDLL_H) 317$(O)windll.obj: crypt.h unzvers.h consts.h 318 $(cc) $(CFLAGS_DL) -I. windll\windll.c -fo=$@ 319 320$(O)windll.res: windll\windll.rc unzvers.h 321 $(rc) $(rflags) /r /fo=$@ /i=windll /dWIN32 windll\windll.rc 322 323# Windll command line example: 324$(O)uzexampl.obj: windll/uzexampl.c windll/uzexampl.h 325 $(cc) $(cdebug) $(cflags) $(cvars) windll\uzexampl.c -fo=$@ 326 327# The bzip2 (de)compression library for BZIP2 support: 328$(IZ_BZIP2)/$(OBDIR)/bz2.lib : .ALWAYS .RECHECK 329 $(MAKE) -h -f $(IZ_BZIP2)/makbz2iz.wat CC=$(cc) AR=lib386 & 330 CFLSYS="$(cdebug) $(cflags)" & 331 BZROOTDIR=$(IZ_BZIP2) BZOBDIR=$(IZ_BZIP2)/$(OBDIR) 332 333# Creation of subdirectory for intermediate files 334$(OBDIR): 335 -mkdir $@ 336 337# Unwanted file removal: 338 339clean_bz2_lib: .SYMBOLIC 340 -$(MAKE) -h -f $(IZ_BZIP2)/makbz2iz.wat & 341 BZROOTDIR=$(IZ_BZIP2) BZOBDIR=$(IZ_BZIP2)\$(OBDIR) clean 342 343clean: clean_bz2_lib .SYMBOLIC 344 del $(O)*.ob? 345 del $(O)*.res 346 347cleaner: clean .SYMBOLIC 348 del UnZip.exe 349 del fUnZip.exe 350 del UnZipSFX.exe 351 del UnZip32.dll 352 del uzexampl.exe 353