| 1 | package Make::Rule::Vars; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | my $generation = 0; # lexical cross-package scope used! | |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | # Package to handle 'magic' variables pertaining to rules e.g. $@ $* $^ $? | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # by using tie to this package 'subsvars' can work with array of | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # hash references to possible sources of variable definitions. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | sub TIEHASH { | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 154 | ▶ | my ( $class, $rule ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 154 | return bless \$rule, $class; | |||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | sub FETCH { | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 462 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=7 SCAR=33.9
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 462 | local $_ = shift; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 462 | my $rule = $$self; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 462 | ▶ | return undef unless (/^[\@^<?*]$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | # print STDERR "FETCH $_ for ",$rule->Name,"\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | return $rule->Name if ( $_ eq '@' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | return $rule->Base if ( $_ eq '*' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | return join( ' ', $rule->exp_depend ) if ( $_ eq '^' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | return join( ' ', $rule->out_of_date ) if ( $_ eq '?' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | # Next one is dubious - I think $< is really more subtle ... | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | return ( $rule->exp_depend )[0] if ( $_ eq '<' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | package Make::Rule; | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # Bottom level 'rule' package | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # An instance exists for each ':' or '::' rule in the makefile. | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # The commands and dependancies are kept here. | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | sub target { | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 2392 | ▶ | return shift->{TARGET}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
target: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | sub Name { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 1318 | ▶ | return shift->target->Name; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | sub Base { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $name = shift->target->Name; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Base: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $name =~ s/\.[^.]+$//; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return $name; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | sub Info { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 875 | ▶ | return shift->target->Info; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Info: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | sub depend { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 1621 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
depend: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1621 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1164 | my $name = $self->Name; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 1164 | my $dep = shift; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 1164 | ▶ | confess "dependants $dep are not an array reference" unless ( 'ARRAY' eq ref $dep ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 1164 | my $file; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 1164 | foreach $file (@$dep) { | |||||||||||||||||||||||||||||||||||||||||
| 66 | 1764 | ▶ | unless ( exists $self->{DEPHASH}{$file} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1752 | $self->{DEPHASH}{$file} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 1752 | push( @{ $self->{DEPEND} }, $file ); | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 1621 | ▶ | return (wantarray) ? @{ $self->{DEPEND} } : $self->{DEPEND}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | sub command { | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 1366 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=7 SCAR=20.5
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1366 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1164 | my $cmd = shift; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 1164 | ▶ | confess "commands $cmd are not an array reference" unless ( 'ARRAY' eq ref $cmd ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1164 | ▶ | if (@$cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 1104 | ▶ | if ( @{ $self->{COMMAND} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | warn "Command for " . $self->Name, " redefined"; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | print STDERR "Was:", join( "\n", @{ $self->{COMMAND} } ), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | print STDERR "Now:", join( "\n", @$cmd ), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 1104 | $self->{COMMAND} = $cmd; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 60 | ▶ | if ( @{ $self->{COMMAND} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | # warn "Command for ".$self->Name," retained"; | ||||||||||||||||||||||||||||||||||||||||||
| 92 | # print STDERR "Was:",join("\n",@{$self->{COMMAND}}),"\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 1366 | ▶ | return (wantarray) ? @{ $self->{COMMAND} } : $self->{COMMAND}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | # | ||||||||||||||||||||||||||||||||||||||||||
| 100 | # The key make test - is target out-of-date as far as this rule is concerned | ||||||||||||||||||||||||||||||||||||||||||
| 101 | # In scalar context - boolean value of 'do we need to apply the rule' | ||||||||||||||||||||||||||||||||||||||||||
| 102 | # In list context the things we are out-of-date with e.g. magic $? variable | ||||||||||||||||||||||||||||||||||||||||||
| 103 | # | ||||||||||||||||||||||||||||||||||||||||||
| 104 | sub out_of_date { | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 199 | ▶ | my $array = wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
out_of_date: called CC=10 SCAR=26.4
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 199 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 199 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 199 | my @dep = (); | |||||||||||||||||||||||||||||||||||||||||
| 109 | 199 | my $tdate = $self->target->date; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 199 | my $dep; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 199 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 199 | foreach $dep ( $self->exp_depend ) { | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | # This is a dumb fix around regex issues with using Strawberry perl. | ||||||||||||||||||||||||||||||||||||||||||
| 115 | # This may not fix for all versions of Strawberry perl or all versions | ||||||||||||||||||||||||||||||||||||||||||
| 116 | # of windows, but is a hacky work-around until a real fix can be implemented | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 221 | ▶ | if ( $^O eq 'MSWin32' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | if ( $dep =~ m/libConfig.pm/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $dep =~ s#libConfig.pm#lib\\Config.pm#; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ( $dep =~ m/COREconfig.h/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $dep =~ s#COREconfig.h#CORE\\config.h#; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 221 | my $date = $info->date($dep); | |||||||||||||||||||||||||||||||||||||||||
| 126 | 221 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 221 | ▶ | if ( !defined($date) || !defined($tdate) || $date < $tdate ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $date && defined $tdate or $date < $tdate
defined $date && defined $tdate
MC/DC66%2/3
not defined $date && defined $tdate or $date < $tdate
defined $date
defined $tdate
$date < $tdate
Truth table75%3/4
not(A && B) or C
A= defined $dateB= defined $tdateC= $date < $tdate
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | # warn $self->Name." ood wrt ".$dep."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 51 | ▶ | return 1 unless $array; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | push( @dep, $dep ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 148 | ▶ | return @dep if $array; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | # Note special case of no dependencies means it is always out-of-date! | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 148 | return !$count; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | # | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # Return list of things rule depends on with variables expanded | ||||||||||||||||||||||||||||||||||||||||||
| 142 | # - May need pathname and vpath processing as well | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # | ||||||||||||||||||||||||||||||||||||||||||
| 144 | sub exp_depend { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 445 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exp_depend: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 445 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 445 | my @dep = map( split( /\s+/, $info->subsvars($_) ), $self->depend ); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 445 | ▶ | return (wantarray) ? @dep : \@dep; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # Return commands to apply rule with variables expanded | ||||||||||||||||||||||||||||||||||||||||||
| 153 | # - No pathname processing needed, commands should always chdir() | ||||||||||||||||||||||||||||||||||||||||||
| 154 | # to logical place (at least till we get very clever at bourne shell parsing). | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # - May need vpath processing | ||||||||||||||||||||||||||||||||||||||||||
| 156 | # | ||||||||||||||||||||||||||||||||||||||||||
| 157 | sub exp_command { | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 154 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exp_command: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 154 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 154 | my $base = $self->Name; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 154 | my %var; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 154 | tie %var, 'Make::Rule::Vars', $self; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 154 | my @cmd = map( $info->subsvars( $_, \%var ), $self->command ); | |||||||||||||||||||||||||||||||||||||||||
| 164 | 154 | ▶ | return (wantarray) ? @cmd : \@cmd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | # | ||||||||||||||||||||||||||||||||||||||||||
| 168 | # clone creates a new rule derived from an existing rule, but | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # with a different target. Used when left hand side was a variable. | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # perhaps should be used for dot/pattern rule processing too. | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # | ||||||||||||||||||||||||||||||||||||||||||
| 172 | sub clone { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 1200 | ▶ | my ( $self, $target ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 1200 | my %hash = %$self; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 1200 | $hash{TARGET} = $target; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 1200 | $hash{DEPEND} = [ @{ $self->{DEPEND} } ]; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 1200 | $hash{DEPHASH} = { %{ $self->{DEPHASH} } }; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 1200 | my $obj = bless \%hash, ref $self; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 1200 | return $obj; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 1152 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 1152 | my $target = shift; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 1152 | my $kind = shift; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 1152 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||
| 187 | TARGET => $target, # parent target (left hand side) | ||||||||||||||||||||||||||||||||||||||||||
| 188 | KIND => $kind, # : or :: | ||||||||||||||||||||||||||||||||||||||||||
| 189 | DEPEND => [], DEPHASH => {}, # right hand args | ||||||||||||||||||||||||||||||||||||||||||
| 190 | COMMAND => [] # command(s) | ||||||||||||||||||||||||||||||||||||||||||
| 191 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 1152 | ▶ | $self->depend(shift) if (@_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 1152 | ▶ | $self->command(shift) if (@_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 1152 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | # | ||||||||||||||||||||||||||||||||||||||||||
| 198 | # This code has to go somewhere but no good home obvious yet. | ||||||||||||||||||||||||||||||||||||||||||
| 199 | # - only applies to ':' rules, but needs top level database | ||||||||||||||||||||||||||||||||||||||||||
| 200 | # - perhaps in ->commands of derived ':' class? | ||||||||||||||||||||||||||||||||||||||||||
| 201 | # | ||||||||||||||||||||||||||||||||||||||||||
| 202 | sub find_commands { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 420 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_commands: called CC=4 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 420 | ▶ | if ( !@{ $self->{COMMAND} } && @{ $self->{DEPEND} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not @{$self->{"COMMAND"};} and @{$self->{"DEPEND"};}
MC/DC0%0/2
not @{$self->{"COMMAND"};} and @{$self->{"DEPEND"};}
not @{$self->{"COMMAND"};}
@{$self->{"DEPEND"};}
Truth table33%1/3
not(A) and B
A= not @{$self->{"COMMAND"};}B= @{$self->{"DEPEND"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $name = $self->Name; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my @dep = $self->depend; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my @rule = $info->patrule( $self->Name ); | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if (@rule) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $self->depend( $rule[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $self->command( $rule[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | # | ||||||||||||||||||||||||||||||||||||||||||
| 217 | # Spew a shell script to perfom the 'make' e.g. make -n | ||||||||||||||||||||||||||||||||||||||||||
| 218 | # | ||||||||||||||||||||||||||||||||||||||||||
| 219 | sub Script { | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Script: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | return unless $self->out_of_date; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my @cmd = $self->exp_command; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if (@cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $file; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | my $com = ( $^O eq 'MSWin32' ) ? 'rem ' : '# '; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | print $com, $self->Name, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | foreach $file ( $self->exp_command ) { | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $file =~ s/^[\@\s-]*//; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | print "$file\n"; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | # | ||||||||||||||||||||||||||||||||||||||||||
| 235 | # Normal 'make' method | ||||||||||||||||||||||||||||||||||||||||||
| 236 | # | ||||||||||||||||||||||||||||||||||||||||||
| 237 | sub Make { | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 199 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Make: called CC=7 SCAR=20.5
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 199 | my $file; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 199 | ▶ | return unless ( $self->out_of_date ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 77 | my @cmd = $self->exp_command; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 77 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 77 | ▶ | if (@cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 77 | foreach my $file ( $self->exp_command ) { | |||||||||||||||||||||||||||||||||||||||||
| 245 | 77 | $file =~ s/^([\@\s-]*)//; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 77 | my $prefix = $1; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 77 | ▶ | print "$file\n" unless ( $prefix =~ /\@/ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 77 | my $code = $info->exec($file); | |||||||||||||||||||||||||||||||||||||||||
| 249 | 66 | ▶ | if ( $code && $prefix !~ /-/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$code and not $prefix =~ /-/
MC/DC0%0/2
$code and not $prefix =~ /-/
$code
not $prefix =~ /-/
Truth table33%1/3
A and not(B)
A= $codeB= not $prefix =~ /-/
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | die "Code $code from $file"; | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | # | ||||||||||||||||||||||||||||||||||||||||||
| 257 | # Print rule out in makefile syntax | ||||||||||||||||||||||||||||||||||||||||||
| 258 | # - currently has variables expanded as debugging aid. | ||||||||||||||||||||||||||||||||||||||||||
| 259 | # - will eventually become make -p | ||||||||||||||||||||||||||||||||||||||||||
| 260 | # - may be useful for writing makefiles from MakeMaker too... | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # | ||||||||||||||||||||||||||||||||||||||||||
| 262 | sub Print { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Print: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my $file; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | print $self->Name, ' ', $self->{KIND}, ' '; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | foreach $file ( $self->depend ) { | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | print " \\\n $file"; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my @cmd = $self->exp_command; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if (@cmd) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | foreach $file ( $self->exp_command ) { | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | print "\t", $file, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | print STDERR "No commands for ", $self->Name, "\n" unless ( $self->target->phony ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | package Make::Target; | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 12 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | # | ||||||||||||||||||||||||||||||||||||||||||
| 288 | # Intermediate 'target' package | ||||||||||||||||||||||||||||||||||||||||||
| 289 | # There is an instance of this for each 'target' that apears on | ||||||||||||||||||||||||||||||||||||||||||
| 290 | # the left hand side of a rule i.e. for each thing that can be made. | ||||||||||||||||||||||||||||||||||||||||||
| 291 | # | ||||||||||||||||||||||||||||||||||||||||||
| 292 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 1224 | ▶ | my ( $class, $info, $target ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 1224 | return bless { | |||||||||||||||||||||||||||||||||||||||||
| 295 | NAME => $target, # name of thing | ||||||||||||||||||||||||||||||||||||||||||
| 296 | MAKEFILE => $info, # Makefile context | ||||||||||||||||||||||||||||||||||||||||||
| 297 | Pass => 0 # Used to determine if 'done' this sweep | ||||||||||||||||||||||||||||||||||||||||||
| 298 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | sub date { | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 199 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 199 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 199 | return $info->date( $self->Name ); | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | sub phony { | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
phony: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return $self->Info->phony( $self->Name ); | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | sub colon { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 2816 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
colon: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 2816 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 984 | ▶ | if ( exists $self->{COLON} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 12 | my $dep = $self->{COLON}; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 12 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | # merging an existing rule | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $other = shift; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $dep->depend( scalar $other->depend ); | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $dep->command( scalar $other->command ); | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 12 | $dep->depend(shift); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 12 | $dep->command(shift); | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 972 | ▶ | $self->{COLON} = ( @_ == 1 ) ? shift->clone($self) : Make::Rule->new( $self, ':', @_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 2816 | ▶ | if ( exists $self->{COLON} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 1645 | ▶ | return (wantarray) ? ( $self->{COLON} ) : $self->{COLON}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 1171 | ▶ | return (wantarray) ? () : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | sub dcolon { | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 1756 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dcolon: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 1756 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 1380 | ▶ | my $rule = ( @_ == 1 ) ? shift->clone($self) : Make::Rule->new( $self, '::', @_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 1380 | ▶ | $self->{DCOLON} = [] unless ( exists $self->{DCOLON} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 1380 | push( @{ $self->{DCOLON} }, $rule ); | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 1756 | ▶ | return ( exists $self->{DCOLON} ) ? @{ $self->{DCOLON} } : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | sub Name { | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 2633 | ▶ | return shift->{NAME}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | sub Info { | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 2876 | ▶ | return shift->{MAKEFILE}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Info: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | sub ProcessColon { | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 1116 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ProcessColon: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 1116 | my $c = $self->colon; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 1116 | ▶ | $c->find_commands if $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | sub ExpandTarget { | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 1116 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ExpandTarget: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 1116 | my $target = $self->Name; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 1116 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 1116 | my $colon = delete $self->{COLON}; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 1116 | my $dcolon = delete $self->{DCOLON}; | |||||||||||||||||||||||||||||||||||||||||
| 371 | 1116 | foreach my $expand ( split( /\s+/, $info->subsvars($target) ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 372 | 1116 | ▶ | next unless defined($expand); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 1116 | my $t = $info->Target($expand); | |||||||||||||||||||||||||||||||||||||||||
| 374 | 1116 | ▶ | if ( defined $colon ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 480 | $t->colon($colon); | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 1116 | foreach my $d ( @{$dcolon} ) { | |||||||||||||||||||||||||||||||||||||||||
| 378 | 720 | $t->dcolon($d); | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | sub done { | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 244 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
done: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 244 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 244 | my $pass = $info->pass; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 244 | ▶ | return 1 if ( $self->{Pass} == $pass ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 198 | $self->{Pass} = $pass; | |||||||||||||||||||||||||||||||||||||||||
| 389 | 198 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | sub recurse { | ||||||||||||||||||||||||||||||||||||||||||
| 393 | 198 | ▶ | my ( $self, $method, @args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recurse: called CC=9 SCAR=26.0
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 198 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 395 | 198 | my $rule; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 198 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 198 | foreach $rule ( $self->colon, $self->dcolon ) { | |||||||||||||||||||||||||||||||||||||||||
| 398 | 222 | my $dep; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 222 | my $j = 0; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 222 | foreach $dep ( $rule->exp_depend ) { | |||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | # This is a dumb fix around regex issues with using Strawberry perl. | ||||||||||||||||||||||||||||||||||||||||||
| 403 | # This may not fix for all versions of Strawberry perl or all versions | ||||||||||||||||||||||||||||||||||||||||||
| 404 | # of windows, but is a hacky work-around until a real fix can be implemented | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 378 | ▶ | if ( ( $dep =~ m/libConfig.pm/ ) and ( $^O eq 'MSWin32' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dep =~ /libConfig.pm/ and $^O eq "MSWin32"
MC/DC0%0/2
$dep =~ /libConfig.pm/ and $^O eq "MSWin32"
$dep =~ /libConfig.pm/
$^O eq "MSWin32"
Truth table33%1/3
A and B
A= $dep =~ /libConfig.pm/B= $^O eq "MSWin32"
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | print STDERR "we got here with $dep\n"; | |||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $dep =~ s#libConfig.pm#lib//Config.pm#; | |||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 378 | ▶ | if ( ( $dep =~ m/COREconfig.h/ ) and ( $^O eq 'MSWin32' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dep =~ /COREconfig.h/ and $^O eq "MSWin32"
MC/DC0%0/2
$dep =~ /COREconfig.h/ and $^O eq "MSWin32"
$dep =~ /COREconfig.h/
$^O eq "MSWin32"
Truth table33%1/3
A and B
A= $dep =~ /COREconfig.h/B= $^O eq "MSWin32"
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | print STDERR "we got here with $dep\n"; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $dep =~ s#COREconfig.h#CORE//config.h#; | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 378 | my $t = $info->{Depend}{$dep}; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 378 | ▶ | if ( defined $t ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 232 | $t->$method(@args); | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 419 | 146 | ▶ | unless ( $info->exists($dep) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my $dir = cwd(); | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | die "Cannot recurse $method - no target $dep in $dir"; | |||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | sub Script { | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Script: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $rule = $self->colon; | |||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | return if ( $self->done ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $self->recurse('Script'); | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | foreach $rule ( $self->colon, $self->dcolon ) { | |||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $rule->Script; | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | sub Make { | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 244 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Make: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 244 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 442 | 244 | my $rule = $self->colon; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 244 | ▶ | return if ( $self->done ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 198 | $self->recurse('Make'); | |||||||||||||||||||||||||||||||||||||||||
| 445 | 178 | foreach $rule ( $self->colon, $self->dcolon ) { | |||||||||||||||||||||||||||||||||||||||||
| 446 | 199 | $rule->Make; | |||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | sub Print { | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Print: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $info = $self->Info; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | return if ( $self->done ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $rule = $self->colon; | |||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | foreach $rule ( $self->colon, $self->dcolon ) { | |||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $rule->Print; | |||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $self->recurse('Print'); | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | package Make; | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 12 | ▶ | use 5.005; # Need look-behind assertions | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | 12 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | 12 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 12 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 12 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 12 | $VERSION = '1.1.1'; | |||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 12 | my %date; | |||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | sub phony { | ||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | my ( $self, $name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
phony: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | return exists $self->{PHONY}{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | sub suffixes { | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 12 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
suffixes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 12 | return keys %{ $self->{'SUFFIXES'} }; | |||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | # | ||||||||||||||||||||||||||||||||||||||||||
| 484 | # Construct a new 'target' (or find old one) | ||||||||||||||||||||||||||||||||||||||||||
| 485 | # - used by parser to add to data structures | ||||||||||||||||||||||||||||||||||||||||||
| 486 | # | ||||||||||||||||||||||||||||||||||||||||||
| 487 | sub Target { | ||||||||||||||||||||||||||||||||||||||||||
| 488 | 2280 | ▶ | my ( $self, $target ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Target: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | 2280 | ▶ | unless ( exists $self->{Depend}{$target} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | 1224 | my $t = Make::Target->new( $self, $target ); | |||||||||||||||||||||||||||||||||||||||||
| 491 | 1224 | $self->{Depend}{$target} = $t; | |||||||||||||||||||||||||||||||||||||||||
| 492 | 1224 | ▶ | if ( $target =~ /%/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 36 | $self->{Pattern}{$target} = $t; | |||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | elsif ( $target =~ /^\./ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 72 | $self->{Dot}{$target} = $t; | |||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 1116 | push( @{ $self->{Targets} }, $t ); | |||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 2280 | return $self->{Depend}{$target}; | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | # | ||||||||||||||||||||||||||||||||||||||||||
| 506 | # Utility routine for patching %.o type 'patterns' | ||||||||||||||||||||||||||||||||||||||||||
| 507 | # | ||||||||||||||||||||||||||||||||||||||||||
| 508 | sub patmatch { | ||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | my $key = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
patmatch: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | local $_ = shift; | |||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $pat = $key; | |||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $pat =~ s/\./\\./; | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $pat =~ s/%/(\[^\/\]*)/; | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | if (/$pat$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | return $1; | |||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | # | ||||||||||||||||||||||||||||||||||||||||||
| 521 | # old vpath lookup routine | ||||||||||||||||||||||||||||||||||||||||||
| 522 | # | ||||||||||||||||||||||||||||||||||||||||||
| 523 | sub locate { | ||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | local $_ = shift; | |||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | return $_ if ( -r $_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $key; | |||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | foreach $key ( keys %{ $self->{vpath} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $Pat; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | if ( defined( $Pat = patmatch( $key, $_ ) ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my $dir; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | foreach $dir ( split( /:/, $self->{vpath}{$key} ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | return "$dir/$_" if ( -r "$dir/$_" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | # | ||||||||||||||||||||||||||||||||||||||||||
| 541 | # Convert traditional .c.o rules into GNU-like into %o : %c | ||||||||||||||||||||||||||||||||||||||||||
| 542 | # | ||||||||||||||||||||||||||||||||||||||||||
| 543 | sub dotrules { | ||||||||||||||||||||||||||||||||||||||||||
| 544 | 12 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dotrules: called CC=10 SCAR=24.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 12 | my $t; | |||||||||||||||||||||||||||||||||||||||||
| 546 | 12 | foreach $t ( keys %{ $self->{Dot} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 547 | 48 | my $e = $self->subsvars($t); | |||||||||||||||||||||||||||||||||||||||||
| 548 | 48 | ▶ | $self->{Dot}{$e} = delete $self->{Dot}{$t} unless ( $t eq $e ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 12 | my (@suffix) = $self->suffixes; | |||||||||||||||||||||||||||||||||||||||||
| 551 | 12 | foreach $t (@suffix) { | |||||||||||||||||||||||||||||||||||||||||
| 552 | 156 | my $d; | |||||||||||||||||||||||||||||||||||||||||
| 553 | 156 | my $r = delete $self->{Dot}{$t}; | |||||||||||||||||||||||||||||||||||||||||
| 554 | 156 | ▶ | if ( defined $r ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | 12 | ▶ | my @rule = ( $r->colon ) ? ( $r->colon->depend ) : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 12 | ▶ | if (@rule) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | delete $self->{Dot}{ $t->Name }; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | print STDERR $t->Name, " has dependants\n"; | |||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | push( @{ $self->{Targets} }, $r ); | |||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 561 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 562 | # print STDERR "Build \% : \%$t\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 563 | 12 | $self->Target('%')->dcolon( [ '%' . $t ], scalar $r->colon->command ); | |||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||
| 566 | 156 | foreach $d (@suffix) { | |||||||||||||||||||||||||||||||||||||||||
| 567 | 2028 | $r = delete $self->{Dot}{ $t . $d }; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 2028 | ▶ | if ( defined $r ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | # print STDERR "Build \%$d : \%$t\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 571 | 36 | $self->Target( '%' . $d )->dcolon( [ '%' . $t ], scalar $r->colon->command ); | |||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | 12 | foreach $t ( keys %{ $self->{Dot} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | push( @{ $self->{Targets} }, delete $self->{Dot}{$t} ); | |||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | # | ||||||||||||||||||||||||||||||||||||||||||
| 581 | # Return 'full' pathname of name given directory info. | ||||||||||||||||||||||||||||||||||||||||||
| 582 | # - may be the place to do vpath stuff ? | ||||||||||||||||||||||||||||||||||||||||||
| 583 | # | ||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | my %pathname; | ||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | sub pathname { | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 578 | ▶ | my ( $self, $name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pathname: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | 578 | my $hash = $self->{'Pathname'}; | |||||||||||||||||||||||||||||||||||||||||
| 590 | 578 | ▶ | unless ( exists $hash->{$name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 228 | ▶ | if ( File::Spec->file_name_is_absolute($name) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 24 | $hash->{$name} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 594 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 204 | $name =~ s,^\./,,; | |||||||||||||||||||||||||||||||||||||||||
| 596 | 204 | $hash->{$name} = File::Spec->catfile( $self->{Dir}, $name ); | |||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 578 | return $hash->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | # | ||||||||||||||||||||||||||||||||||||||||||
| 604 | # Return modified date of name if it exists | ||||||||||||||||||||||||||||||||||||||||||
| 605 | # | ||||||||||||||||||||||||||||||||||||||||||
| 606 | sub date { | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 566 | ▶ | my ( $self, $name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 608 | 566 | my $path = $self->pathname($name); | |||||||||||||||||||||||||||||||||||||||||
| 609 | 566 | ▶ | unless ( exists $date{$path} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | 312 | $date{$path} = -M $path; | |||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 566 | return $date{$path}; | |||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | # | ||||||||||||||||||||||||||||||||||||||||||
| 616 | # Check to see if name is a target we can make or an existing | ||||||||||||||||||||||||||||||||||||||||||
| 617 | # file - used to see if pattern rules are valid | ||||||||||||||||||||||||||||||||||||||||||
| 618 | # - Needs extending to do vpath lookups | ||||||||||||||||||||||||||||||||||||||||||
| 619 | # | ||||||||||||||||||||||||||||||||||||||||||
| 620 | sub exists { | ||||||||||||||||||||||||||||||||||||||||||
| 621 | 146 | ▶ | my ( $self, $name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exists: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | 146 | ▶ | return 1 if ( exists $self->{Depend}{$name} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 623 | 146 | ▶ | return 1 if defined $self->date($name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | # print STDERR "$name '$path' does not exist\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | # | ||||||||||||||||||||||||||||||||||||||||||
| 630 | # See if we can find a %.o : %.c rule for target | ||||||||||||||||||||||||||||||||||||||||||
| 631 | # .c.o rules are already converted to this form | ||||||||||||||||||||||||||||||||||||||||||
| 632 | # | ||||||||||||||||||||||||||||||||||||||||||
| 633 | sub patrule { | ||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | my ( $self, $target ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
patrule: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | my $key; | |||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | # print STDERR "Trying pattern for $target\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | foreach $key ( keys %{ $self->{Pattern} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | my $Pat; | |||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | if ( defined( $Pat = patmatch( $key, $target ) ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | my $t = $self->{Pattern}{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | my $rule; | |||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | foreach $rule ( $t->dcolon ) { | |||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my @dep = $rule->exp_depend; | |||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | if (@dep) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my $dep = $dep[0]; | |||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $dep =~ s/%/$Pat/g; | |||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | # print STDERR "Try $target : $dep\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | if ( $self->exists($dep) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | foreach (@dep) { | |||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | s/%/$Pat/g; | |||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | return ( \@dep, scalar $rule->command ); | |||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | # | ||||||||||||||||||||||||||||||||||||||||||
| 664 | # Old code to handle vpath stuff - not used yet | ||||||||||||||||||||||||||||||||||||||||||
| 665 | # | ||||||||||||||||||||||||||||||||||||||||||
| 666 | sub needs { | ||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | my ( $self, $target ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
needs: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | unless ( $self->{Done}{$target} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | if ( exists $self->{Depend}{$target} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my @depend = split( /\s+/, $self->subsvars( $self->{Depend}{$target} ) ); | |||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | foreach (@depend) { | |||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | $self->needs($_); | |||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 675 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | my $vtarget = $self->locate($target); | |||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | if ( defined $vtarget ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $self->{Need}{$vtarget} = $target; | |||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 680 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | $self->{Need}{$target} = $target; | |||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | # | ||||||||||||||||||||||||||||||||||||||||||
| 688 | # Substitute $(xxxx) and $x style variable references | ||||||||||||||||||||||||||||||||||||||||||
| 689 | # - should handle ${xxx} as well | ||||||||||||||||||||||||||||||||||||||||||
| 690 | # - recurses till they all go rather than doing one level, | ||||||||||||||||||||||||||||||||||||||||||
| 691 | # which may need fixing | ||||||||||||||||||||||||||||||||||||||||||
| 692 | # | ||||||||||||||||||||||||||||||||||||||||||
| 693 | sub subsvars { | ||||||||||||||||||||||||||||||||||||||||||
| 694 | 2553 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subsvars: called CC=21 SCAR=47.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | 2553 | local $_ = shift; | |||||||||||||||||||||||||||||||||||||||||
| 696 | 2553 | my @var = @_; | |||||||||||||||||||||||||||||||||||||||||
| 697 | 2553 | push( @var, $self->{Override}, $self->{Vars}, \%ENV ); | |||||||||||||||||||||||||||||||||||||||||
| 698 | 2553 | ▶ | croak("Trying to subsitute undef value") unless ( defined $_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 2553 | ▶ | while ( /(?<!\$)\$\(([^()]+)\)/ || /(?<!\$)\$([<\@^?*])/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
/(?<!\$)\$\(([^()]+)\)/ or /(?<!\$)\$([<\@^?*])/
MC/DC50%1/2
/(?<!\$)\$\(([^()]+)\)/ or /(?<!\$)\$([<\@^?*])/
/(?<!\$)\$\(([^()]+)\)/
/(?<!\$)\$([<\@^?*])/
Truth table66%2/3
A or B
A= /(?<!\$)\$\(([^()]+)\)/B= /(?<!\$)\$([<\@^?*])/
| |||||||||||||||||||||||||||||||||||||||||||
| 700 | 1974 | my ( $key, $head, $tail ) = ( $1, $`, $' ); | |||||||||||||||||||||||||||||||||||||||||
| 701 | 1974 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 702 | 1974 | ▶ | if ( $key =~ /^([\w._]+|\S)(?::(.*))?$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 703 | 1974 | my ( $var, $op ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||
| 704 | 1974 | foreach my $hash (@var) { | |||||||||||||||||||||||||||||||||||||||||
| 705 | 4428 | $value = $hash->{$var}; | |||||||||||||||||||||||||||||||||||||||||
| 706 | 4428 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | 1956 | last; | |||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 710 | 1974 | ▶ | unless ( defined $value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 18 | ▶ | die "$var not defined in '$_'" unless ( length($var) > 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | 18 | $value = ''; | |||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 1974 | ▶ | if ( defined $op ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | if ( $op =~ /^s(.).*\1.*\1/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | local $_ = $self->subsvars($value); | |||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | $op =~ s/\\/\\\\/g; | |||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | eval $op . 'g'; | |||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | $value = $_; | |||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||
| 721 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | die "$var:$op = '$value'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | elsif ( $key =~ /wildcard\s*(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | $value = join( ' ', glob( $self->pathname($1) ) ); | |||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||
| 729 | elsif ( $key =~ /shell\s*(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | $value = join( ' ', split( '\n', `$1` ) ); | |||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||
| 732 | elsif ( $key =~ /addprefix\s*([^,]*),(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | $value = join( ' ', map( $1 . $_, split( '\s+', $2 ) ) ); | |||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | elsif ( $key =~ /notdir\s*(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my @files = split( /\s+/, $1 ); | |||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | foreach (@files) { | |||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | s#^.*/([^/]*)$#$1#; | |||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | $value = join( ' ', @files ); | |||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 742 | elsif ( $key =~ /dir\s*(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my @files = split( /\s+/, $1 ); | |||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | foreach (@files) { | |||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | s#^(.*)/[^/]*$#$1#; | |||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | $value = join( ' ', @files ); | |||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||
| 749 | elsif ( $key =~ /^subst\s+([^,]*),([^,]*),(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | my ( $a, $b ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | $value = $3; | |||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | $a =~ s/\./\\./; | |||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | $value =~ s/$a/$b/; | |||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||
| 755 | elsif ( $key =~ /^mktmp,(\S+)\s*(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | my ( $file, $content ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | open( TMP, ">$file" ) || die "Cannot open $file:$!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | $content =~ s/\\n//g; | |||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | print TMP $content; | |||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | close(TMP); | |||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $value = $file; | |||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | warn "Cannot evaluate '$key' in '$_'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | 1974 | $_ = "$head$value$tail"; | |||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||
| 768 | 2553 | s/\$\$/\$/g; | |||||||||||||||||||||||||||||||||||||||||
| 769 | 2553 | return $_; | |||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | # | ||||||||||||||||||||||||||||||||||||||||||
| 773 | # Split a string into tokens - like split(/\s+/,...) but handling | ||||||||||||||||||||||||||||||||||||||||||
| 774 | # $(keyword ...) with embedded \s | ||||||||||||||||||||||||||||||||||||||||||
| 775 | # Perhaps should also understand "..." and '...' ? | ||||||||||||||||||||||||||||||||||||||||||
| 776 | # | ||||||||||||||||||||||||||||||||||||||||||
| 777 | sub tokenize { | ||||||||||||||||||||||||||||||||||||||||||
| 778 | 2208 | ▶ | local $_ = $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tokenize: called CC=12 SCAR=25.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 779 | 2208 | my @result = (); | |||||||||||||||||||||||||||||||||||||||||
| 780 | 2208 | s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||
| 781 | 2208 | ▶ | while ( length($_) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 782 | 2820 | s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 783 | 2820 | ▶ | last unless (/^\S/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 784 | 2820 | my $token = ""; | |||||||||||||||||||||||||||||||||||||||||
| 785 | 2820 | ▶ | while (/^\S/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 786 | 3456 | ▶ | if (s/^\$([\(\{])//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 787 | 840 | $token .= $&; | |||||||||||||||||||||||||||||||||||||||||
| 788 | 840 | my $paren = $1 eq '('; | |||||||||||||||||||||||||||||||||||||||||
| 789 | 840 | my $brace = $1 eq '{'; | |||||||||||||||||||||||||||||||||||||||||
| 790 | 840 | my $count = 1; | |||||||||||||||||||||||||||||||||||||||||
| 791 | 840 | ▶ | while ( length($_) && ( $paren || $brace ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
length $_ and $paren || $brace
$paren or $brace
MC/DC0%0/3
length $_ and $paren || $brace
length $_
$paren
$brace
Truth table50%2/4
A and B or C
A= length $_B= $parenC= $brace
| |||||||||||||||||||||||||||||||||||||||||||
| 792 | 8784 | s/^.//; | |||||||||||||||||||||||||||||||||||||||||
| 793 | 8784 | $token .= $&; | |||||||||||||||||||||||||||||||||||||||||
| 794 | 8784 | $paren += ( $& eq '(' ); | |||||||||||||||||||||||||||||||||||||||||
| 795 | 8784 | $paren -= ( $& eq ')' ); | |||||||||||||||||||||||||||||||||||||||||
| 796 | 8784 | $brace += ( $& eq '{' ); | |||||||||||||||||||||||||||||||||||||||||
| 797 | 8784 | $brace -= ( $& eq '}' ); | |||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 799 | 840 | ▶ | die "Mismatched {} in $_[0]" if ($brace); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 800 | 840 | ▶ | die "Mismatched () in $_[0]" if ($paren); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||
| 802 | elsif (s/^(\$\S?|[^\s\$]+)//) { | ||||||||||||||||||||||||||||||||||||||||||
| 803 | 2616 | $token .= $&; | |||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||
| 806 | 2820 | push( @result, $token ); | |||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 808 | 2208 | ▶ | return (wantarray) ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | # | ||||||||||||||||||||||||||||||||||||||||||
| 812 | # read makefile (or fragment of one) either as a result | ||||||||||||||||||||||||||||||||||||||||||
| 813 | # of a command line, or an 'include' in another makefile. | ||||||||||||||||||||||||||||||||||||||||||
| 814 | # | ||||||||||||||||||||||||||||||||||||||||||
| 815 | sub makefile { | ||||||||||||||||||||||||||||||||||||||||||
| 816 | 24 | ▶ | my ( $self, $makefile, $name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makefile: called CC=24 SCAR=34.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 817 | 24 | local $_; | |||||||||||||||||||||||||||||||||||||||||
| 818 | 24 | print STDERR "Reading $name\n"; | |||||||||||||||||||||||||||||||||||||||||
| 819 | Makefile: | ||||||||||||||||||||||||||||||||||||||||||
| 820 | 24 | ▶ | while (<$makefile>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 821 | 4944 | ▶ | last unless ( defined $_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 822 | 4920 | chomp($_); | |||||||||||||||||||||||||||||||||||||||||
| 823 | 4920 | ▶ | if (/\\$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 824 | 48 | chop($_); | |||||||||||||||||||||||||||||||||||||||||
| 825 | 48 | s/\s*$//; | |||||||||||||||||||||||||||||||||||||||||
| 826 | 48 | my $more = <$makefile>; | |||||||||||||||||||||||||||||||||||||||||
| 827 | 48 | $more =~ s/^\s*/ /; | |||||||||||||||||||||||||||||||||||||||||
| 828 | 48 | $_ .= $more; | |||||||||||||||||||||||||||||||||||||||||
| 829 | 48 | redo; | |||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||
| 831 | 4872 | ▶ | next if (/^\s*#/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | 4224 | ▶ | next if (/^\s*$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 833 | 3540 | s/#.*$//; | |||||||||||||||||||||||||||||||||||||||||
| 834 | 3540 | s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 835 | 3540 | ▶ | if (/^(-?)include\s+(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | my $opt = $1; | |||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | my $file; | |||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | foreach $file ( tokenize( $self->subsvars($2) ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | local *Makefile; | |||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | my $path = $self->pathname($file); | |||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | if ( open( Makefile, "<$path" ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | $self->makefile( \*Makefile, $path ); | |||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | close(Makefile); | |||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||
| 845 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | warn "Cannot open $path:$!" unless ( $opt eq '-' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||
| 850 | elsif (/^\s*([\w._]+)\s*:?=\s*(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 851 | 2436 | ▶ | $self->{Vars}{$1} = ( defined $2 ) ? $2 : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||
| 853 | # print STDERR "$1 = ",$self->{Vars}{$1},"\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||
| 855 | elsif (/^vpath\s+(\S+)\s+(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | my ( $pat, $path ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | $self->{Vpath}{$pat} = $path; | |||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||
| 859 | elsif (/^\s*([^:]*)(::?)\s*(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 860 | 1104 | my ( $target, $kind, $depend ) = ( $1, $2, $3 ); | |||||||||||||||||||||||||||||||||||||||||
| 861 | 1104 | my @cmnds; | |||||||||||||||||||||||||||||||||||||||||
| 862 | 1104 | ▶ | if ( $depend =~ /^([^;]*);(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ( $depend, $cmnds[0] ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||
| 865 | 1104 | ▶ | while (<$makefile>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | 7716 | ▶ | next if (/^\s*#/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 867 | 7044 | ▶ | next if (/^\s*$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | 5016 | ▶ | last unless (/^\t/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 869 | 3936 | chop($_); | |||||||||||||||||||||||||||||||||||||||||
| 870 | 3936 | ▶ | if (/\\$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 871 | 1020 | chop($_); | |||||||||||||||||||||||||||||||||||||||||
| 872 | 1020 | $_ .= ' '; | |||||||||||||||||||||||||||||||||||||||||
| 873 | 1020 | $_ .= <$makefile>; | |||||||||||||||||||||||||||||||||||||||||
| 874 | 1020 | redo; | |||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | 2916 | ▶ | next if (/^\s*$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 877 | 2916 | s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 878 | 2916 | push( @cmnds, $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||
| 880 | 1104 | $depend =~ s/\s\s+/ /; | |||||||||||||||||||||||||||||||||||||||||
| 881 | 1104 | $target =~ s/\s\s+/ /; | |||||||||||||||||||||||||||||||||||||||||
| 882 | 1104 | my @depend = tokenize($depend); | |||||||||||||||||||||||||||||||||||||||||
| 883 | 1104 | foreach ( tokenize($target) ) { | |||||||||||||||||||||||||||||||||||||||||
| 884 | 1116 | my $t = $self->Target($_); | |||||||||||||||||||||||||||||||||||||||||
| 885 | 1116 | my $index = 0; | |||||||||||||||||||||||||||||||||||||||||
| 886 | 1116 | ▶ | if ( $kind eq '::' || /%/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$kind eq "::" or /%/
MC/DC50%1/2
$kind eq "::" or /%/
$kind eq "::"
/%/
Truth table66%2/3
A or B
A= $kind eq "::"B= /%/
| |||||||||||||||||||||||||||||||||||||||||||
| 887 | 612 | $t->dcolon( \@depend, \@cmnds ); | |||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||
| 889 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 890 | 504 | $t->colon( \@depend, \@cmnds ); | |||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||
| 893 | 1104 | redo Makefile; | |||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||
| 895 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | warn "Ignore '$_'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||
| 901 | sub pseudos { | ||||||||||||||||||||||||||||||||||||||||||
| 902 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pseudos: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 903 | 12 | my $key; | |||||||||||||||||||||||||||||||||||||||||
| 904 | 12 | foreach $key (qw(SUFFIXES PHONY PRECIOUS PARALLEL)) { | |||||||||||||||||||||||||||||||||||||||||
| 905 | 48 | my $t = delete $self->{Dot}{ '.' . $key }; | |||||||||||||||||||||||||||||||||||||||||
| 906 | 48 | ▶ | if ( defined $t ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 907 | 24 | my $dep; | |||||||||||||||||||||||||||||||||||||||||
| 908 | 24 | $self->{$key} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 909 | 24 | foreach $dep ( $t->colon->exp_depend ) { | |||||||||||||||||||||||||||||||||||||||||
| 910 | 468 | $self->{$key}{$dep} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 911 | } | ||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | sub ExpandTarget { | ||||||||||||||||||||||||||||||||||||||||||
| 917 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ExpandTarget: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 918 | 12 | foreach my $t ( @{ $self->{'Targets'} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 919 | 1116 | $t->ExpandTarget; | |||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||
| 921 | 12 | foreach my $t ( @{ $self->{'Targets'} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 922 | 1116 | $t->ProcessColon; | |||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||
| 926 | sub parse { | ||||||||||||||||||||||||||||||||||||||||||
| 927 | 12 | ▶ | my ( $self, $file ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=6 SCAR=25.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 928 | 12 | ▶ | if ( defined $file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 929 | 12 | $file = $self->pathname($file); | |||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||
| 931 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my @files = qw(makefile Makefile); | |||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | ▶ | unshift( @files, 'GNUmakefile' ) if ( $self->{GNU} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | my $name; | |||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | foreach $name (@files) { | |||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | $file = $self->pathname($name); | |||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | if ( -r $file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | $self->{Makefile} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||
| 943 | 12 | local (*Makefile); | |||||||||||||||||||||||||||||||||||||||||
| 944 | 12 | ▶ | open( Makefile, "<$file" ) || croak("Cannot open $file:$!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 945 | 12 | $self->makefile( \*Makefile, $file ); | |||||||||||||||||||||||||||||||||||||||||
| 946 | 12 | close(Makefile); | |||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||
| 948 | # Next bits should really be done 'lazy' on need. | ||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | 12 | $self->pseudos; # Pull out .SUFFIXES etc. | |||||||||||||||||||||||||||||||||||||||||
| 951 | 12 | $self->dotrules; # Convert .c.o into %.o : %.c | |||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||
| 954 | sub PrintVars { | ||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PrintVars: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | local $_; | |||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | foreach ( keys %{ $self->{Vars} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | print "$_ = ", $self->{Vars}{$_}, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | sub exec { | ||||||||||||||||||||||||||||||||||||||||||
| 964 | 77 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exec: called CC=5 SCAR=18.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 965 | 77 | undef %date; | |||||||||||||||||||||||||||||||||||||||||
| 966 | 77 | $generation++; | |||||||||||||||||||||||||||||||||||||||||
| 967 | 77 | ▶ | if ( $^O eq 'MSWin32' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | my $cwd = cwd(); | |||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my $ret; | |||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | chdir $self->{Dir}; | |||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | $ret = system(@_); | |||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | chdir $cwd; | |||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||
| 975 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 976 | 77 | my $pid = fork; | |||||||||||||||||||||||||||||||||||||||||
| 977 | 77 | ▶ | if ($pid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 978 | 66 | waitpid $pid, 0; | |||||||||||||||||||||||||||||||||||||||||
| 979 | 66 | return $?; | |||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||
| 981 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 982 | 11 | my $dir = $self->{Dir}; | |||||||||||||||||||||||||||||||||||||||||
| 983 | 11 | ▶ | chdir($dir) || die "Cannot cd to $dir"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||
| 985 | # handle leading VAR=value here ? | ||||||||||||||||||||||||||||||||||||||||||
| 986 | # To handle trivial cases like ': libpTk.a' force using /bin/sh | ||||||||||||||||||||||||||||||||||||||||||
| 987 | 11 | ▶ | exec( "/bin/sh", "-c", @_ ) || confess "Cannot exec " . join( ' ', @_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||
| 992 | 12 | ▶ | sub NextPass { shift->{Pass}++ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NextPass: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 993 | 244 | ▶ | sub pass { shift->{Pass} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pass: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||
| 995 | sub apply { | ||||||||||||||||||||||||||||||||||||||||||
| 996 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: called CC=6 SCAR=19.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 997 | 12 | my $method = shift; | |||||||||||||||||||||||||||||||||||||||||
| 998 | 12 | $self->NextPass; | |||||||||||||||||||||||||||||||||||||||||
| 999 | 12 | my @targets = (); | |||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||
| 1001 | # print STDERR join(' ',Apply => $method,@_),"\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | 12 | foreach (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 12 | ▶ | if (/^(\w+)=(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||
| 1005 | # print STDERR "OVERRIDE: $1 = $2\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | $self->{Override}{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | 12 | push( @targets, $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | # This expansion is dubious as it alters the database | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | # as a function of current values of Override. | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | 12 | $self->ExpandTarget; # Process $(VAR) : | |||||||||||||||||||||||||||||||||||||||||
| 1017 | 12 | ▶ | @targets = ( $self->{'Targets'}[0] )->Name unless (@targets); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||
| 1019 | # print STDERR join(' ',Targets => $method,map($_->Name,@targets)),"\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | 12 | foreach (@targets) { | |||||||||||||||||||||||||||||||||||||||||
| 1021 | 12 | my $t = $self->{Depend}{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 1022 | 12 | ▶ | unless ( defined $t ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | print STDERR join( ' ', $method, @_ ), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | die "Cannot `$method' - no target $_"; | |||||||||||||||||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | 12 | $t->$method(); | |||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | sub Script { | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | shift->apply( Script => @_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Script: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1032 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||
| 1034 | sub Print { | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | ▶ | shift->apply( Print => @_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Print: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||
| 1038 | sub Make { | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | 12 | ▶ | shift->apply( Make => @_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Make: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||
| 1042 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | 12 | ▶ | my ( $class, %args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1044 | 12 | ▶ | unless ( defined $args{Dir} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 12 | chomp( $args{Dir} = getcwd() ); | |||||||||||||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | 12 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||
| 1048 | %args, | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | Pattern => {}, # GNU style %.o : %.c | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | Dot => {}, # Trad style .c.o | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | Vpath => {}, # vpath %.c info | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | Vars => {}, # Variables defined in makefile | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | Depend => {}, # hash of targets | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | Targets => [], # ordered version so we can find 1st one | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | Pass => 0, # incremented each sweep | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | Pathname => {}, # cache of expanded names | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | Need => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | Done => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | 12 | $self->{Vars}{CC} = $Config{cc}; | |||||||||||||||||||||||||||||||||||||||||
| 1061 | 12 | $self->{Vars}{AR} = $Config{ar}; | |||||||||||||||||||||||||||||||||||||||||
| 1062 | 12 | $self->{Vars}{CFLAGS} = $Config{optimize}; | |||||||||||||||||||||||||||||||||||||||||
| 1063 | 12 | $self->makefile( \*DATA, __FILE__ ); | |||||||||||||||||||||||||||||||||||||||||
| 1064 | 12 | $self->parse( $self->{Makefile} ); | |||||||||||||||||||||||||||||||||||||||||
| 1065 | 12 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 1066 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||
| 1068 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | Make - module for processing makefiles | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||
| 1072 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | require Make; | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | my $make = Make->new(...); | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | $make->parse($file); | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | $make->Script(@ARGV) | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | $make->Make(@ARGV) | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | $make->Print(@ARGV) | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | my $targ = $make->Target($name); | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | $targ->colon([dependancy...],[command...]); | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | $targ->dolon([dependancy...],[command...]); | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | my @depends = $targ->colon->depend; | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | my @commands = $targ->colon->command; | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||
| 1087 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||
| 1089 | Make->new creates an object if C<new(Makefile =E<gt> $file)> is specified | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | then it is parsed. If not the usual makefile Makefile sequence is | ||||||||||||||||||||||||||||||||||||||||||
| 1091 | used. (If GNU => 1 is passed to new then GNUmakefile is looked for first.) | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||
| 1093 | C<$make-E<gt>Make(target...)> 'makes' the target(s) specified | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | (or the first 'real' target in the makefile). | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||
| 1096 | C<$make-E<gt>Print> can be used to 'print' to current C<select>'ed stream | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | a form of the makefile with all variables expanded. | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||
| 1099 | C<$make-E<gt>Script(target...)> can be used to 'print' to | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | current C<select>'ed stream the equivalent bourne shell script | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | that a make would perform i.e. the output of C<make -n>. | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||
| 1103 | There are other methods (used by parse) which can be used to add and | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | manipulate targets and their dependants. There is a hierarchy of classes | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | which is still evolving. These classes and their methods will be documented when | ||||||||||||||||||||||||||||||||||||||||||
| 1106 | they are a little more stable. | ||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||
| 1108 | The syntax of makefile accepted is reasonably generic, but I have not re-read | ||||||||||||||||||||||||||||||||||||||||||
| 1109 | any documentation yet, rather I have implemented my own mental model of how | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | make works (then fixed it...). | ||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||
| 1112 | In addition to traditional | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||
| 1114 | .c.o : | ||||||||||||||||||||||||||||||||||||||||||
| 1115 | $(CC) -c ... | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | GNU make's 'pattern' rules e.g. | ||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||
| 1119 | %.o : %.c | ||||||||||||||||||||||||||||||||||||||||||
| 1120 | $(CC) -c ... | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||
| 1122 | Likewise a subset of GNU makes $(function arg...) syntax is supported. | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||
| 1124 | Via pmake Make has built perl/Tk from the C<MakeMaker> generated Makefiles... | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||
| 1126 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||
| 1128 | At present C<new> must always find a makefile, and | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | C<$make-E<gt>parse($file)> can only be used to augment that file. | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||
| 1131 | More attention needs to be given to using the package to I<write> makefiles. | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||
| 1133 | The rules for matching 'dot rules' e.g. .c.o and/or pattern rules e.g. %.o : %.c | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | are suspect. For example give a choice of .xs.o vs .xs.c + .c.o behaviour | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | seems a little odd. | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||
| 1137 | Variables are probably substituted in different 'phases' of the process | ||||||||||||||||||||||||||||||||||||||||||
| 1138 | than in make(1) (or even GNU make), so 'clever' uses will probably not | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | work. | ||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||
| 1141 | UNIXisms abound. | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||
| 1143 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||
| 1145 | L<pmake> | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||
| 1147 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||
| 1149 | Nick Ing-Simmons | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||
| 1151 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||
| 1153 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1154 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | # Remainder of file is in makefile syntax and constitutes | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | # the built in rules | ||||||||||||||||||||||||||||||||||||||||||
| 1157 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | __DATA__ | ||||||||||||||||||||||||||||||||||||||||||