Makefile
Upload User: andy_li
Upload Date: 2007-01-06
Package Size: 1019k
Code Size: 10k
Development Platform:

MultiPlatform

  1. ######################################################################
  2. #
  3. # Makefile for Info-ZIP's unzip, unzipsfx, and funzip on BeOS
  4. #
  5. # Copyright (c) 1998 Info-ZIP
  6. #             Chris Herborth (chrish@qnx.com)
  7. #
  8. # This is the new New and Improved Makefile for BeOS; it will:
  9. #
  10. # 1) automatically detect your platform (PowerPC or x86) if none is
  11. #    specified; the default compiler is CodeWarrior for PowerPC, or
  12. #    gcc for x86
  13. #
  14. # 2) let you cross-compile for the other platform (PowerPC or x86), in
  15. #    theory
  16. #
  17. # 3) let you use Metrowerks CodeWarrior (default) or GNU C to build with
  18. #    for either platfor, in theory
  19. #
  20. # To choose a specific architecture, define the ARCH environment
  21. # variable on the make command-line:
  22. #
  23. # ARCH=what make -f beos/Makefile
  24. #
  25. # where "what" can be "powerpc" or "x86".
  26. #
  27. # To choose a specific compiler, define the CC environment variable on
  28. # the make command-line:
  29. #
  30. # CC=compiler make -f beos/Makefile
  31. #
  32. # where "compiler" can be "mwcc" or "x86".
  33. #
  34. # Of course, you can combine these two:
  35. #
  36. # ARCH=powerpc CC=mwcc make -f beos/Makefile
  37. #
  38. # or:
  39. #
  40. # CC=gcc ARCH=x86 make -f beos/Makefile
  41. #
  42. # To automatically install the fresh new unzip, use the "install" target:
  43. #
  44. # make -f beos/Makefile install
  45. ######################################################################
  46. # Things that don't change:
  47. SHELL = /bin/sh
  48. # Punish those of you not running on SMP hardware...
  49. MAKE  = make -j 4 -f beos/Makefile
  50. LOC=$(LOCAL_UNZIP) -DPASSWD_FROM_STDIN
  51. AF=$(LOC)
  52. # UnZipSfx flags
  53. SL = -o unzipsfx
  54. SL2 = $(LF2)
  55. # fUnZip flags
  56. FL = -o funzip
  57. FL2 = $(LF2)
  58. # general-purpose stuff
  59. CP = cp
  60. RM = rm -f
  61. LN = ln -sf
  62. E =
  63. O = .o
  64. M = beos
  65. # defaults for crc32 stuff and system-dependent headers
  66. CRC32 = crc32
  67. OSDEP_H = beos/beos.h
  68. # object files
  69. OBJS1 = unzip$O $(CRC32)$O crctab$O crypt$O envargs$O explode$O
  70. OBJS2 = extract$O fileio$O globals$O inflate$O list$O match$O
  71. OBJS3 = process$O ttyio$O unreduce$O unshrink$O zipinfo$O
  72. OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $M$O $(BEOS_MAIN)
  73. LOBJS = $(OBJS)
  74. OBJSDLL = $(OBJS) api$O
  75. OBJX = unzipsfx$O $(CRC32)$O crctab$O crypt$O extract_$O fileio$O globals$O 
  76. inflate$O match$O process_$O ttyio$O $M_$O $(BEOS_MAIN)
  77. LOBJX = $(OBJX)
  78. OBJF = funzip$O $(CRC32)$O crypt_$O globals_$O inflate_$O ttyio_$O
  79. UNZIP_H = unzip.h unzpriv.h globals.h $(OSDEP_H)
  80. # installation
  81. INSTALL = install
  82. # on some systems, manext=l and MANDIR=/usr/man/man$(manext) may be appropriate
  83. manext = 1
  84. prefix = /boot/home/config
  85. BINDIR = $(prefix)/bin# where to install executables
  86. MANDIR = $(prefix)/man/man$(manext)# where to install man pages
  87. INSTALLEDBIN = $(BINDIR)/funzip$E $(BINDIR)/zipinfo$E $(BINDIR)/unzipsfx$E 
  88. $(BINDIR)/unzip$E
  89. INSTALLEDMAN = $(MANDIR)/unzip.$(manext) $(MANDIR)/funzip.$(manext) 
  90. $(MANDIR)/unzipsfx.$(manext) $(MANDIR)/zipinfo.$(manext)
  91. #
  92. UNZIPS = unzip$E funzip$E unzipsfx$E zipinfo$E
  93. # this is a little ugly...well, no, it's a lot ugly:
  94. MANS = unix/unzip.1 unix/unzipsfx.1 unix/zipinfo.1 unix/funzip.1
  95. DOCS = unzip.doc unzipsfx.doc zipinfo.doc funzip.doc
  96. ######################################################################
  97. # Things that change:
  98. # Select an architecture:
  99. ifndef ARCH
  100. MACHINE=$(shell uname -m)
  101. ifeq "$(MACHINE)" "BePC"
  102. ARCH=x86
  103. CC=gcc
  104. else
  105. ARCH=powerpc
  106. CC=mwcc
  107. endif
  108. endif
  109. # Now select compiler flags and whatnot based on the ARCH and CC:
  110. WHAT=$(ARCH)-$(CC)
  111. ifeq "$(WHAT)" "powerpc-mwcc"
  112. CC=mwccppc
  113. LD=mwccppc
  114. CF=-w9 -O7 -opt schedule604 -rostr -I. $(LOC)
  115. LF=-o unzip
  116. LF2=-warn -L/boot/develop/lib/ppc -lbe -lroot
  117. BEOS_MAIN=beosmain$O
  118. TARGET=$(UNZIPS)
  119. endif
  120. ifeq "$(WHAT)" "powerpc-gcc"
  121. CC=gcc
  122. LD=gcc
  123. CF=-O3 -mcpu=604 -Wall -ansi -I. -I/boot/develop/headers/be/support 
  124.    -I/boot/develop/headers/be/storage $(LOC)
  125. LF=-o unzip
  126. LF2=-L/boot/develop/lib/ppc -lbe -lroot
  127. BEOS_MAIN=beosmain$O
  128. TARGET=$(UNZIPS)
  129. endif
  130. # This isn't likely to happen for R4 or later...
  131. ifeq "$(WHAT)" "x86-mwcc"
  132. CC=mwccx86
  133. LD=mwccx86
  134. CF=-O2 -w9 -I. $(LOC)
  135. LF=-o unzip
  136. LF2=-warn -L/boot/develop/lib/x86 -lbe -lroot
  137. BEOS_MAIN=beosmain$O
  138. TARGET=$(UNZIPS)
  139. endif
  140. ifeq "$(WHAT)" "x86-gcc"
  141. CC=gcc
  142. LD=gcc
  143. CF=-O3 -mcpu=i586 -Wall -ansi -I. -I/boot/develop/headers/be/support 
  144.    -I/boot/develop/headers/be/storage $(LOC)
  145. LF=-o unzip
  146. LF2=-L/boot/develop/lib/x86 -lbe -lroot
  147. BEOS_MAIN=beosmain$O
  148. TARGET=$(UNZIPS)
  149. endif
  150. ifndef TARGET
  151. TARGET=help
  152. endif
  153. ######################################################################
  154. # Helpful targets
  155. all:
  156. @echo 'TARGET = $(TARGET)'
  157. @echo 'ARCH   = $(ARCH)'
  158. @echo 'CC     = $(CC)'
  159. if [ -n "$(TARGET)" ] ; then 
  160. $(MAKE) CC=$(CC) CF="$(CF)" LD="$(LD)" 
  161. LF="$(LF)" LF2="$(LF2)" CCPP="$(CC)" CPPF="$(CF)" 
  162. OBJS="$(OBJS)" LOBJS="$(LOBJS)" OBJX="$(OBJX)" 
  163. LOBJX="$(LOBJX)" $(TARGET) ; 
  164. else 
  165. $(MAKE) help ; 
  166. fi
  167. help:
  168. @echo ''
  169. @echo "This Makefile lets you build Info-ZIP's zip."
  170. @echo ''
  171. @echo 'To build zip for this computer using the default compiler, just do:'
  172. @echo ''
  173. @echo ' make -f beos/Makefile'
  174. @echo ''
  175. @echo 'To build zip for a specific architecture using a specific'
  176. @echo 'compiler, do:'
  177. @echo ''
  178. @echo ' ARCH=cpu CC=compiler make -f beos/Makefile'
  179. @echo ''
  180. @echo 'Where:'
  181. @echo ' cpu is either "powerpc" or "x86"'
  182. @echo ' compiler is either "mwcc" or "gcc"'
  183. @echo ''
  184. ######################################################################
  185. # Basic compile instructions and dependencies
  186. # this is for GNU make; comment out and notify zip-bugs if it causes errors
  187. .SUFFIXES: .c .o
  188. # default for compiling C files
  189. .c.o:
  190. $(CC) -c $(CF) $*.c
  191. unzips: $(UNZIPS)
  192. objs: $(OBJS)
  193. objsdll: $(OBJSDLL)
  194. docs: $(DOCS)
  195. unzipsman: unzips docs
  196. unzipsdocs: unzips docs
  197. unzip$E: $(OBJS) beos/unzip.rsc
  198. $(LD) $(LF) $(LOBJS) $(LF2)
  199. chmod +x unzip$E
  200. xres -o unzip$E beos/unzip.rsc
  201. mimeset -f -all unzip$E
  202. unzipsfx$E: $(OBJX) beos/unzipsfx.rsc
  203. $(LD) $(SL) $(LOBJX) $(SL2)
  204. chmod +x unzipsfx$E
  205. xres -o unzipsfx$E beos/unzipsfx.rsc
  206. mimeset -f -all unzipsfx
  207. funzip$E: $(OBJF)
  208. $(LD) $(FL) $(OBJF) $(FL2)
  209. chmod +x funzip$E
  210. zipinfo$E: unzip$E
  211. $(LN) unzip$E zipinfo$E
  212. crc32$O: crc32.c $(UNZIP_H) zip.h
  213. crctab$O: crctab.c $(UNZIP_H) zip.h
  214. crypt$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
  215. envargs$O: envargs.c $(UNZIP_H)
  216. explode$O: explode.c $(UNZIP_H)
  217. extract$O: extract.c $(UNZIP_H) crypt.h
  218. fileio$O: fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
  219. funzip$O: funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
  220. globals$O: globals.c $(UNZIP_H)
  221. inflate$O: inflate.c inflate.h $(UNZIP_H)
  222. list$O: list.c $(UNZIP_H)
  223. match$O: match.c $(UNZIP_H)
  224. process$O: process.c $(UNZIP_H)
  225. ttyio$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
  226. unreduce$O: unreduce.c $(UNZIP_H)
  227. unshrink$O: unshrink.c $(UNZIP_H)
  228. unzip$O: unzip.c $(UNZIP_H) crypt.h version.h consts.h
  229. zipinfo$O: zipinfo.c $(UNZIP_H)
  230. crypt_$O: crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
  231. $(CP) crypt.c crypt_.c
  232. $(CC) -c $(CF) -DFUNZIP crypt_.c
  233. $(RM) crypt_.c
  234. extract_$O: extract.c $(UNZIP_H) crypt.h # unzipsfx only
  235. $(CP) extract.c extract_.c
  236. $(CC) -c $(CF) -DSFX extract_.c
  237. $(RM) extract_.c
  238. globals_$O: globals.c $(UNZIP_H) # funzip only
  239. $(CP) globals.c globals_.c
  240. $(CC) -c $(CF) -DFUNZIP globals_.c
  241. $(RM) globals_.c
  242. inflate_$O: inflate.c inflate.h $(UNZIP_H) crypt.h # funzip only
  243. $(CP) inflate.c inflate_.c
  244. $(CC) -c $(CF) -DFUNZIP inflate_.c
  245. $(RM) inflate_.c
  246. ttyio_$O: ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h # funzip only
  247. $(CP) ttyio.c ttyio_.c
  248. $(CC) -c $(CF) -DFUNZIP ttyio_.c
  249. $(RM) ttyio_.c
  250. process_$O: process.c $(UNZIP_H) # unzipsfx only
  251. $(CP) process.c process_.c
  252. $(CC) -c $(CF) -DSFX process_.c
  253. $(RM) process_.c
  254. beos$O: beos/beos.c $(UNZIP_H) version.h # BeOS only
  255. $(CC) -c $(CF) beos/beos.c
  256. beosmain$O: beos/beosmain.cpp $(UNZIP_H) version.h # BeOS only
  257. $(CCPP) -c $(CPPF) beos/beosmain.cpp
  258. # version() not used by unzipsfx, so no version.h dependency
  259. beos_$O: beos/beos.c $(UNZIP_H) # unzipsfx only
  260. $(CP) beos/beos.c beos_.c
  261. $(CC) -c $(CF) -Ibeos -DSFX beos_.c
  262. $(RM) beos_.c
  263. beosmain_$O: beos/beosmain.cpp $(UNZIP_H)
  264. $(CP) beos/beosmain.cpp beosmain_.cpp
  265. $(CCPP) -c $(CPPF) -Ibeos -DSFX beosmain_.cpp
  266. $(RM) beosmain_.cpp
  267. unzipsfx$O: unzip.c $(UNZIP_H) crypt.h version.h consts.h # unzipsfx only
  268. $(CP) unzip.c unzipsfx.c
  269. $(CC) -c $(CF) -DSFX unzipsfx.c
  270. $(RM) unzipsfx.c
  271. # this really only works for Unix targets, unless E and O specified on cmd line
  272. clean:
  273. -rm -f $(UNZIPS) $(OBJS) $(OBJF) $(OBJX) api$O apihelp$O crc_gcc$O 
  274.   unzipstb$O beosmain.o beosmain_.o
  275. install: all
  276. $(INSTALL) -m 755 $(UNZIPS) $(BINDIR)
  277. mimeset -f -all $(BINDIR)/unzip
  278. mimeset -f -all $(BINDIR)/unzipsfx
  279. $(RM) $(BINDIR)/zipinfo$E
  280. $(LN) unzip$E $(BINDIR)/zipinfo$E
  281. $(RM) $(BINDIR)/zipgrep$E
  282. $(INSTALL) -m 755 unix/zipgrep $(BINDIR)/zipgrep$E
  283. $(INSTALL) -m 644 unix/unzip.1 $(MANDIR)/unzip.$(manext)
  284. $(INSTALL) -m 644 unix/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
  285. $(INSTALL) -m 644 unix/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
  286. $(INSTALL) -m 644 unix/funzip.1 $(MANDIR)/funzip.$(manext)
  287. $(INSTALL) -m 644 $(DOCS) $(MANDIR)
  288. # alternatively, could use zip method:  -cd $(BINDIR); rm -f $(UNZIPS)  [etc.]
  289. uninstall:
  290. rm -f $(INSTALLEDBIN) $(INSTALLEDMAN)
  291. TESTZIP = testmake.zip # the test zipfile
  292. # test some basic features of the build
  293. test: check
  294. check: unzips
  295. @echo '  This is a Unix-specific target.  (Just so you know.)'
  296. @echo '  (Should work ok on BeOS... [cjh])'
  297. if test ! -f $(TESTZIP); then 
  298. echo "  error:  can't find test file $(TESTZIP)"; exit 1; fi
  299. #
  300. echo "  testing extraction"
  301. ./unzip -b $(TESTZIP) testmake.zipinfo
  302. if test $? ; then 
  303.     echo "  error:  file extraction from $(TESTZIP) failed"; exit 1; fi
  304. #
  305. echo '  testing zipinfo (unzip -Z)'
  306. ./unzip -Z $(TESTZIP) > testmake.unzip-Z
  307. if diff testmake.unzip-Z testmake.zipinfo; then ;; else 
  308.     echo '  error:  zipinfo output doesn't match stored version'; fi
  309. $(RM) testmake.unzip-Z testmake.zipinfo
  310. #
  311. echo '  testing unzip -d exdir option'
  312. ./unzip -b $(TESTZIP) -d testun
  313. cat testun/notes
  314. #
  315. echo '  testing unzip -o and funzip (ignore funzip warning)'
  316. ./unzip -boq $(TESTZIP) notes -d testun
  317. ./funzip < $(TESTZIP) > testun/notes2
  318. if diff testun/notes testun/notes2; then ;; else 
  319.     echo 'error:  funzip output disagrees with unzip'; fi
  320. #
  321. echo '  testing unzipsfx (self-extractor)'
  322. cat unzipsfx $(TESTZIP) > testsfx
  323. $(CHMOD) 0700 testsfx
  324. ./testsfx -b notes
  325. if diff notes testun/notes; then ;; else 
  326.     echo '  error:  unzipsfx file disagrees with unzip'; fi
  327. $(RM) testsfx notes testun/notes testun/notes2
  328. rmdir testun
  329. #
  330. echo '  testing complete.'