home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / unzip540.zip / beos / Makefile < prev    next >
Makefile  |  1998-11-02  |  11KB  |  382 lines

  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. ######################################################################
  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. CRC32 = crc32
  75. OSDEP_H = beos/beos.h
  76.  
  77. # object files
  78. OBJS1 = unzip$O $(CRC32)$O crctab$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 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 crctab$O crypt$O extract_$O fileio$O globals$O \
  85.     inflate$O match$O process_$O ttyio$O $M_$O $(BEOS_MAIN)
  86. LOBJX = $(OBJX)
  87. OBJF = funzip$O $(CRC32)$O crypt_$O globals_$O inflate_$O ttyio_$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 = unix/unzip.1 unix/unzipsfx.1 unix/zipinfo.1 unix/funzip.1
  105. DOCS = unzip.doc unzipsfx.doc zipinfo.doc funzip.doc
  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 -mcpu=i586 -Wall -ansi -I. -I/boot/develop/headers/be/support \
  161.    -I/boot/develop/headers/be/storage $(LOC)
  162. LF=-o unzip
  163. LF2=-L/boot/develop/lib/x86 -lbe -lroot
  164. BEOS_MAIN=beosmain$O
  165. TARGET=$(UNZIPS)
  166. endif
  167.  
  168. ifndef TARGET
  169. TARGET=help
  170. endif
  171.  
  172. ######################################################################
  173. # Helpful targets
  174. all:
  175.     @echo 'TARGET = $(TARGET)'
  176.     @echo 'ARCH   = $(ARCH)'
  177.     @echo 'CC     = $(CC)'
  178.     if [ -n "$(TARGET)" ] ; then \
  179.         $(MAKE) CC=$(CC) CF="$(CF)" LD="$(LD)" \
  180.             LF="$(LF)" LF2="$(LF2)" CCPP="$(CC)" CPPF="$(CF)" \
  181.             OBJS="$(OBJS)" LOBJS="$(LOBJS)" OBJX="$(OBJX)" \
  182.             LOBJX="$(LOBJX)" $(TARGET) ; \
  183.     else \
  184.         $(MAKE) help ; \
  185.     fi
  186.  
  187. help:
  188.     @echo ''
  189.     @echo "This Makefile lets you build Info-ZIP's zip."
  190.     @echo ''
  191.     @echo 'To build zip for this computer using the default compiler, just do:'
  192.     @echo ''
  193.     @echo '    make -f beos/Makefile'
  194.     @echo ''
  195.     @echo 'To build zip for a specific architecture using a specific'
  196.     @echo 'compiler, do:'
  197.     @echo ''
  198.     @echo '    ARCH=cpu CC=compiler make -f beos/Makefile'
  199.     @echo ''
  200.     @echo 'Where:'
  201.     @echo '    cpu is either "powerpc" or "x86"'
  202.     @echo '    compiler is either "mwcc" or "gcc"'
  203.     @echo ''
  204.  
  205. ######################################################################
  206. # Basic compile instructions and dependencies
  207.  
  208. # this is for GNU make; comment out and notify zip-bugs if it causes errors
  209. .SUFFIXES:    .c .o
  210.  
  211. # default for compiling C files
  212. .c.o:
  213.     $(CC) -c $(CF) $*.c
  214.  
  215.  
  216. unzips:        $(UNZIPS)
  217. objs:        $(OBJS)
  218. objsdll:    $(OBJSDLL)
  219. docs:        $(DOCS)
  220. unzipsman:    unzips docs
  221. unzipsdocs:    unzips docs
  222.  
  223.  
  224. unzip$E:    $(OBJS) beos/unzip.rsc
  225.     $(LD) $(LF) $(LOBJS) $(LF2)
  226.     chmod +x unzip$E
  227.     xres -o unzip$E beos/unzip.rsc
  228.     mimeset -f -all unzip$E
  229.  
  230. unzipsfx$E:    $(OBJX) beos/unzipsfx.rsc
  231.     $(LD) $(SL) $(LOBJX) $(SL2)
  232.     chmod +x unzipsfx$E
  233.     xres -o unzipsfx$E beos/unzipsfx.rsc
  234.     mimeset -f -all unzipsfx
  235.  
  236. funzip$E:    $(OBJF)
  237.     $(LD) $(FL) $(OBJF) $(FL2)
  238.     chmod +x funzip$E
  239.  
  240. zipinfo$E:    unzip$E
  241.     $(LN) unzip$E zipinfo$E
  242.  
  243.  
  244. crc32$O:    crc32.c $(UNZIP_H) zip.h
  245. crctab$O:    crctab.c $(UNZIP_H) zip.h
  246. crypt$O:    crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h
  247. envargs$O:    envargs.c $(UNZIP_H)
  248. explode$O:    explode.c $(UNZIP_H)
  249. extract$O:    extract.c $(UNZIP_H) crypt.h
  250. fileio$O:    fileio.c $(UNZIP_H) crypt.h ttyio.h ebcdic.h
  251. funzip$O:    funzip.c $(UNZIP_H) crypt.h ttyio.h tables.h
  252. globals$O:    globals.c $(UNZIP_H)
  253. inflate$O:    inflate.c inflate.h $(UNZIP_H)
  254. list$O:        list.c $(UNZIP_H)
  255. match$O:    match.c $(UNZIP_H)
  256. process$O:    process.c $(UNZIP_H)
  257. ttyio$O:    ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h
  258. unreduce$O:    unreduce.c $(UNZIP_H)
  259. unshrink$O:    unshrink.c $(UNZIP_H)
  260. unzip$O:    unzip.c $(UNZIP_H) crypt.h version.h consts.h
  261. zipinfo$O:    zipinfo.c $(UNZIP_H)
  262.  
  263. crypt_$O:    crypt.c $(UNZIP_H) zip.h crypt.h ttyio.h    # funzip only
  264.     $(CP) crypt.c crypt_.c
  265.     $(CC) -c $(CF) -DFUNZIP crypt_.c
  266.     $(RM) crypt_.c
  267.  
  268. extract_$O:    extract.c $(UNZIP_H) crypt.h            # unzipsfx only
  269.     $(CP) extract.c extract_.c
  270.     $(CC) -c $(CF) -DSFX extract_.c
  271.     $(RM) extract_.c
  272.  
  273. globals_$O:    globals.c $(UNZIP_H)                # funzip only
  274.     $(CP) globals.c globals_.c
  275.     $(CC) -c $(CF) -DFUNZIP globals_.c
  276.     $(RM) globals_.c
  277.  
  278. inflate_$O:    inflate.c inflate.h $(UNZIP_H) crypt.h        # funzip only
  279.     $(CP) inflate.c inflate_.c
  280.     $(CC) -c $(CF) -DFUNZIP inflate_.c
  281.     $(RM) inflate_.c
  282.  
  283. ttyio_$O:    ttyio.c $(UNZIP_H) zip.h crypt.h ttyio.h    # funzip only
  284.     $(CP) ttyio.c ttyio_.c
  285.     $(CC) -c $(CF) -DFUNZIP ttyio_.c
  286.     $(RM) ttyio_.c
  287.  
  288. process_$O:    process.c $(UNZIP_H)                # unzipsfx only
  289.     $(CP) process.c process_.c
  290.     $(CC) -c $(CF) -DSFX process_.c
  291.     $(RM) process_.c
  292.  
  293. beos$O:        beos/beos.c $(UNZIP_H) version.h        # BeOS only
  294.     $(CC) -c $(CF) beos/beos.c
  295.  
  296. beosmain$O:    beos/beosmain.cpp $(UNZIP_H) version.h    # BeOS only
  297.     $(CCPP) -c $(CPPF) beos/beosmain.cpp
  298.  
  299. # version() not used by unzipsfx, so no version.h dependency
  300. beos_$O:        beos/beos.c $(UNZIP_H)                # unzipsfx only
  301.     $(CP) beos/beos.c beos_.c
  302.     $(CC) -c $(CF) -Ibeos -DSFX beos_.c
  303.     $(RM) beos_.c
  304.  
  305. beosmain_$O:    beos/beosmain.cpp $(UNZIP_H)
  306.     $(CP) beos/beosmain.cpp beosmain_.cpp
  307.     $(CCPP) -c $(CPPF) -Ibeos -DSFX beosmain_.cpp
  308.     $(RM) beosmain_.cpp
  309.  
  310. unzipsfx$O:    unzip.c $(UNZIP_H) crypt.h version.h consts.h    # unzipsfx only
  311.     $(CP) unzip.c unzipsfx.c
  312.     $(CC) -c $(CF) -DSFX unzipsfx.c
  313.     $(RM) unzipsfx.c
  314.  
  315.  
  316. # this really only works for Unix targets, unless E and O specified on cmd line
  317. clean:
  318.     -rm -f $(UNZIPS) $(OBJS) $(OBJF) $(OBJX) api$O apihelp$O crc_gcc$O \
  319.       unzipstb$O beosmain.o beosmain_.o
  320.  
  321. install:    all
  322.     $(INSTALL) -m 755 $(UNZIPS) $(BINDIR)
  323.     mimeset -f -all $(BINDIR)/unzip
  324.     mimeset -f -all $(BINDIR)/unzipsfx
  325.     $(RM) $(BINDIR)/zipinfo$E
  326.     $(LN) unzip$E $(BINDIR)/zipinfo$E
  327.     $(RM) $(BINDIR)/zipgrep$E
  328.     $(INSTALL) -m 755 unix/zipgrep $(BINDIR)/zipgrep$E
  329.     $(INSTALL) -m 644 unix/unzip.1 $(MANDIR)/unzip.$(manext)
  330.     $(INSTALL) -m 644 unix/unzipsfx.1 $(MANDIR)/unzipsfx.$(manext)
  331.     $(INSTALL) -m 644 unix/zipinfo.1 $(MANDIR)/zipinfo.$(manext)
  332.     $(INSTALL) -m 644 unix/funzip.1 $(MANDIR)/funzip.$(manext)
  333.     $(INSTALL) -m 644 $(DOCS) $(MANDIR)
  334.  
  335. # alternatively, could use zip method:  -cd $(BINDIR); rm -f $(UNZIPS)  [etc.]
  336. uninstall:
  337.     rm -f $(INSTALLEDBIN) $(INSTALLEDMAN)
  338.  
  339.  
  340. TESTZIP = testmake.zip    # the test zipfile
  341.  
  342. # test some basic features of the build
  343. test:        check
  344.  
  345. check:    unzips
  346.     @echo '  This is a Unix-specific target.  (Just so you know.)'
  347.     @echo '  (Should work ok on BeOS... [cjh])'
  348.     if test ! -f $(TESTZIP); then \
  349.         echo "  error:  can't find test file $(TESTZIP)"; exit 1; fi
  350. #
  351.     echo "  testing extraction"
  352.     ./unzip -b $(TESTZIP) testmake.zipinfo
  353.     if test $? ; then \
  354.         echo "  error:  file extraction from $(TESTZIP) failed"; exit 1; fi
  355. #
  356.     echo '  testing zipinfo (unzip -Z)'
  357.     ./unzip -Z $(TESTZIP) > testmake.unzip-Z
  358.     if diff testmake.unzip-Z testmake.zipinfo; then ;; else \
  359.         echo '  error:  zipinfo output doesn't match stored version'; fi
  360.     $(RM) testmake.unzip-Z testmake.zipinfo
  361. #
  362.     echo '  testing unzip -d exdir option'
  363.     ./unzip -b $(TESTZIP) -d testun
  364.     cat testun/notes
  365. #
  366.     echo '  testing unzip -o and funzip (ignore funzip warning)'
  367.     ./unzip -boq $(TESTZIP) notes -d testun
  368.     ./funzip < $(TESTZIP) > testun/notes2
  369.     if diff testun/notes testun/notes2; then ;; else \
  370.         echo 'error:  funzip output disagrees with unzip'; fi
  371. #
  372.     echo '  testing unzipsfx (self-extractor)'
  373.     cat unzipsfx $(TESTZIP) > testsfx
  374.     $(CHMOD) 0700 testsfx
  375.     ./testsfx -b notes
  376.     if diff notes testun/notes; then ;; else \
  377.         echo '  error:  unzipsfx file disagrees with unzip'; fi
  378.     $(RM) testsfx notes testun/notes testun/notes2
  379.     rmdir testun
  380. #
  381.     echo '  testing complete.'
  382.