1#------------------------------------------------------------------------------
2# Makefile for UnZip 5.53 and later                     Greg Roelofs and others
3# Version:  Microsoft C (5.x and later)                               29 Dec 05
4#------------------------------------------------------------------------------
5
6# Users of MSC 6/7 and NMAKE can use the Unix Makefile (target msc_dos),
7# if desired.  This makefile works just fine, too, however.  OS/2 users
8# can cross-compile using os2/makefile.os2 (target mscdos).  Note that
9# there is possibly a bug in MSC 6 which screws up funzip (goes into
10# infinite loop? --this has not been confirmed in over a year...).  There
11# is definitely a bug (internal compiler error) in MSC 6.00 while com-
12# piling explode.c (fixed in 6.0a, 6.0ax, 6.0ax2, 7.*, 8.*).
13
14
15#    GNU make doesn't like the return value from "rem"
16#STRIP=rem
17STRIP=echo  Ignore this line.
18#    If you don't have UPX, LZEXE, or PKLITE, get one of them. Then define:
19#    (NOTE: upx needs a 386 or higher system to run the exe compressor)
20#STRIP=upx --8086 --best
21#    or
22#STRIP=lzexe
23#    or
24#STRIP=pklite
25#    and remove /e from LDFLAGS.
26#    This makes a big difference in .exe size (and possibly load time).
27
28#    Optional nonstandard preprocessor flags (as -DCHECK_EOF or -DDOS_WILD)
29#    should be added to the environment via "set LOCAL_UNZIP=-DFOO" or added
30#    to the declaration of LOC here:
31LOC = $(LOCAL_UNZIP)
32
33# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc.
34CPU_TYP = 0
35
36#UNMODEL=M	# medium model for UnZip
37# with MSC 5.1, 6.0 and 8.x, small model exceeds 64k code segment; use medium
38# deflate64 support requires large or compact model
39UNMODEL=L	# large model for UnZip with Deflate64 support
40FUMODEL=C	# compact model for fUnZip (Deflate64 support enabled)
41SXMODEL=S	# small model for UnZipSFX (without Deflate64 support)
42
43# name of Flag to select memory model for assembler compiles, supported
44# values are __SMALL__ , __MEDIUM__ , __COMPACT__ , __LARGE__ :
45# for MSC 5.1 and 8.x use:
46ASUNMODEL=__LARGE__	# keep in sync with UNMODEL definition !!
47ASFUMODEL=__COMPACT__	# keep in sync with FUMODEL definition !!
48ASSXMODEL=__SMALL__	# keep in sync with SXMODEL definition !!
49
50# Uncomment the following three macros to use the optimized CRC32 assembler
51# routine in UnZip and UnZipSFX:
52ASMFLG = -DASM_CRC
53ASMOBJS = crc_i86.obj
54ASMOBJF = crc_i86_.obj
55ASMOBJX = crc_i86x.obj
56
57ASCPUFLAG = __$(CPU_TYP)86
58
59CC = cl
60# add -G2(3,4) for 286 (386, 486) and/or -FPi87 for 80x87:
61CC_GENFLAGS = -nologo -DMSC $(ASMFLG) $(LOC) -I. -G$(CPU_TYP)
62CC_SPEEDOPT = -Oait -Gs         # -Ox does not work for inflate.c
63CC_SIZEOPT  = -Oas -Gs
64CFLAGS_UN = -A$(UNMODEL) $(CC_GENFLAGS) $(CC_SPEEDOPT)
65CFLAGS_FU = -A$(FUMODEL) $(CC_GENFLAGS) $(CC_SPEEDOPT) -DFUNZIP
66CFLAGS_SX = -A$(SXMODEL) $(CC_GENFLAGS) $(CC_SIZEOPT) -DSFX
67
68AS = masm
69ASFLAGS = -ml -D$(ASCPUFLAG) $(LOC)
70
71LD = Link	# mixed case to disable special handling by GNU Make
72# remove /e if you have LZEXE or PKLITE:
73LDFLAGS = /nologo/noi/e/st:0x0c00/farcall/packcode
74# "/farcall/packcode" are only useful for `large code' memory models
75# but should be a "no-op" for small code models.
76LDFLAGS2 = ,$*
77LDFLAGS2_UN = $(LDFLAGS2);
78LDFLAGS2_FU = $(LDFLAGS2);
79LDFLAGS2_SX = $(LDFLAGS2);
80
81OBJS1 = unzip.obj crc32.obj crypt.obj envargs.obj explode.obj
82OBJS2 = extract.obj fileio.obj globals.obj inflate.obj list.obj match.obj
83OBJS3 = process.obj ttyio.obj unreduce.obj unshrink.obj zipinfo.obj
84OBJS4 = msdos.obj $(ASMOBJS)
85OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4)
86
87OBJX1 = unzipsfx.obj crc32x.obj cryptx.obj extractx.obj fileiox.obj
88OBJX2 = globalsx.obj inflatex.obj matchx.obj processx.obj ttyiox.obj
89OBJX3 = msdosx.obj $(ASMOBJX)
90OBJX = $(OBJX1) $(OBJX2) $(OBJX3)
91
92OBJF = funzip.obj crc32_.obj crypt_.obj globals_.obj inflate_.obj ttyio_.obj \
93	msdos_.obj $(ASMOBJF)
94
95UNZIP_H = unzip.h unzpriv.h globals.h msdos/doscfg.h
96
97
98default:        unzip.exe funzip.exe unzipsfx.exe
99
100#clean:
101# As long as the brain damaged old ``Make'' utility from MSC 5.1 and earlier
102# (NMAKE from MSC 6.0 + would work !) remains supported, a "clean" target
103# cannot be inserted !!
104
105# pattern rules for implicit dependencies:
106.asm.obj:
107	$(AS) $(ASFLAGS) -D$(ASUNMODEL) $<, $@;
108
109.c.obj:
110	$(CC) -c $(CFLAGS_UN) $*.c
111
112# individual dependencies and action rules:
113crc_i86.obj:    msdos/crc_i86.asm
114	$(AS) $(ASFLAGS) -D$(ASUNMODEL) msdos/crc_i86.asm, $@;
115
116crc_i86_.obj:   msdos/crc_i86.asm
117	$(AS) $(ASFLAGS) -D$(ASFUMODEL) msdos/crc_i86.asm, $@;
118
119crc_i86x.obj:   msdos/crc_i86.asm
120	$(AS) $(ASFLAGS) -D$(ASSXMODEL) msdos/crc_i86.asm, $@;
121
122crc32.obj:      crc32.c $(UNZIP_H) zip.h crc32.h
123
124crc32_.obj:     crc32.c $(UNZIP_H) zip.h crc32.h
125	$(CC) -c $(CFLAGS_FU) -Focrc32_.obj crc32.c
126
127crc32x.obj:     crc32.c $(UNZIP_H) zip.h crc32.h
128	$(CC) -c $(CFLAGS_SX) -Focrc32x.obj crc32.c
129
130crypt.obj:      crypt.c $(UNZIP_H) crypt.h crc32.h ttyio.h zip.h
131
132crypt_.obj:     crypt.c $(UNZIP_H) crypt.h crc32.h ttyio.h zip.h
133	$(CC) -c $(CFLAGS_FU) -Focrypt_.obj crypt.c
134
135cryptx.obj:     crypt.c $(UNZIP_H) crypt.h crc32.h ttyio.h zip.h
136	$(CC) -c $(CFLAGS_SX) -Focryptx.obj crypt.c
137
138envargs.obj:    envargs.c $(UNZIP_H)
139
140explode.obj:    explode.c $(UNZIP_H)
141
142extract.obj:    extract.c $(UNZIP_H) crc32.h crypt.h
143
144extractx.obj:   extract.c $(UNZIP_H) crc32.h crypt.h
145	$(CC) -c $(CFLAGS_SX) -Foextractx.obj extract.c
146
147fileio.obj:     fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
148
149fileiox.obj:    fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
150	$(CC) -c $(CFLAGS_SX) -Fofileiox.obj fileio.c
151
152funzip.obj:     funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h
153	$(CC) -c $(CFLAGS_FU) funzip.c
154
155globals.obj:    globals.c $(UNZIP_H)
156
157globals_.obj:   globals.c $(UNZIP_H)
158	$(CC) -c $(CFLAGS_FU) -Foglobals_.obj globals.c
159
160globalsx.obj:   globals.c $(UNZIP_H)
161	$(CC) -c $(CFLAGS_SX) -Foglobalsx.obj globals.c
162
163inflate.obj:    inflate.c inflate.h $(UNZIP_H)
164
165inflate_.obj:   inflate.c inflate.h $(UNZIP_H) crypt.h
166	$(CC) -c $(CFLAGS_FU) -Foinflate_.obj inflate.c
167
168inflatex.obj:   inflate.c inflate.h $(UNZIP_H) crypt.h
169	$(CC) -c $(CFLAGS_SX) -Foinflatex.obj inflate.c
170
171list.obj:       list.c $(UNZIP_H)
172
173match.obj:      match.c $(UNZIP_H)
174
175matchx.obj:     match.c $(UNZIP_H)
176	$(CC) -c $(CFLAGS_SX) -Fomatchx.obj match.c
177
178msdos.obj:      msdos/msdos.c $(UNZIP_H)
179	$(CC) -c $(CFLAGS_UN) msdos/msdos.c
180
181msdos_.obj:     msdos/msdos.c $(UNZIP_H)
182	$(CC) -c $(CFLAGS_FU) -Fomsdos_.obj msdos/msdos.c
183
184msdosx.obj:     msdos/msdos.c $(UNZIP_H)
185	$(CC) -c $(CFLAGS_SX) -Fomsdosx.obj msdos/msdos.c
186
187process.obj:    process.c $(UNZIP_H) crc32.h
188
189processx.obj:   process.c $(UNZIP_H) crc32.h
190	$(CC) -c $(CFLAGS_SX) -Foprocessx.obj process.c
191
192ttyio.obj:      ttyio.c $(UNZIP_H) crypt.h ttyio.h zip.h
193
194ttyio_.obj:     ttyio.c $(UNZIP_H) crypt.h ttyio.h zip.h
195	$(CC) -c $(CFLAGS_FU) -Fottyio_.obj ttyio.c
196
197ttyiox.obj:     ttyio.c $(UNZIP_H) crypt.h ttyio.h zip.h
198	$(CC) -c $(CFLAGS_SX) -Fottyiox.obj ttyio.c
199
200unreduce.obj:   unreduce.c $(UNZIP_H)
201
202unshrink.obj:   unshrink.c $(UNZIP_H)
203
204unzip.obj:      unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
205
206unzipsfx.obj:   unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
207	$(CC) -c $(CFLAGS_SX) -Founzipsfx.obj unzip.c
208
209zipinfo.obj:    zipinfo.c $(UNZIP_H)
210
211
212# MS make:
213# -------
214unzip.exe:      $(OBJS)
215	echo $(OBJS1)+ > unzip.rsp
216	echo $(OBJS2)+ >> unzip.rsp
217	echo $(OBJS3)+ >> unzip.rsp
218	echo $(OBJS4) >> unzip.rsp
219	echo $(LDFLAGS2_UN) >> unzip.rsp
220	$(LD) $(LDFLAGS) @unzip.rsp
221	del unzip.rsp
222	$(STRIP) unzip.exe
223
224unzipsfx.exe:   $(OBJX)
225	echo $(OBJX1)+ > unzipsfx.rsp
226	echo $(OBJX2)+ >> unzipsfx.rsp
227	echo $(OBJX3) >> unzipsfx.rsp
228	echo $(LDFLAGS2_UN) >> unzipsfx.rsp
229	$(LD) $(LDFLAGS) @unzipsfx.rsp
230	del unzipsfx.rsp
231	$(STRIP) unzipsfx.exe
232
233funzip.exe:     $(OBJF)
234	echo $(OBJF) > funzip.rsp
235	echo $(LDFLAGS2_FU) >> funzip.rsp
236	$(LD) $(LDFLAGS) @funzip.rsp
237	del funzip.rsp
238	$(STRIP) funzip.exe
239
240# better makes which know how to deal with 128-char limit on command line:
241# -----------------------------------------------------------------------
242#unzip.exe:      $(OBJS)
243#	$(LD) $(LDFLAGS) $(OBJS) $(LDFLAGS2)
244#	$(STRIP) unzip.exe
245#
246#unzipsfx.exe:   $(OBJX)
247#	$(LD) $(LDFLAGS) $(OBJX) $(LDFLAGS2)
248#	$(STRIP) unzipsfx.exe
249#
250#funzip.exe:     $(OBJF)
251#	$(LD) $(LDFLAGS) $(OBJF) $(LDFLAGS2_FU)
252#	$(STRIP) funzip.exe
253