7 use ExtUtils::MakeMaker 5.16 ;
8 use ExtUtils::Install (); # only needed to check for version
15 my $GZIP_OS_CODE = -1 ;
16 my $USE_PPPORT_H = ($ENV{PERL_CORE}) ? '' : '-DUSE_PPPORT_H';
18 #$WALL = ' -pedantic ' if $Config{'cc'} =~ /gcc/ ;
19 #$WALL = ' -Wall -Wno-comment ' if $Config{'cc'} =~ /gcc/ ;
21 # Ticket #18986 says that ExtUtils::Install 1.39 fixes the in-use issue
22 # on win32/cygwin, so make the code below conditional on the version of
25 # Don't ask if MM_USE_DEFAULT is set -- enables perl core building on cygwin
26 if ($^O =~ /cygwin/i and $ExtUtils::Install::VERSION < 1.39
27 and not ($ENV{PERL_MM_USE_DEFAULT} or $ENV{PERL_CORE}))
31 I see you are running Cygwin.
33 Please note that this module cannot be installed on Cygwin using the CPAN
34 shell. The CPAN Shell uses Compress::Raw::Zlib internally and it is not
35 possible to delete an active DLL.
37 If you are running the CPAN shell, please exit it and install this module
38 by hand by running 'make install' under the directory
40 ~/.cpan/build/Compress-Raw-Zlib-VERSION
44 print "Do you want to continue? [Y/N]: " ;
45 my $answer = <STDIN> ;
47 if ($answer =~ /^yes|y/i)
49 print "continuing...\n"
53 print "exiting...\n" ;
62 UpDowngrade(getPerlFiles('MANIFEST'))
63 unless $ENV{PERL_CORE};
66 NAME => 'Compress::Raw::Zlib',
67 VERSION_FROM => 'lib/Compress/Raw/Zlib.pm',
68 INC => "-I$ZLIB_INCLUDE" ,
69 DEFINE => "$OLD_ZLIB $WALL -DGZIP_OS_CODE=$GZIP_OS_CODE $USE_PPPORT_H" ,
70 XS => { 'Zlib.xs' => 'Zlib.c'},
71 'depend' => { 'Makefile' => 'config.in' },
72 'clean' => { FILES => '*.c constants.h constants.xs' },
73 'dist' => { COMPRESS => 'gzip',
76 DIST_DEFAULT => 'MyTrebleCheck tardist',
87 ? zlib_files($ZLIB_LIB)
88 : (LIBS => [ "-L$ZLIB_LIB -lz " ])
93 ? (ABSTRACT_FROM => 'lib/Compress/Raw/Zlib.pm',
94 AUTHOR => 'Paul Marquess <pmqs@cpan.org>')
98 INSTALLDIRS => ($] >= 5.009 ? 'perl' : 'site'),
100 ((ExtUtils::MakeMaker->VERSION() gt '6.30') ?
101 ('LICENSE' => 'perl') : ()),
119 Z_DEFAULT_COMPRESSION
145 if (eval {require ExtUtils::Constant; 1}) {
146 # Check the constants above all appear in @EXPORT in Zlib.pm
147 my %names = map { $_, 1} @names, 'ZLIB_VERSION';
148 open F, "<lib/Compress/Raw/Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
151 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
158 delete $names{$1} if defined $1 ;
164 my $missing = join ("\n\t", sort keys %names) ;
165 die "The following names are missing from \@EXPORT in Zlib.pm\n" .
169 push @names, {name => 'ZLIB_VERSION', type => 'PV' };
171 ExtUtils::Constant::WriteConstants(
174 C_FILE => 'constants.h',
175 XS_FILE => 'constants.xs',
180 foreach my $name (qw( constants.h constants.xs ))
182 my $from = catfile('fallback', $name);
184 or die "Can't copy $from to $name: $!";
193 my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB GZIP_OS_CODE ) ;
194 my %ValidOption = map {$_, 1} @Options ;
195 my %Parsed = %ValidOption ;
196 my $CONFIG = 'config.in' ;
198 print "Parsing $CONFIG...\n" ;
200 open(F, "<$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
203 next if /^\s*$/ or /^\s*#/ ;
206 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
208 if ($ValidOption{$k}) {
218 print "Unknown keys in $CONFIG ignored [@badkey]\n"
221 # check parsed values
223 die "The following keys are missing from $CONFIG [@missing]\n"
224 if @missing = keys %Parsed ;
226 $ZLIB_INCLUDE = $ENV{'ZLIB_INCLUDE'} || $Info{'INCLUDE'} ;
227 $ZLIB_LIB = $ENV{'ZLIB_LIB'} || $Info{'LIB'} ;
230 $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
231 $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
234 my $y = $ENV{'OLD_ZLIB'} || $Info{'OLD_ZLIB'} ;
235 $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
237 my $x = $ENV{'BUILD_ZLIB'} || $Info{'BUILD_ZLIB'} ;
239 if ($x and $x =~ /^yes|on|true|1$/i ) {
243 # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when
244 # BUILD_ZLIB is specified.
245 die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n"
246 if $ZLIB_LIB ne $ZLIB_INCLUDE ;
248 # Check the zlib source directory exists
249 die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n"
250 unless -d $ZLIB_LIB ;
252 # check for a well known file
253 die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n"
254 unless -e catfile($ZLIB_LIB, 'zlib.h') ;
258 print "Building Zlib enabled\n" ;
261 $GZIP_OS_CODE = defined $ENV{'GZIP_OS_CODE'}
262 ? $ENV{'GZIP_OS_CODE'}
263 : $Info{'GZIP_OS_CODE'} ;
265 die "GZIP_OS_CODE not 'AUTO_DETECT' or a number between 0 and 255\n"
266 unless uc $GZIP_OS_CODE eq 'AUTO_DETECT'
267 || ( $GZIP_OS_CODE =~ /^(\d+)$/ && $1 >= 0 && $1 <= 255) ;
269 if (uc $GZIP_OS_CODE eq 'AUTO_DETECT')
271 print "Auto Detect Gzip OS Code..\n" ;
272 $GZIP_OS_CODE = getOSCode() ;
275 my $name = getOSname($GZIP_OS_CODE);
276 print "Setting Gzip OS Code to $GZIP_OS_CODE [$name]\n" ;
279 INCLUDE [$ZLIB_INCLUDE]
281 GZIP_OS_CODE [$GZIP_OS_CODE]
283 BUILD_ZLIB [$BUILD_ZLIB]
287 print "Looks Good.\n" ;
300 if (-f catfile($dir, "infback.c")) {
301 # zlib 1.2.0 or greater
303 @h_files = qw(crc32.h inffast.h inflate.h trees.h zconf.in.h
304 zutil.h deflate.h inffixed.h inftrees.h zconf.h
307 @c_files = qw(adler32 crc32 infback inflate uncompr
308 compress deflate inffast inftrees
315 @h_files = qw(deflate.h infcodes.h inftrees.h zconf.h zutil.h
316 infblock.h inffast.h infutil.h zlib.h
318 @c_files = qw(adler32 compress crc32 uncompr
319 deflate trees zutil inflate infblock
320 inftrees infcodes infutil inffast
324 @h_files = map { catfile($dir, $_) } @h_files ;
325 my @o_files = map { "$_\$(OBJ_EXT)" } 'Zlib', @c_files;
326 @c_files = map { "$_.c" } 'Zlib', @c_files ;
328 foreach my $file (@c_files)
329 { copy(catfile($dir, $file), '.') }
332 #'H' => [ @h_files ],
333 'C' => [ @c_files ] ,
334 #'OBJECT' => qq[ @o_files ],
335 'OBJECT' => q[ $(O_FILES) ],
343 use vars qw ( @GZIP_OS_Names %OSnames) ;
348 [ '' => 0, 'MS-DOS' ],
349 [ 'amigaos' => 1, 'Amiga' ],
350 [ 'VMS' => 2, 'VMS' ],
351 [ '' => 3, 'Unix/Default' ],
352 [ '' => 4, 'VM/CMS' ],
353 [ '' => 5, 'Atari TOS' ],
354 [ 'os2' => 6, 'HPFS (OS/2, NT)' ],
355 [ 'MacOS' => 7, 'Macintosh' ],
356 [ '' => 8, 'Z-System' ],
358 [ '' => 10, 'TOPS-20' ],
359 [ '' => 11, 'NTFS (NT)' ],
360 [ '' => 12, 'SMS QDOS' ],
361 [ '' => 13, 'Acorn RISCOS' ],
362 [ 'MSWin32' => 14, 'VFAT file system (Win95, NT)' ],
364 [ 'beos' => 16, 'BeOS' ],
365 [ '' => 17, 'Tandem/NSK' ],
366 [ '' => 18, 'THEOS' ],
367 [ '' => 255, 'Unknown OS' ],
370 %OSnames = map { $$_[1] => $$_[2] }
376 my $default = 3 ; # Unix is the default
380 for my $h (@GZIP_OS_Names)
382 my ($pattern, $code, $name) = @$h;
385 if $pattern && $uname eq $pattern ;
395 return $OSnames{$code} || 'Unknown OS' ;
398 # end of file Makefile.PL