~ubuntu-branches/debian/squeeze/libnet-ssh2-perl/squeeze

« back to all changes in this revision

Viewing changes to inc/Module/Install/Makefile.pm

  • Committer: Bazaar Package Importer
  • Author(s): Salvatore Bonaccorso
  • Date: 2010-07-13 20:16:02 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100713201602-3judlzka0y3cgety
Tags: 0.33-1
* New upstream release
* Bump Standards-Version to 3.9.0 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
use strict 'vars';
5
5
use ExtUtils::MakeMaker   ();
6
6
use Module::Install::Base ();
 
7
use Fcntl qw/:flock :seek/;
7
8
 
8
9
use vars qw{$VERSION @ISA $ISCORE};
9
10
BEGIN {
10
 
        $VERSION = '0.94';
 
11
        $VERSION = '1.00';
11
12
        @ISA     = 'Module::Install::Base';
12
13
        $ISCORE  = 1;
13
14
}
25
26
                die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])";
26
27
        }
27
28
 
28
 
        # In automated testing, always use defaults
29
 
        if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) {
 
29
        # In automated testing or non-interactive session, always use defaults
 
30
        if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) {
30
31
                local $ENV{PERL_MM_USE_DEFAULT} = 1;
31
32
                goto &ExtUtils::MakeMaker::prompt;
32
33
        } else {
45
46
        ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0
46
47
}
47
48
 
 
49
# Ripped from ExtUtils::MakeMaker 6.56, and slightly modified
 
50
# as we only need to know here whether the attribute is an array
 
51
# or a hash or something else (which may or may not be appendable).
 
52
my %makemaker_argtype = (
 
53
 C                  => 'ARRAY',
 
54
 CONFIG             => 'ARRAY',
 
55
# CONFIGURE          => 'CODE', # ignore
 
56
 DIR                => 'ARRAY',
 
57
 DL_FUNCS           => 'HASH',
 
58
 DL_VARS            => 'ARRAY',
 
59
 EXCLUDE_EXT        => 'ARRAY',
 
60
 EXE_FILES          => 'ARRAY',
 
61
 FUNCLIST           => 'ARRAY',
 
62
 H                  => 'ARRAY',
 
63
 IMPORTS            => 'HASH',
 
64
 INCLUDE_EXT        => 'ARRAY',
 
65
 LIBS               => 'ARRAY', # ignore ''
 
66
 MAN1PODS           => 'HASH',
 
67
 MAN3PODS           => 'HASH',
 
68
 META_ADD           => 'HASH',
 
69
 META_MERGE         => 'HASH',
 
70
 PL_FILES           => 'HASH',
 
71
 PM                 => 'HASH',
 
72
 PMLIBDIRS          => 'ARRAY',
 
73
 PMLIBPARENTDIRS    => 'ARRAY',
 
74
 PREREQ_PM          => 'HASH',
 
75
 CONFIGURE_REQUIRES => 'HASH',
 
76
 SKIP               => 'ARRAY',
 
77
 TYPEMAPS           => 'ARRAY',
 
78
 XS                 => 'HASH',
 
79
# VERSION            => ['version',''],  # ignore
 
80
# _KEEP_AFTER_FLUSH  => '',
 
81
 
 
82
 clean      => 'HASH',
 
83
 depend     => 'HASH',
 
84
 dist       => 'HASH',
 
85
 dynamic_lib=> 'HASH',
 
86
 linkext    => 'HASH',
 
87
 macro      => 'HASH',
 
88
 postamble  => 'HASH',
 
89
 realclean  => 'HASH',
 
90
 test       => 'HASH',
 
91
 tool_autosplit => 'HASH',
 
92
 
 
93
 # special cases where you can use makemaker_append
 
94
 CCFLAGS   => 'APPENDABLE',
 
95
 DEFINE    => 'APPENDABLE',
 
96
 INC       => 'APPENDABLE',
 
97
 LDDLFLAGS => 'APPENDABLE',
 
98
 LDFROM    => 'APPENDABLE',
 
99
);
 
100
 
48
101
sub makemaker_args {
49
 
        my $self = shift;
 
102
        my ($self, %new_args) = @_;
50
103
        my $args = ( $self->{makemaker_args} ||= {} );
51
 
        %$args = ( %$args, @_ );
 
104
        foreach my $key (keys %new_args) {
 
105
                if ($makemaker_argtype{$key}) {
 
106
                        if ($makemaker_argtype{$key} eq 'ARRAY') {
 
107
                                $args->{$key} = [] unless defined $args->{$key};
 
108
                                unless (ref $args->{$key} eq 'ARRAY') {
 
109
                                        $args->{$key} = [$args->{$key}]
 
110
                                }
 
111
                                push @{$args->{$key}},
 
112
                                        ref $new_args{$key} eq 'ARRAY'
 
113
                                                ? @{$new_args{$key}}
 
114
                                                : $new_args{$key};
 
115
                        }
 
116
                        elsif ($makemaker_argtype{$key} eq 'HASH') {
 
117
                                $args->{$key} = {} unless defined $args->{$key};
 
118
                                foreach my $skey (keys %{ $new_args{$key} }) {
 
119
                                        $args->{$key}{$skey} = $new_args{$key}{$skey};
 
120
                                }
 
121
                        }
 
122
                        elsif ($makemaker_argtype{$key} eq 'APPENDABLE') {
 
123
                                $self->makemaker_append($key => $new_args{$key});
 
124
                        }
 
125
                }
 
126
                else {
 
127
                        if (defined $args->{$key}) {
 
128
                                warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n};
 
129
                        }
 
130
                        $args->{$key} = $new_args{$key};
 
131
                }
 
132
        }
52
133
        return $args;
53
134
}
54
135
 
58
139
        my $self = shift;
59
140
        my $name = shift;
60
141
        my $args = $self->makemaker_args;
61
 
        $args->{name} = defined $args->{$name}
62
 
                ? join( ' ', $args->{name}, @_ )
 
142
        $args->{$name} = defined $args->{$name}
 
143
                ? join( ' ', $args->{$name}, @_ )
63
144
                : join( ' ', @_ );
64
145
}
65
146
 
100
181
        $self->makemaker_args( INC => shift );
101
182
}
102
183
 
103
 
my %test_dir = ();
104
 
 
105
184
sub _wanted_t {
106
 
        /\.t$/ and -f $_ and $test_dir{$File::Find::dir} = 1;
107
185
}
108
186
 
109
187
sub tests_recursive {
110
188
        my $self = shift;
111
 
        if ( $self->tests ) {
112
 
                die "tests_recursive will not work if tests are already defined";
113
 
        }
114
189
        my $dir = shift || 't';
115
190
        unless ( -d $dir ) {
116
191
                die "tests_recursive dir '$dir' does not exist";
117
192
        }
118
 
        %test_dir = ();
 
193
        my %tests = map { $_ => 1 } split / /, ($self->tests || '');
119
194
        require File::Find;
120
 
        File::Find::find( \&_wanted_t, $dir );
121
 
        if ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) {
122
 
                File::Find::find( \&_wanted_t, 'xt' );
123
 
        }
124
 
        $self->tests( join ' ', map { "$_/*.t" } sort keys %test_dir );
 
195
        File::Find::find(
 
196
        sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 },
 
197
        $dir
 
198
    );
 
199
        $self->tests( join ' ', sort keys %tests );
125
200
}
126
201
 
127
202
sub write {
158
233
        my $args = $self->makemaker_args;
159
234
        $args->{DISTNAME} = $self->name;
160
235
        $args->{NAME}     = $self->module_name || $self->name;
161
 
        $args->{VERSION}  = $self->version;
162
236
        $args->{NAME}     =~ s/-/::/g;
 
237
        $args->{VERSION}  = $self->version or die <<'EOT';
 
238
ERROR: Can't determine distribution version. Please specify it
 
239
explicitly via 'version' in Makefile.PL, or set a valid $VERSION
 
240
in a module, and provide its file path via 'version_from' (or
 
241
'all_from' if you prefer) in Makefile.PL.
 
242
EOT
 
243
 
163
244
        $DB::single = 1;
164
245
        if ( $self->tests ) {
 
246
                my @tests = split ' ', $self->tests;
 
247
                my %seen;
165
248
                $args->{test} = {
166
 
                        TESTS => $self->tests,
 
249
                        TESTS => (join ' ', grep {!$seen{$_}++} @tests),
167
250
                };
 
251
    } elsif ( $Module::Install::ExtraTests::use_extratests ) {
 
252
        # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness.
 
253
        # So, just ignore our xt tests here.
168
254
        } elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) {
169
255
                $args->{test} = {
170
256
                        TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ),
172
258
        }
173
259
        if ( $] >= 5.005 ) {
174
260
                $args->{ABSTRACT} = $self->abstract;
175
 
                $args->{AUTHOR}   = $self->author;
 
261
                $args->{AUTHOR}   = join ', ', @{$self->author || []};
176
262
        }
177
263
        if ( $self->makemaker(6.10) ) {
178
264
                $args->{NO_META}   = 1;
184
270
        unless ( $self->is_admin ) {
185
271
                delete $args->{SIGN};
186
272
        }
 
273
        if ( $self->makemaker(6.31) and $self->license ) {
 
274
                $args->{LICENSE} = $self->license;
 
275
        }
187
276
 
188
277
        my $prereq = ($args->{PREREQ_PM} ||= {});
189
278
        %$prereq = ( %$prereq,
208
297
        # Remove any reference to perl, BUILD_REQUIRES doesn't support it
209
298
        delete $args->{BUILD_REQUIRES}->{perl};
210
299
 
211
 
        # Delete bundled dists from prereq_pm
212
 
        my $subdirs = ($args->{DIR} ||= []);
 
300
        # Delete bundled dists from prereq_pm, add it to Makefile DIR
 
301
        my $subdirs = ($args->{DIR} || []);
213
302
        if ($self->bundles) {
 
303
                my %processed;
214
304
                foreach my $bundle (@{ $self->bundles }) {
215
 
                        my ($file, $dir) = @$bundle;
216
 
                        push @$subdirs, $dir if -d $dir;
217
 
                        delete $build_prereq->{$file}; #Delete from build prereqs only
 
305
                        my ($mod_name, $dist_dir) = @$bundle;
 
306
                        delete $prereq->{$mod_name};
 
307
                        $dist_dir = File::Basename::basename($dist_dir); # dir for building this module
 
308
                        if (not exists $processed{$dist_dir}) {
 
309
                                if (-d $dist_dir) {
 
310
                                        # List as sub-directory to be processed by make
 
311
                                        push @$subdirs, $dist_dir;
 
312
                                }
 
313
                                # Else do nothing: the module is already present on the system
 
314
                                $processed{$dist_dir} = undef;
 
315
                        }
218
316
                }
219
317
        }
220
318
 
233
331
                }
234
332
        }
235
333
 
236
 
        $args->{INSTALLDIRS} = $self->installdirs;
 
334
        if ($self->installdirs) {
 
335
                warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS};
 
336
                $args->{INSTALLDIRS} = $self->installdirs;
 
337
        }
237
338
 
238
339
        my %args = map {
239
340
                ( $_ => $args->{$_} ) } grep {defined($args->{$_} )
264
365
                . ($self->postamble || '');
265
366
 
266
367
        local *MAKEFILE;
267
 
        open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
 
368
        open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
 
369
        eval { flock MAKEFILE, LOCK_EX };
268
370
        my $makefile = do { local $/; <MAKEFILE> };
269
 
        close MAKEFILE or die $!;
270
371
 
271
372
        $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
272
373
        $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
286
387
        # XXX - This is currently unused; not sure if it breaks other MM-users
287
388
        # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
288
389
 
289
 
        open  MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
 
390
        seek MAKEFILE, 0, SEEK_SET;
 
391
        truncate MAKEFILE, 0;
290
392
        print MAKEFILE  "$preamble$makefile$postamble" or die $!;
291
393
        close MAKEFILE  or die $!;
292
394
 
310
412
 
311
413
__END__
312
414
 
313
 
#line 439
 
415
#line 541