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