1# Makefile for UnZip(SFX) and fUnZip for Borland C++ 2.x-4.x and Turbo C++ 1.0
2# Version: 5.53 and later        Alvin Koh, Jim Knoble, Christian Spieler, etc.
3#
4# Last revised:  29 Dec 05
5#
6# To compile with Turbo C++ 1.0, set the macro CC_REV to 1 at the command line
7# (make -fmsdos/makefile.bc -DCC_REV=1).
8
9
10#    GNU make doesn't like the return value from "rem"
11#STRIP=rem
12STRIP=echo  Ignore this line.
13#    If you don't have UPX, LZEXE, or PKLITE, get one of them. Then define:
14#    (NOTE: upx needs a 386 or higher system to run the exe compressor)
15#STRIP=upx --8086 --best
16#    or
17#STRIP=lzexe
18#    or
19#STRIP=pklite
20#    This makes a big difference in .exe size (and possibly load time).
21
22
23#    Optional nonstandard preprocessor flags (as -DCHECK_EOF or -DDOS_WILD)
24#    should be added to the environment via "set LOCAL_UNZIP=-DFOO" or added
25#    to the declaration of LOC here:
26LOC = $(LOCAL_UNZIP)
27
28# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
29CPU_TYP = 0
30
31# (De)Select inclusion of optimized assembler CRC32 routine:
32USE_ASMCRC = 1
33
34!if $(CC_REV) == 1
35# Turbo C++ 1.0
36CC = tcc
37!else
38# Borland C++ 2.0, 3.0, 3.1 ...
39! if !$(CC_REV)
40CC_REV = 3
41! endif
42CC = bcc
43!endif
44
45AS = tasm
46
47# "near data" model is sufficient for UnZip and ZipInfo, now that strings moved
48# switched to medium model; UnZip code has grown beyond the 64k limit.
49# since 5.42: switched to large model; medium model requires to much memory
50# to compile zipinfo, reported for BC++ 4.51 and TC++ 1.0
51# (compilation worked with 624k DOS memory and TC++ 1.0, but that much free
52# space requires an almost "empty" DOS system)
53# for 5.5: large or compact model required for Deflate64 support
54UNMODEL = l		# large model for UnZip and ZipInfo
55ASUNMODEL=__LARGE__	# keep in sync with UNMODEL definition !!
56
57FUMODEL = c		# need compact model for fUnZip with Deflate64 support
58ASFUMODEL=__COMPACT__	# keep in sync with FUMODEL definition !!
59
60SXMODEL = s		# use small model for SFXUnZip (no Deflate64 support)
61ASSXMODEL=__SMALL__	# keep in sync with SXMODEL definition !!
62
63!if $(USE_ASMCRC)
64ASMFLG = -DASM_CRC
65ASMOBJS = crc_i86.obj
66ASMOBJF = crc_i86_.obj
67ASMOBJX = crc_i86x.obj
68!else
69ASMFLG =
70ASMOBJS =
71ASMOBJF =
72ASMOBJX =
73!endif
74
75
76# compiler flags
77
78ASCPUFLAG = __$(CPU_TYP)86
79!if $(CPU_TYP) != 0
80CC_CPUFLG = -$(CPU_TYP)
81!endif
82ASFLAGS = -ml -m2 -w0 -D$(ASCPUFLAG) $(LOC)
83!if $(CC_REV) == 1
84# Bug: TC ++ 1.0 ignores "far" on "const" strings, so const is disabled!
85CCOPTIM = -O -G -Z -a -d -DZCONST
86LDFLAGS = -lxncd		# for tcc
87!else
88CCOPTIM = -O2
89LDFLAGS = -lxncd -l-P		# for bcc
90!endif
91CFLAGS  = $(CCOPTIM) $(CC_CPUFLG) -ff- -k- -P-.C -I. $(ASMFLG) $(LOC)
92UNFLAGS = -m$(UNMODEL) $(CFLAGS)
93FUFLAGS = -m$(FUMODEL) $(CFLAGS) -K -d
94SXFLAGS = -m$(SXMODEL) $(CFLAGS)
95
96# implicit rules
97
98.asm.obj:
99	$(AS) $(ASFLAGS) -D$(ASUNMODEL) $<
100
101.c.obj:
102	$(CC) -c $(UNFLAGS) {$< }
103
104# list macros
105
106OBJU1 = unzip.obj crc32.obj crypt.obj envargs.obj explode.obj
107OBJU2 = extract.obj fileio.obj globals.obj inflate.obj list.obj match.obj
108OBJU3 = process.obj ttyio.obj unreduce.obj unshrink.obj zipinfo.obj
109OBJUS = msdos.obj $(ASMOBJS)
110OBJU  = $(OBJU1) $(OBJU2) $(OBJU3) $(OBJUS)
111OBJF  = funzip.obj crc32f.obj cryptf.obj globalsf.obj inflatef.obj \
112	ttyiof.obj msdosf.obj $(ASMOBJF)
113OBJX1 = unzipsfx.obj crc32x.obj cryptx.obj extractx.obj fileiox.obj
114OBJX2 = globalsx.obj inflatex.obj matchx.obj processx.obj ttyiox.obj
115OBJXS = msdosx.obj $(ASMOBJX)
116OBJX  = $(OBJX1) $(OBJX2) $(OBJXS)
117
118UNZIP_H = unzip.h unzpriv.h globals.h msdos/doscfg.h
119
120# explicit rules
121
122all:    unzip.exe funzip.exe unzipsfx.exe
123
124unzip.exe:      $(OBJU)
125	$(CC) -m$(UNMODEL) $(LDFLAGS) -eunzip.exe @&&|
126$(OBJU)
127|
128	$(STRIP) unzip.exe
129
130funzip.exe:     $(OBJF)
131	$(CC) -m$(FUMODEL) $(LDFLAGS) -efunzip.exe @&&|
132$(OBJF)
133|
134	$(STRIP) funzip.exe
135
136unzipsfx.exe:   $(OBJX)
137	$(CC) -m$(SXMODEL) $(LDFLAGS) -eunzipsfx.exe @&&|
138$(OBJX)
139|
140	$(STRIP) unzipsfx.exe
141
142clean:
143	rem Ignore any errors in the following...
144	-del *.obj
145	-del unzip.exe
146	-del funzip.exe
147	-del unzipsfx.exe
148
149# individual file dependencies
150
151crc32.obj:      crc32.c $(UNZIP_H) zip.h crc32.h
152crypt.obj:      crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
153envargs.obj:    envargs.c $(UNZIP_H)
154explode.obj:    explode.c $(UNZIP_H)
155extract.obj:    extract.c $(UNZIP_H) crc32.h crypt.h
156fileio.obj:     fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
157globals.obj:    globals.c $(UNZIP_H)
158inflate.obj:    inflate.c inflate.h $(UNZIP_H)
159list.obj:       list.c $(UNZIP_H)
160match.obj:      match.c $(UNZIP_H)
161process.obj:    process.c $(UNZIP_H) crc32.h
162ttyio.obj:      ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
163unreduce.obj:   unreduce.c $(UNZIP_H)
164unshrink.obj:   unshrink.c $(UNZIP_H)
165unzip.obj:      unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
166zipinfo.obj:    zipinfo.c $(UNZIP_H)
167
168crc_i86.obj:    msdos/crc_i86.asm
169	$(AS) $(ASFLAGS) -D$(ASUNMODEL) msdos\crc_i86.asm, $*.obj ;
170
171crc_i86_.obj:   msdos/crc_i86.asm
172	$(AS) $(ASFLAGS) -D$(ASFUMODEL) msdos\crc_i86.asm, $*.obj ;
173
174crc_i86x.obj:   msdos/crc_i86.asm
175	$(AS) $(ASFLAGS) -D$(ASSXMODEL) msdos\crc_i86.asm, $*.obj ;
176
177msdos.obj:      msdos/msdos.c $(UNZIP_H)
178	$(CC) -c $(UNFLAGS) msdos/msdos.c
179
180funzip.obj:     funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h
181	$(CC) -c $(FUFLAGS) funzip.c
182
183crc32f.obj:     crc32.c $(UNZIP_H) zip.h crc32.h
184	$(CC) -c $(FUFLAGS) -DFUNZIP -ocrc32f.obj crc32.c
185
186cryptf.obj:     crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
187	$(CC) -c $(FUFLAGS) -DFUNZIP -ocryptf.obj crypt.c
188
189globalsf.obj:   globals.c $(UNZIP_H)
190	$(CC) -c $(FUFLAGS) -DFUNZIP -oglobalsf.obj globals.c
191
192inflatef.obj:   inflate.c inflate.h $(UNZIP_H) crypt.h
193	$(CC) -c $(FUFLAGS) -DFUNZIP -oinflatef.obj inflate.c
194
195ttyiof.obj:     ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
196	$(CC) -c $(FUFLAGS) -DFUNZIP -ottyiof.obj ttyio.c
197
198msdosf.obj:     msdos/msdos.c $(UNZIP_H)
199	$(CC) -c $(FUFLAGS) -DFUNZIP -omsdosf.obj msdos/msdos.c
200
201unzipsfx.obj:   unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
202	$(CC) -c $(SXFLAGS) -DSFX -ounzipsfx.obj unzip.c
203
204crc32x.obj:     crc32.c $(UNZIP_H) zip.h crc32.h
205	$(CC) -c $(SXFLAGS) -DSFX -ocrc32x.obj crc32.c
206
207cryptx.obj:     crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
208	$(CC) -c $(SXFLAGS) -DSFX -ocryptx.obj crypt.c
209
210extractx.obj:   extract.c $(UNZIP_H) crc32.h crypt.h
211	$(CC) -c $(SXFLAGS) -DSFX -oextractx.obj extract.c
212
213fileiox.obj:    fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
214	$(CC) -c $(SXFLAGS) -DSFX -ofileiox.obj fileio.c
215
216globalsx.obj:   globals.c $(UNZIP_H)
217	$(CC) -c $(SXFLAGS) -DSFX -oglobalsx.obj globals.c
218
219inflatex.obj:   inflate.c inflate.h $(UNZIP_H)
220	$(CC) -c $(SXFLAGS) -DSFX -oinflatex.obj inflate.c
221
222matchx.obj:     match.c $(UNZIP_H)
223	$(CC) -c $(SXFLAGS) -DSFX -omatchx.obj match.c
224
225processx.obj:   process.c $(UNZIP_H) crc32.h
226	$(CC) -c $(SXFLAGS) -DSFX -oprocessx.obj process.c
227
228ttyiox.obj:     ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
229	$(CC) -c $(SXFLAGS) -DSFX -ottyiox.obj ttyio.c
230
231msdosx.obj:     msdos/msdos.c $(UNZIP_H)
232	$(CC) -c $(SXFLAGS) -DSFX -omsdosx.obj msdos/msdos.c
233