line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Panotools::Makefile::Variable; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Panotools::Makefile::Variable - Assemble Makefile Variable definitions |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Simple interface for generating Makefile syntax |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Writing Makefiles directly from perl scripts with print and "\t" etc... is |
14
|
|
|
|
|
|
|
prone to error, this library provides a simple perl interface for assembling |
15
|
|
|
|
|
|
|
Makefiles. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
69816
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
28
|
|
20
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
380
|
use Panotools::Makefile::Utils qw/quotetarget quoteprerequisite quoteshell/; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
497
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 USAGE |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$var = new Panotools::Makefile::Variable; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
..or define the 'variable name' at the same time: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$var = new Panotools::Makefile::Variable ('USERS'); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
..or define the name and values at the same time: |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$var = new Panotools::Makefile::Variable ('USERS', 'Andy Pandy'); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new |
39
|
|
|
|
|
|
|
{ |
40
|
2
|
|
|
2
|
0
|
580
|
my $class = shift; |
41
|
2
|
|
33
|
|
|
10
|
$class = ref $class || $class; |
42
|
2
|
|
|
|
|
9
|
my $self = bless {name => shift, value => [@_]}, $class; |
43
|
2
|
|
|
|
|
5
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=pod |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Set or query the name: |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$var->Name ('USERS'); |
51
|
|
|
|
|
|
|
$text = $var->Name; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub Name |
56
|
|
|
|
|
|
|
{ |
57
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
58
|
1
|
50
|
|
|
|
7
|
$self->{name} = shift if @_; |
59
|
1
|
|
|
|
|
3
|
return $self->{name}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub NameRef |
63
|
|
|
|
|
|
|
{ |
64
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
65
|
0
|
|
|
|
|
0
|
return '$('. $self->Name .')'; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub NameRefShell |
69
|
|
|
|
|
|
|
{ |
70
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
71
|
0
|
|
|
|
|
0
|
return '$('. $self->Name .'_SHELL)'; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$var->Values ('James Brine', 'George Loveless'); |
77
|
|
|
|
|
|
|
$var->Values ('Thomas Standfield'); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub Values |
82
|
|
|
|
|
|
|
{ |
83
|
4
|
|
|
4
|
0
|
13
|
my $self = shift; |
84
|
4
|
|
|
|
|
4
|
push @{$self->{value}}, @_; |
|
4
|
|
|
|
|
9
|
|
85
|
4
|
|
|
|
|
7
|
return $self->{value}; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=pod |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Construct a text fragment that defines this variable suitable for use in a |
91
|
|
|
|
|
|
|
Makefile like so: |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$text = $var->Assemble; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub Assemble |
98
|
|
|
|
|
|
|
{ |
99
|
8
|
|
|
8
|
0
|
15
|
my $self = shift; |
100
|
8
|
50
|
|
|
|
18
|
return '' unless defined $self->{name}; |
101
|
|
|
|
|
|
|
|
102
|
8
|
|
|
|
|
12
|
my $text; |
103
|
8
|
|
|
|
|
20
|
$text .= quotetarget ($self->{name}); |
104
|
8
|
|
|
|
|
14
|
$text .= ' = '; |
105
|
8
|
|
|
|
|
10
|
$text .= join ' ', (map { quotetarget ($_)} grep /./, @{$self->{value}}); |
|
24
|
|
|
|
|
45
|
|
|
8
|
|
|
|
|
36
|
|
106
|
8
|
|
|
|
|
12
|
$text .= "\n"; |
107
|
8
|
|
|
|
|
22
|
$text .= quotetarget ($self->{name} .'_SHELL'); |
108
|
8
|
|
|
|
|
13
|
$text .= ' = '; |
109
|
8
|
|
|
|
|
9
|
my @items = map { quoteshell ($_)} grep /./, @{$self->{value}}; |
|
24
|
|
|
|
|
43
|
|
|
8
|
|
|
|
|
37
|
|
110
|
8
|
|
|
|
|
12
|
@items = map {s/\$\(([^)]+)\)/\$($1_SHELL)/g; $_} @items; |
|
24
|
|
|
|
|
30
|
|
|
24
|
|
|
|
|
34
|
|
111
|
8
|
|
|
|
|
19
|
$text .= join ' ', @items; |
112
|
8
|
|
|
|
|
12
|
$text .= "\n"; |
113
|
8
|
|
|
|
|
41
|
return $text; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |