1# Makefile for UnZip, fUnZip and UnZipSFX
2# for emx 0.9c / gcc under MS-DOS. Derived from makefile.os2
3# By E-Yen Tan (with mods by Christian Spieler).
4# Last updated 25 December 2006 (Christian Spieler).
5#
6# This makefile should work fine with GNU make and hopefully some others.
7# Tested with GNU make 3.71 gnuish 16-bit and djgpp 32-bit versions.
8
9#ifdef NOASM
10#AS_FLAGS =
11#else
12AS_FLAGS = -DASM_CRC
13#endif
14
15CP=copy
16RM=del
17
18CC=gcc -O -I. -m486
19
20# Version 5.1 of the RSX extender provides long file name support under
21# Windows 95. If you don't have Windows 95 or use a version of RSX prior
22# to 5.1 (or simply don't want LFN support) remove -DUSE_VFAT from CFLAGS.
23# Note that if you have a version of RSX prior to 5.1, you can still compile
24# with USE_VFAT enabled and upgrade RSX.EXE at a later stage.
25#
26# If you enable USE_VFAT then long file names under plain DOS will simply be
27# truncated to 8.3 format without mapping. See doscfg.h for details.
28#
29CFLAGS=-Wall -DMSDOS $(AS_FLAGS) $(LOCAL_UNZIP) -DUSE_VFAT
30NFLAGS=
31DLLFLAG=
32AS=gcc
33ASFLAGS=-Di386
34LDFLAGS=-o ./
35LDFLAGS2=-Zsmall-conv -s
36OUT=-o
37OBJ=.o
38
39#ifdef NOASM
40#CRCA_O=
41#else
42CRCA_O=crc_gcc$(OBJ)
43#endif
44OBJUS=msdos$(OBJ)
45OBJXS=msdos_$(OBJ)
46OSDEP_H=msdos/doscfg.h
47
48
49# default settings for target dependent macros:
50DIRSEP = /
51AS_DIRSEP = /
52
53OBJU1 = unzip$(OBJ) crc32$(OBJ) $(CRCA_O) crypt$(OBJ) envargs$(OBJ)
54OBJU2 = explode$(OBJ) extract$(OBJ) fileio$(OBJ) globals$(OBJ)
55OBJU3 = inflate$(OBJ) list$(OBJ) match$(OBJ) process$(OBJ) ttyio$(OBJ)
56OBJU4 = ubz2err$(OBJ) unreduce$(OBJ) unshrink$(OBJ) zipinfo$(OBJ)
57OBJU  = $(OBJU1) $(OBJU2) $(OBJU3) $(OBJU4) $(OBJUS)
58OBJX1 = unzipsf_$(OBJ) crc32_$(OBJ) $(CRCA_O) crypt_$(OBJ)
59OBJX2 = extract_$(OBJ) fileio_$(OBJ) globals_$(OBJ) inflate_$(OBJ)
60OBJX3 = match_$(OBJ) process_$(OBJ) ttyio_$(OBJ) ubz2err_$(OBJ)
61OBJX  = $(OBJX1) $(OBJX2) $(OBJX3) $(OBJXS)
62OBJF  = funzip$(OBJ) crc32f$(OBJ) $(CRCA_O) cryptf$(OBJ) inflatef$(OBJ) \
63	globalsf$(OBJ) ttyiof$(OBJ)
64
65UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H)
66
67# rules
68
69.SUFFIXES:	.c $(OBJ)
70
71.c$(OBJ):
72	$(CC) -c $(CFLAGS) $(DLLFLAG) $(OUT)$@ $<
73
74# targets
75
76all:	unzip.exe funzip.exe unzipsfx.exe
77
78# This next bit is nasty, but is needed to overcome the MS-DOS command
79# line limit as response files for emx's gcc seem to only work if each
80# file is on a different line. DJGPP doesn't do this (if you are at all
81# interested).
82
83unzip.exe: $(OBJU)
84	@ echo off
85#	-@ $(RM) unzip.rsp
86#	@ for %f in ($(OBJU1)) do echo %f >> unzip.rsp
87#	@ for %f in ($(OBJU2)) do echo %f >> unzip.rsp
88#	@ for %f in ($(OBJU3)) do echo %f >> unzip.rsp
89#	@ for %f in ($(OBJU4) $(OBJUS)) do echo %f >> unzip.rsp
90	@ echo unzip$(OBJ) > unzip.rsp
91	@ echo crc32$(OBJ)  >> unzip.rsp
92	@ if not "$(CRCA_O)"=="" echo $(CRCA_O)  >> unzip.rsp
93	@ echo crypt$(OBJ)  >> unzip.rsp
94	@ echo envargs$(OBJ)  >> unzip.rsp
95	@ echo explode$(OBJ)  >> unzip.rsp
96	@ echo extract$(OBJ)  >> unzip.rsp
97	@ echo fileio$(OBJ)  >> unzip.rsp
98	@ echo globals$(OBJ)  >> unzip.rsp
99	@ echo inflate$(OBJ)  >> unzip.rsp
100	@ echo list$(OBJ)  >> unzip.rsp
101	@ echo match$(OBJ)  >> unzip.rsp
102	@ echo process$(OBJ)  >> unzip.rsp
103	@ echo ttyio$(OBJ)  >> unzip.rsp
104	@ echo ubz2err$(OBJ)  >> unzip.rsp
105	@ echo unreduce$(OBJ)  >> unzip.rsp
106	@ echo unshrink$(OBJ)  >> unzip.rsp
107	@ echo zipinfo$(OBJ)  >> unzip.rsp
108	@ echo msdos$(OBJ)  >> unzip.rsp
109	$(CC) $(LDFLAGS)$@ $(DEF) @unzip.rsp $(LDFLAGS2)
110	@ $(RM) unzip.rsp
111
112funzip.exe: $(OBJF)
113	$(CC) $(LDFLAGS)$@ $(DEF) $(OBJF) $(LDFLAGS2)
114
115unzipsfx.exe:	$(OBJX)
116	@ echo off
117#	-@ $(RM) unzipsfx.rsp
118#	@ for %f in ($(OBJX1)) do echo %f >> unzipsfx.rsp
119#	@ for %f in ($(OBJX2)) do echo %f >> unzipsfx.rsp
120#	@ for %f in ($(OBJX3)) do echo %f >> unzipsfx.rsp
121#	@ for %f in ($(OBJXS)) do echo %f >> unzipsfx.rsp
122	@ echo unzipsf_$(OBJ) > unzipsfx.rsp
123	@ echo crc32_$(OBJ)  >> unzipsfx.rsp
124	@ if not "$(CRCA_O)"=="" echo $(CRCA_O)  >> unzipsfx.rsp
125	@ echo crypt_$(OBJ)  >> unzipsfx.rsp
126	@ echo extract_$(OBJ)  >> unzipsfx.rsp
127	@ echo fileio_$(OBJ)  >> unzipsfx.rsp
128	@ echo globals_$(OBJ)  >> unzipsfx.rsp
129	@ echo inflate_$(OBJ)  >> unzipsfx.rsp
130	@ echo match_$(OBJ)  >> unzipsfx.rsp
131	@ echo process_$(OBJ)  >> unzipsfx.rsp
132	@ echo ttyio_$(OBJ)  >> unzipsfx.rsp
133	@ echo ubz2err_$(OBJ)  >> unzipsfx.rsp
134	@ echo msdos_$(OBJ)  >> unzipsfx.rsp
135	$(CC) $(LDFLAGS)$@ $(DEF) @unzipsfx.rsp $(LDFLAGS2)
136	@ $(RM) unzipsfx.rsp
137
138# dependencies
139
140apihelp$(OBJ):	apihelp.c $(UNZIP_H) unzvers.h
141crc32$(OBJ):	crc32.c $(UNZIP_H) zip.h crc32.h
142envargs$(OBJ):	envargs.c $(UNZIP_H)
143explode$(OBJ):	explode.c $(UNZIP_H)
144extract$(OBJ):	extract.c $(UNZIP_H) crc32.h crypt.h
145fileio$(OBJ):	fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
146globals$(OBJ):	globals.c $(UNZIP_H)
147inflate$(OBJ):	inflate.c $(UNZIP_H)
148list$(OBJ):	list.c $(UNZIP_H)
149match$(OBJ):	match.c $(UNZIP_H)
150process$(OBJ):	process.c $(UNZIP_H) crc32.h
151ttyio$(OBJ):	ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
152ubz2err$(OBJ):	ubz2err.c $(UNZIP_H)
153unreduce$(OBJ):	unreduce.c $(UNZIP_H)
154unshrink$(OBJ):	unshrink.c $(UNZIP_H)
155unzip$(OBJ):	unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
156api$(OBJ):	api.c $(UNZIP_H) unzvers.h
157zipinfo$(OBJ):	zipinfo.c $(UNZIP_H)
158
159funzip$(OBJ):	funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h	# funzip only
160	$(CC) -c $(CFLAGS) $(OUT)$@ funzip.c
161
162msdos$(OBJ):	msdos/msdos.c $(UNZIP_H) unzvers.h		# DOS only
163	$(CC) -c $(CFLAGS) $(OUT)$@ msdos$(DIRSEP)msdos.c
164
165msdos_$(OBJ):	msdos/msdos.c $(UNZIP_H)			# DOS unzipsfx
166	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ msdos$(DIRSEP)msdos.c
167
168crc_gcc$(OBJ):	crc_i386.S					# 32bit, GNU AS
169	$(AS) $(ASFLAGS) -x assembler-with-cpp -c -o $@ crc_i386.S
170
171# NFLAGS are solely used as work-around for optimization bug in IBM C++ Set
172crypt$(OBJ):	crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
173	$(CC) -c $(CFLAGS) $(DLLFLAG) $(NFLAGS) $(OUT)$@ crypt.c
174
175# funzip specific section
176crc32f$(OBJ):	crc32.c $(UNZIP_H) zip.h crc32.h
177	$(CC) -c $(CFLAGS) -DFUNZIP $(OUT)$@ crc32.c
178
179cryptf$(OBJ):	crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
180	$(CC) -c $(CFLAGS) $(NFLAGS) -DFUNZIP $(OUT)$@ crypt.c
181
182globalsf$(OBJ):	globals.c $(UNZIP_H)
183	$(CC) -c $(CFLAGS) -DFUNZIP $(OUT)$@ globals.c
184
185inflatef$(OBJ):	inflate.c inflate.h $(UNZIP_H) crypt.h
186	$(CC) -c $(CFLAGS) -DFUNZIP $(OUT)$@ inflate.c
187
188ttyiof$(OBJ):	ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
189	$(CC) -c $(CFLAGS) $(NFLAGS) -DFUNZIP $(OUT)$@ ttyio.c
190
191# unzipsfx specific section
192crc32_$(OBJ):	crc32.c $(UNZIP_H) zip.h crc32.h
193	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ crc32.c
194
195crypt_$(OBJ):	crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
196	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ crypt.c
197
198extract_$(OBJ):	extract.c $(UNZIP_H) crc32.h crypt.h
199	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ extract.c
200
201fileio_$(OBJ):	fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
202	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ fileio.c
203
204globals_$(OBJ):	globals.c $(UNZIP_H)
205	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ globals.c
206
207inflate_$(OBJ):	inflate.c inflate.h $(UNZIP_H) crypt.h
208	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ inflate.c
209
210match_$(OBJ):	match.c $(UNZIP_H)
211	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ match.c
212
213process_$(OBJ):	process.c $(UNZIP_H) crc32.h
214	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ process.c
215
216ttyio_$(OBJ):	ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
217	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ ttyio.c
218
219ubz2err_$(OBJ):	ubz2err.c $(UNZIP_H)
220	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ ubz2err.c
221
222unzipsf_$(OBJ):	unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
223	$(CC) -c $(CFLAGS) -DSFX $(OUT)$@ unzip.c
224