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 -Wno-comment ' if $Config{'cc'} =~ /gcc/ ;
31 unless($ENV{PERL_CORE}) {
32 $ENV{PERL_CORE} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
35 # don't ask if MM_USE_DEFAULT is set -- enables perl core building on cygwin
36 if ($^O =~ /cygwin/i and not ($ENV{PERL_MM_USE_DEFAULT} or $ENV{PERL_CORE}))
40 I see you are running Cygwin.
42 Please note that this module cannot be installed on Cygwin using the
43 CPAN shell. The CPAN Shell uses Compress::Zlib internally and it is not
44 possible to delete an active DLL.
46 If you are running the CPAN shell, please exit it and install this module
47 by hand by running 'make install' under the directory
49 ~/.cpan/build/Compress-Zlib-VERSION
53 print "Do you want to continue? [Y/N]: " ;
54 my $answer = <STDIN> ;
56 if ($answer =~ /^yes|y/i)
58 print "continuing...\n"
62 print "exiting...\n" ;
71 my @files = ('Zlib.pm', 't/ZlibTestUtils.pm',
74 glob("lib/CompressPlugin/*.pm"),
75 glob("lib/UncompressPlugin/*.pm"),
76 glob("lib/IO/Compress/*.pm"),
77 glob("lib/IO/Uncompress/*.pm"),
78 glob("lib/Compress/Zlib/*.pm"),
79 glob("lib/Compress/Gzip/*.pm"),
80 glob("lib/File/*.pm"),
82 grep(!/\.bak$/, glob("examples/*"))) ;
84 UpDowngrade(@files) unless $ENV{PERL_CORE};
87 NAME => 'Compress::Zlib',
88 VERSION_FROM => 'Zlib.pm',
90 INC => "-I$ZLIB_INCLUDE" ,
91 DEFINE => "$OLD_ZLIB $WALL -DGZIP_OS_CODE=$GZIP_OS_CODE" ,
92 XS => { 'Zlib.xs' => 'Zlib.c'},
95 : (PREREQ_PM => { 'Scalar::Util' => 0,
96 $] >= 5.005 && $] < 5.006 ? ('File::BSDGlob' => 0) : () }
98 'depend' => { 'Makefile' => 'config.in' },
99 'clean' => { FILES => '*.c constants.h constants.xs' },
100 'dist' => { COMPRESS => 'gzip',
102 DIST_DEFAULT => 'MyDoubleCheck downgrade tardist',
105 ? zlib_files($ZLIB_LIB)
106 : (LIBS => [ "-L$ZLIB_LIB -lz " ])
109 ? (ABSTRACT_FROM => 'Zlib.pm',
110 AUTHOR => 'Paul Marquess <pmqs@cpan.org>')
129 Z_DEFAULT_COMPRESSION
155 if (eval {require ExtUtils::Constant; 1}) {
156 # Check the constants above all appear in @EXPORT in Zlib.pm
157 my %names = map { $_, 1} @names, 'ZLIB_VERSION';
158 open F, "<Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
161 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
168 delete $names{$1} if defined $1 ;
174 my $missing = join ("\n\t", sort keys %names) ;
175 die "The following names are missing from \@EXPORT in Zlib.pm\n" .
179 push @names, {name => 'ZLIB_VERSION', type => 'PV' };
181 ExtUtils::Constant::WriteConstants(
184 C_FILE => 'constants.h',
185 XS_FILE => 'constants.xs',
190 foreach my $name (qw( constants.h constants.xs ))
192 my $from = catfile('fallback', $name);
194 or die "Can't copy $from to $name: $!";
204 if $path =~ /(~|\.bak|_bak)$/ ||
205 $path =~ /\..*\.sw(o|p)$/ ||
206 $path =~ /\B\.svn\b/;
213 my $postamble = <<'EOM';
217 perl Makefile.PL -downgrade
220 @echo Checking config.in is setup for a release
221 @(grep '^LIB *= *./zlib-src' config.in && \
222 grep '^INCLUDE *= *./zlib-src' config.in && \
223 grep '^OLD_ZLIB *= *False' config.in && \
224 grep '^GZIP_OS_CODE *= *AUTO_DETECT' config.in && \
225 grep '^BUILD_ZLIB *= *True' config.in) >/dev/null || \
226 (echo config.in needs fixing ; exit 1)
227 @echo config.in is ok
230 @echo Checking for $$^W in files: '. "@files" . '
232 exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \
233 \' ' . " @files || " . ' \
234 (echo found unexpected $$^W ; exit 1)
238 @echo Running test suite with Devel::Cover
239 $(MAKE) test COMPRESS_ZLIB_RUN_ALL=1
242 @echo Running test suite with Devel::Cover
243 HARNESS_PERL_SWITCHES=-MDevel::Cover $(MAKE) test
246 @echo Running test suite with Devel::Cover
247 HARNESS_PERL_SWITCHES=-MDevel::Cover $(MAKE) test COMPRESS_ZLIB_RUN_ALL=1
250 @echo Running test suite with unicode support enabled
251 env PERL_UNICODE=63 $(MAKE) test
255 $postamble .= <<'EOM' if $^O eq 'linux' ;
258 @echo Running test suite with gcov and Devel::Cover [needs gcc 3.4?]
259 rm -f *.o *.gcov *.da *.bbg *.bb *.gcno
260 HARNESS_PERL_SWITCHES=-MDevel::Cover $(MAKE) test \
262 CCFLAGS=-O0\ -fprofile-arcs\ -ftest-coverage \
263 OTHERLDFLAGS=-fprofile-arcs\ -ftest-coverage
265 gcov2perl -db cover_db Zlib.xs.gcov
277 my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB GZIP_OS_CODE ) ;
278 my %ValidOption = map {$_, 1} @Options ;
279 my %Parsed = %ValidOption ;
280 my $CONFIG = 'config.in' ;
282 print "Parsing $CONFIG...\n" ;
284 open(F, "<$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
287 next if /^\s*$/ or /^\s*#/ ;
290 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
292 if ($ValidOption{$k}) {
302 print "Unknown keys in $CONFIG ignored [@badkey]\n"
305 # check parsed values
307 die "The following keys are missing from $CONFIG [@missing]\n"
308 if @missing = keys %Parsed ;
310 $ZLIB_INCLUDE = $ENV{'ZLIB_INCLUDE'} || $Info{'INCLUDE'} ;
311 $ZLIB_LIB = $ENV{'ZLIB_LIB'} || $Info{'LIB'} ;
314 $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
315 $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
318 my $y = $ENV{'OLD_ZLIB'} || $Info{'OLD_ZLIB'} ;
319 $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
321 my $x = $ENV{'BUILD_ZLIB'} || $Info{'BUILD_ZLIB'} ;
323 if ($x and $x =~ /^yes|on|true|1$/i ) {
327 # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when
328 # BUILD_ZLIB is specified.
329 die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n"
330 if $ZLIB_LIB ne $ZLIB_INCLUDE ;
332 # Check the zlib source directory exists
333 die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n"
334 unless -d $ZLIB_LIB ;
336 # check for a well known file
337 die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n"
338 unless -e catfile($ZLIB_LIB, 'zlib.h') ;
342 print "Building Zlib enabled\n" ;
345 $GZIP_OS_CODE = defined $ENV{'GZIP_OS_CODE'}
346 ? $ENV{'GZIP_OS_CODE'}
347 : $Info{'GZIP_OS_CODE'} ;
349 die "GZIP_OS_CODE not 'AUTO_DETECT' or a number between 0 and 255\n"
350 unless uc $GZIP_OS_CODE eq 'AUTO_DETECT'
351 || ( $GZIP_OS_CODE =~ /^(\d+)$/ && $1 >= 0 && $1 <= 255) ;
353 if (uc $GZIP_OS_CODE eq 'AUTO_DETECT')
355 print "Auto Detect Gzip OS Code..\n" ;
356 $GZIP_OS_CODE = getOSCode() ;
359 my $name = getOSname($GZIP_OS_CODE);
360 print "Setting Gzip OS Code to $GZIP_OS_CODE [$name]\n" ;
363 INCLUDE [$ZLIB_INCLUDE]
365 GZIP_OS_CODE [$GZIP_OS_CODE]
367 BUILD_ZLIB [$BUILD_ZLIB]
371 print "Looks Good.\n" ;
379 # our and use bytes/utf8 is stable from 5.6.0 onward
380 # warnings is stable from 5.6.1 onward
382 # Note: this code assumes that each statement it modifies is not
383 # split across multiple lines.
389 my $opt = shift @ARGV || '' ;
390 my $upgrade = ($opt =~ /^-upgrade/i);
391 my $downgrade = ($opt =~ /^-downgrade/i);
392 push @ARGV, $opt unless $downgrade || $upgrade;
395 # From: use|no warnings "blah"
396 # To: local ($^W) = 1; # use|no warnings "blah"
398 s/^(\s*)(no\s+warnings)/${1}local (\$^W) = 0; #$2/ ;
399 s/^(\s*)(use\s+warnings)/${1}local (\$^W) = 1; #$2/ ;
402 elsif ($] >= 5.006001 || $upgrade) {
403 # From: local ($^W) = 1; # use|no warnings "blah"
404 # To: use|no warnings "blah"
406 s/^(\s*)local\s*\(\$\^W\)\s*=\s*\d+\s*;\s*#\s*((no|use)\s+warnings.*)/$1$2/ ;
412 if ( /^(\s*)our\s+\(\s*([^)]+\s*)\)/ ) {
414 my $vars = join ' ', split /\s*,\s*/, $2;
415 $_ = "${indent}use vars qw($vars);\n";
417 elsif ( /^(\s*)((use|no)\s+(bytes|utf8)\s*;.*)$/)
423 elsif ($] >= 5.006000 || $upgrade) {
425 if ( /^(\s*)use\s+vars\s+qw\((.*?)\)/ ) {
427 my $vars = join ', ', split ' ', $2;
428 $_ = "${indent}our ($vars);\n";
430 elsif ( /^(\s*)#\s*((use|no)\s+(bytes|utf8)\s*;.*)$/)
437 if (! $our_sub && ! $warn_sub) {
438 warn "Up/Downgrade not needed.\n";
439 if ($upgrade || $downgrade)
446 { doUpDown($our_sub, $warn_sub, $_) }
448 warn "Up/Downgrade complete.\n" ;
449 exit 0 if $upgrade || $downgrade;
457 my $warn_sub = shift;
461 local ($^I) = ($^O eq 'VMS') ? "_bak" : ".bak";
462 local (@ARGV) = shift;
466 print, last if /^__(END|DATA)__/ ;
468 &{ $our_sub }() if $our_sub ;
469 &{ $warn_sub }() if $warn_sub ;
487 if (-f catfile($dir, "infback.c")) {
488 # zlib 1.2.0 or greater
490 @h_files = qw(crc32.h inffast.h inflate.h trees.h zconf.in.h
491 zutil.h deflate.h inffixed.h inftrees.h zconf.h
494 @c_files = qw(adler32 crc32 infback inflate uncompr
495 compress deflate inffast inftrees
502 @h_files = qw(deflate.h infcodes.h inftrees.h zconf.h zutil.h
503 infblock.h inffast.h infutil.h zlib.h
505 @c_files = qw(adler32 compress crc32 uncompr
506 deflate trees zutil inflate infblock
507 inftrees infcodes infutil inffast
511 @h_files = map { catfile($dir, $_) } @h_files ;
512 my @o_files = map { "$_\$(OBJ_EXT)" } 'Zlib', @c_files;
513 @c_files = map { "$_.c" } 'Zlib', @c_files ;
515 foreach my $file (@c_files)
516 { copy(catfile($dir, $file), '.') }
519 #'H' => [ @h_files ],
520 'C' => [ @c_files ] ,
521 #'OBJECT' => qq[ @o_files ],
522 'OBJECT' => q[ $(O_FILES) ],
536 [ '' => 0, 'MS-DOS' ],
537 [ 'amigaos' => 1, 'Amiga' ],
538 [ 'VMS' => 2, 'VMS' ],
539 [ '' => 3, 'Unix/Default' ],
540 [ '' => 4, 'VM/CMS' ],
541 [ '' => 5, 'Atari TOS' ],
542 [ 'os2' => 6, 'HPFS (OS/2, NT)' ],
543 [ 'MacOS' => 7, 'Macintosh' ],
544 [ '' => 8, 'Z-System' ],
546 [ '' => 10, 'TOPS-20' ],
547 [ '' => 11, 'NTFS (NT)' ],
548 [ '' => 12, 'SMS QDOS' ],
549 [ '' => 13, 'Acorn RISCOS' ],
550 [ 'MSWin32' => 14, 'VFAT file system (Win95, NT)' ],
552 [ 'beos' => 16, 'BeOS' ],
553 [ '' => 17, 'Tandem/NSK' ],
554 [ '' => 18, 'THEOS' ],
555 [ '' => 255, 'Unknown OS' ],
558 %OSnames = map { $$_[1] => $$_[2] }
564 my $default = 3 ; # Unix is the default
568 for my $h (@GZIP_OS_Names)
570 my ($pattern, $code, $name) = @$h;
573 if $pattern && $uname eq $pattern ;
583 return $OSnames{$code} || 'Unknown OS' ;
586 # end of file Makefile.PL