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 # don't ask if MM_USE_DEFAULT is set -- enables perl core building on cygwin
29 if ($^O =~ /cygwin/i and not $ENV{PERL_MM_USE_DEFAULT})
33 I see you are running Cygwin.
35 Please note that this module cannot be installed on Cygwin using the
36 CPAN shell. The CPAN Shell uses Compress::Zlib internally and it is not
37 possible to delete an active DLL.
39 If you are running the CPAN shell, please exit it and install this module
40 by hand by running 'make install' under the directory
42 ~/.cpan/build/Compress-Zlib-VERSION
46 print "Do you want to continue? [Y/N]: " ;
47 my $answer = <STDIN> ;
49 if ($answer =~ /^yes|y/i)
51 print "continuing...\n"
55 print "exiting...\n" ;
64 my @files = ('Zlib.pm', glob("t/*.t"), grep(!/\.bak$/, glob("examples/*"))) ;
68 NAME => 'Compress::Zlib',
69 VERSION_FROM => 'Zlib.pm',
70 INC => "-I$ZLIB_INCLUDE" ,
71 DEFINE => "$OLD_ZLIB $WALL" ,
72 XS => { 'Zlib.xs' => 'Zlib.c' },
73 'depend' => { 'Makefile' => 'config.in' },
74 'clean' => { FILES => '*.c constants.h constants.xs' },
75 'dist' => { COMPRESS => 'gzip',
77 DIST_DEFAULT => 'MyDoubleCheck Downgrade tardist',
80 ? zlib_files($ZLIB_LIB)
81 : (LIBS => [ "-L$ZLIB_LIB -lz " ])
84 ? (ABSTRACT_FROM => 'Zlib.pm',
85 AUTHOR => 'Paul Marquess <pmqs@cpan.org>')
103 Z_DEFAULT_COMPRESSION
125 if (eval {require ExtUtils::Constant; 1}) {
126 # Check the constants above all appear in @EXPORT in Zlib.pm
127 my %names = map { $_, 1} @names, 'ZLIB_VERSION';
128 open F, "<Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
131 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
138 delete $names{$1} if defined $1 ;
144 my $missing = join ("\n\t", sort keys %names) ;
145 die "The following names are missing from \@EXPORT in Zlib.pm\n" .
149 push @names, {name => 'ZLIB_VERSION', type => 'PV' };
151 ExtUtils::Constant::WriteConstants(
154 C_FILE => 'constants.h',
155 XS_FILE => 'constants.xs',
160 copy ('fallback.h', 'constants.h')
161 or die "Can't copy fallback.h to constants.h: $!";
162 copy ('fallback.xs', 'constants.xs')
163 or die "Can't copy fallback.xs to constants.xs: $!";
168 my $postamble = <<'EOM';
172 perl Makefile.PL -downgrade
175 @echo Checking config.in is setup for a release
176 @(grep '^LIB *= *./zlib' config.in && \
177 grep '^INCLUDE *= *./zlib' config.in && \
178 grep '^OLD_ZLIB *= *False' config.in && \
179 grep '^BUILD_ZLIB *= *True' config.in) >/dev/null || \
180 (echo config.in needs fixing ; exit 1)
181 @echo config.in is ok
184 @echo Checking for $$^W in files: '. "@files" . '
186 exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \
187 \' ' . " @files || " . ' \
188 (echo found unexpected $$^W ; exit 1)
205 my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB ) ;
206 my %ValidOption = map {$_, 1} @Options ;
207 my %Parsed = %ValidOption ;
208 my $CONFIG = 'config.in' ;
210 print "Parsing $CONFIG...\n" ;
212 open(F, "<$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
215 next if /^\s*$/ or /^\s*#/ ;
218 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
220 if ($ValidOption{$k}) {
230 print "Unknown keys in $CONFIG ignored [@badkey]\n"
233 # check parsed values
235 die "The following keys are missing from $CONFIG [@missing]\n"
236 if @missing = keys %Parsed ;
238 $ZLIB_INCLUDE = $ENV{'ZLIB_INCLUDE'} || $Info{'INCLUDE'} ;
239 $ZLIB_LIB = $ENV{'ZLIB_LIB'} || $Info{'LIB'} ;
242 $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
243 $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
246 my $y = $ENV{'OLD_ZLIB'} || $Info{'OLD_ZLIB'} ;
247 $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
249 my $x = $ENV{'BUILD_ZLIB'} || $Info{'BUILD_ZLIB'} ;
251 if ($x and $x =~ /^yes|on|true|1$/i ) {
255 # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when
256 # BUILD_ZLIB is specified.
257 die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n"
258 if $ZLIB_LIB ne $ZLIB_INCLUDE ;
260 # Check the zlib source directory exists
261 die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n"
262 unless -d $ZLIB_LIB ;
264 # check for a well known file
265 die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n"
266 unless -e catfile($ZLIB_LIB, 'zlib.h') ;
269 # check Makefile.zlib has been copied to ZLIB_LIB
270 #copy 'Makefile.zlib', catfile($ZLIB_LIB, 'Makefile.PL') ||
271 #die "Could not copy Makefile.zlib to " . catfile($ZLIB_LIB, 'Makefile.PL') . ": $!\n" ;
272 #print "Created a Makefile.PL for zlib\n" ;
275 print "Building Zlib enabled\n" ;
279 INCLUDE [$ZLIB_INCLUDE]
284 print "Looks Good.\n" ;
292 # our is stable from 5.6.0 onward
293 # warnings is stable from 5.6.1 onward
295 # Note: this code assumes that each statement it modifies is not
296 # split across multiple lines.
302 my $opt = shift @ARGV || '' ;
303 my $upgrade = ($opt =~ /^-upgrade/i);
304 my $downgrade = ($opt =~ /^-downgrade/i);
305 push @ARGV, $opt unless $downgrade || $upgrade;
308 # From: use|no warnings "blah"
309 # To: local ($^W) = 1; # use|no warnings "blah"
311 s/^(\s*)(no\s+warnings)/${1}local (\$^W) = 0; #$2/ ;
312 s/^(\s*)(use\s+warnings)/${1}local (\$^W) = 1; #$2/ ;
315 elsif ($] >= 5.006001 || $upgrade) {
316 # From: local ($^W) = 1; # use|no warnings "blah"
317 # To: use|no warnings "blah"
319 s/^(\s*)local\s*\(\$\^W\)\s*=\s*\d+\s*;\s*#\s*((no|use)\s+warnings.*)/$1$2/ ;
325 if ( /^(\s*)our\s+\(\s*([^)]+\s*)\)/ ) {
327 my $vars = join ' ', split /\s*,\s*/, $2;
328 $_ = "${indent}use vars qw($vars);\n";
332 elsif ($] >= 5.006000 || $upgrade) {
334 if ( /^(\s*)use\s+vars\s+qw\((.*?)\)/ ) {
336 my $vars = join ', ', split ' ', $2;
337 $_ = "${indent}our ($vars);\n";
342 if (! $our_sub && ! $warn_sub) {
343 warn "Up/Downgrade not needed.\n";
344 if ($upgrade || $downgrade)
351 { doUpDown($our_sub, $warn_sub, $_) }
353 warn "Up/Downgrade complete.\n" ;
354 exit 0 if $upgrade || $downgrade;
362 my $warn_sub = shift;
364 local ($^I) = ($^O eq 'VMS') ? "_bak" : ".bak";
365 local (@ARGV) = shift;
369 print, last if /^__(END|DATA)__/ ;
371 &{ $our_sub }() if $our_sub ;
372 &{ $warn_sub }() if $warn_sub ;
390 if (-f catfile($dir, "infback.c")) {
391 # zlib 1.2.0 or greater
393 @h_files = qw(crc32.h inffast.h inflate.h trees.h zconf.in.h
394 zutil.h deflate.h inffixed.h inftrees.h zconf.h
397 @c_files = qw(adler32 crc32 infback inflate uncompr
398 compress deflate gzio inffast inftrees
405 @h_files = qw(deflate.h infcodes.h inftrees.h zconf.h zutil.h
406 infblock.h inffast.h infutil.h zlib.h
408 @c_files = qw(adler32 compress crc32 gzio uncompr
409 deflate trees zutil inflate infblock
410 inftrees infcodes infutil inffast
414 @h_files = map { catfile($dir, $_) } @h_files ;
415 my @o_files = map { "$_\$(OBJ_EXT)" } 'Zlib', @c_files;
416 @c_files = map { "$_.c" } 'Zlib', @c_files ;
418 foreach my $file (@c_files)
419 { copy(catfile($dir, $file), '.') }
422 #'H' => [ @h_files ],
423 'C' => [ @c_files ] ,
424 #'OBJECT' => qq[ @o_files ],
425 'OBJECT' => q[ $(O_FILES) ],
432 # end of file Makefile.PL