6 use ExtUtils::MakeMaker 5.16 ;
12 eval { require File::Spec::Functions ; File::Spec::Functions->import() } ;
15 *catfile = sub { return "$_[0]/$_[1]" }
19 require VMS::Filespec if $^O eq 'VMS';
28 unless($ENV{PERL_CORE}) {
29 $ENV{PERL_CORE} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
32 # don't ask if MM_USE_DEFAULT is set -- enables perl core building on cygwin
33 if ($^O =~ /cygwin/i and not $ENV{PERL_MM_USE_DEFAULT} and not $ENV{PERL_CORE})
37 I see you are running Cygwin.
39 Please note that this module cannot be installed on Cygwin using the
40 CPAN shell. The CPAN Shell uses Compress::Zlib internally and it is not
41 possible to delete an active DLL.
43 If you are running the CPAN shell, please exit it and install this module
44 by hand by running 'make install' under the directory
46 ~/.cpan/build/Compress-Zlib-VERSION
50 print "Do you want to continue? [Y/N]: " ;
51 my $answer = <STDIN> ;
53 if ($answer =~ /^yes|y/i)
55 print "continuing...\n"
59 print "exiting...\n" ;
68 my @files = ('Zlib.pm', glob("t/*.t"), grep(!/\.bak$/, glob("examples/*"))) ;
72 NAME => 'Compress::Zlib',
73 VERSION_FROM => 'Zlib.pm',
74 INC => "-I$ZLIB_INCLUDE" ,
75 DEFINE => "$OLD_ZLIB $WALL" ,
76 XS => { 'Zlib.xs' => 'Zlib.c' },
77 'depend' => { 'Makefile' => 'config.in' },
78 'clean' => { FILES => '*.c constants.h constants.xs' },
79 'dist' => { COMPRESS => 'gzip',
81 DIST_DEFAULT => 'MyDoubleCheck Downgrade tardist',
84 ? zlib_files($ZLIB_LIB)
85 : (LIBS => [ "-L$ZLIB_LIB -lz " ])
88 ? (ABSTRACT_FROM => 'Zlib.pm',
89 AUTHOR => 'Paul Marquess <pmqs@cpan.org>')
107 Z_DEFAULT_COMPRESSION
129 if (eval {require ExtUtils::Constant; 1}) {
130 # Check the constants above all appear in @EXPORT in Zlib.pm
131 my %names = map { $_, 1} @names, 'ZLIB_VERSION';
132 open F, "<Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
135 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
142 delete $names{$1} if defined $1 ;
148 my $missing = join ("\n\t", sort keys %names) ;
149 die "The following names are missing from \@EXPORT in Zlib.pm\n" .
153 push @names, {name => 'ZLIB_VERSION', type => 'PV' };
155 ExtUtils::Constant::WriteConstants(
158 C_FILE => 'constants.h',
159 XS_FILE => 'constants.xs',
164 copy ('fallback.h', 'constants.h')
165 or die "Can't copy fallback.h to constants.h: $!";
166 copy ('fallback.xs', 'constants.xs')
167 or die "Can't copy fallback.xs to constants.xs: $!";
172 my $postamble = <<'EOM';
176 perl Makefile.PL -downgrade
179 @echo Checking config.in is setup for a release
180 @(grep '^LIB *= *./zlib' config.in && \
181 grep '^INCLUDE *= *./zlib' config.in && \
182 grep '^OLD_ZLIB *= *False' config.in && \
183 grep '^BUILD_ZLIB *= *True' config.in) >/dev/null || \
184 (echo config.in needs fixing ; exit 1)
185 @echo config.in is ok
188 @echo Checking for $$^W in files: '. "@files" . '
190 exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \
191 \' ' . " @files || " . ' \
192 (echo found unexpected $$^W ; exit 1)
209 my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB ) ;
210 my %ValidOption = map {$_, 1} @Options ;
211 my %Parsed = %ValidOption ;
212 my $CONFIG = 'config.in' ;
214 print "Parsing $CONFIG...\n" ;
216 open(F, "<$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
219 next if /^\s*$/ or /^\s*#/ ;
222 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
224 if ($ValidOption{$k}) {
234 print "Unknown keys in $CONFIG ignored [@badkey]\n"
237 # check parsed values
239 die "The following keys are missing from $CONFIG [@missing]\n"
240 if @missing = keys %Parsed ;
242 $ZLIB_INCLUDE = $ENV{'ZLIB_INCLUDE'} || $Info{'INCLUDE'} ;
243 $ZLIB_LIB = $ENV{'ZLIB_LIB'} || $Info{'LIB'} ;
246 $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
247 $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
250 my $y = $ENV{'OLD_ZLIB'} || $Info{'OLD_ZLIB'} ;
251 $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
253 my $x = $ENV{'BUILD_ZLIB'} || $Info{'BUILD_ZLIB'} ;
255 if ($x and $x =~ /^yes|on|true|1$/i ) {
259 # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when
260 # BUILD_ZLIB is specified.
261 die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n"
262 if $ZLIB_LIB ne $ZLIB_INCLUDE ;
264 # Check the zlib source directory exists
265 die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n"
266 unless -d $ZLIB_LIB ;
268 # check for a well known file
269 die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n"
270 unless -e catfile($ZLIB_LIB, 'zlib.h') ;
273 # check Makefile.zlib has been copied to ZLIB_LIB
274 #copy 'Makefile.zlib', catfile($ZLIB_LIB, 'Makefile.PL') ||
275 #die "Could not copy Makefile.zlib to " . catfile($ZLIB_LIB, 'Makefile.PL') . ": $!\n" ;
276 #print "Created a Makefile.PL for zlib\n" ;
279 print "Building Zlib enabled\n" ;
283 INCLUDE [$ZLIB_INCLUDE]
288 print "Looks Good.\n" ;
296 # our is stable from 5.6.0 onward
297 # warnings is stable from 5.6.1 onward
299 # Note: this code assumes that each statement it modifies is not
300 # split across multiple lines.
306 my $opt = shift @ARGV || '' ;
307 my $upgrade = ($opt =~ /^-upgrade/i);
308 my $downgrade = ($opt =~ /^-downgrade/i);
309 push @ARGV, $opt unless $downgrade || $upgrade;
312 # From: use|no warnings "blah"
313 # To: local ($^W) = 1; # use|no warnings "blah"
315 s/^(\s*)(no\s+warnings)/${1}local (\$^W) = 0; #$2/ ;
316 s/^(\s*)(use\s+warnings)/${1}local (\$^W) = 1; #$2/ ;
319 elsif ($] >= 5.006001 || $upgrade) {
320 # From: local ($^W) = 1; # use|no warnings "blah"
321 # To: use|no warnings "blah"
323 s/^(\s*)local\s*\(\$\^W\)\s*=\s*\d+\s*;\s*#\s*((no|use)\s+warnings.*)/$1$2/ ;
329 if ( /^(\s*)our\s+\(\s*([^)]+\s*)\)/ ) {
331 my $vars = join ' ', split /\s*,\s*/, $2;
332 $_ = "${indent}use vars qw($vars);\n";
336 elsif ($] >= 5.006000 || $upgrade) {
338 if ( /^(\s*)use\s+vars\s+qw\((.*?)\)/ ) {
340 my $vars = join ', ', split ' ', $2;
341 $_ = "${indent}our ($vars);\n";
346 if (! $our_sub && ! $warn_sub) {
347 warn "Up/Downgrade not needed.\n";
348 if ($upgrade || $downgrade)
355 { doUpDown($our_sub, $warn_sub, $_) }
357 warn "Up/Downgrade complete.\n" ;
358 exit 0 if $upgrade || $downgrade;
366 my $warn_sub = shift;
368 local ($^I) = ($^O eq 'VMS') ? "_bak" : ".bak";
369 local (@ARGV) = shift;
373 print, last if /^__(END|DATA)__/ ;
375 &{ $our_sub }() if $our_sub ;
376 &{ $warn_sub }() if $warn_sub ;
394 if (-f catfile($dir, "infback.c")) {
395 # zlib 1.2.0 or greater
397 @h_files = qw(crc32.h inffast.h inflate.h trees.h zconf.in.h
398 zutil.h deflate.h inffixed.h inftrees.h zconf.h
401 @c_files = qw(adler32 crc32 infback inflate uncompr
402 compress deflate gzio inffast inftrees
409 @h_files = qw(deflate.h infcodes.h inftrees.h zconf.h zutil.h
410 infblock.h inffast.h infutil.h zlib.h
412 @c_files = qw(adler32 compress crc32 gzio uncompr
413 deflate trees zutil inflate infblock
414 inftrees infcodes infutil inffast
418 @h_files = map { catfile($dir, $_) } @h_files ;
419 my @o_files = map { "$_\$(OBJ_EXT)" } 'Zlib', @c_files;
420 @c_files = map { "$_.c" } 'Zlib', @c_files ;
422 foreach my $file (@c_files)
423 { copy(catfile($dir, $file), '.') }
426 #'H' => [ @h_files ],
427 'C' => [ @c_files ] ,
428 #'OBJECT' => qq[ @o_files ],
429 'OBJECT' => q[ $(O_FILES) ],
436 # end of file Makefile.PL