1# Makefile for Zip, ZipCloak, ZipNote and ZipSplit
2# using emx 0.9c+rsxnt for Windows 95/98 and Windows NT and emx 0.9c for DOS.
3# By Kai-Uwe Rommel, Chr. Spieler, E-Yen Tan (and others).
4# Last updated 18th February 2007.
5#
6# Supported Make utilities:
7# - Microsoft/IBM nmake (e.g. from MSC 6.0 or newer)
8# - dmake 3.8 or higher
9# - GNU make, at least version 3.68 (GNUish 16-bit port, RSXNT Make 3.75,
10#   DJGPP v1.12 Make 3.71, some versions of DJGPP v2.x 32-bit Make;
11#   current DJGPP v2.01 Make 3.76.1 does NOT work)
12# - NOT watcom make
13# The "smart" Make utilities mentioned below are Christian Spieler's
14# enhanced version of GNUish 16-bit Make (3.74) and his adaption of these
15# GNU Make sources to EMX (32-bit).
16
17# Supported 32-bit C Compilers (created programs run under WinNT/Win95 only):
18# - GNU gcc (emx/rsxnt kit 0.9c or newer)
19
20# Supported Cross-Compilers for MS-DOS:
21# - GNU gcc (emx kit 0.9c or newer, 32-bit)
22
23# Supported Assemblers:
24# - GNU as with GNU gcc
25
26
27# To use, enter "make/nmake/dmake -f win32/makefile.emx"
28# (this makefile depends on its name being "win32/makefile.emx").
29
30# Add -DDYN_ALLOC to ASFLAGS if you have defined it in tailor.h or CFLAGS
31
32# Note: assembly language modules are really only supported for
33# GNU gcc 32-bit compilation.
34
35
36default:
37	@echo "Enter $(MAKE) -f win32/makefile.emx target"
38	@echo "where target is one of:"
39	@echo "   gcc gccso gccdyn gccdebug gcczl gccdos gccdoszl"
40	@echo "   -----------------------------------------------"
41	@echo "Or, specify a specific target for a partial build,"
42	@echo "This uses >gcc< setup (win32 statically linked binary)"
43
44# emx 0.9c, gcc, PE format, statically linked C runtime and rsxnt.dll
45gcc:	all
46
47# emx 0.9c, gcc, PE format, statically linked C runtime, standalone
48gccso:
49	$(MAKE) -f win32/makefile.emx all \
50	CC="gcc -Zwin32 -Zsys -O2 -m486 -Wall" \
51	CFLAGS="-DWIN32 -DASM_CRC" \
52	AS="gcc -Zwin32" \
53	ASFLAGS="-Di386" \
54	LDFLAGS="-o ./" \
55	LDFLAGS2="-ladvapi32 -s" \
56	OUT="-o" \
57	OBJ=".o" \
58	CRCA_O="crc_gcc.o" \
59	CRCAUO="crcgcc_.o" \
60	OBJA="matchgcc.o" \
61	DEF="win32/zip.def"
62
63# emx 0.9c, gcc, PE format, dynamically linked C runtime and rsxnt.dll
64gccdyn:
65	$(MAKE) -f win32/makefile.emx all \
66	CC="gcc -Zwin32 -Zcrtdll=crtrsxnt -O2 -m486 -Wall" \
67	CFLAGS="-DWIN32 -DASM_CRC" \
68	AS="gcc -Zwin32" \
69	ASFLAGS="-Di386" \
70	LDFLAGS="-o ./" \
71	LDFLAGS2="-ladvapi32 -s" \
72	OUT="-o" \
73	OBJ=".o" \
74	CRCA_O="crc_gcc.o" \
75	CRCAUO="crcgcc_.o" \
76	OBJA="matchgcc.o" \
77	DEF="win32/zip.def"
78
79# emx 0.9c, gcc, PE format, with debug info for gdb
80gccdebug:
81	$(MAKE) -f win32/makefile.emx all \
82	CC="gcc -Zwin32 -O2 -g -Wall" \
83	CFLAGS="-DWIN32 -DASM_CRC" \
84	AS="gcc -Zwin32" \
85	ASFLAGS="-Di386" \
86	LDFLAGS="-o ./" \
87	LDFLAGS2="-ladvapi32 -Zsmall-conv" \
88	OUT="-o" \
89	OBJ=".o" \
90	CRCA_O="crc_gcc.o" \
91	CRCAUO="crcgcc_.o" \
92	OBJA="matchgcc.o" \
93	DEF="win32/zip.def"
94
95# emx 0.9c, gcc, PE format,, statically linked zlib, C runtime, and rsxnt.dll
96gcczl:
97	$(MAKE) -f win32/makefile.emx all \
98	CC="gcc -Zwin32 -O2 -m486 -Wall" \
99	CFLAGS="-DWIN32 -DUSE_ZLIB" \
100	AS="gcc -Zwin32" \
101	ASFLAGS="-Di386 -DUSE_ZLIB" \
102	LDFLAGS="-o ./" \
103	LDFLAGS2="-L. -lzlib -ladvapi32 -s" \
104	OUT="-o" \
105	OBJ=".o" \
106	CRCA_O="" \
107	CRCAUO="" \
108	OBJA="" \
109	DEF="win32/zip.def"
110
111# emx 0.9c, gcc, a.out format, for MS-DOS
112gccdos:
113	$(MAKE) -f win32/makefile.emx all \
114	CC="gcc -O2 -m486 -Wall" \
115	CFLAGS="-DDOS -DMSDOS -DASM_CRC" \
116	AS="gcc" \
117	ASFLAGS="-Di386" \
118	LDFLAGS="-o ./" \
119	LDFLAGS2="-s -Zsmall-conv" \
120	OUT="-o" \
121	OBJ=".o" \
122	CRCA_O="crc_gcc.o" \
123	CRCAUO="crcgcc_.o" \
124	OBJA="matchgcc.o" \
125	OBJZS="msdos.o" \
126	OBJUS="msdos_.o" \
127	OSDEP_H="msdos/osdep.h" \
128	ZIPUP_H="msdos/zipup.h"
129
130# emx 0.9c, gcc, a.out format, for MS-DOS, using zlib
131gccdoszl:
132	$(MAKE) -f win32/makefile.emx all \
133	CC="gcc -O2 -m486 -Wall" \
134	CFLAGS="-DDOS -DMSDOS -DUSE_ZLIB" \
135	AS="gcc" \
136	ASFLAGS="-Di386 -DUSE_ZLIB" \
137	LDFLAGS="-o ./" \
138	LDFLAGS2="-L. -lzlib -s -Zsmall-conv" \
139	OUT="-o" \
140	OBJ=".o" \
141	CRCA_O="" \
142	CRCAUO="" \
143	OBJA="" \
144	OBJZS="msdos.o" \
145	OBJUS="msdos_.o" \
146	OSDEP_H="msdos/osdep.h" \
147	ZIPUP_H="msdos/zipup.h"
148
149# VPATH = .;win32
150
151# variables
152
153#default settings for target dependent macros:
154
155# the "gcc" (statically linked Win32 executables) target:
156CC=gcc -Zwin32 -O2 -m486 -Wall
157CFLAGS=-DWIN32 -DASM_CRC
158AS=gcc -Zwin32
159ASFLAGS=-Di386
160LDFLAGS=-o ./
161LDFLAGS2=-ladvapi32 -s -Zsmall-conv
162OUT=-o
163OBJ=.o
164CRCA_O=crc_gcc$(OBJ)
165CRCAUO=crcgcc_$(OBJ)
166OBJA=matchgcc$(OBJ)
167OSDEP_H=win32/osdep.h
168ZIPUP_H=win32/zipup.h
169DEF=win32/zip.def
170
171DIRSEP = /
172AS_DIRSEP = /
173RM = del
174LOCAL_OPTS = $(LOCAL_ZIP)
175CCFLAGS = $(CFLAGS) $(LOCAL_OPTS)
176
177
178OBJZ1 = zip$(OBJ) zipfile$(OBJ) zipup$(OBJ) fileio$(OBJ) util$(OBJ) \
179	crc32$(OBJ) $(CRCA_O)
180OBJZ2 = globals$(OBJ) deflate$(OBJ) trees$(OBJ) crypt$(OBJ) \
181	ttyio$(OBJ)
182OBJZS =	win32zip$(OBJ) win32$(OBJ) nt$(OBJ)
183OBJZ  = $(OBJZ1) $(OBJZ2) $(OBJZS) $(OBJA)
184
185OBJU1 = zipfile_$(OBJ) fileio_$(OBJ) util_$(OBJ) crc32_$(OBJ) $(CRCAUO) \
186	globals$(OBJ)
187OBJUS = win32_$(OBJ)
188OBJU  = $(OBJU1) $(OBJUS)
189
190OBJN  = zipnote$(OBJ) $(OBJU)
191OBJS  = zipsplit$(OBJ) $(OBJU)
192OBJC1 = zipcloak$(OBJ) crypt_$(OBJ) ttyio$(OBJ)
193OBJC  = $(OBJC1) $(OBJU)
194
195ZIP_H = zip.h ziperr.h tailor.h $(OSDEP_H)
196
197# rules
198
199.SUFFIXES: .c $(OBJ)
200
201.c$(OBJ):
202	$(CC) -c -I. $(CCFLAGS) $(OUT)$@ $<
203
204# targets
205
206all:	zip.exe zipnote.exe zipsplit.exe zipcloak.exe
207
208zip$(OBJ):	zip.c $(ZIP_H) revision.h crc32.h crypt.h ttyio.h
209zipfile$(OBJ):	zipfile.c $(ZIP_H) crc32.h
210zipup$(OBJ):	zipup.c $(ZIP_H) revision.h crc32.h crypt.h $(ZIPUP_H)
211fileio$(OBJ):	fileio.c $(ZIP_H) crc32.h
212util$(OBJ):	util.c $(ZIP_H)
213globals$(OBJ):	globals.c $(ZIP_H)
214deflate$(OBJ):	deflate.c $(ZIP_H)
215trees$(OBJ):	trees.c $(ZIP_H)
216crc32$(OBJ):	crc32.c $(ZIP_H) crc32.h
217crypt$(OBJ):	crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h
218ttyio$(OBJ):	ttyio.c $(ZIP_H) crypt.h ttyio.h
219
220msdos$(OBJ):	msdos/msdos.c $(ZIP_H)
221	$(CC) -c -I. $(CCFLAGS) msdos$(DIRSEP)msdos.c
222
223win32zip$(OBJ):	win32/win32zip.c $(ZIP_H) win32/win32zip.h win32/nt.h
224	$(CC) -c -I. $(CCFLAGS) win32$(DIRSEP)win32zip.c
225
226win32$(OBJ):	win32/win32.c $(ZIP_H) win32/win32zip.h
227	$(CC) -c -I. $(CCFLAGS) win32$(DIRSEP)win32.c
228
229nt$(OBJ):	win32/nt.c $(ZIP_H) win32/nt.h
230	$(CC) -c -I. $(CCFLAGS) win32$(DIRSEP)nt.c
231
232crc_gcc$(OBJ):	crc_i386.S					# 32bit, GNU AS
233	$(AS) $(ASFLAGS) -x assembler-with-cpp -c -o $@ crc_i386.S
234
235matchgcc$(OBJ):	match.S
236	$(AS) $(ASFLAGS) -x assembler-with-cpp -c -o $@ match.S
237
238zipcloak$(OBJ):	zipcloak.c $(ZIP_H) revision.h crypt.h ttyio.h
239zipnote$(OBJ):	zipnote.c $(ZIP_H) revision.h
240zipsplit$(OBJ): zipsplit.c $(ZIP_H) revision.h
241
242zipfile_$(OBJ):	zipfile.c $(ZIP_H) crc32.h
243	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ zipfile.c
244
245fileio_$(OBJ):	fileio.c $(ZIP_H) crc32.h
246	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ fileio.c
247
248util_$(OBJ):	util.c $(ZIP_H)
249	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ util.c
250
251crc32_$(OBJ):	crc32.c $(ZIP_H) crc32.h
252	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ crc32.c
253
254crypt_$(OBJ):	crypt.c $(ZIP_H) crypt.h crc32.h ttyio.h
255	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ crypt.c
256
257msdos_$(OBJ):	msdos/msdos.c $(ZIP_H)
258	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ msdos$(DIRSEP)msdos.c
259
260win32_$(OBJ):	win32/win32.c $(ZIP_H) win32/win32zip.h
261	$(CC) -c -I. $(CCFLAGS) -DUTIL $(OUT)$@ win32$(DIRSEP)win32.c
262
263crcgcc_$(OBJ):	crc_i386.S					# 32bit, GNU AS
264	$(AS) $(ASFLAGS) -DUTIL -x assembler-with-cpp -c -o $@ crc_i386.S
265
266zip.exe: $(OBJZ)
267# for DUMB make utilities, uncomment the following commands:
268	-@$(RM) zip.rsp
269	@for %%f in ($(OBJZ1)) do echo %%f >> zip.rsp
270	@for %%f in ($(OBJZ2)) do echo %%f >> zip.rsp
271	@for %%f in ($(OBJZS) $(OBJA)) do echo %%f >> zip.rsp
272	$(CC) $(LDFLAGS)$@ @zip.rsp $(LDFLAGS2)
273	@$(RM) zip.rsp
274# smart make utilities (like well done ports of GNU Make) can use this:
275#	$(CC) $(LDFLAGS)$@ $(OBJZ) $(LDFLAGS2)
276
277zipcloak.exe: $(OBJC)
278# for DUMB make utilities, uncomment the following commands:
279	-@$(RM) zipcloak.rsp
280	@for %%f in ($(OBJC1)) do echo %%f >> zipcloak.rsp
281	@for %%f in ($(OBJU1)) do echo %%f >> zipcloak.rsp
282	@for %%f in ($(OBJUS)) do echo %%f >> zipcloak.rsp
283	$(CC) $(LDFLAGS)$@ @zipcloak.rsp $(LDFLAGS2)
284	@$(RM) zipcloak.rsp
285# smart make utilities (like well done ports of GNU Make) can use this:
286#	$(CC) $(LDFLAGS)$@ $(OBJC) $(LDFLAGS2)
287
288zipnote.exe: $(OBJN)
289# for DUMB make utilities, uncomment the following commands:
290	-@$(RM) zipnote.rsp
291	@for %%f in ($(OBJN)) do echo %%f >> zipnote.rsp
292	$(CC) $(LDFLAGS)$@ @zipnote.rsp $(LDFLAGS2)
293	@$(RM) zipnote.rsp
294# smart make utilities (like well done ports of GNU Make) can use this:
295#	$(CC) $(LDFLAGS)$@ $(OBJN) $(LDFLAGS2)
296
297zipsplit.exe: $(OBJS)
298# for DUMB make utilities, uncomment the following commands:
299	-@$(RM) zipsplit.rsp
300	@for %%f in ($(OBJN)) do echo %%f >> zipsplit.rsp
301	$(CC) $(LDFLAGS)$@ @zipsplit.rsp $(LDFLAGS2)
302	@$(RM) zipsplit.rsp
303# smart make utilities (like well done ports of GNU Make) can use this:
304#	$(CC) $(LDFLAGS)$@ $(OBJS) $(LDFLAGS2)
305