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 # Windows uses a different name for the zlib library
25 my $ZLIB_LIBRARY_NAME = $^O eq 'MSWin32' ? 'zlib' : 'z' ;
27 #$WALL = ' -pedantic ' if $Config{'cc'} =~ /gcc/ ;
28 #$WALL = ' -Wall -Wno-comment ' if $Config{'cc'} =~ /gcc/ ;
30 # Ticket #18986 says that ExtUtils::Install 1.39 fixes the in-use issue
31 # on win32/cygwin, so make the code below conditional on the version of
34 # Don't ask if MM_USE_DEFAULT is set -- enables perl core building on cygwin
35 if ($^O =~ /cygwin/i and $ExtUtils::Install::VERSION < 1.39
36 and not ($ENV{PERL_MM_USE_DEFAULT} or $ENV{PERL_CORE}))
40 I see you are running Cygwin.
42 Please note that this module cannot be installed on Cygwin using the CPAN
43 shell. The CPAN Shell uses Compress::Raw::Zlib internally and it is not
44 possible to delete an active DLL.
46 If you are running the CPAN shell, please exit it and install this module
47 by hand by running 'make install' under the directory
49 ~/.cpan/build/Compress-Raw-Zlib-VERSION
53 print "Do you want to continue? [Y/N]: " ;
54 my $answer = <STDIN> ;
56 if ($answer =~ /^yes|y/i)
58 print "continuing...\n"
62 print "exiting...\n" ;
71 UpDowngrade(getPerlFiles('MANIFEST'))
72 unless $ENV{PERL_CORE};
75 NAME => 'Compress::Raw::Zlib',
76 VERSION_FROM => 'lib/Compress/Raw/Zlib.pm',
77 INC => "-I$ZLIB_INCLUDE" ,
78 DEFINE => "-DNO_VIZ -DZ_SOLO $OLD_ZLIB $WALL -DGZIP_OS_CODE=$GZIP_OS_CODE $USE_PPPORT_H" ,
79 XS => { 'Zlib.xs' => 'Zlib.c'},
80 'depend' => { 'Makefile' => 'config.in' },
81 'clean' => { FILES => '*.c constants.h constants.xs' },
82 'dist' => { COMPRESS => 'gzip',
85 DIST_DEFAULT => 'MyTrebleCheck tardist',
90 ? zlib_files($ZLIB_LIB)
91 : (LIBS => [ "-L$ZLIB_LIB -l$ZLIB_LIBRARY_NAME " ])
93 OPTIMIZE => $OPTIMIZE,
95 INSTALLDIRS => ($] >= 5.009 && $] < 5.011 ? 'perl' : 'site'),
97 ( eval { ExtUtils::MakeMaker->VERSION(6.46) }
100 "meta-spec" => { version => 2 },
103 directory => [ 't', 'private' ],
109 web => 'https://github.com/pmqs/Compress-Raw-Zlib/issues'
112 homepage => 'https://github.com/pmqs/Compress-Raw-Zlib',
116 url => 'git://github.com/pmqs/Compress-Raw-Zlib.git',
117 web => 'https://github.com/pmqs/Compress-Raw-Zlib',
125 ((ExtUtils::MakeMaker->VERSION() gt '6.30') ?
126 ('LICENSE' => 'perl') : ()),
134 return [ "#if ZLIB_VERNUM >= 0x$ver\n", "#endif\n" ];
151 Z_DEFAULT_COMPRESSION
177 my %verSpecificNames = (
181 if (eval {require ExtUtils::Constant; 1}) {
182 # Check the constants above all appear in @EXPORT in Zlib.pm
183 my %names = %verSpecificNames, map { $_, 1} @names, 'ZLIB_VERSION';
184 open F, "<lib/Compress/Raw/Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
187 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
194 delete $names{$1} if defined $1 ;
200 my $missing = join ("\n\t", sort keys %names) ;
201 die "The following names are missing from \@EXPORT in Zlib.pm\n" .
205 push @names, { name => 'ZLIB_VERSION', type => 'PV' };
207 push @names, map { { name => $_,
208 macro => version_Macro $verSpecificNames{$_}
211 keys %verSpecificNames ;
213 ExtUtils::Constant::WriteConstants(
216 C_FILE => 'constants.h',
217 XS_FILE => 'constants.xs',
223 foreach my $name (qw( constants.h constants.xs ))
225 my $from = catfile('fallback', $name);
227 or die "Can't copy $from to $name: $!";
236 my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB GZIP_OS_CODE ) ;
237 my %ValidOption = map {$_, 1} @Options ;
238 my %Parsed = %ValidOption ;
239 my $CONFIG = 'config.in' ;
241 print "Parsing $CONFIG...\n" ;
243 open(F, "<$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
246 next if /^\s*$/ or /^\s*#/ ;
249 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
251 if ($ValidOption{$k}) {
261 print "Unknown keys in $CONFIG ignored [@badkey]\n"
264 # check parsed values
266 die "The following keys are missing from $CONFIG [@missing]\n"
267 if @missing = keys %Parsed ;
269 $ZLIB_INCLUDE = defined $ENV{'ZLIB_INCLUDE'}
270 ? $ENV{'ZLIB_INCLUDE'}
272 $ZLIB_LIB = defined $ENV{'ZLIB_LIB'}
277 $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
278 $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
281 my $y = defined $ENV{'OLD_ZLIB'}
283 : $Info{'OLD_ZLIB'} ;
284 $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
286 my $x = defined $ENV{'BUILD_ZLIB'}
288 : $Info{'BUILD_ZLIB'} ;
290 if ($x and $x =~ /^yes|on|true|1$/i ) {
294 # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when
295 # BUILD_ZLIB is specified.
296 die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n"
297 if $ZLIB_LIB ne $ZLIB_INCLUDE ;
299 # Check the zlib source directory exists
300 die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n"
301 unless -d $ZLIB_LIB ;
303 # check for a well known file
304 die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n"
305 unless -e catfile($ZLIB_LIB, 'zlib.h') ;
309 print "Building Zlib enabled\n" ;
312 $GZIP_OS_CODE = defined $ENV{'GZIP_OS_CODE'}
313 ? $ENV{'GZIP_OS_CODE'}
314 : $Info{'GZIP_OS_CODE'} ;
316 die "GZIP_OS_CODE not 'AUTO_DETECT' or a number between 0 and 255\n"
317 unless uc $GZIP_OS_CODE eq 'AUTO_DETECT'
318 || ( $GZIP_OS_CODE =~ /^(\d+)$/ && $1 >= 0 && $1 <= 255) ;
320 if (uc $GZIP_OS_CODE eq 'AUTO_DETECT')
322 print "Auto Detect Gzip OS Code..\n" ;
323 $GZIP_OS_CODE = getOSCode() ;
326 my $name = getOSname($GZIP_OS_CODE);
327 print "Setting Gzip OS Code to $GZIP_OS_CODE [$name]\n" ;
330 INCLUDE [$ZLIB_INCLUDE]
332 GZIP_OS_CODE [$GZIP_OS_CODE]
334 BUILD_ZLIB [$BUILD_ZLIB]
338 print "Looks Good.\n" ;
351 if (-f catfile($dir, "infback.c")) {
352 # zlib 1.2.0 or greater
354 @h_files = qw(crc32.h inffast.h inflate.h trees.h zconf.in.h
355 zutil.h deflate.h inffixed.h inftrees.h zconf.h
358 @c_files = qw(adler32 crc32 infback inflate uncompr
359 compress deflate inffast inftrees
366 @h_files = qw(deflate.h infcodes.h inftrees.h zconf.h zutil.h
367 infblock.h inffast.h infutil.h zlib.h
369 @c_files = qw(adler32 compress crc32 uncompr
370 deflate trees zutil inflate infblock
371 inftrees infcodes infutil inffast
375 @h_files = map { catfile($dir, $_) } @h_files ;
376 my @o_files = map { "$_\$(OBJ_EXT)" } 'Zlib', @c_files;
377 @c_files = map { "$_.c" } 'Zlib', @c_files ;
379 foreach my $file (@c_files)
380 { copy(catfile($dir, $file), '.') }
383 #'H' => [ @h_files ],
384 'C' => [ @c_files ] ,
385 #'OBJECT' => qq[ @o_files ],
386 'OBJECT' => q[ $(O_FILES) ],
394 use vars qw ( @GZIP_OS_Names %OSnames) ;
399 [ '' => 0, 'MS-DOS' ],
400 [ 'amigaos' => 1, 'Amiga' ],
401 [ 'VMS' => 2, 'VMS' ],
402 [ '' => 3, 'Unix/Default' ],
403 [ '' => 4, 'VM/CMS' ],
404 [ '' => 5, 'Atari TOS' ],
405 [ 'os2' => 6, 'HPFS (OS/2, NT)' ],
406 [ 'MacOS' => 7, 'Macintosh' ],
407 [ '' => 8, 'Z-System' ],
409 [ '' => 10, 'TOPS-20' ],
410 [ '' => 11, 'NTFS (NT)' ],
411 [ '' => 12, 'SMS QDOS' ],
412 [ '' => 13, 'Acorn RISCOS' ],
413 [ 'MSWin32' => 14, 'VFAT file system (Win95, NT)' ],
415 [ 'beos' => 16, 'BeOS' ],
416 [ '' => 17, 'Tandem/NSK' ],
417 [ '' => 18, 'THEOS' ],
418 [ '' => 255, 'Unknown OS' ],
421 %OSnames = map { $$_[1] => $$_[2] }
427 my $default = 3 ; # Unix is the default
431 for my $h (@GZIP_OS_Names)
433 my ($pattern, $code, $name) = @$h;
436 if $pattern && $uname eq $pattern ;
446 return $OSnames{$code} || 'Unknown OS' ;
449 # end of file Makefile.PL