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