6 use ExtUtils::MakeMaker 5.16 ;
7 use Config qw(%Config) ;
12 eval { require File::Spec::Functions ; File::Spec::Functions->import() } ;
15 *catfile = sub { return "$_[0]/$_[1]" }
19 require VMS::Filespec if $^O eq 'VMS';
26 my $GZIP_OS_CODE = -1 ;
28 #$WALL = ' -pedantic ' if $Config{'cc'} =~ /gcc/ ;
29 $WALL = ' -Wall ' if $Config{'cc'} =~ /gcc/ ;
31 # don't ask if MM_USE_DEFAULT is set -- enables perl core building on cygwin
32 if ($^O =~ /cygwin/i and not $ENV{PERL_MM_USE_DEFAULT})
36 I see you are running Cygwin.
38 Please note that this module cannot be installed on Cygwin using the
39 CPAN shell. The CPAN Shell uses Compress::Zlib internally and it is not
40 possible to delete an active DLL.
42 If you are running the CPAN shell, please exit it and install this module
43 by hand by running 'make install' under the directory
45 ~/.cpan/build/Compress-Zlib-VERSION
49 print "Do you want to continue? [Y/N]: " ;
50 my $answer = <STDIN> ;
52 if ($answer =~ /^yes|y/i)
54 print "continuing...\n"
58 print "exiting...\n" ;
67 my @files = ('Zlib.pm', 't/ZlibTestUtils.pm',
69 glob("lib/IO/Compress/*.pm"),
70 glob("lib/IO/Uncompress/*.pm"),
71 glob("lib/Compress/Zlib/*.pm"),
72 glob("lib/Compress/Gzip/*.pm"),
73 glob("lib/File/*.pm"),
74 grep(!/\.bak$/, glob("examples/*"))) ;
76 UpDowngrade(@files) unless grep { $_ eq 'PERL_CORE=1' } @ARGV;
79 NAME => 'Compress::Zlib',
80 VERSION_FROM => 'Zlib.pm',
81 INC => "-I$ZLIB_INCLUDE" ,
82 DEFINE => "$OLD_ZLIB $WALL -DGZIP_OS_CODE=$GZIP_OS_CODE" ,
83 XS => { 'Zlib.xs' => 'Zlib.c' },
84 PREREQ_PM => { 'Scalar::Util' => 0,
85 $] >= 5.005 && $] < 5.006 ? ('File::BSDGlob' => 0) : () },
86 'depend' => { 'Makefile' => 'config.in' },
87 'clean' => { FILES => '*.c constants.h constants.xs' },
88 'dist' => { COMPRESS => 'gzip',
90 DIST_DEFAULT => 'MyDoubleCheck downgrade tardist',
93 ? zlib_files($ZLIB_LIB)
94 : (LIBS => [ "-L$ZLIB_LIB -lz " ])
97 ? (ABSTRACT_FROM => 'Zlib.pm',
98 AUTHOR => 'Paul Marquess <pmqs@cpan.org>')
117 Z_DEFAULT_COMPRESSION
143 if (eval {require ExtUtils::Constant; 1}) {
144 # Check the constants above all appear in @EXPORT in Zlib.pm
145 my %names = map { $_, 1} @names, 'ZLIB_VERSION';
146 open F, "<Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
149 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
156 delete $names{$1} if defined $1 ;
162 my $missing = join ("\n\t", sort keys %names) ;
163 die "The following names are missing from \@EXPORT in Zlib.pm\n" .
167 push @names, {name => 'ZLIB_VERSION', type => 'PV' };
169 ExtUtils::Constant::WriteConstants(
172 C_FILE => 'constants.h',
173 XS_FILE => 'constants.xs',
178 foreach my $name (qw( constants.h constants.xs ))
180 my $from = catfile('fallback', $name);
182 or die "Can't copy $from to $name: $!";
192 if $path =~ /(~|\.bak|_bak)$/ ||
193 $path =~ /\..*\.swp$/ ;
200 my $postamble = <<'EOM';
204 perl Makefile.PL -downgrade
207 @echo Checking config.in is setup for a release
208 @(grep '^LIB *= *./zlib-src' config.in && \
209 grep '^INCLUDE *= *./zlib-src' config.in && \
210 grep '^OLD_ZLIB *= *False' config.in && \
211 grep '^GZIP_OS_CODE *= *AUTO_DETECT' config.in && \
212 grep '^BUILD_ZLIB *= *True' config.in) >/dev/null || \
213 (echo config.in needs fixing ; exit 1)
214 @echo config.in is ok
217 @echo Checking for $$^W in files: '. "@files" . '
219 exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \
220 \' ' . " @files || " . ' \
221 (echo found unexpected $$^W ; exit 1)
225 @echo Running test suite with Devel::Cover
226 $(MAKE) test COMPRESS_ZLIB_RUN_ALL=1
229 @echo Running test suite with Devel::Cover
230 HARNESS_PERL_SWITCHES=-MDevel::Cover $(MAKE) test
233 @echo Running test suite with Devel::Cover
234 HARNESS_PERL_SWITCHES=-MDevel::Cover $(MAKE) test COMPRESS_ZLIB_RUN_ALL=1
237 @echo Running test suite with utf-8 enabled
238 env LC_ALL=en_GB.UTF-8 $(MAKE) test
241 @echo Running test suite with utf-8 and non-english enabled
242 env LC_ALL=de_DE.UTF-8 $(MAKE) test
246 $postamble .= <<'EOM' if $^O eq 'linux' ;
249 @echo Running test suite with gcov and Devel::Cover [needs gcc 3.4?]
250 #@test "${CC}" = "gcc" || (echo 'gcov' needs gcc, you have ${CC} ; exit 1)
251 rm -f *.o *.gcov *.da *.bbg *.bb *.gcno
252 $(MAKE) OPTIMIZE=-g DEFINE="-fprofile-arcs -ftest-coverage"
253 HARNESS_PERL_SWITCHES=-MDevel::Cover $(MAKE) test
255 #gcov2perl -db cover_db Zlib.xs.gcov
268 my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB GZIP_OS_CODE ) ;
269 my %ValidOption = map {$_, 1} @Options ;
270 my %Parsed = %ValidOption ;
271 my $CONFIG = 'config.in' ;
273 print "Parsing $CONFIG...\n" ;
275 open(F, "<$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
278 next if /^\s*$/ or /^\s*#/ ;
281 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
283 if ($ValidOption{$k}) {
293 print "Unknown keys in $CONFIG ignored [@badkey]\n"
296 # check parsed values
298 die "The following keys are missing from $CONFIG [@missing]\n"
299 if @missing = keys %Parsed ;
301 $ZLIB_INCLUDE = $ENV{'ZLIB_INCLUDE'} || $Info{'INCLUDE'} ;
302 $ZLIB_LIB = $ENV{'ZLIB_LIB'} || $Info{'LIB'} ;
305 $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
306 $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
309 my $y = $ENV{'OLD_ZLIB'} || $Info{'OLD_ZLIB'} ;
310 $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
312 my $x = $ENV{'BUILD_ZLIB'} || $Info{'BUILD_ZLIB'} ;
314 if ($x and $x =~ /^yes|on|true|1$/i ) {
318 # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when
319 # BUILD_ZLIB is specified.
320 die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n"
321 if $ZLIB_LIB ne $ZLIB_INCLUDE ;
323 # Check the zlib source directory exists
324 die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n"
325 unless -d $ZLIB_LIB ;
327 # check for a well known file
328 die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n"
329 unless -e catfile($ZLIB_LIB, 'zlib.h') ;
333 print "Building Zlib enabled\n" ;
336 $GZIP_OS_CODE = defined $ENV{'GZIP_OS_CODE'}
337 ? $ENV{'GZIP_OS_CODE'}
338 : $Info{'GZIP_OS_CODE'} ;
340 die "GZIP_OS_CODE not 'AUTO_DETECT' or a number between 0 and 255\n"
341 unless uc $GZIP_OS_CODE eq 'AUTO_DETECT'
342 || ( $GZIP_OS_CODE =~ /^(\d+)$/ && $1 >= 0 && $1 <= 255) ;
344 if (uc $GZIP_OS_CODE eq 'AUTO_DETECT')
346 print "Auto Detect Gzip OS Code..\n" ;
347 $GZIP_OS_CODE = getOSCode() ;
350 my $name = getOSname($GZIP_OS_CODE);
351 print "Setting Gzip OS Code to $GZIP_OS_CODE [$name]\n" ;
354 INCLUDE [$ZLIB_INCLUDE]
356 GZIP_OS_CODE [$GZIP_OS_CODE]
358 BUILD_ZLIB [$BUILD_ZLIB]
362 print "Looks Good.\n" ;
370 # our and use bytes/utf8 is stable from 5.6.0 onward
371 # warnings is stable from 5.6.1 onward
373 # Note: this code assumes that each statement it modifies is not
374 # split across multiple lines.
380 my $opt = shift @ARGV || '' ;
381 my $upgrade = ($opt =~ /^-upgrade/i);
382 my $downgrade = ($opt =~ /^-downgrade/i);
383 push @ARGV, $opt unless $downgrade || $upgrade;
386 # From: use|no warnings "blah"
387 # To: local ($^W) = 1; # use|no warnings "blah"
389 s/^(\s*)(no\s+warnings)/${1}local (\$^W) = 0; #$2/ ;
390 s/^(\s*)(use\s+warnings)/${1}local (\$^W) = 1; #$2/ ;
393 elsif ($] >= 5.006001 || $upgrade) {
394 # From: local ($^W) = 1; # use|no warnings "blah"
395 # To: use|no warnings "blah"
397 s/^(\s*)local\s*\(\$\^W\)\s*=\s*\d+\s*;\s*#\s*((no|use)\s+warnings.*)/$1$2/ ;
403 if ( /^(\s*)our\s+\(\s*([^)]+\s*)\)/ ) {
405 my $vars = join ' ', split /\s*,\s*/, $2;
406 $_ = "${indent}use vars qw($vars);\n";
408 elsif ( /^(\s*)((use|no)\s+(bytes|utf8)\s*;.*)$/)
414 elsif ($] >= 5.006000 || $upgrade) {
416 if ( /^(\s*)use\s+vars\s+qw\((.*?)\)/ ) {
418 my $vars = join ', ', split ' ', $2;
419 $_ = "${indent}our ($vars);\n";
421 elsif ( /^(\s*)#\s*((use|no)\s+(bytes|utf8)\s*;.*)$/)
428 if (! $our_sub && ! $warn_sub) {
429 warn "Up/Downgrade not needed.\n";
430 if ($upgrade || $downgrade)
437 { doUpDown($our_sub, $warn_sub, $_) }
439 warn "Up/Downgrade complete.\n" ;
440 exit 0 if $upgrade || $downgrade;
448 my $warn_sub = shift;
452 local ($^I) = ($^O eq 'VMS') ? "_bak" : ".bak";
453 local (@ARGV) = shift;
457 print, last if /^__(END|DATA)__/ ;
459 &{ $our_sub }() if $our_sub ;
460 &{ $warn_sub }() if $warn_sub ;
478 if (-f catfile($dir, "infback.c")) {
479 # zlib 1.2.0 or greater
481 @h_files = qw(crc32.h inffast.h inflate.h trees.h zconf.in.h
482 zutil.h deflate.h inffixed.h inftrees.h zconf.h
485 @c_files = qw(adler32 crc32 infback inflate uncompr
486 compress deflate inffast inftrees
493 @h_files = qw(deflate.h infcodes.h inftrees.h zconf.h zutil.h
494 infblock.h inffast.h infutil.h zlib.h
496 @c_files = qw(adler32 compress crc32 uncompr
497 deflate trees zutil inflate infblock
498 inftrees infcodes infutil inffast
502 @h_files = map { catfile($dir, $_) } @h_files ;
503 my @o_files = map { "$_\$(OBJ_EXT)" } 'Zlib', @c_files;
504 @c_files = map { "$_.c" } 'Zlib', @c_files ;
506 foreach my $file (@c_files)
507 { copy(catfile($dir, $file), '.') }
510 #'H' => [ @h_files ],
511 'C' => [ @c_files ] ,
512 #'OBJECT' => qq[ @o_files ],
513 'OBJECT' => q[ $(O_FILES) ],
527 [ '' => 0, 'MS-DOS' ],
528 [ 'amigaos' => 1, 'Amiga' ],
529 [ 'VMS' => 2, 'VMS' ],
530 [ '' => 3, 'Unix/Default' ],
531 [ '' => 4, 'VM/CMS' ],
532 [ '' => 5, 'Atari TOS' ],
533 [ 'os2' => 6, 'HPFS (OS/2, NT)' ],
534 [ 'MacOS' => 7, 'Macintosh' ],
535 [ '' => 8, 'Z-System' ],
537 [ '' => 10, 'TOPS-20' ],
538 [ '' => 11, 'NTFS (NT)' ],
539 [ '' => 12, 'SMS QDOS' ],
540 [ '' => 13, 'Acorn RISCOS' ],
541 [ 'MSWin32' => 14, 'VFAT file system (Win95, NT)' ],
543 [ 'beos' => 16, 'BeOS' ],
544 [ '' => 17, 'Tandem/NSK' ],
545 [ '' => 18, 'THEOS' ],
546 [ '' => 255, 'Unknown OS' ],
549 %OSnames = map { $$_[1] => $$_[2] }
555 my $default = 3 ; # Unix is the default
559 for my $h (@GZIP_OS_Names)
561 my ($pattern, $code, $name) = @$h;
564 if $pattern && $uname eq $pattern ;
574 return $OSnames{$code} || 'Unknown OS' ;
577 # end of file Makefile.PL