1 ######################################################################
3 # Makefile for Info-ZIP's unzip, unzipsfx, and funzip on BeOS
5 # Copyright (c) 1998-2006 Info-ZIP
6 # Chris Herborth (chrish@qnx.com)
8 # This is the new New and Improved Makefile for BeOS; it will:
10 # 1) automatically detect your platform (PowerPC or x86) if none is
11 # specified; the default compiler is CodeWarrior for PowerPC, or
14 # 2) let you cross-compile for the other platform (PowerPC or x86), in
17 # 3) let you use Metrowerks CodeWarrior (default) or GNU C to build with
18 # for either platfor, in theory
20 # To choose a specific architecture, define the ARCH environment
21 # variable on the make command-line:
23 # ARCH=what make -f beos/Makefile
25 # where "what" can be "powerpc" or "x86".
27 # To choose a specific compiler, define the CC environment variable on
28 # the make command-line:
30 # CC=compiler make -f beos/Makefile
32 # where "compiler" can be "mwcc" or "x86".
34 # Of course, you can combine these two:
36 # ARCH=powerpc CC=mwcc make -f beos/Makefile
40 # CC=gcc ARCH=x86 make -f beos/Makefile
42 # To automatically install the fresh new unzip, use the "install" target:
44 # make -f beos/Makefile install
46 ######################################################################
47 # Things that don't change:
51 # Punish those of you not running on SMP hardware...
52 MAKE = make -j 4 -f beos/Makefile
54 LOC=$(LOCAL_UNZIP) -DPASSWD_FROM_STDIN
65 # general-purpose stuff
73 # defaults for crc32 stuff and system-dependent headers
75 OSDEP_H = beos/beocfg.h
78 OBJS1 = unzip$O crc32$O crypt$O envargs$O explode$O
79 OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O
80 OBJS3 = process$O ttyio$O ubz2err$O unreduce$O unshrink$O zipinfo$O
81 OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O $(BEOS_MAIN)
83 OBJSDLL = $(OBJS) api$O
84 OBJX = unzipsfx$O crc32_$O crypt_$O extract_$O fileio_$O globals_$O \
85 inflate_$O match_$O process_$O ttyio_$O ubz2err_$O $M_$O $(BEOS_MAIN)
87 OBJF = funzip$O crc32f$O cryptf$O globalsf$O inflatef$O ttyiof$O
88 UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H)
92 # on some systems, manext=l and MANDIR=/usr/man/man$(manext) may be appropriate
94 prefix = /boot/home/config
95 BINDIR = $(prefix)/bin# where to install executables
96 MANDIR = $(prefix)/man/man$(manext)# where to install man pages
97 INSTALLEDBIN = $(BINDIR)/funzip$E $(BINDIR)/zipinfo$E $(BINDIR)/unzipsfx$E \
99 INSTALLEDMAN = $(MANDIR)/unzip.$(manext) $(MANDIR)/funzip.$(manext) \
100 $(MANDIR)/unzipsfx.$(manext) $(MANDIR)/zipinfo.$(manext)
102 UNZIPS = unzip$E funzip$E unzipsfx$E zipinfo$E
103 # this is a little ugly...well, no, it's a lot ugly:
104 MANS = man/unzip.1 man/unzipsfx.1 man/zipinfo.1 man/funzip.1 man/zipgrep.1
105 DOCS = unzip.txt unzipsfx.txt zipinfo.txt funzip.txt zipgrep.txt
107 ######################################################################
108 # Things that change:
110 # Select an architecture:
112 MACHINE=$(shell uname -m)
113 ifeq "$(MACHINE)" "BePC"
122 # Now select compiler flags and whatnot based on the ARCH and CC:
125 ifeq "$(WHAT)" "powerpc-mwcc"
128 CF=-w9 -O7 -opt schedule604 -rostr -I. $(LOC)
130 LF2=-warn -L/boot/develop/lib/ppc -lbe -lroot
135 ifeq "$(WHAT)" "powerpc-gcc"
138 CF=-O3 -mcpu=604 -Wall -ansi -I. -I/boot/develop/headers/be/support \
139 -I/boot/develop/headers/be/storage $(LOC)
141 LF2=-L/boot/develop/lib/ppc -lbe -lroot
146 # This isn't likely to happen for R4 or later...
147 ifeq "$(WHAT)" "x86-mwcc"
150 CF=-O2 -w9 -I. $(LOC)
152 LF2=-warn -L/boot/develop/lib/x86 -lbe -lroot
157 ifeq "$(WHAT)" "x86-gcc"
160 CF=-O3 -mpentiumpro \
161 -Wall -Wno-multichar -Wno-trigraphs \
162 -ansi -I. -I/boot/develop/headers/be/support \
163 -I/boot/develop/headers/be/storage $(LOC)
165 LF2=-L/boot/develop/lib/x86 -lbe -lroot
174 ######################################################################
177 @echo 'TARGET = $(TARGET)'
178 @echo 'ARCH = $(ARCH)'
180 if [ -n "$(TARGET)" ] ; then \
181 $(MAKE) CC=$(CC) CF="$(CF)" LD="$(LD)" \
182 LF="$(LF)" LF2="$(LF2)" CCPP="$(CC)" CPPF="$(CF)" \
183 OBJS="$(OBJS)" LOBJS="$(LOBJS)" OBJX="$(OBJX)" \
184 LOBJX="$(LOBJX)" $(TARGET) ; \
191 @echo "This Makefile lets you build Info-ZIP's zip."
193 @echo 'To build zip for this computer using the default compiler, just do:'
195 @echo ' make -f beos/Makefile'
197 @echo 'To build zip for a specific architecture using a specific'
198 @echo 'compiler, do:'
200 @echo ' ARCH=cpu CC=compiler make -f beos/Makefile'
203 @echo ' cpu is either "powerpc" or "x86"'
204 @echo ' compiler is either "mwcc" or "gcc"'
207 ######################################################################
208 # Basic compile instructions and dependencies
210 # this is for GNU make; comment out and notify zip-bugs if it causes errors
213 # default for compiling C files
222 unzipsman: unzips docs
223 unzipsdocs: unzips docs
226 unzip$E: $(OBJS) beos/unzip.rsc
227 $(LD) $(LF) $(LOBJS) $(LF2)
229 xres -o unzip$E beos/unzip.rsc
230 mimeset -f -all unzip$E
232 unzipsfx$E: $(OBJX) beos/unzipsfx.rsc
233 $(LD) $(SL) $(LOBJX) $(SL2)
235 xres -o unzipsfx$E beos/unzipsfx.rsc
236 mimeset -f -all unzipsfx
239 $(LD) $(FL) $(OBJF) $(FL2)
243 $(LN) unzip$E zipinfo$E
246 crc32$O: crc32.c $(UNZIP_H) zip.h crc32.h
247 crypt$O: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
248 envargs$O: envargs.c $(UNZIP_H)
249 explode$O: explode.c $(UNZIP_H)
250 extract$O: extract.c $(UNZIP_H) crc32.h crypt.h
251 fileio$O: fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
252 funzip$O: funzip.c $(UNZIP_H) crc32.h crypt.h ttyio.h
253 globals$O: globals.c $(UNZIP_H)
254 inflate$O: inflate.c inflate.h $(UNZIP_H)
255 list$O: list.c $(UNZIP_H)
256 match$O: match.c $(UNZIP_H)
257 process$O: process.c $(UNZIP_H)
258 ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
259 ubz2err$O: ubz2err.c $(UNZIP_H)
260 unreduce$O: unreduce.c $(UNZIP_H)
261 unshrink$O: unshrink.c $(UNZIP_H)
262 unzip$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
263 zipinfo$O: zipinfo.c $(UNZIP_H)
265 # unzipsfx compilation section
266 unzipsfx$O: unzip.c $(UNZIP_H) crypt.h unzvers.h consts.h
267 $(CP) unzip.c unzipsfx.c
268 $(CC) -c $(CF) -DSFX unzipsfx.c
271 crc32_$O: crc32.c $(UNZIP_H) zip.h crc32.h
272 $(CP) crc32.c crc32_.c
273 $(CC) -c $(CF) -DSFX crc32_.c
276 crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
277 $(CP) crypt.c crypt_.c
278 $(CC) -c $(CF) -DSFX crypt_.c
281 extract_$O: extract.c $(UNZIP_H) crc32.h crypt.h
282 $(CP) extract.c extract_.c
283 $(CC) -c $(CF) -DSFX extract_.c
286 fileio_$O: fileio.c $(UNZIP_H) crc32.h crypt.h ttyio.h ebcdic.h
287 $(CP) fileio.c fileio_.c
288 $(CC) -c $(CF) -DSFX fileio_.c
291 globals_$O: globals.c $(UNZIP_H)
292 $(CP) globals.c globals_.c
293 $(CC) -c $(CF) -DSFX globals_.c
296 inflate_$O: inflate.c inflate.h $(UNZIP_H) crypt.h
297 $(CP) inflate.c inflate_.c
298 $(CC) -c $(CF) -DSFX inflate_.c
301 process_$O: process.c $(UNZIP_H) crc32.h
302 $(CP) process.c process_.c
303 $(CC) -c $(CF) -DSFX process_.c
306 ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
307 $(CP) ttyio.c ttyio_.c
308 $(CC) -c $(CF) -DSFX ttyio_.c
311 ubz2err$O: ubz2err.c $(UNZIP_H)
312 $(CP) ubz2err.c ubz2err_.c
313 $(CC) -c $(CF) -DSFX ubz2err_.c
316 # funzip compilation section
317 crc32f$O: crc32.c $(UNZIP_H) zip.h crc32.h
318 $(CP) crc32.c crc32f.c
319 $(CC) -c $(CF) -DFUNZIP crc32f.c
322 cryptf$O: crypt.c $(UNZIP_H) zip.h crypt.h crc32.h ttyio.h
323 $(CP) crypt.c cryptf.c
324 $(CC) -c $(CF) -DFUNZIP cryptf.c
327 globalsf$O: globals.c $(UNZIP_H)
328 $(CP) globals.c globalsf.c
329 $(CC) -c $(CF) -DFUNZIP globalsf.c
332 inflatef$O: inflate.c inflate.h $(UNZIP_H) crypt.h
333 $(CP) inflate.c inflatef.c
334 $(CC) -c $(CF) -DFUNZIP inflatef.c
337 ttyiof$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
338 $(CP) ttyio.c ttyiof.c
339 $(CC) -c $(CF) -DFUNZIP ttyiof.c
343 beos$O: beos/beos.c $(UNZIP_H) unzvers.h beos/beos.h
344 $(CC) -c $(CF) beos/beos.c
346 beosmain$O: beos/beosmain.cpp $(UNZIP_H) unzvers.h
347 $(CCPP) -c $(CPPF) beos/beosmain.cpp
349 # version() not used by unzipsfx, so no unzvers.h dependency
350 beos_$O: beos/beos.c $(UNZIP_H) beos/beos.h # unzipsfx only
351 $(CP) beos/beos.c beos_.c
352 $(CC) -c $(CF) -Ibeos -DSFX beos_.c
355 beosmain_$O: beos/beosmain.cpp $(UNZIP_H) # unzipsfx only
356 $(CP) beos/beosmain.cpp beosmain_.cpp
357 $(CCPP) -c $(CPPF) -Ibeos -DSFX beosmain_.cpp
361 # this really only works for Unix targets, unless E and O specified on cmd line
363 -rm -f $(UNZIPS) $(OBJS) $(OBJF) $(OBJX) api$O apihelp$O crc_gcc$O \
364 unzipstb$O beosmain.o beosmain_.o
367 $(INSTALL) -m 755 $(UNZIPS) $(BINDIR)
368 mimeset -f -all $(BINDIR)/unzip
369 mimeset -f -all $(BINDIR)/unzipsfx
370 $(RM) $(BINDIR)/zipinfo$E
371 $(LN) unzip$E $(BINDIR)/zipinfo$E
372 $(RM) $(BINDIR)/zipgrep$E
373 $(INSTALL) -m 755 unix/zipgrep $(BINDIR)/zipgrep$E
374 $(INSTALL) -m 644 man/unzip.1 $(MANDIR)/unzip.$(manext)
375 $(INSTALL) -m 644 man/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
376 $(INSTALL) -m 644 man/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
377 $(INSTALL) -m 644 man/funzip.1 $(MANDIR)/funzip.$(manext)
378 $(INSTALL) -m 644 man/zipgrep.1 $(MANDIR)/zipgrep.$(manext)
379 $(INSTALL) -m 644 $(DOCS) $(MANDIR)
381 # alternatively, could use zip method: -cd $(BINDIR); rm -f $(UNZIPS) [etc.]
383 rm -f $(INSTALLEDBIN) $(INSTALLEDMAN)
386 TESTZIP = testmake.zip # the test zipfile
388 # test some basic features of the build
392 @echo ' This is a Unix-specific target. (Just so you know.)'
393 @echo ' (Should work ok on BeOS... [cjh])'
394 if test ! -f $(TESTZIP); then \
395 echo " error: can't find test file $(TESTZIP)"; exit 1; fi
397 echo " testing extraction"
398 ./unzip -b $(TESTZIP) testmake.zipinfo
400 echo " error: file extraction from $(TESTZIP) failed"; exit 1; fi
402 echo ' testing zipinfo (unzip -Z)'
403 ./unzip -Z $(TESTZIP) > testmake.unzip-Z
404 if diff testmake.unzip-Z testmake.zipinfo; then ;; else \
405 echo ' error: zipinfo output doesn't match stored version'; fi
406 $(RM) testmake.unzip-Z testmake.zipinfo
408 echo ' testing unzip -d exdir option'
409 ./unzip -b $(TESTZIP) -d testun
412 echo ' testing unzip -o and funzip (ignore funzip warning)'
413 ./unzip -boq $(TESTZIP) notes -d testun
414 ./funzip < $(TESTZIP) > testun/notes2
415 if diff testun/notes testun/notes2; then ;; else \
416 echo 'error: funzip output disagrees with unzip'; fi
418 echo ' testing unzipsfx (self-extractor)'
419 cat unzipsfx $(TESTZIP) > testsfx
420 $(CHMOD) 0700 testsfx
422 if diff notes testun/notes; then ;; else \
423 echo ' error: unzipsfx file disagrees with unzip'; fi
424 $(RM) testsfx notes testun/notes testun/notes2
427 echo ' testing complete.'