Compress::Zlib becomes zlib agnostic
[p5sagit/p5-mst-13.2.git] / ext / Compress / Zlib / README
CommitLineData
642e522c 1
f4c6fd49 2 Compress::Zlib
3
1a6a8453 4 Version 2.000_07
642e522c 5
1a6a8453 6 9 Jan 2006
f4c6fd49 7
1a6a8453 8 Copyright (c) 1995-2006 Paul Marquess. All rights reserved.
642e522c 9 This program is free software; you can redistribute it
10 and/or modify it under the same terms as Perl itself.
f4c6fd49 11
f4c6fd49 12
642e522c 13 The directory zlib-src contains a subset of the
14 source files copied directly from zlib version 1.2.3.
15 These files are Copyright(C) 1995-2005
16 Jean-loup Gailly and Mark Adler.
17 Full source for the zlib library is available at
5993747c 18 http://www.zlib.org
f4c6fd49 19
20
642e522c 21 WARNING
22 THIS IS BETA CODE.
23
24 DO NOT use in production code.
25 Please report any problems.
26
f4c6fd49 27DESCRIPTION
28-----------
29
30This module provides a Perl interface to most of the zlib compression
1a6a8453 31library. For more details see the pod documentation embedded in the file
32Zlib.pm.
f4c6fd49 33
34If you have downloaded this module in the expectation of manipulating the
35contents of .zip files, you will need to fetch and build the Archive::Zip
36module below once you have installed this one.
37
38 http://www.cpan.org/modules/by-module/Archive/Archive-Zip-*.tar.gz
39
40
642e522c 41
42
f4c6fd49 43PREREQUISITES
44-------------
45
46Before you can build Compress::Zlib you need to have the following
47installed on your system:
48
49 * A C compiler
50
51 * Perl 5.004 or better.
52
53By default, Compress::Zlib will build its own private copy of the zlib
54library. If you want to use a different version of zlib, follow the
55instructions in the section called "Controlling the version of zlib used
56by Compress::Zlib" later in this document.
57
58
59BUILDING THE MODULE
60-------------------
61
62Assuming you have met all the prerequisites, the module can now be built
63using this sequence of commands:
64
65 perl Makefile.PL
66 make
67 make test
68
69
70
71INSTALLATION
72------------
73
74To install Compress::Zlib, run the command below:
75
76 make install
77
78UPDATES
79-------
80
81The most recent version of Compress::Zlib is always available at
82
83 http://www.cpan.org/modules/by-module/Compress/
84
85
86
87Controlling the version of zlib used by Compress::Zlib
88-----------------------------------------------------
89
90Compress::Zlib interfaces to the zlib compression library. There are
91three options available to control which version/instance of the zlib
92library is used:
93
94 1. Build a private copy of the zlib library using the zlib library
95 source that is included with this module.
96 This is the default and recommended option.
97
98 2. Build a private copy of the zlib library using a standard zlib
99 source distribution.
100
5993747c 101 3. Use a pre-built zlib library.
f4c6fd49 102
103Note that if you intend to use either Option 2 or 3, you need to have
642e522c 104zlib version 1.0.5 or better.
f4c6fd49 105
106
107The contents of the file config.in are used to control which of the
642e522c 108three options is actually used. This file is read during the
f4c6fd49 109
110 perl Makefile.PL
111
112step of the build, so remember to make any required changes to config.in
113before building this module.
114
115
116
117 Option 1
118 --------
119
120 For option 1, edit the file config.in and set the variables in it
121 as follows:
122
642e522c 123 BUILD_ZLIB = True
124 INCLUDE = ./zlib-src
125 LIB = ./zlib-src
126 OLD_ZLIB = False
127 GZIP_OS_CODE = AUTO_DETECT
f4c6fd49 128
129
130 Option 2
131 --------
132
133 For option 2, fetch a copy of the zlib source distribution from
1a6a8453 134 http://www.zlib.org and unpack it into the Compress::Zlib source directory.
135 Assuming you have fetched zlib 1.2.3, it will create a
642e522c 136 directory called zlib-1.2.3.
f4c6fd49 137
138 Now set the variables in the file config.in as follows (if the version
1a6a8453 139 you have fetched isn't 1.2.3, change the INCLUDE and LIB
140 variables appropriately):
f4c6fd49 141
642e522c 142 BUILD_ZLIB = True
143 INCLUDE = ./zlib-1.2.3
144 LIB = ./zlib-1.2.3
145 OLD_ZLIB = False
146 GZIP_OS_CODE = AUTO_DETECT
f4c6fd49 147
148
149 Option 3
150 --------
151
152 For option 3, you need to find out where zlib is stored on your system.
153 There are two parts to this.
154
155 First, find the directory where the zlib library is stored (some common
156 names for the library are libz.a and libz.so). Set the LIB variable in
157 the config.in file to that directory.
158
159 Secondly, find the directory where the file zlib.h is stored. Now set
160 the INCLUDE variable in the config.in file to that directory.
161
642e522c 162 Next set BUILD_ZLIB to False.
f4c6fd49 163
164 Finally, if you are running zlib 1.0.5 or older, set the OLD_ZLIB
165 variable to True. Otherwise set it to False.
166
167 As an example, if the zlib library on your system is in /usr/local/lib,
642e522c 168 zlib.h is in /usr/local/include and zlib is more recent than version
f4c6fd49 169 1.0.5, the variables in config.in should be set as follows:
170
642e522c 171 BUILD_ZLIB = False
172 INCLUDE = /usr/local/include
173 LIB = /usr/local/lib
174 OLD_ZLIB = False
175 GZIP_OS_CODE = AUTO_DETECT
f4c6fd49 176
177
642e522c 178Setting the Gzip OS Code
179------------------------
180
1a6a8453 181Every gzip stream stores a byte in its header to identify the Operating
182System that was used to create the gzip stream. When you build
183Compress::Zlib it will attempt to determine the value that is correct for
184your Operating System. This will then be used by IO::Gzip as the default
185value for the OS byte in all gzip headers it creates.
642e522c 186
1a6a8453 187The variable GZIP_OS_CODE in the config.in file controls the setting of
188this value when building Compress::Zlib. If GZIP_OS_CODE is set to
189AUTO_DETECT, Compress::Zlib will attempt to determine the correct value for
190your Operating System.
642e522c 191
192Alternatively, you can override auto-detection of the default OS code and
1a6a8453 193explicitly set it yourself. Set the GZIP_OS_CODE variable in the config.in
194file to be a number between 0 and 255. For example
642e522c 195
196 GZIP_OS_CODE = 3
197
198See RFC 1952 for valid OS codes that can be used.
199
1a6a8453 200If you are running one of the less popular Operating Systems, it could be
201that the default value picked by this module is incorrect or the default
202value (3) is used when there is a better value available. When
203Compress::Zlib cannot determine what operating system you are running, it
204will use the default value 3 for the OS code.
642e522c 205
206If you find you have to change this value, because you think the value auto
1a6a8453 207detected is incorrect, please take a few moments to contact the author of
208this module.
f4c6fd49 209
210
211TROUBLESHOOTING
212---------------
213
214Undefined Symbol gzsetparams
215----------------------------
216
217If you get the error shown below when you run the Compress::Zlib test
218harness it probably means you are running a copy of zlib that is version
2191.0.5 or older.
220
221t/01version.........Can't load 'blib/arch/auto/Compress/Zlib/Zlib.so' for
222 module Compress::Zlib: blib/arch/auto/Compress/Zlib/Zlib.so:
223 undefined symbol: gzsetparams at ...
224
225There are two ways to fix this problem:
226
227 1. Upgrade to the latest version of zlib.
228
229 2. Edit config.in and set the OLD_ZLIB variable to True.
230
231
232
233Test Harness 01version fails
234----------------------------
235If the 01version test harness fails, and the problem isn't covered by
236the scenario above, it probably means that you have two versions of zlib
237installed on your system.
238
239Run the command below to see if this is indeed the case
240
241 make test TEST_VERBOSE=1 TEST_FILES=t/01version.t
242
243Try removing the one you don't want to use and rebuild.
244
245
246
f4c6fd49 247Solaris build fails with "language optional software package not installed"
248---------------------------------------------------------------------------
249
250If you are trying to build this module under Solaris and you get an
251error message like this
252
253 /usr/ucb/cc: language optional software package not installed
254
255it means that Perl cannot find the C compiler on your system. The cryptic
256message is just Sun's way of telling you that you haven't bought their
257C compiler.
258
259When you build a Perl module that needs a C compiler, the Perl build
260system tries to use the same C compiler that was used to build perl
261itself. In this case your Perl binary was built with a C compiler that
262lived in /usr/ucb.
263
264To continue with building this module, you need to get a C compiler,
265or tell Perl where your C compiler is, if you already have one.
266
642e522c 267Assuming you have now got a C compiler, what you do next will be dependent
f4c6fd49 268on what C compiler you have installed. If you have just installed Sun's
269C compiler, you shouldn't have to do anything. Just try rebuilding
270this module.
271
272If you have installed another C compiler, say gcc, you have to tell perl
273how to use it instead of /usr/ucb/cc.
274
275This set of options seems to work if you want to use gcc. Your mileage
276may vary.
277
278 perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" "
279 make test
280
281If that doesn't work for you, it's time to make changes to the Makefile
282by hand. Good luck!
283
284
285
286
287Solaris build fails with "gcc: unrecognized option `-KPIC'"
288-----------------------------------------------------------
289
290You are running Solaris and you get an error like this when you try to
291build this Perl module
292
293 gcc: unrecognized option `-KPIC'
294
295This symptom usually means that you are using a Perl binary that has been
296built with the Sun C compiler, but you are using gcc to build this module.
297
298When Perl builds modules that need a C compiler, it will attempt to use
299the same C compiler and command line options that was used to build perl
300itself. In this case "-KPIC" is a valid option for the Sun C compiler,
301but not for gcc. The equivalent option for gcc is "-fPIC".
302
303The solution is either:
304
305 1. Build both Perl and this module with the same C compiler, either
306 by using the Sun C compiler for both or gcc for both.
307
308 2. Try generating the Makefile for this module like this perl
309
310 perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" " LD=gcc
311 make test
312
313 This second option seems to work when mixing a Perl binary built
314 with the Sun C compiler and this module built with gcc. Your
315 mileage may vary.
316
317
642e522c 318The t/17isize Test Suite
319------------------------
320
321This test suite checks that Compress::Zlib can cope with gzip files
322that are larger than 2^32 bytes.
323
324By default these test are NOT run when you do a "make test". If you
325really want to run them, you need to execute "make longtest".
326
327Be warned though -- this test suite can take hours to run on a slow box.
328
329Also, due to the way the tests are constructed, some architectures will
1a6a8453 330run out of memory during this test. This should not be considered a bug
642e522c 331in the Compress::Zlib module.
332
333
f4c6fd49 334
335HP-UX Notes
336-----------
337
338I've had a report that when building Compress::Zlib under HP-UX that it
339is necessary to have first built the zlib library with the -fpic option.
340
341
342
343Linux Notes
344-----------
345
346Although most Linux distributions already come with zlib, some people
347report getting this error when they try to build this module:
348
349$ make
350cp Zlib.pm blib/lib/Compress/Zlib.pm
351AutoSplitting blib/lib/Compress/Zlib.pm (blib/lib/auto/Compress/Zlib)
352/usr/bin/perl -I/usr/lib/perl5/5.6.1/i386-linux -I/usr/lib/perl5/5.6.1 /usr/lib/perl5/5.6.1/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.6.1/ExtUtils/typemap -typemap typemap Zlib.xs > Zlib.xsc && mv Zlib.xsc Zlib.c
353gcc -c -I/usr/local/include -fno-strict-aliasing -I/usr/local/include -O2 -march=i386 -mcpu=i686 -DVERSION=\"1.16\" -DXS_VERSION=\"1.16\" -fPIC -I/usr/lib/perl5/5.6.1/i386-linux/CORE Zlib.c
354Zlib.xs:25:19: zlib.h: No such file or directory
355make: *** [Zlib.o] Error 1
356
357This usually means that you have not installed the development RPM
358for zlib. Check for an RPM that start with "zlib-devel" in your Linux
359distribution.
360
361
362
363
364Win32 Notes
365-----------
366
367If you are running Activestate Perl (from http://www.activestate.com),
368it ships with a pre-compiled version of Compress::Zlib. To check if a
369newer version of Compress::Zlib is available run this from the command
370prompt
371
372 C:\> ppm verify -upgrade Compress-Zlib
373
374
375If you are not running Activestate Perl and you don't have access
376to a C compiler, you will not be able to build and install this module.
377
378
379
380
381Win32 & Cygwin Notes
382--------------------
383
384It is not possible to install Compress::Zlib using the CPAN shell.
385This is because the Compress::Zlib DLL is itself used by the CPAN shell
386and it is impossible to remove a DLL while it is already loaded under
387Windows.
388
389The workaround is to install Compress::Zlib manually using the
390instructions given at the start of this file.
391
392
393
f4c6fd49 394FEEDBACK
395--------
396
397How to report a problem with Compress::Zlib.
398
399To help me help you, I need all of the following information:
400
401 1. The *complete* output from running this
402
403 perl -V
404
405 Do not edit the output in any way.
406 Note, I want you to run "perl -V" and NOT "perl -v".
407
408 If your perl does not understand the "-V" option it is too
409 old. This module needs Perl version 5.004 or better.
410
411 2. The version of Compress::Zlib you have.
412 If you have successfully installed Compress::Zlib, this one-liner
413 will tell you:
414
415 perl -MCompress::Zlib -e 'print qq[ver $Compress::Zlib::VERSION\n]'
416
417 If you are running windows use this
418
419 perl -MCompress::Zlib -e "print qq[ver $Compress::Zlib::VERSION\n]"
420
421 If you haven't installed Compress::Zlib then search Compress::Zlib.pm
422 for a line like this:
423
424 $VERSION = "1.05" ;
425
426 3. The version of zlib you have installed.
427 If you have successfully installed Compress::Zlib, this one-liner
428 will tell you:
429
430 perl -MCompress::Zlib -e "print q[zlib ver ]. Compress::Zlib::ZLIB_VERSION.qq[\n]"
431
432
433 If not, look at the beginning of the file zlib.h.
434
435 4. If you are having problems building Compress::Zlib, send me a
436 complete log of what happened. Start by unpacking the Compress:Zlib
437 module into a fresh directory and keep a log of all the steps
438
439 [edit config.in, if necessary]
440 perl Makefile.PL
441 make
442 make test TEST_VERBOSE=1
443
444
445Paul Marquess <pmqs@cpan.org>