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