1# Makefile for UnZip, fUnZip and UnZipSFX
2# for emx 0.9d + rsxnt 1.42 / gcc under WIN32. Derived from makefile.os2
3# By E-Yen Tan and Christian Spieler. Last updated 25 December 2006.
4#
5# This makefile should work fine with GNU make and hopefully some others.
6# Tested with Spieler's special GNU make 3.74 gnuish 16-bit version.
7#
8# If make does not support long command-line passing to gcc, the link step
9# will fail. In this case, you have to edit the link commands to use the
10# commented-out alternative that creates a link response file "by hand".
11
12#ifdef NOASM
13#AS_FLAGS =
14#else
15AS_FLAGS = -DASM_CRC
16#endif
17
18CP=copy
19RM=del
20
21CC=gcc -Zwin32 -I.
22CC_OSIZ=-O1
23CC_OTIM=-O2 -mpentium
24CC_OPTS=-Wall -DWIN32 $(AS_FLAGS) $(LOCAL_UNZIP)
25CFLAGS=$(CC_OTIM) $(CC_OPTS)
26CFLAGSX=$(CC_OSIZ) $(CC_OPTS) -DSFX
27CFLAGSF=$(CC_OTIM) $(CC_OPTS) -DFUNZIP
28DLLFLAG=
29AS=gcc
30ASFLAGS=-Di386
31LDFLAGS=-Zsys -o ./
32LDFLAGS2=-ladvapi32 -Zsmall-conv -s
33OUT=-o
34OBJ=.o
35
36#ifdef NOASM
37#CRCA_O=
38#else
39CRCA_O=crc_gcc
40#endif
41OBJUS=win32$(OBJ) nt$(OBJ)
42OBJXS=win32_$(OBJ) nt_$(OBJ)
43OBJFS=win32f$(OBJ)
44OSDEP_H=win32/w32cfg.h
45
46
47# default settings for target dependent macros:
48DIRSEP = /
49AS_DIRSEP = /
50
51OBJU1 = unzip$(OBJ) crc32$(OBJ) $(CRCA_O) crypt$(OBJ) envargs$(OBJ)
52OBJU2 = explode$(OBJ) extract$(OBJ) fileio$(OBJ) globals$(OBJ)
53OBJU3 = inflate$(OBJ) list$(OBJ) match$(OBJ) process$(OBJ) ttyio$(OBJ)
54OBJU4 = ubz2err$(OBJ) unreduce$(OBJ) unshrink$(OBJ) zipinfo$(OBJ)
55OBJU  = $(OBJU1) $(OBJU2) $(OBJU3) $(OBJU4) $(OBJUS)
56OBJX1 = unzipsf_$(OBJ) crc32_$(OBJ) $(CRCA_O) crypt_$(OBJ)
57OBJX2 = extract_$(OBJ) fileio_$(OBJ) globals_$(OBJ) inflate_$(OBJ)
58OBJX3 = match_$(OBJ) process_$(OBJ) ttyio_$(OBJ) ubz2err_$(OBJ)
59OBJX  = $(OBJX1) $(OBJX2) $(OBJX3) $(OBJXS)
60OBJF  = funzip$(OBJ) crc32f$(OBJ) $(CRCA_O) cryptf$(OBJ) inflatef$(OBJ) \
61	globalsf$(OBJ) ttyiof$(OBJ) $(OBJFS)
62
63UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H)
64
65# rules
66
67.SUFFIXES:	.c $(OBJ)
68
69.c$(OBJ):
70	$(CC) -c $(CFLAGS) $(DLLFLAG) $(OUT)$@ $<
71
72# targets
73
74all:	unzip.exe funzip.exe unzipsfx.exe
75
76# This next bit is nasty, but is needed to overcome the MS-DOS command
77# line limit as response files for emx's gcc seem to only work if each
78# file is on a different line. DJGPP doesn't do this (if you are at all
79# interested).
80
81unzip.exe: $(OBJU)
82#	@ echo off
83#	-@ $(RM) unzip.rsp
84#	@ for %f in ($(OBJU1)) do echo %f >> unzip.rsp
85#	@ for %f in ($(OBJU2)) do echo %f >> unzip.rsp
86#	@ for %f in ($(OBJU3)) do echo %f >> unzip.rsp
87#	@ for %f in ($(OBJU4) $(OBJUS)) do echo %f >> unzip.rsp
88#	$(CC) $(LDFLAGS)$@ $(DEF) @unzip.rsp $(LDFLAGS2)
89	$(CC) $(LDFLAGS)$@ $(DEF) $(OBJU) $(LDFLAGS2)
90#	@ $(RM) unzip.rsp
91
92funzip.exe: $(OBJF)
93	$(CC) $(LDFLAGS)$@ $(DEF) $(OBJF) $(LDFLAGS2)
94
95unzipsfx.exe:	$(OBJX)
96#	@ echo off
97#	-@ $(RM) unzipsfx.rsp
98#	@ for %f in ($(OBJX1)) do echo %f >> unzipsfx.rsp
99#	@ for %f in ($(OBJX2)) do echo %f >> unzipsfx.rsp
100#	@ for %f in ($(OBJX3)) do echo %f >> unzipsfx.rsp
101#	@ for %f in ($(OBJXS)) do echo %f >> unzipsfx.rsp
102#	$(CC) $(LDFLAGS)$@ $(DEF) @unzipsfx.rsp $(LDFLAGS2)
103	$(CC) $(LDFLAGS)$@ $(DEF) $(OBJX) $(LDFLAGS2)
104#	@ $(RM) unzipsfx.rsp
105
106uzexampl.exe:	uzexampl$(OBJ)
107	$(CC) $(LDFLAGS)$@ $(DEF) uzexampl$(OBJ) -lversion $(LDFLAGS2)
108
109# dependencies
110
111apihelp$(OBJ):	apihelp.c $(UNZIP_H) unzvers.h
112crc32$(OBJ):	crc32.c $(UNZIP_H) zip.h crc32.h
113envargs$(OBJ):	envargs.c $(UNZIP_H)
114explode$(OBJ):	explode.c $(UNZIP_H)
115extract$(OBJ):	extract.c $(UNZIP_H) crc32.h crypt.h
116fileio$(OBJ):	fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
117globals$(OBJ):	globals.c $(UNZIP_H)
118inflate$(OBJ):	inflate.c $(UNZIP_H)
119list$(OBJ):	list.c $(UNZIP_H)
120match$(OBJ):	match.c $(UNZIP_H)
121process$(OBJ):	process.c $(UNZIP_H) crc32.h
122ttyio$(OBJ):	ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
123ubz2err$(OBJ):	ubz2err.c $(UNZIP_H)
124unreduce$(OBJ):	unreduce.c $(UNZIP_H)
125unshrink$(OBJ):	unshrink.c $(UNZIP_H)
126unzip$(OBJ):	unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
127api$(OBJ):	api.c $(UNZIP_H) unzvers.h
128zipinfo$(OBJ):	zipinfo.c $(UNZIP_H)
129
130funzip$(OBJ):	funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h	# funzip only
131	$(CC) -c $(CFLAGS) $(OUT)$@ funzip.c
132
133unzipstb$(OBJ):	unzipstb.c					# DLL version
134	$(CC) -c $(CFLAGS) $(OUT)$@ unzipstb.c
135
136uzexampl$(OBJ):	windll/uzexampl.c windll/uzexampl.h		# WINDLL example
137	$(CC) -c $(CFLAGS) $(OUT)$@ windll/uzexampl.c
138
139win32$(OBJ):	win32/win32.c $(UNZIP_H) win32/nt.h unzvers.h	# win32 only
140	$(CC) -c $(CFLAGS) $(OUT)$@ win32$(DIRSEP)win32.c
141
142win32f$(OBJ):	win32/win32.c $(UNZIP_H) win32/nt.h		# win32 funzip
143	$(CC) -c $(CFLAGSF) $(OUT)$@ win32$(DIRSEP)win32.c
144
145win32_$(OBJ):	win32/win32.c $(UNZIP_H) win32/nt.h		# win32 unzipsfx
146	$(CC) -c $(CFLAGSX) $(OUT)$@ win32$(DIRSEP)win32.c
147
148nt$(OBJ):	win32/nt.c $(UNZIP_H) win32/nt.h		# win32 only
149	$(CC) -c $(CFLAGS) $(OUT)$@ win32$(DIRSEP)nt.c
150
151nt_$(OBJ):	win32/nt.c $(UNZIP_H) win32/nt.h		# win32 only
152	$(CC) -c $(CFLAGSX) $(OUT)$@ win32$(DIRSEP)nt.c
153
154os2$(OBJ):	os2/os2.c $(UNZIP_H) unzvers.h			# OS/2 only
155	$(CC) -c $(CFLAGS) $(DLLFLAG) $(OUT)$@ os2$(DIRSEP)os2.c
156
157os2_$(OBJ):	os2/os2.c $(UNZIP_H)				# OS/2 unzipsfx
158	$(CC) -c $(CFLAGSX) $(OUT)$@ os2$(DIRSEP)os2.c
159
160os2acl$(OBJ):	os2/os2acl.c $(UNZIP_H) unzvers.h		# OS/2 only
161	$(CC) -c $(CFLAGS) $(DLLFLAG) $(OUT)$@ os2$(DIRSEP)os2acl.c
162
163rexxhelp$(OBJ):	os2/rexxhelp.c					# OS/2 DLL only
164	$(CC) -c $(CFLAGS) $(DLLFLAG) $(OUT)$@ os2$(DIRSEP)rexxhelp.c
165
166rexxapi$(OBJ):	os2/rexxapi.c					# OS/2 DLL only
167	$(CC) -c $(CFLAGS) $(DLLFLAG) $(OUT)$@ os2$(DIRSEP)rexxapi.c
168
169crc_i86$(OBJ):	msdos/crc_i86.asm				# 16bit only
170	$(AS) $(ASFLAGS) msdos$(AS_DIRSEP)crc_i86.asm $(ASEOL)
171
172crc_i386$(OBJ):	win32/crc_i386.asm				# 32bit, MASM
173	$(AS) $(ASFLAGS) win32$(AS_DIRSEP)crc_i386.asm $(ASEOL)
174
175crc_gcc$(OBJ):	crc_i386.S					# 32bit, GNU AS
176	$(AS) $(ASFLAGS) -x assembler-with-cpp -c -o $@ crc_i386.S
177
178crypt$(OBJ):	crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
179	$(CC) -c $(CFLAGS) $(DLLFLAG) $(OUT)$@ crypt.c
180
181# funzip compilation section
182cryptf$(OBJ):	crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
183	$(CC) -c $(CFLAGSF) $(OUT)$@ crypt.c
184
185crc32f$(OBJ):	crc32.c $(UNZIP_H) zip.h crc32.h
186	$(CC) -c $(CFLAGSF) $(OUT)$@ crc32.c
187
188globalsf$(OBJ):	globals.c $(UNZIP_H)
189	$(CC) -c $(CFLAGSF) $(OUT)$@ globals.c
190
191inflatef$(OBJ):	inflate.c inflate.h $(UNZIP_H) crypt.h
192	$(CC) -c $(CFLAGSF) $(OUT)$@ inflate.c
193
194ttyiof$(OBJ):	ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
195	$(CC) -c $(CFLAGSF) $(OUT)$@ ttyio.c
196
197# unzipsfx compilation section
198crc32_$(OBJ):	crc32.c $(UNZIP_H) zip.h crc32.h
199	$(CC) -c $(CFLAGSX) $(OUT)$@ crc32.c
200
201crypt_$(OBJ):	crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
202	$(CC) -c $(CFLAGSX) $(OUT)$@ crypt.c
203
204extract_$(OBJ):	extract.c $(UNZIP_H) crc32.h crypt.h
205	$(CC) -c $(CFLAGSX) $(OUT)$@ extract.c
206
207fileio_$(OBJ):	fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
208	$(CC) -c $(CFLAGSX) $(OUT)$@ fileio.c
209
210globals_$(OBJ):	globals.c $(UNZIP_H)
211	$(CC) -c $(CFLAGSX) $(OUT)$@ globals.c
212
213inflate_$(OBJ):	inflate.c inflate.h $(UNZIP_H) crypt.h
214	$(CC) -c $(CFLAGSX) $(OUT)$@ inflate.c
215
216match_$(OBJ):	match.c $(UNZIP_H)
217	$(CC) -c $(CFLAGSX) $(OUT)$@ match.c
218
219process_$(OBJ):	process.c $(UNZIP_H) crc32.h
220	$(CC) -c $(CFLAGSX) $(OUT)$@ process.c
221
222ttyio_$(OBJ):	ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
223	$(CC) -c $(CFLAGSX) $(OUT)$@ ttyio.c
224
225ubz2err_$(OBJ):	ubz2err.c $(UNZIP_H)
226	$(CC) -c $(CFLAGSX) $(OUT)$@ ubz2err.c
227
228unzipsf_$(OBJ):	unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
229	$(CC) -c $(CFLAGSX) $(OUT)$@ unzip.c
230