7 use ExtUtils::MakeMaker 5.16 ;
8 use ExtUtils::Install (); # only needed to check for version
16 my $GZIP_OS_CODE = -1 ;
17 my $USE_PPPORT_H = ($ENV{PERL_CORE}) ? '' : '-DUSE_PPPORT_H';
18 my $OPTIMIZE = $Config{'optimize'};
19 if ($Config{'gccversion'} and $OPTIMIZE =~ /-g (gdb)? 3/x) {
20 $OPTIMIZE =~ s/-g(gdb)?3/-g/g; # [88936] out of memory with -g3 since 2.062
23 #$WALL = ' -pedantic ' if $Config{'cc'} =~ /gcc/ ;
24 #$WALL = ' -Wall -Wno-comment ' if $Config{'cc'} =~ /gcc/ ;
26 # Ticket #18986 says that ExtUtils::Install 1.39 fixes the in-use issue
27 # on win32/cygwin, so make the code below conditional on the version of
30 # Don't ask if MM_USE_DEFAULT is set -- enables perl core building on cygwin
31 if ($^O =~ /cygwin/i and $ExtUtils::Install::VERSION < 1.39
32 and not ($ENV{PERL_MM_USE_DEFAULT} or $ENV{PERL_CORE}))
36 I see you are running Cygwin.
38 Please note that this module cannot be installed on Cygwin using the CPAN
39 shell. The CPAN Shell uses Compress::Raw::Zlib internally and it is not
40 possible to delete an active DLL.
42 If you are running the CPAN shell, please exit it and install this module
43 by hand by running 'make install' under the directory
45 ~/.cpan/build/Compress-Raw-Zlib-VERSION
49 print "Do you want to continue? [Y/N]: " ;
50 my $answer = <STDIN> ;
52 if ($answer =~ /^yes|y/i)
54 print "continuing...\n"
58 print "exiting...\n" ;
67 UpDowngrade(getPerlFiles('MANIFEST'))
68 unless $ENV{PERL_CORE};
71 NAME => 'Compress::Raw::Zlib',
72 VERSION_FROM => 'lib/Compress/Raw/Zlib.pm',
73 INC => "-I$ZLIB_INCLUDE" ,
74 DEFINE => "-DNO_VIZ -DZ_SOLO $OLD_ZLIB $WALL -DGZIP_OS_CODE=$GZIP_OS_CODE $USE_PPPORT_H" ,
75 XS => { 'Zlib.xs' => 'Zlib.c'},
76 'depend' => { 'Makefile' => 'config.in' },
77 'clean' => { FILES => '*.c constants.h constants.xs' },
78 'dist' => { COMPRESS => 'gzip',
81 DIST_DEFAULT => 'MyTrebleCheck tardist',
86 ? zlib_files($ZLIB_LIB)
87 : (LIBS => [ "-L$ZLIB_LIB -lz " ])
89 OPTIMIZE => $OPTIMIZE,
91 INSTALLDIRS => ($] >= 5.009 && $] < 5.011 ? 'perl' : 'site'),
95 directory => [ 't', 'private' ],
99 ((ExtUtils::MakeMaker->VERSION() gt '6.30') ?
100 ('LICENSE' => 'perl') : ()),
108 return [ "#if ZLIB_VERNUM >= 0x$ver\n", "#endif\n" ];
125 Z_DEFAULT_COMPRESSION
151 my %verSpecificNames = (
155 if (eval {require ExtUtils::Constant; 1}) {
156 # Check the constants above all appear in @EXPORT in Zlib.pm
157 my %names = %verSpecificNames, map { $_, 1} @names, 'ZLIB_VERSION';
158 open F, "<lib/Compress/Raw/Zlib.pm" or die "Cannot open Zlib.pm: $!\n";
161 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
168 delete $names{$1} if defined $1 ;
174 my $missing = join ("\n\t", sort keys %names) ;
175 die "The following names are missing from \@EXPORT in Zlib.pm\n" .
179 push @names, { name => 'ZLIB_VERSION', type => 'PV' };
181 push @names, map { { name => $_,
182 macro => version_Macro $verSpecificNames{$_}
185 keys %verSpecificNames ;
187 ExtUtils::Constant::WriteConstants(
190 C_FILE => 'constants.h',
191 XS_FILE => 'constants.xs',
197 foreach my $name (qw( constants.h constants.xs ))
199 my $from = catfile('fallback', $name);
201 or die "Can't copy $from to $name: $!";
210 my @Options = qw( INCLUDE LIB BUILD_ZLIB OLD_ZLIB GZIP_OS_CODE ) ;
211 my %ValidOption = map {$_, 1} @Options ;
212 my %Parsed = %ValidOption ;
213 my $CONFIG = 'config.in' ;
215 print "Parsing $CONFIG...\n" ;
217 open(F, "<$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
220 next if /^\s*$/ or /^\s*#/ ;
223 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
225 if ($ValidOption{$k}) {
235 print "Unknown keys in $CONFIG ignored [@badkey]\n"
238 # check parsed values
240 die "The following keys are missing from $CONFIG [@missing]\n"
241 if @missing = keys %Parsed ;
243 $ZLIB_INCLUDE = defined $ENV{'ZLIB_INCLUDE'}
244 ? $ENV{'ZLIB_INCLUDE'}
246 $ZLIB_LIB = defined $ENV{'ZLIB_LIB'}
251 $ZLIB_INCLUDE = VMS::Filespec::vmspath($ZLIB_INCLUDE);
252 $ZLIB_LIB = VMS::Filespec::vmspath($ZLIB_LIB);
255 my $y = defined $ENV{'OLD_ZLIB'}
257 : $Info{'OLD_ZLIB'} ;
258 $OLD_ZLIB = '-DOLD_ZLIB' if $y and $y =~ /^yes|on|true|1$/i;
260 my $x = defined $ENV{'BUILD_ZLIB'}
262 : $Info{'BUILD_ZLIB'} ;
264 if ($x and $x =~ /^yes|on|true|1$/i ) {
268 # ZLIB_LIB & ZLIB_INCLUDE must point to the same place when
269 # BUILD_ZLIB is specified.
270 die "INCLUDE & LIB must be the same when BUILD_ZLIB is True\n"
271 if $ZLIB_LIB ne $ZLIB_INCLUDE ;
273 # Check the zlib source directory exists
274 die "LIB/INCLUDE directory '$ZLIB_LIB' does not exits\n"
275 unless -d $ZLIB_LIB ;
277 # check for a well known file
278 die "LIB/INCLUDE directory, '$ZLIB_LIB', doesn't seem to have the zlib source files\n"
279 unless -e catfile($ZLIB_LIB, 'zlib.h') ;
283 print "Building Zlib enabled\n" ;
286 $GZIP_OS_CODE = defined $ENV{'GZIP_OS_CODE'}
287 ? $ENV{'GZIP_OS_CODE'}
288 : $Info{'GZIP_OS_CODE'} ;
290 die "GZIP_OS_CODE not 'AUTO_DETECT' or a number between 0 and 255\n"
291 unless uc $GZIP_OS_CODE eq 'AUTO_DETECT'
292 || ( $GZIP_OS_CODE =~ /^(\d+)$/ && $1 >= 0 && $1 <= 255) ;
294 if (uc $GZIP_OS_CODE eq 'AUTO_DETECT')
296 print "Auto Detect Gzip OS Code..\n" ;
297 $GZIP_OS_CODE = getOSCode() ;
300 my $name = getOSname($GZIP_OS_CODE);
301 print "Setting Gzip OS Code to $GZIP_OS_CODE [$name]\n" ;
304 INCLUDE [$ZLIB_INCLUDE]
306 GZIP_OS_CODE [$GZIP_OS_CODE]
308 BUILD_ZLIB [$BUILD_ZLIB]
312 print "Looks Good.\n" ;
325 if (-f catfile($dir, "infback.c")) {
326 # zlib 1.2.0 or greater
328 @h_files = qw(crc32.h inffast.h inflate.h trees.h zconf.in.h
329 zutil.h deflate.h inffixed.h inftrees.h zconf.h
332 @c_files = qw(adler32 crc32 infback inflate uncompr
333 compress deflate inffast inftrees
340 @h_files = qw(deflate.h infcodes.h inftrees.h zconf.h zutil.h
341 infblock.h inffast.h infutil.h zlib.h
343 @c_files = qw(adler32 compress crc32 uncompr
344 deflate trees zutil inflate infblock
345 inftrees infcodes infutil inffast
349 @h_files = map { catfile($dir, $_) } @h_files ;
350 my @o_files = map { "$_\$(OBJ_EXT)" } 'Zlib', @c_files;
351 @c_files = map { "$_.c" } 'Zlib', @c_files ;
353 foreach my $file (@c_files)
354 { copy(catfile($dir, $file), '.') }
357 #'H' => [ @h_files ],
358 'C' => [ @c_files ] ,
359 #'OBJECT' => qq[ @o_files ],
360 'OBJECT' => q[ $(O_FILES) ],
368 use vars qw ( @GZIP_OS_Names %OSnames) ;
373 [ '' => 0, 'MS-DOS' ],
374 [ 'amigaos' => 1, 'Amiga' ],
375 [ 'VMS' => 2, 'VMS' ],
376 [ '' => 3, 'Unix/Default' ],
377 [ '' => 4, 'VM/CMS' ],
378 [ '' => 5, 'Atari TOS' ],
379 [ 'os2' => 6, 'HPFS (OS/2, NT)' ],
380 [ 'MacOS' => 7, 'Macintosh' ],
381 [ '' => 8, 'Z-System' ],
383 [ '' => 10, 'TOPS-20' ],
384 [ '' => 11, 'NTFS (NT)' ],
385 [ '' => 12, 'SMS QDOS' ],
386 [ '' => 13, 'Acorn RISCOS' ],
387 [ 'MSWin32' => 14, 'VFAT file system (Win95, NT)' ],
389 [ 'beos' => 16, 'BeOS' ],
390 [ '' => 17, 'Tandem/NSK' ],
391 [ '' => 18, 'THEOS' ],
392 [ '' => 255, 'Unknown OS' ],
395 %OSnames = map { $$_[1] => $$_[2] }
401 my $default = 3 ; # Unix is the default
405 for my $h (@GZIP_OS_Names)
407 my ($pattern, $code, $name) = @$h;
410 if $pattern && $uname eq $pattern ;
420 return $OSnames{$code} || 'Unknown OS' ;
423 # end of file Makefile.PL