Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ######################################################################
  2. #
  3. # Makefile for Info-ZIP's unzip, unzipsfx, and funzip on BeOS
  4. #
  5. # Copyright (c) 1998-2006 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. ######################################################################
  47. # Things that don't change:
  48.  
  49. SHELL = /bin/sh
  50.  
  51. # Punish those of you not running on SMP hardware...
  52. MAKE  = make -j 4 -f beos/Makefile
  53.  
  54. LOC=$(LOCAL_UNZIP) -DPASSWD_FROM_STDIN
  55. AF=$(LOC)
  56.  
  57. # UnZipSfx flags
  58. SL = -o unzipsfx
  59. SL2 = $(LF2)
  60.  
  61. # fUnZip flags
  62. FL = -o funzip
  63. FL2 = $(LF2)
  64.  
  65. # general-purpose stuff
  66. CP = cp
  67. RM = rm -f
  68. LN = ln -sf
  69. E =
  70. O = .o
  71. M = beos
  72.  
  73. # defaults for crc32 stuff and system-dependent headers
  74. CRCA_O =
  75. OSDEP_H = beos/beocfg.h
  76.  
  77. # object files
  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)
  82. LOBJS = $(OBJS)
  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)
  86. LOBJX = $(OBJX)
  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)
  89.  
  90. # installation
  91. INSTALL = install
  92. # on some systems, manext=l and MANDIR=/usr/man/man$(manext) may be appropriate
  93. manext = 1
  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 \
  98.         $(BINDIR)/unzip$E
  99. INSTALLEDMAN = $(MANDIR)/unzip.$(manext) $(MANDIR)/funzip.$(manext) \
  100.         $(MANDIR)/unzipsfx.$(manext) $(MANDIR)/zipinfo.$(manext)
  101. #
  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
  106.  
  107. ######################################################################
  108. # Things that change:
  109.  
  110. # Select an architecture:
  111. ifndef ARCH
  112. MACHINE=$(shell uname -m)
  113. ifeq "$(MACHINE)" "BePC"
  114. ARCH=x86
  115. CC=gcc
  116. else
  117. ARCH=powerpc
  118. CC=mwcc
  119. endif
  120. endif
  121.  
  122. # Now select compiler flags and whatnot based on the ARCH and CC:
  123. WHAT=$(ARCH)-$(CC)
  124.  
  125. ifeq "$(WHAT)" "powerpc-mwcc"
  126. CC=mwccppc
  127. LD=mwccppc
  128. CF=-w9 -O7 -opt schedule604 -rostr -I. $(LOC)
  129. LF=-o unzip
  130. LF2=-warn -L/boot/develop/lib/ppc -lbe -lroot
  131. BEOS_MAIN=beosmain$O
  132. TARGET=$(UNZIPS)
  133. endif
  134.  
  135. ifeq "$(WHAT)" "powerpc-gcc"
  136. CC=gcc
  137. LD=gcc
  138. CF=-O3 -mcpu=604 -Wall -ansi -I. -I/boot/develop/headers/be/support \
  139.    -I/boot/develop/headers/be/storage $(LOC)
  140. LF=-o unzip
  141. LF2=-L/boot/develop/lib/ppc -lbe -lroot
  142. BEOS_MAIN=beosmain$O
  143. TARGET=$(UNZIPS)
  144. endif
  145.  
  146. # This isn't likely to happen for R4 or later...
  147. ifeq "$(WHAT)" "x86-mwcc"
  148. CC=mwccx86
  149. LD=mwccx86
  150. CF=-O2 -w9 -I. $(LOC)
  151. LF=-o unzip
  152. LF2=-warn -L/boot/develop/lib/x86 -lbe -lroot
  153. BEOS_MAIN=beosmain$O
  154. TARGET=$(UNZIPS)
  155. endif
  156.  
  157. ifeq "$(WHAT)" "x86-gcc"
  158. CC=gcc
  159. LD=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)
  164. LF=-o unzip
  165. LF2=-L/boot/develop/lib/x86 -lbe -lroot
  166. BEOS_MAIN=beosmain$O
  167. TARGET=$(UNZIPS)
  168. endif
  169.  
  170. ifndef TARGET
  171. TARGET=help
  172. endif
  173.  
  174. ######################################################################
  175. # Helpful targets
  176. all:
  177.         @echo 'TARGET = $(TARGET)'
  178.         @echo 'ARCH   = $(ARCH)'
  179.         @echo 'CC     = $(CC)'
  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) ; \
  185.         else \
  186.                 $(MAKE) help ; \
  187.         fi
  188.  
  189. help:
  190.         @echo ''
  191.         @echo "This Makefile lets you build Info-ZIP's zip."
  192.         @echo ''
  193.         @echo 'To build zip for this computer using the default compiler, just do:'
  194.         @echo ''
  195.         @echo ' make -f beos/Makefile'
  196.         @echo ''
  197.         @echo 'To build zip for a specific architecture using a specific'
  198.         @echo 'compiler, do:'
  199.         @echo ''
  200.         @echo ' ARCH=cpu CC=compiler make -f beos/Makefile'
  201.         @echo ''
  202.         @echo 'Where:'
  203.         @echo ' cpu is either "powerpc" or "x86"'
  204.         @echo ' compiler is either "mwcc" or "gcc"'
  205.         @echo ''
  206.  
  207. ######################################################################
  208. # Basic compile instructions and dependencies
  209.  
  210. # this is for GNU make; comment out and notify zip-bugs if it causes errors
  211. .SUFFIXES:      .c .o
  212.  
  213. # default for compiling C files
  214. .c.o:
  215.         $(CC) -c $(CF) $*.c
  216.  
  217.  
  218. unzips:         $(UNZIPS)
  219. objs:           $(OBJS)
  220. objsdll:        $(OBJSDLL)
  221. docs:           $(DOCS)
  222. unzipsman:      unzips docs
  223. unzipsdocs:     unzips docs
  224.  
  225.  
  226. unzip$E:        $(OBJS) beos/unzip.rsc
  227.         $(LD) $(LF) $(LOBJS) $(LF2)
  228.         chmod +x unzip$E
  229.         xres -o unzip$E beos/unzip.rsc
  230.         mimeset -f -all unzip$E
  231.  
  232. unzipsfx$E:     $(OBJX) beos/unzipsfx.rsc
  233.         $(LD) $(SL) $(LOBJX) $(SL2)
  234.         chmod +x unzipsfx$E
  235.         xres -o unzipsfx$E beos/unzipsfx.rsc
  236.         mimeset -f -all unzipsfx
  237.  
  238. funzip$E:       $(OBJF)
  239.         $(LD) $(FL) $(OBJF) $(FL2)
  240.         chmod +x funzip$E
  241.  
  242. zipinfo$E:      unzip$E
  243.         $(LN) unzip$E zipinfo$E
  244.  
  245.  
  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)
  264.  
  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
  269.         $(RM) unzipsfx.c
  270.  
  271. crc32_$O:       crc32.c $(UNZIP_H) zip.h crc32.h
  272.         $(CP) crc32.c crc32_.c
  273.         $(CC) -c $(CF) -DSFX crc32_.c
  274.         $(RM) crc32_.c
  275.  
  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
  279.         $(RM) crypt_.c
  280.  
  281. extract_$O:     extract.c $(UNZIP_H) crc32.h crypt.h
  282.         $(CP) extract.c extract_.c
  283.         $(CC) -c $(CF) -DSFX extract_.c
  284.         $(RM) extract_.c
  285.  
  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
  289.         $(RM) fileio_.c
  290.  
  291. globals_$O:     globals.c $(UNZIP_H)
  292.         $(CP) globals.c globals_.c
  293.         $(CC) -c $(CF) -DSFX globals_.c
  294.         $(RM) globals_.c
  295.  
  296. inflate_$O:     inflate.c inflate.h $(UNZIP_H) crypt.h
  297.         $(CP) inflate.c inflate_.c
  298.         $(CC) -c $(CF) -DSFX inflate_.c
  299.         $(RM) inflate_.c
  300.  
  301. process_$O:     process.c $(UNZIP_H) crc32.h
  302.         $(CP) process.c process_.c
  303.         $(CC) -c $(CF) -DSFX process_.c
  304.         $(RM) process_.c
  305.  
  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
  309.         $(RM) ttyio_.c
  310.  
  311. ubz2err$O:      ubz2err.c $(UNZIP_H)
  312.         $(CP) ubz2err.c ubz2err_.c
  313.         $(CC) -c $(CF) -DSFX ubz2err_.c
  314.         $(RM) ubz2err_.c
  315.  
  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
  320.         $(RM) crc32f.c
  321.  
  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
  325.         $(RM) cryptf.c
  326.  
  327. globalsf$O:     globals.c $(UNZIP_H)
  328.         $(CP) globals.c globalsf.c
  329.         $(CC) -c $(CF) -DFUNZIP globalsf.c
  330.         $(RM) globalsf.c
  331.  
  332. inflatef$O:     inflate.c inflate.h $(UNZIP_H) crypt.h
  333.         $(CP) inflate.c inflatef.c
  334.         $(CC) -c $(CF) -DFUNZIP inflatef.c
  335.         $(RM) inflatef.c
  336.  
  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
  340.         $(RM) ttyiof.c
  341.  
  342. # BeOS specific code
  343. beos$O:         beos/beos.c $(UNZIP_H) unzvers.h beos/beos.h
  344.         $(CC) -c $(CF) beos/beos.c
  345.  
  346. beosmain$O:     beos/beosmain.cpp $(UNZIP_H) unzvers.h
  347.         $(CCPP) -c $(CPPF) beos/beosmain.cpp
  348.  
  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
  353.         $(RM) beos_.c
  354.  
  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
  358.         $(RM) beosmain_.cpp
  359.  
  360.  
  361. # this really only works for Unix targets, unless E and O specified on cmd line
  362. clean:
  363.         -rm -f $(UNZIPS) $(OBJS) $(OBJF) $(OBJX) api$O apihelp$O crc_gcc$O \
  364.           unzipstb$O beosmain.o beosmain_.o
  365.  
  366. install:        all
  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)
  380.  
  381. # alternatively, could use zip method:  -cd $(BINDIR); rm -f $(UNZIPS)  [etc.]
  382. uninstall:
  383.         rm -f $(INSTALLEDBIN) $(INSTALLEDMAN)
  384.  
  385.  
  386. TESTZIP = testmake.zip  # the test zipfile
  387.  
  388. # test some basic features of the build
  389. test:           check
  390.  
  391. check:  unzips
  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
  396. #
  397.         echo "  testing extraction"
  398.         ./unzip -b $(TESTZIP) testmake.zipinfo
  399.         if test $? ; then \
  400.             echo "  error:  file extraction from $(TESTZIP) failed"; exit 1; fi
  401. #
  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
  407. #
  408.         echo '  testing unzip -d exdir option'
  409.         ./unzip -b $(TESTZIP) -d testun
  410.         cat testun/notes
  411. #
  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
  417. #
  418.         echo '  testing unzipsfx (self-extractor)'
  419.         cat unzipsfx $(TESTZIP) > testsfx
  420.         $(CHMOD) 0700 testsfx
  421.         ./testsfx -b notes
  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
  425.         rmdir testun
  426. #
  427.         echo '  testing complete.'
  428.