8 use ExtUtils::MakeMaker 5.16 ;
9 use ExtUtils::Install (); # only needed to check for version
17 my $GZIP_OS_CODE = -1 ;
18 my $USE_PPPORT_H = ($ENV{PERL_CORE}) ? '' : '-DUSE_PPPORT_H';
19 my $OPTIMIZE = $Config{'optimize'};
20 if ($Config{'gccversion'} and $OPTIMIZE =~ /-g (gdb)? 3/x) {
21 $OPTIMIZE =~ s/-g(gdb)?3/-g/g; # [88936] out of memory with -g3 since 2.062
24 #$WALL = ' -pedantic ' if $Config{'cc'} =~ /gcc/ ;
25 #$WALL = ' -Wall -Wno-comment ' if $Config{'cc'} =~ /gcc/ ;
27 # Ticket #18986 says that ExtUtils::Install 1.39 fixes the in-use issue
28 # on win32/cygwin, so make the code below conditional on the version of
31 # Don't ask if MM_USE_DEFAULT is set -- enables perl core building on cygwin
32 if ($^O =~ /cygwin/i and $ExtUtils::Install::VERSION < 1.39
33 and not ($ENV{PERL_MM_USE_DEFAULT} or $ENV{PERL_CORE}))
37 I see you are running Cygwin.
39 Please note that this module cannot be installed on Cygwin using the CPAN
40 shell. The CPAN Shell uses Compress::Raw::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-Raw-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 UpDowngrade(getPerlFiles('MANIFEST'))
69 unless $ENV{PERL_CORE};
72 NAME => 'Compress::Raw::Zlib',
73 VERSION_FROM => 'lib/Compress/Raw/Zlib.pm',
74 INC => "-I$ZLIB_INCLUDE" ,
75 DEFINE => "-DNO_VIZ -DZ_SOLO $OLD_ZLIB $WALL -DGZIP_OS_CODE=$GZIP_OS_CODE $USE_PPPORT_H" ,
76 XS => { 'Zlib.xs' => 'Zlib.c'},
77 'depend' => { 'Makefile' => 'config.in' },
78 'clean' => { FILES => '*.c constants.h constants.xs' },
79 'dist' => { COMPRESS => 'gzip',
82 DIST_DEFAULT => 'MyTrebleCheck tardist',
87 ? zlib_files($ZLIB_LIB)
88 : (LIBS => [ "-L$ZLIB_LIB -lz " ])
90 OPTIMIZE => $OPTIMIZE,
92 INSTALLDIRS => ($] >= 5.009 && $] < 5.011 ? 'perl' : 'site'),
96 directory => [ 't', 'private' ],
100 ((ExtUtils::MakeMaker->VERSION() gt '6.30') ?
101 ('LICENSE' => 'perl') : ()),
109 return [ "#if ZLIB_VERNUM >= 0x$ver\n", "#endif\n" ];
126 Z_DEFAULT_COMPRESSION
152 my %verSpecificNames = (
156 if (eval {require ExtUtils::Constant; 1}) {
157 # Check the constants above all appear in @EXPORT in Zlib.pm
158 my %names = %verSpecificNames, map { $_, 1} @names, 'ZLIB_VERSION';
159 open F, "<lib/Compress/Raw/Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
162 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
169 delete $names{$1} if defined $1 ;
175 my $missing = join ("\n\t", sort keys %names) ;
176 die "The following names are missing from \@EXPORT in Zlib.pm\n" .
180 push @names, { name => 'ZLIB_VERSION', type => 'PV' };
182 push @names, map { { name => $_,
183 macro => version_Macro $verSpecificNames{$_}
186 keys %verSpecificNames ;
188 ExtUtils::Constant::WriteConstants(
191 C_FILE => 'constants.h',
192 XS_FILE => 'constants.xs',
198 foreach my $name (qw( constants.h constants.xs ))
200 my $from = catfile('fallback', $name);
202 or die "Can't copy $from to $name: $!";
211 my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB GZIP_OS_CODE ) ;
212 my %ValidOption = map {$_, 1} @Options ;
213 my %Parsed = %ValidOption ;
214 my $CONFIG = 'config.in' ;
216 print "Parsing $CONFIG...\n" ;
218 open(F, "<$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
221 next if /^\s*$/ or /^\s*#/ ;
224 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
226 if ($ValidOption{$k}) {
236 print "Unknown keys in $CONFIG ignored [@badkey]\n"
239 # check parsed values
241 die "The following keys are missing from $CONFIG [@missing]\n"
242 if @missing = keys %Parsed ;
244 $ZLIB_INCLUDE = defined $ENV{'ZLIB_INCLUDE'}
245 ? $ENV{'ZLIB_INCLUDE'}
247 $ZLIB_LIB = defined $ENV{'ZLIB_LIB'}
252 $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
253 $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
256 my $y = defined $ENV{'OLD_ZLIB'}
258 : $Info{'OLD_ZLIB'} ;
259 $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
261 my $x = defined $ENV{'BUILD_ZLIB'}
263 : $Info{'BUILD_ZLIB'} ;
265 if ($x and $x =~ /^yes|on|true|1$/i ) {
269 # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when
270 # BUILD_ZLIB is specified.
271 die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n"
272 if $ZLIB_LIB ne $ZLIB_INCLUDE ;
274 # Check the zlib source directory exists
275 die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n"
276 unless -d $ZLIB_LIB ;
278 # check for a well known file
279 die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n"
280 unless -e catfile($ZLIB_LIB, 'zlib.h') ;
284 print "Building Zlib enabled\n" ;
287 $GZIP_OS_CODE = defined $ENV{'GZIP_OS_CODE'}
288 ? $ENV{'GZIP_OS_CODE'}
289 : $Info{'GZIP_OS_CODE'} ;
291 die "GZIP_OS_CODE not 'AUTO_DETECT' or a number between 0 and 255\n"
292 unless uc $GZIP_OS_CODE eq 'AUTO_DETECT'
293 || ( $GZIP_OS_CODE =~ /^(\d+)$/ && $1 >= 0 && $1 <= 255) ;
295 if (uc $GZIP_OS_CODE eq 'AUTO_DETECT')
297 print "Auto Detect Gzip OS Code..\n" ;
298 $GZIP_OS_CODE = getOSCode() ;
301 my $name = getOSname($GZIP_OS_CODE);
302 print "Setting Gzip OS Code to $GZIP_OS_CODE [$name]\n" ;
305 INCLUDE [$ZLIB_INCLUDE]
307 GZIP_OS_CODE [$GZIP_OS_CODE]
309 BUILD_ZLIB [$BUILD_ZLIB]
313 print "Looks Good.\n" ;
326 if (-f catfile($dir, "infback.c")) {
327 # zlib 1.2.0 or greater
329 @h_files = qw(crc32.h inffast.h inflate.h trees.h zconf.in.h
330 zutil.h deflate.h inffixed.h inftrees.h zconf.h
333 @c_files = qw(adler32 crc32 infback inflate uncompr
334 compress deflate inffast inftrees
341 @h_files = qw(deflate.h infcodes.h inftrees.h zconf.h zutil.h
342 infblock.h inffast.h infutil.h zlib.h
344 @c_files = qw(adler32 compress crc32 uncompr
345 deflate trees zutil inflate infblock
346 inftrees infcodes infutil inffast
350 @h_files = map { catfile($dir, $_) } @h_files ;
351 my @o_files = map { "$_\$(OBJ_EXT)" } 'Zlib', @c_files;
352 @c_files = map { "$_.c" } 'Zlib', @c_files ;
354 foreach my $file (@c_files)
355 { copy(catfile($dir, $file), '.') }
358 #'H' => [ @h_files ],
359 'C' => [ @c_files ] ,
360 #'OBJECT' => qq[ @o_files ],
361 'OBJECT' => q[ $(O_FILES) ],
369 use vars qw ( @GZIP_OS_Names %OSnames) ;
374 [ '' => 0, 'MS-DOS' ],
375 [ 'amigaos' => 1, 'Amiga' ],
376 [ 'VMS' => 2, 'VMS' ],
377 [ '' => 3, 'Unix/Default' ],
378 [ '' => 4, 'VM/CMS' ],
379 [ '' => 5, 'Atari TOS' ],
380 [ 'os2' => 6, 'HPFS (OS/2, NT)' ],
381 [ 'MacOS' => 7, 'Macintosh' ],
382 [ '' => 8, 'Z-System' ],
384 [ '' => 10, 'TOPS-20' ],
385 [ '' => 11, 'NTFS (NT)' ],
386 [ '' => 12, 'SMS QDOS' ],
387 [ '' => 13, 'Acorn RISCOS' ],
388 [ 'MSWin32' => 14, 'VFAT file system (Win95, NT)' ],
390 [ 'beos' => 16, 'BeOS' ],
391 [ '' => 17, 'Tandem/NSK' ],
392 [ '' => 18, 'THEOS' ],
393 [ '' => 255, 'Unknown OS' ],
396 %OSnames = map { $$_[1] => $$_[2] }
402 my $default = 3 ; # Unix is the default
406 for my $h (@GZIP_OS_Names)
408 my ($pattern, $code, $name) = @$h;
411 if $pattern && $uname eq $pattern ;
421 return $OSnames{$code} || 'Unknown OS' ;
424 # end of file Makefile.PL