install.txt 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. HOW TO ADD BZIP2 SUPPORT TO ZIP
  2. This document describes how to add bzip2 support to Zip.
  3. Compiling or linking in the bzip2 library adds an additional bzip2
  4. compression method to Zip. This new method can be selected instead
  5. of the Zip traditional compression method deflation to compress files
  6. and often gives a better compression ratio (perhaps at the cost of
  7. greater CPU time). The compression method is specified using the
  8. "-Z method" command-line option, where "method" may be either "deflate"
  9. (the default), or "bzip2" (if Zip is built with bzip2 support). Zip
  10. has been tested with bzip2 library 1.0.5 and earlier.
  11. Notes
  12. Compression method bzip2 requires a modern unzip. Before using bzip2
  13. compression in Zip, verify that a modern UnZip program with bzip2 support
  14. will be used to read the resulting zip archive so that entries compressed
  15. with bzip2 (compression method 12) can be read. Older unzips probably
  16. won't recognize the compression method and will skip those entries.
  17. The Zip source kit does not include the bzip2 library or source files, but
  18. these can be found at "http://www.bzip.org/" for example. See below for
  19. how to add bzip2 to Zip for various operating systems.
  20. Zip using bzip2 compression is not compatible with the bzip2 application,
  21. but instead provides an additional way to compress files before adding
  22. them to a Zip archive. It does not replace the bzip2 program itself,
  23. which creates bzip2 archives in a different format that are not
  24. compatible with zip or unzip.
  25. The bzip2 code and algorithms are provided under the bzip2 license
  26. (provided in the bzip2 source kit) and what is not covered by that license
  27. is covered under the Info-ZIP license. Info-ZIP will look at issues
  28. involving the use of bzip2 compression in Zip, but any questions about
  29. the bzip2 code and algorithms or bzip2 licensing, for example, should be
  30. directed to the bzip2 maintainer.
  31. Installation
  32. To build Zip with bzip2 support, Zip generally needs one bzip2 header
  33. file, "bzlib.h", and the object library, typically "libbz2.a", except
  34. in cases where the source files are compiled in directly. If you
  35. are either compiling the bzip2 library or compiling in the bzip2
  36. source files, we recommend defining the C macro BZ_NO_STDIO, which
  37. excludes a lot of standalone error code (not used when bzip2 is
  38. used as a library and makes the library smaller) and provides hooks
  39. that Zip can use to provide better error handling. However, a
  40. standard bzip2 object library will work, though any errors that bzip2
  41. generates may be more cryptic.
  42. Building the bzip2 library from the bzip2 source files (recommended):
  43. Download the latest bzip2 package (from "http://www.bzip.org/", for
  44. example).
  45. Unpack the bzip2 source kit (bzip2-1.0.5.tar.gz was current as of
  46. this writing, but the latest should work).
  47. Read the README file in the bzip2 source kit.
  48. Compile the bzip2 library for your OS, preferably defining
  49. BZ_NO_STDIO. Note: On UNIX systems, this may be done automatically
  50. when building Zip, as explained below.
  51. Installation on UNIX (see below for installation on other systems):
  52. Note: Zip on UNIX uses the "bzlib.h" include file and the compiled
  53. "libbz2.a" library to static link to bzip2. Currently we do not
  54. support using the shared library (patches welcome).
  55. The easiest approach may be to drop the two above files in the
  56. bzip2 directory of the Zip source tree and build Zip using the
  57. "generic" target, that is, using a command like
  58. make -f unix/Makefile generic
  59. If all goes well, make should confirm that it found the files and
  60. will be compiling in bzip2 by setting the BZIP2_SUPPORT flag and
  61. then including the libraries while compiling and linking Zip.
  62. To use bzlib.h and libbz2.a from somewhere else on your system,
  63. define the "make" macro IZ_BZIP2 to point to that directory. For
  64. example:
  65. make -f unix/Makefile generic IZ_BZIP2=/mybz2
  66. where /mybz2 might be "/usr/local/src/bzip2/bzip2-1.0.5" on some
  67. systems. Only a compiled bzip2 library can be pointed to using
  68. IZ_BZIP2 and Zip will not compile bzip2 source in other than the
  69. bzip2 directory.
  70. If IZ_BZIP2 is not defined, Zip will look for the bzip2 files in
  71. the "bzip2" directory in the Zip source directory. The bzip2
  72. directory is empty in the Zip source distribution (except for
  73. this install.txt file) and is provided as a place to put the
  74. bzip2 files. To use this directory, either drop bzlib.h and
  75. libbz2.a in it to use the compiled library as noted above or drop
  76. the contents of the bzip2 source kit in this directory so that
  77. bzlib.h is directly in the bzip2 directory and Zip will try to
  78. compile it if no compiled library is already there.
  79. Unpacking bzip2 so Zip compiles it:
  80. To make this work, the bzip2 source kit must be unpacked directly
  81. into the Zip "bzip2" directory. For example:
  82. # Unpack the Zip source kit.
  83. gzip -cd zip30.tar-gz | tar xfo -
  84. # Move down to the Zip kit's "bzip2" directory, ...
  85. cd zip30/bzip2
  86. # ... and unpack the bzip2 source kit there.
  87. gzip -cd ../../bzip2-1.0.5.tar.gz | tar xfo -
  88. # Move the bzip2 source files up to the Zip kit's bzip2 directory.
  89. cd bzip2-1.0.5
  90. mv * ..
  91. # Return to the Zip source kit directory, ready to build.
  92. cd ../..
  93. # Build Zip.
  94. make -f unix/Makefile generic
  95. Using a system bzip2 library:
  96. If IZ_BZIP2 is not defined and both a compiled library and the bzip2
  97. source files are missing from the Zip bzip2 directory, Zip will test
  98. to see if bzip2 is globally defined on the system in the default
  99. include and library paths and, if found, link in the system bzip2
  100. library. This is automatic.
  101. Preventing inclusion of bzip2:
  102. To build Zip with _no_ bzip2 support on a system where the automatic
  103. bzip2 detection scheme will find bzip2, you can specify a bad
  104. IZ_BZIP2 directory. For example:
  105. make -f unix/Makefile generic IZ_BZIP2=no_such_directory
  106. You can also define NO_BZIP2_SUPPORT to exclude bzip2.
  107. Verifying bzip2 support in Zip:
  108. When the Zip build is complete, verify that bzip2 support has been
  109. enabled by checking the feature list:
  110. ./zip -v
  111. If all went well, bzip2 (and its library version) should be listed.
  112. Installation on other systems
  113. MSDOS:
  114. Thanks to Robert Riebisch, the DJGPP 2.x Zip port now supports bzip2.
  115. To include bzip2, first install bzip2. The new msdos/makebz2.dj2
  116. makefile then looks in the standard bzip2 installation directories
  117. for the needed files. As he says:
  118. It doesn't try to be clever about finding libbz2.a. It just
  119. expects bzip2 stuff installed to the default include and library
  120. folders, e.g., "C:\DJGPP\include" and "C:\DJGPP\lib" on DOS.
  121. Given a standard DJGPP 2.x installation, this should create a
  122. version of Zip 3.0 with bzip2 support.
  123. The bzip2 library for DJGPP can be found on any DJGPP mirror in
  124. "current/v2apps" (or "beta/v2apps/" for the latest beta). This
  125. library has been ported to MSDOS/DJGPP by Juan Manuel Guerrero.
  126. WIN32 (Windows NT/2K/XP/2K3/... and Windows 95/98/ME):
  127. For Windows there seems to be two approaches, either use bzip2
  128. as a dynamic link library or compile the bzip2 source in directly.
  129. I have not gotten the static library libbz2.lib to work, but that
  130. may be me.
  131. Using bzip2 as a dynamic link library:
  132. Building bzip2:
  133. If you have the needed bzlib.h, libbz2.lib, and libbz2.dll files
  134. you can skip building bzip2. If not, open the libbz2.dsp project
  135. and build libbz2.dll
  136. This creates
  137. debug/libbz2.lib
  138. and
  139. libbz2.dll
  140. Building Zip:
  141. Copy libbz2.lib to the bzip2 directory in the Zip source tree. This
  142. is needed to compile Zip with bzip2 support. Also copy the matching
  143. bzlib.h from the bzip2 source to the same directory.
  144. Add libbz2.lib to the link list for whatever you are building. Also
  145. define the compiler define BZIP2_SUPPORT.
  146. Build Zip.
  147. Using Zip with bzip2 as dll:
  148. Put libbz2.dll in your command path. This is needed to run Zip with
  149. bzip2 support.
  150. Verify that bzip2 is enabled with the command
  151. zip -v
  152. You should see bzip2 listed.
  153. Compiling in bzip2 from the bzip2 source:
  154. This approach compiles in the bzip2 code directly. No external
  155. library is needed.
  156. Get a copy of the bzip2 source and copy the contents to the bzip2
  157. directory in the Zip source tree so that bzlib.h is directly in
  158. the bzip2 directory.
  159. Use the vc6bz2 project to build Zip. This project knows of the
  160. added bzip2 files.
  161. Verify that bzip2 is enabled with the command
  162. zip -v
  163. Windows DLL (WIN32):
  164. Nothing yet.
  165. Mac OS X:
  166. Follow the standard UNIX build procedure. Mac OS X includes bzip2
  167. and the UNIX builders should find the bzip2 files in the standard
  168. places. Note that the version of bzip2 on your OS may not be
  169. current and you can instead specify a different library or compile
  170. your own bzip2 library as noted in the Unix procedures above.
  171. OS/2:
  172. Nothing yet.
  173. VMS (OpenVMS):
  174. See [.vms]install_vms.txt for how to enable bzip2 support on VMS.
  175. Last updated 26 March 2007, 15 July 2007, 9 April 2008, 27 June 2008
  176. S. Schweda, E. Gordon