1#==============================================================================
2# Makefile for UnZip, UnZipSFX and fUnZip:  Atari           ("real" makes only)
3# Version:  5.53                                               25 December 2006
4#==============================================================================
5
6
7# INSTRUCTIONS (such as they are):
8#
9# "make"	-- makes UnZip on a generic Atari
10#
11# CF are flags for the C compiler.  LF are flags for the loader.  LF2 are more
12# flags for the loader, if they need to be at the end of the line instead of at
13# the beginning (for example, some libraries).  FL and FL2 are the corre-
14# sponding flags for fUnZip.  LOCAL_UNZIP is an environment variable that can
15# be used to add default C flags to your compile without editing the Makefile
16# (e.g., -DDEBUG_STRUC, or -FPi87 on PCs using Microsoft C).
17#
18# Be sure to test your new UnZip (and UnZipSFX and fUnZip); successful compila-
19# tion does not always imply a working program.
20
21
22#####################
23# MACRO DEFINITIONS #
24#####################
25
26# Defaults most systems use (use LOCAL_UNZIP in environment to add flags,
27# such as -DDOSWILD).
28
29# UnZip flags
30CC = gcc#	try using "gcc" target rather than changing this (if you do,
31LD = $(CC)#	you MUST change LD, too--else "unresolved symbol:  ___main")
32LOC = $(LOCAL_UNZIP)
33CF = $(CFLAGS) $(LOC)
34LF = -o unzip$E
35LF2 = -s
36
37# UnZipSFX flags
38SL = -o unzipsfx$E
39SL2 = $(LF2)
40
41# fUnZip flags
42FL = -o funzip$E
43FL2 = $(LF2)
44
45# general-purpose stuff
46CP = ln -s
47LN = ln
48RM = rm -f
49CHMOD = chmod
50STRIP = strip
51E = .ttp
52O = .o
53M = atari
54SHELL = /bin/sh
55
56# object files
57OBJS1 = unzip$O crc32$O crypt$O envargs$O explode$O
58OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O
59OBJS3 = process$O ttyio$O ubz2err$O unreduce$O unshrink$O zipinfo$O
60OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O
61LOBJS = $(OBJS)
62OBJSDLL = $(OBJS) api$O
63OBJX = unzipsfx$O crc32$O crypt_$O extract_$O fileio_$O \
64	globals_$O inflate_$O match_$O process_$O ttyio_$O ubz2err_$O $M_$O
65LOBJX = $(OBJX)
66OBJF = funzip$O crc32$O cryptf$O globalsf$O inflatef$O ttyiof$O
67#OBJS_OS2 = $(OBJS1:.o=.obj) $(OBJS2:.o=.obj) os2.obj
68#OBJF_OS2 = $(OBJF:.o=.obj)
69
70UNZIP_H = unzip.h unzpriv.h globals.h
71
72# installation
73INSTALL = cp#	probably can change this to 'install' if you have it
74# on some systems, manext=l and MANDIR=/usr/man/man$(manext) may be appropriate
75manext = 1
76prefix = /usr/local
77BINDIR = $(prefix)/bin#			where to install executables
78MANDIR = $(prefix)/man/man$(manext)#	where to install man pages
79INSTALLEDBIN = $(BINDIR)/funzip$E $(BINDIR)/zipinfo$E $(BINDIR)/unzipsfx$E \
80	$(BINDIR)/unzip$E
81INSTALLEDMAN = $(MANDIR)/unzip.$(manext) $(MANDIR)/funzip.$(manext) \
82	$(MANDIR)/unzipsfx.$(manext) $(MANDIR)/zipinfo.$(manext)
83#
84UNZIPS = unzip$E funzip$E unzipsfx$E
85# this is a little ugly...well, no, it's a lot ugly:
86MANS = man/unzip.1 man/unzipsfx.1 man/zipinfo.1 man/funzip.1
87DOCS = unzip.txt unzipsfx.txt zipinfo.txt funzip.txt
88
89
90###############################################
91# BASIC COMPILE INSTRUCTIONS AND DEPENDENCIES #
92###############################################
93
94# this is for GNU make; comment out and notify zip-bugs if it causes errors
95.SUFFIXES:	.c .o .obj
96
97# yes, we should be able to use the $O macro to combine these two, but it
98# fails on some brain-damaged makes (e.g., AIX's)...no big deal
99.c.o:
100	$(CC) -c $(CF) $*.c
101
102.c.obj:
103	$(CC) -c $(CF) $*.c
104
105
106####################
107# DEFAULT HANDLING #
108####################
109
110
111all:		unzips
112unzips:		$(UNZIPS)
113docs:		$(DOCS)
114unzipsman:	unzips docs
115unzipsdocs:	unzips docs
116
117
118unzip$E:	$(OBJS)
119	$(LD) $(LF) $(LOBJS) $(LF2)
120
121unzipsfx$E:	$(OBJX)
122	$(LD) $(SL) $(LOBJX) $(SL2)
123
124funzip$E:	$(OBJF)
125	$(LD) $(FL) $(OBJF) $(FL2)
126
127
128crc32$O:	crc32.c $(UNZIP_H) zip.h crc32.h
129crypt$O:	crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
130envargs$O:	envargs.c $(UNZIP_H)
131explode$O:	explode.c $(UNZIP_H)
132extract$O:	extract.c $(UNZIP_H) crc32.h crypt.h
133fileio$O:	fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
134funzip$O:	funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h
135globals$O:	globals.c $(UNZIP_H)
136inflate$O:	inflate.c inflate.h $(UNZIP_H)
137list$O:		list.c $(UNZIP_H)
138match$O:	match.c $(UNZIP_H)
139process$O:	process.c $(UNZIP_H) crc32.h
140ttyio$O:	ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
141ubz2err$O:	ubz2err.c $(UNZIP_H)
142unreduce$O:	unreduce.c $(UNZIP_H)
143unshrink$O:	unshrink.c $(UNZIP_H)
144unzip$O:	unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
145zipinfo$O:	zipinfo.c $(UNZIP_H)
146
147# unzipsfx only
148crypt_$O:	crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
149	$(CP) crypt.c crypt_.c
150	$(CC) -c $(CF) -DSFX crypt_.c
151	$(RM) crypt_.c
152
153extract_$O:	extract.c $(UNZIP_H) crc32.h crypt.h
154	$(CP) extract.c extract_.c
155	$(CC) -c $(CF) -DSFX extract_.c
156	$(RM) extract_.c
157
158fileio_$O:	fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
159	$(CP) fileio.c fileio_.c
160	$(CC) -c $(CF) -DSFX fileio_.c
161	$(RM) fileio_.c
162
163globals_$O:	globals.c $(UNZIP_H)
164	$(CP) globals.c globals_.c
165	$(CC) -c $(CF) -DSFX globals_.c
166	$(RM) globals_.c
167
168inflate_$O:	inflate.c inflate.h $(UNZIP_H) crypt.h
169	$(CP) inflate.c inflate_.c
170	$(CC) -c $(CF) -DSFX inflate_.c
171	$(RM) inflate_.c
172
173match_$O:	match.c $(UNZIP_H)
174	$(CP) match.c match_.c
175	$(CC) -c $(CF) -DSFX match_.c
176	$(RM) match_.c
177
178process_$O:	process.c $(UNZIP_H) crc32.h
179	$(CP) process.c process_.c
180	$(CC) -c $(CF) -DSFX process_.c
181	$(RM) process_.c
182
183ttyio_$O:	ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
184	$(CP) ttyio.c ttyio_.c
185	$(CC) -c $(CF) -DSFX ttyio_.c
186	$(RM) ttyio_.c
187
188ubz2err$O:	ubz2err.c $(UNZIP_H)
189	$(CP) ubz2err.c ubz2err_.c
190	$(CC) -c $(CF) -DSFX ubz2err_.c
191	$(RM) ubz2err_.c
192
193unzipsfx$O:	unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
194	$(CP) unzip.c unzipsfx.c
195	$(CC) -c $(CF) -DSFX unzipsfx.c
196	$(RM) unzipsfx.c
197
198
199# funzip only
200cryptf$O:	crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
201	$(CP) crypt.c cryptf.c
202	$(CC) -c $(CF) -DFUNZIP cryptf.c
203	$(RM) cryptf.c
204
205globalsf$O:	globals.c $(UNZIP_H)
206	$(CP) globals.c globalsf.c
207	$(CC) -c $(CF) -DFUNZIP globalsf.c
208	$(RM) globalsf.c
209
210inflatef$O:	inflate.c inflate.h $(UNZIP_H) crypt.h
211	$(CP) inflate.c inflatef.c
212	$(CC) -c $(CF) -DFUNZIP inflatef.c
213	$(RM) inflatef.c
214
215ttyiof$O:	ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
216	$(CP) ttyio.c ttyiof.c
217	$(CC) -c $(CF) -DFUNZIP ttyiof.c
218	$(RM) ttyiof.c
219
220
221# system-specific code
222atari$O:	atari/atari.c $(UNZIP_H)
223	$(CC) -c $(CF) atari/atari.c
224
225atari_$O:	atari/atari.c $(UNZIP_H)
226	$(CP) atari/atari.c atari_.c
227	$(CC) -c $(CF) -DSFX atari_.c
228	$(RM) atari_.c
229
230
231# this really only works for Unix targets, unless specify E and O on cmd line
232clean:
233	@echo ""
234	@echo '         This is a Unix-specific target.  (Just so you know.)'
235	@echo ""
236	rm -f $(OBJS) api$O apihelp$O unzipstb$O $(OBJF) $(OBJX) $(UNZIPS)
237
238install:	$(UNZIPS) $(MANS)
239	$(INSTALL) $(UNZIPS) $(BINDIR)
240	$(RM) $(BINDIR)/zipinfo$E
241	$(LN) $(BINDIR)/unzip$E $(BINDIR)/zipinfo$E
242	$(INSTALL) man/unzip.1 $(MANDIR)/unzip.$(manext)
243	$(INSTALL) man/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
244	$(INSTALL) man/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
245	$(INSTALL) man/funzip.1 $(MANDIR)/funzip.$(manext)
246	$(CHMOD) 755  $(INSTALLEDBIN)
247	$(CHMOD) 644  $(INSTALLEDMAN)
248
249# alternatively, could use zip method:  -cd $(BINDIR); rm -f $(UNZIPS)  [etc.]
250uninstall:
251	rm -f $(INSTALLEDBIN) $(INSTALLEDMAN)
252
253
254TESTZIP = testmake.zip	# the test zipfile
255
256# test some basic features of the build
257test:		check
258
259check:	unzips
260	@echo '  This is a Unix-specific target.  (Just so you know.)'
261	if test ! -f $(TESTZIP); then \
262		echo "  error:  can't find test file $(TESTZIP)"; exit 1; fi
263#
264	echo "  testing extraction"
265	./unzip -b $(TESTZIP) testmake.zipinfo
266	if test $? ; then \
267	    echo "  error:  file extraction from $(TESTZIP) failed"; exit 1; fi
268#
269	echo '  testing zipinfo (unzip -Z)'
270	./unzip -Z $(TESTZIP) > testmake.unzip-Z
271	if diff testmake.unzip-Z testmake.zipinfo; then ;; else \
272	    echo '  error:  zipinfo output doesn't match stored version'; fi
273	$(RM) testmake.unzip-Z testmake.zipinfo
274#
275	echo '  testing unzip -d exdir option'
276	./unzip -b $(TESTZIP) -d testun
277	cat testun/notes
278#
279	echo '  testing unzip -o and funzip (ignore funzip warning)'
280	./unzip -boq $(TESTZIP) notes -d testun
281	./funzip < $(TESTZIP) > testun/notes2
282	if diff testun/notes testun/notes2; then ;; else \
283	    echo 'error:  funzip output disagrees with unzip'; fi
284#
285	echo '  testing unzipsfx (self-extractor)'
286	cat unzipsfx $(TESTZIP) > testsfx
287	$(CHMOD) 0700 testsfx
288	./testsfx -b notes
289	if diff notes testun/notes; then ;; else \
290	    echo '  error:  unzipsfx file disagrees with unzip'; fi
291	$(RM) testsfx notes testun/notes testun/notes2
292	rmdir testun
293#
294	echo '  testing complete.'
295
296
297################################
298# INDIVIDUAL MACHINE MAKERULES #
299################################
300
301# these are left over for backward compatibility/convenience
302
303generic:	unzips
304atari:		unzips
305