require
5.006;
sub
log
($@);
(
$Mpp::progname
= $0) =~ s@.*/@@;
my
%progname
=
(
b
=>
'builtin'
,
bcc
=>
'_build_cache_control'
,
c
=>
'clean'
,
g
=>
'graph'
,
i
=>
'info'
,
l
=>
'log'
,
r
=>
'replay'
);
$Mpp::progname
=~ s/^mpp([bcgilr]|bcc)$/makepp
$progname
{$1}/;
BEGIN {
*MAKEPP
=
$Mpp::Text::N
[0] }
sub
maybe_die() {
if
( $@ ) {
(
my
$msg
= $@) =~ s!\(
eval
\d+\)!expression!g;
chomp
$msg
;
die
"$msg\n"
;
}
}
sub
find_logfiles(\@) {
@{
$_
[0]} =
'.'
unless
@{
$_
[0]};
for
( @{
$_
[0]} ) {
next
if
$_
eq
'-'
|| -f;
$_
.=
'/.makepp/log'
;
s!/.makepp/!/!
unless
-r;
die
"$Mpp::progname: can't read `$_'--$!\n"
if
!-r;
}
}
my
(
$max_up
,
$cwd_re
);
sub
Mpp::Rewrite::cwd(;$$$) {
if
(
defined
and
$_
ne
''
) {
my
(
$up
,
$name
,
$sep
) =
@_
;
unless
(
$cwd_re
) {
my
$tmp
= dereference
$CWD_INFO
;
my
@path
=
split
/(?=\/)/, absolute_filename
$tmp
;
if
(
@path
> 1 &&
$path
[0] eq
'/'
) {
shift
@path
;
substr
$path
[0], 0, 0,
'/'
;
}
$max_up
=
@path
- 1;
$cwd_re
=
join
(
'(?:'
,
map
quotemeta
,
@path
) . (
'())?'
x
$max_up
);
}
s!(.)/$!$1!;
if
(
my
@match
= /^(
$cwd_re
(\/|$))/o ) {
$up
= !
$up
? 0 :
$up
>
$max_up
?
$max_up
:
$up
;
my
$up_found
=
$max_up
+ 2 -
grep
defined
,
@match
;
if
(
$up_found
<=
$up
) {
$name
=
'..'
unless
defined
$name
;
$sep
=
'/'
unless
defined
$sep
;
substr
$_
, 0,
length
(
$match
[0] ),
(
join
(
$sep
, (
$name
) x
$up_found
,
$match
[-1] ?
''
: () ) || (
$match
[-1] ?
''
:
'.'
));
1;
}
}
}
}
my
$flags
=
"\U$Mpp::progname\EFLAGS"
;
unshift
@ARGV
, Mpp::Text::unquote_split_on_whitespace
$ENV
{
$flags
}
if
exists
$ENV
{
$flags
};
1;