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