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 => "-DNO_VIZ $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',
81 ? zlib_files($ZLIB_LIB)
82 : (LIBS => [ "-L$ZLIB_LIB -lz " ])
85 INSTALLDIRS => ($] >= 5.009 ? 'perl' : 'site'),
87 ((ExtUtils::MakeMaker->VERSION() gt '6.30') ?
88 ('LICENSE' => 'perl') : ()),
96 return [ "#if ZLIB_VERNUM >= 0x$ver\n", "#endif\n" ];
114 Z_DEFAULT_COMPRESSION
140 my %verSpecificNames = (
144 if (eval {require ExtUtils::Constant; 1}) {
145 # Check the constants above all appear in @EXPORT in Zlib.pm
146 my %names = %verSpecificNames, map { $_, 1} @names, 'ZLIB_VERSION';
147 open F, "<lib/Compress/Raw/Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
150 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
157 delete $names{$1} if defined $1 ;
163 my $missing = join ("\n\t", sort keys %names) ;
164 die "The following names are missing from \@EXPORT in Zlib.pm\n" .
168 push @names, { name => 'ZLIB_VERSION', type => 'PV' };
170 push @names, map { { name => $_,
171 macro => version_Macro $verSpecificNames{$_}
174 keys %verSpecificNames ;
176 ExtUtils::Constant::WriteConstants(
179 C_FILE => 'constants.h',
180 XS_FILE => 'constants.xs',
186 foreach my $name (qw( constants.h constants.xs ))
188 my $from = catfile('fallback', $name);
190 or die "Can't copy $from to $name: $!";
199 my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB GZIP_OS_CODE ) ;
200 my %ValidOption = map {$_, 1} @Options ;
201 my %Parsed = %ValidOption ;
202 my $CONFIG = 'config.in' ;
204 print "Parsing $CONFIG...\n" ;
206 open(F, "<$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
209 next if /^\s*$/ or /^\s*#/ ;
212 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
214 if ($ValidOption{$k}) {
224 print "Unknown keys in $CONFIG ignored [@badkey]\n"
227 # check parsed values
229 die "The following keys are missing from $CONFIG [@missing]\n"
230 if @missing = keys %Parsed ;
232 $ZLIB_INCLUDE = $ENV{'ZLIB_INCLUDE'} || $Info{'INCLUDE'} ;
233 $ZLIB_LIB = $ENV{'ZLIB_LIB'} || $Info{'LIB'} ;
236 $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
237 $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
240 my $y = $ENV{'OLD_ZLIB'} || $Info{'OLD_ZLIB'} ;
241 $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
243 my $x = $ENV{'BUILD_ZLIB'} || $Info{'BUILD_ZLIB'} ;
245 if ($x and $x =~ /^yes|on|true|1$/i ) {
249 # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when
250 # BUILD_ZLIB is specified.
251 die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n"
252 if $ZLIB_LIB ne $ZLIB_INCLUDE ;
254 # Check the zlib source directory exists
255 die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n"
256 unless -d $ZLIB_LIB ;
258 # check for a well known file
259 die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n"
260 unless -e catfile($ZLIB_LIB, 'zlib.h') ;
264 print "Building Zlib enabled\n" ;
267 $GZIP_OS_CODE = defined $ENV{'GZIP_OS_CODE'}
268 ? $ENV{'GZIP_OS_CODE'}
269 : $Info{'GZIP_OS_CODE'} ;
271 die "GZIP_OS_CODE not 'AUTO_DETECT' or a number between 0 and 255\n"
272 unless uc $GZIP_OS_CODE eq 'AUTO_DETECT'
273 || ( $GZIP_OS_CODE =~ /^(\d+)$/ && $1 >= 0 && $1 <= 255) ;
275 if (uc $GZIP_OS_CODE eq 'AUTO_DETECT')
277 print "Auto Detect Gzip OS Code..\n" ;
278 $GZIP_OS_CODE = getOSCode() ;
281 my $name = getOSname($GZIP_OS_CODE);
282 print "Setting Gzip OS Code to $GZIP_OS_CODE [$name]\n" ;
285 INCLUDE [$ZLIB_INCLUDE]
287 GZIP_OS_CODE [$GZIP_OS_CODE]
289 BUILD_ZLIB [$BUILD_ZLIB]
293 print "Looks Good.\n" ;
306 if (-f catfile($dir, "infback.c")) {
307 # zlib 1.2.0 or greater
309 @h_files = qw(crc32.h inffast.h inflate.h trees.h zconf.in.h
310 zutil.h deflate.h inffixed.h inftrees.h zconf.h
313 @c_files = qw(adler32 crc32 infback inflate uncompr
314 compress deflate inffast inftrees
321 @h_files = qw(deflate.h infcodes.h inftrees.h zconf.h zutil.h
322 infblock.h inffast.h infutil.h zlib.h
324 @c_files = qw(adler32 compress crc32 uncompr
325 deflate trees zutil inflate infblock
326 inftrees infcodes infutil inffast
330 @h_files = map { catfile($dir, $_) } @h_files ;
331 my @o_files = map { "$_\$(OBJ_EXT)" } 'Zlib', @c_files;
332 @c_files = map { "$_.c" } 'Zlib', @c_files ;
334 foreach my $file (@c_files)
335 { copy(catfile($dir, $file), '.') }
338 #'H' => [ @h_files ],
339 'C' => [ @c_files ] ,
340 #'OBJECT' => qq[ @o_files ],
341 'OBJECT' => q[ $(O_FILES) ],
349 use vars qw ( @GZIP_OS_Names %OSnames) ;
354 [ '' => 0, 'MS-DOS' ],
355 [ 'amigaos' => 1, 'Amiga' ],
356 [ 'VMS' => 2, 'VMS' ],
357 [ '' => 3, 'Unix/Default' ],
358 [ '' => 4, 'VM/CMS' ],
359 [ '' => 5, 'Atari TOS' ],
360 [ 'os2' => 6, 'HPFS (OS/2, NT)' ],
361 [ 'MacOS' => 7, 'Macintosh' ],
362 [ '' => 8, 'Z-System' ],
364 [ '' => 10, 'TOPS-20' ],
365 [ '' => 11, 'NTFS (NT)' ],
366 [ '' => 12, 'SMS QDOS' ],
367 [ '' => 13, 'Acorn RISCOS' ],
368 [ 'MSWin32' => 14, 'VFAT file system (Win95, NT)' ],
370 [ 'beos' => 16, 'BeOS' ],
371 [ '' => 17, 'Tandem/NSK' ],
372 [ '' => 18, 'THEOS' ],
373 [ '' => 255, 'Unknown OS' ],
376 %OSnames = map { $$_[1] => $$_[2] }
382 my $default = 3 ; # Unix is the default
386 for my $h (@GZIP_OS_Names)
388 my ($pattern, $code, $name) = @$h;
391 if $pattern && $uname eq $pattern ;
401 return $OSnames{$code} || 'Unknown OS' ;
404 # end of file Makefile.PL