our
$traditional
;
our
$hybrid
;
our
$depth
;
if
(
defined
$traditional
||
defined
$hybrid
) {
$depth
= 50
unless
defined
$depth
;
die
"`--traditional-recursive-make'
has
reached max depth.
Probably your invocations of \$(MAKE) have a cycle (which gmake ignores).
For e.g. 70 levels of recursion, add to command line: recursive_makepp=70\n"
if
--
$depth
< 0;
}
my
$_MAKEPPFLAGS
;
if
(
$ENV
{MAKEPP_IGNORE_OPTS} ) {
my
(
@lx
,
@l
,
@sx
,
@s
);
for
my
$opt
(
split
' '
,
$ENV
{MAKEPP_IGNORE_OPTS} ) {
if
(
$opt
=~ /^--(.+)=/ ) {
push
@lx
, $1;
}
elsif
(
$opt
=~ /^--(.+)/ ) {
push
@l
, $1;
}
elsif
(
$opt
=~ /^-(.)./ ) {
push
@sx
, $1;
}
elsif
(
$opt
=~ /^-(.)/ ) {
push
@s
, $1;
}
else
{
die
"\$MAKEPP_IGNORE_OPTS: '$opt' not understood\n"
;
}
}
my
$nop
;
local
$" =
''
;
if
(
@lx
||
@sx
) {
my
$lx
=
@lx
?
join
'|'
,
@lx
:
'DUMMY'
;
$lx
=
qr/$lx/
;
my
$sx
=
@sx
> 1 ?
qr/[@sx]/
:
$sx
[0];
push
@Mpp::ignore_opts
, [
$sx
,
$lx
, \
$nop
, 1];
}
if
(
@l
||
@s
) {
my
$l
=
@l
?
join
'|'
,
@l
:
'DUMMY'
;
$l
=
qr/$l/
;
my
$s
=
@s
> 1 ?
qr/[@s]/
:
$s
[0];
push
@Mpp::ignore_opts
, [
$s
,
$l
, \
$nop
];
}
}
END {
local
$?;
defined
$traditional
||
defined
$hybrid
and
$Mpp::Rule::last_build_cwd
and
$Mpp::print_directory
and
print
"$Mpp::progname: Leaving directory `"
. absolute_filename(
$Mpp::Rule::last_build_cwd
).
"'\n"
;
}
our
$socket
;
our
$socket_name
=
$Mpp::global_ENV
{MAKEPP_SOCKET}
if
exists
$Mpp::global_ENV
{MAKEPP_SOCKET};
sub
setup_socket {
return
if
$socket_name
;
$socket_name
= Mpp::Subs::f_mktemp
'/tmp/makepp.'
;
$socket
=
IO::Socket::UNIX->new(
Local
=>
$socket_name
,
Type
=>
eval
'use IO::Socket; SOCK_STREAM'
,
Listen
=> 2) or
die
"$progname: can't create socket $socket_name\n"
;
chmod
0600,
$socket_name
;
read_wait
$socket
, \
&connection
;
}
our
$command
;
my
$traditional_command
;
sub
connection {
my
$connected_socket
=
$_
[0]->
accept
();
return
unless
$connected_socket
;
my
$whole_command
=
''
;
my
$read_sub
;
$read_sub
=
sub
{
my
$fh
=
$_
[0];
my
$line
;
if
(
sysread
(
$fh
,
$line
, 8192) == 0) {
$fh
->
close
;
return
;
}
$whole_command
.=
$line
;
if
(
$whole_command
=~ s/^(.*)\01END\01//s) {
my
@lines
=
split
(/\n/, $1);
my
@words
= unquote_split_on_whitespace
shift
@lines
;
my
%this_ENV
;
foreach
(
@lines
) {
if
( s/^([^=]+)=// ) {
$this_ENV
{$1} = unquote
$_
;
}
else
{
die
"illegal command received from recursive make process:\n$_\n"
;
}
}
chdir
shift
@words
;
Mpp::Event::Process::adjust_max_processes(1);
my
$status
=
eval
{
local
@ARGV
=
@words
;
wait_for Mpp::parse_command_line
%this_ENV
;
};
if
( $@ ) {
if
(
defined
$hybrid
&& $@ =~ /\Aattempt to load two makefiles/ ) {
local
$traditional
= 1;
local
$command
=
$traditional_command
;
$depth
= 50
unless
defined
$depth
;
$status
=
'exec '
. Mpp::Subs::f_MAKE(
undef
, {},
'recursion'
) .
"\n$_MAKEPPFLAGS\n"
;
$traditional_command
||=
$command
;
$@ =
''
;
}
else
{
$status
= 1;
}
}
elsif
(
'Mpp::File'
eq
ref
$status
) {
$status
=
'2 Dependency of `'
. absolute_filename(
$status
) .
"' failed"
;
}
Mpp::Event::Process::adjust_max_processes(-1);
print
$fh
"$status $@"
;
close
$fh
;
}
else
{
read_wait
$fh
,
$read_sub
;
}
};
read_wait
$connected_socket
,
$read_sub
;
read_wait
$_
[0], \
&connection
;
}
no
warnings
'redefine'
;
my
$n
= -1;
sub
Mpp::Subs::f_MAKE {
if
(
defined
$traditional
) {
$_
[1]{EXPORTS}{_MAKEPPFLAGS} =
$_MAKEPPFLAGS
||= join_with_protection
defined
$hybrid
?
'--hybrid'
:
'--traditional'
,
$Mpp::build_check_method_name
ne
'exact_match'
?
"--buildcheck=$Mpp::build_check_method_name"
: (),
$Mpp::Subs::defer_include
?
'--deferinclude'
: (),
$Mpp::final_rule_only
?
'--finalruleonly'
: (),
$Mpp::gullible
?
'--gullible'
: (),
$Mpp::last_chance_rules
?
'--lastchancerules'
: (),
$Mpp::log_level
== 1 ?
'-v'
:
$Mpp::log_level
== 0 ?
'--nolog'
: (),
$Mpp::no_path_executable_dependencies
?
'--nopathexedep'
: (),
$Mpp::remake_makefiles
? () :
'--noremakemakefiles'
,
$Mpp::rm_stale_files
?
'--rmstalefiles'
: (),
$Mpp::sigmethod_name
?
"-m$Mpp::sigmethod_name"
: (),
map
{ /^makepp_/ ?
"$_=$Mpp::Makefile::global_command_line_vars->{$_}"
: () }
keys
%$Mpp::Makefile::global_command_line_vars
;
unless
(
defined
$command
) {
$command
= $0;
unless
(
$command
=~ m@^/@ ) {
foreach
( Mpp::Text::split_path(),
'.'
) {
my
$finfo
= file_info
"$_/$0"
,
$Mpp::original_cwd
;
if
( file_exists
$finfo
) {
$command
= absolute_filename
$finfo
;
last
;
}
}
}
}
my
$log
=
''
;
if
(
$Mpp::log_level
== 2 ) {
$log
=
".makepp/log-$$-"
. ++
$n
;
Mpp::
log
LOG
=>
$_
[2],
$log
if
$Mpp::log_level
;
substr
$log
, 0, 0,
' --log='
;
}
Mpp::PERL .
" $command recursive_makepp=$depth$log"
;
}
else
{
die
"makepp: recursive make without --traditional-recursive-make only supported on Cygwin Perl\n"
if
Mpp::is_windows < -1 || Mpp::is_windows > 0;
my
$makefile
=
$_
[1];
$command
||= Mpp::PERL .
' '
.
absolute_filename( file_info
$Mpp::datadir
,
$Mpp::original_cwd
) .
'/recursive_makepp'
;
$makefile
->cleanup_vars;
join
' '
,
$command
,
map
{
"$_="
. requote
$makefile
->{COMMAND_LINE_VARS}{
$_
} }
keys
%{
$makefile
->{COMMAND_LINE_VARS}};
}
}
1;