1#! perl -w 2 3use strict ; 4require 5.006 ; 5 6use private::MakeUtil; 7use ExtUtils::MakeMaker 5.16 ; 8 9my $WALL= ''; 10$WALL = ' -Wall -Wno-comment ' if $Config{'cc'} =~ /gcc/ ; 11my $USE_PPPORT_H = ($ENV{PERL_CORE}) ? '' : '-DUSE_PPPORT_H'; 12 13 14my $BUILD_BZIP2 = defined($ENV{BUILD_BZIP2}) ? $ENV{BUILD_BZIP2} : 1; 15my $BZIP2_LIB = defined($ENV{BZIP2_LIB}) ? $ENV{BZIP2_LIB} : 'bzip2-src'; 16my $BZIP2_INCLUDE = defined($ENV{BZIP2_INCLUDE}) ? $ENV{BZIP2_INCLUDE} : '.'; 17 18#ParseCONFIG() ; 19 20UpDowngrade(getPerlFiles('MANIFEST')) 21 unless $ENV{PERL_CORE}; 22 23WriteMakefile( 24 NAME => 'Compress::Raw::Bzip2', 25 VERSION_FROM => 'lib/Compress/Raw/Bzip2.pm', 26 INC => "-I$BZIP2_INCLUDE" , 27 DEFINE => "$WALL -DBZ_NO_STDIO $USE_PPPORT_H" , 28 XS => { 'Bzip2.xs' => 'Bzip2.c'}, 29 'clean' => { FILES => '*.c bzip2.h bzlib.h bzlib_private.h constants.h constants.xs' }, 30 #'depend' => { 'Makefile' => 'config.in' }, 31 'dist' => { COMPRESS => 'gzip', 32 TARFLAGS => '-chvf', 33 SUFFIX => 'gz', 34 DIST_DEFAULT => 'MyTrebleCheck tardist', 35 }, 36 37 ( 38 $BUILD_BZIP2 39 ? bzip2_files($BZIP2_LIB) 40 : (LIBS => [ "-L$BZIP2_LIB -lbz2 " ]) 41 ), 42 43 ( 44 $] >= 5.005 45 ? (ABSTRACT_FROM => 'lib/Compress/Raw/Bzip2.pm', 46 AUTHOR => 'Paul Marquess <pmqs@cpan.org>') 47 : () 48 ), 49 50 INSTALLDIRS => ($] > 5.010 && $] < 5.011 ? 'perl' : 'site'), 51 52 META_MERGE => { 53 no_index => { 54 directory => [ 't', 'private' ], 55 }, 56 }, 57 58 ((ExtUtils::MakeMaker->VERSION() gt '6.30') ? 59 ('LICENSE' => 'perl') : ()), 60 61) ; 62 63my @names = qw( 64 BZ_RUN 65 BZ_FLUSH 66 BZ_FINISH 67 68 BZ_OK 69 BZ_RUN_OK 70 BZ_FLUSH_OK 71 BZ_FINISH_OK 72 BZ_STREAM_END 73 BZ_SEQUENCE_ERROR 74 BZ_PARAM_ERROR 75 BZ_MEM_ERROR 76 BZ_DATA_ERROR 77 BZ_DATA_ERROR_MAGIC 78 BZ_IO_ERROR 79 BZ_UNEXPECTED_EOF 80 BZ_OUTBUFF_FULL 81 BZ_CONFIG_ERROR 82 ); 83 84if (eval {require ExtUtils::Constant; 1}) { 85 # Check the constants above all appear in @EXPORT in Bzip2.pm 86 my %names = map { $_, 1} @names ; #, 'BZ_VERSION'; 87 open F, "<lib/Compress/Raw/Bzip2.pm" or die "Cannot open Bzip2.pm: $!\n"; 88 while (<F>) 89 { 90 last if /^\s*\@EXPORT\s+=\s+qw\(/ ; 91 } 92 93 while (<F>) 94 { 95 last if /^\s*\)/ ; 96 /(\S+)/ ; 97 delete $names{$1} if defined $1 ; 98 } 99 close F ; 100 101 if ( keys %names ) 102 { 103 my $missing = join ("\n\t", sort keys %names) ; 104 die "The following names are missing from \@EXPORT in Bzip2.pm\n" . 105 "\t$missing\n" ; 106 } 107 108 #push @names, {name => 'BZ_VERSION', type => 'PV' }; 109 110 ExtUtils::Constant::WriteConstants( 111 NAME => 'Bzip2', 112 NAMES => \@names, 113 C_FILE => 'constants.h', 114 XS_FILE => 'constants.xs', 115 116 ); 117} 118else { 119 foreach my $name (qw( constants.h constants.xs )) 120 { 121 my $from = catfile('fallback', $name); 122 copy ($from, $name) 123 or die "Can't copy $from to $name: $!"; 124 } 125} 126 127 128sub bzip2_files 129{ 130 my $dir = shift ; 131 132 my @c_files = qw( 133 blocksort.c 134 huffman.c 135 crctable.c 136 randtable.c 137 compress.c 138 decompress.c 139 bzlib.c 140 ); 141 142 my @h_files = qw( bzlib.h bzlib_private.h ); 143 144 foreach my $file (@c_files, @h_files) 145 { copy(catfile($dir, $file), '.') } 146 147 148 @h_files = map { catfile($dir, $_) } @h_files ; 149 my @o_files = map { "$_\$(OBJ_EXT)" } 'Bzip2', @c_files; 150 push @c_files, 'Bzip2.c' ; 151 152 return ( 153 #'H' => [ @h_files ], 154 'C' => [ @c_files ] , 155 #'OBJECT' => qq[ @o_files ], 156 'OBJECT' => q[ $(O_FILES) ], 157 158 159 ) ; 160} 161 162 163 164