author | Alan Coopersmith <Alan.Coopersmith@Sun.COM> |
Sat, 05 Dec 2009 22:13:03 -0800 | |
changeset 851 | d428083dbbdd |
parent 810 | 6f94d3da0552 |
child 907 | 3c35d611cdaa |
permissions | -rwxr-xr-x |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
1 |
#! /usr/perl5/bin/perl -w |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
2 |
|
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
3 |
# |
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
4 |
# Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
5 |
# Use is subject to license terms. |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
6 |
# |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
7 |
# Permission is hereby granted, free of charge, to any person obtaining a |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
8 |
# copy of this software and associated documentation files (the |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
9 |
# "Software"), to deal in the Software without restriction, including |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
10 |
# without limitation the rights to use, copy, modify, merge, publish, |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
11 |
# distribute, and/or sell copies of the Software, and to permit persons |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
12 |
# to whom the Software is furnished to do so, provided that the above |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
13 |
# copyright notice(s) and this permission notice appear in all copies of |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
14 |
# the Software and that both the above copyright notice(s) and this |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
15 |
# permission notice appear in supporting documentation. |
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
16 |
# |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
17 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
18 |
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
19 |
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
20 |
# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
21 |
# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
22 |
# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
23 |
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
24 |
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
25 |
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
26 |
# |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
27 |
# Except as contained in this notice, the name of a copyright holder |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
28 |
# shall not be used in advertising or otherwise to promote the sale, use |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
29 |
# or other dealings in this Software without prior written authorization |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
30 |
# of the copyright holder. |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
31 |
# |
851
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
32 |
# ident "@(#)xmake 1.3 09/12/05 SMI" |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
33 |
# |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
34 |
|
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
35 |
require 5.005; # minimal Perl version required |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
36 |
use strict; # |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
37 |
use diagnostics; # |
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
38 |
use File::Path; |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
39 |
use File::Spec; |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
40 |
use English qw( -nomatchvars ); |
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
41 |
use POSIX qw(uname); |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
42 |
|
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
43 |
my $verbose = 0; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
44 |
if ((scalar(@ARGV) > 0) && ($ARGV[0] eq '-v')) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
45 |
shift @ARGV; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
46 |
$verbose = 1; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
47 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
48 |
|
851
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
49 |
my @makeargs = (); |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
50 |
|
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
51 |
# Arguments: (envvar, defval) |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
52 |
# If environment variable 'envvar' is not set, set it to 'defval' |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
53 |
sub setenv_default { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
54 |
my ($envvar, $defval) = @_; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
55 |
|
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
56 |
if (!exists $ENV{$envvar}) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
57 |
$ENV{$envvar} = $defval; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
58 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
59 |
|
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
60 |
if ($verbose > 0) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
61 |
print $envvar, '=', $ENV{$envvar}, "\n"; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
62 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
63 |
|
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
64 |
return $ENV{$envvar}; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
65 |
} |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
66 |
|
851
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
67 |
sub exec_verbose { |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
68 |
my $program = shift @_; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
69 |
|
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
70 |
if ($verbose > 0) { |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
71 |
print join(' ', $program, @_), "\n"; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
72 |
} |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
73 |
exec($program, @_) |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
74 |
or die "$0: exec of $program failed: $OS_ERROR"; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
75 |
} |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
76 |
|
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
77 |
# save full path to current directory |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
78 |
my $startdir = File::Spec->rel2abs(File::Spec->curdir()); |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
79 |
|
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
80 |
# climb the tree to find the open-src module directory we're in |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
81 |
my @dirtree = File::Spec->splitdir($startdir); |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
82 |
my $osdepth; |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
83 |
|
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
84 |
for my $n (1..$#dirtree) { |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
85 |
if ($dirtree[$n] eq 'open-src') { |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
86 |
if (-f File::Spec->catfile( @dirtree[0..$n], 'common/Makefile.inc')) { |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
87 |
$osdepth = $n; |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
88 |
last; |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
89 |
} |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
90 |
} |
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
91 |
if ($dirtree[$n] eq 'closed-src') { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
92 |
if (-f File::Spec->catfile( @dirtree[0..($n-1)], |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
93 |
'open-src/common/Makefile.inc')) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
94 |
$osdepth = $n; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
95 |
last; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
96 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
97 |
} |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
98 |
} |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
99 |
|
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
100 |
if (!defined($osdepth)) { |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
101 |
die "$0: Cannot find path to open-src/common/Makefile.inc from here"; |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
102 |
} |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
103 |
|
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
104 |
|
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
105 |
# Use dmake unless user environment overrides |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
106 |
my $make_cmd = setenv_default('MAKE', 'dmake'); |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
107 |
|
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
108 |
if ($make_cmd =~ m/dmake/) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
109 |
# Set dmake environment for parallel builds by default |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
110 |
setenv_default('DMAKE_MODE', 'parallel'); |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
111 |
setenv_default('DMAKE_OUTPUT_MODE', 'TXT2'); |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
112 |
|
851
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
113 |
my $max_jobs; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
114 |
|
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
115 |
foreach my $i ( 0..($#ARGV - 1) ) { |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
116 |
if ($ARGV[$i] eq '-j') { |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
117 |
$max_jobs = $ARGV[$i+1]; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
118 |
$ARGV[$i] = ''; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
119 |
$ARGV[$i+1] = ''; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
120 |
} |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
121 |
} |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
122 |
|
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
123 |
if (!defined($max_jobs) && exists $ENV{'DMAKE_MAX_JOBS'}) { |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
124 |
$max_jobs = $ENV{'DMAKE_MAX_JOBS'}; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
125 |
} |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
126 |
|
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
127 |
if (!defined($max_jobs)) { |
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
128 |
my $machlist = join('/', $ENV{'HOME'}, '.make.machines'); |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
129 |
if ( -f $machlist ) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
130 |
my $nodename = (POSIX::uname())[1]; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
131 |
if (open my $MACHLIST, '<', $machlist) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
132 |
while (my $m = <$MACHLIST>) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
133 |
my ($hostname, $vars) = split ' ', $m, 2; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
134 |
|
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
135 |
next if (!defined($hostname) || !defined($vars)); |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
136 |
if ($hostname eq $nodename) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
137 |
my @varlist = split /\s+/, $vars; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
138 |
foreach my $v (@varlist) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
139 |
my ($var, $val) = split /=/, $v; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
140 |
if ($var eq 'max') { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
141 |
$max_jobs = $val; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
142 |
last; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
143 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
144 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
145 |
last; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
146 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
147 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
148 |
close $MACHLIST; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
149 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
150 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
151 |
if (!defined($max_jobs)) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
152 |
$max_jobs = 0; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
153 |
|
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
154 |
if (open my $PSRINFO, '-|', '/usr/sbin/psrinfo') { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
155 |
while (my $p = <$PSRINFO>) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
156 |
if ($p =~ m/on-line/) { |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
157 |
$max_jobs++; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
158 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
159 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
160 |
close $PSRINFO; |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
161 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
162 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
163 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
164 |
|
851
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
165 |
push @makeargs, '-j', $max_jobs; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
166 |
|
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
167 |
my $dmake_odir = |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
168 |
setenv_default('DMAKE_ODIR', File::Spec->catfile(@dirtree[0..($osdepth-1)], |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
169 |
'log', '.dmake')); |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
170 |
mkpath($dmake_odir); |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
171 |
} |
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
172 |
|
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
173 |
# if in top two levels, just run make |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
174 |
if ($osdepth >= ($#dirtree - 2)) { |
851
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
175 |
print join(' ', $make_cmd, @makeargs, @ARGV), "\n"; |
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
176 |
exec_verbose($make_cmd, @makeargs, @ARGV); |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
177 |
} |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
178 |
|
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
179 |
my $subdir_target = 'build-in-subdir'; |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
180 |
for my $f (@ARGV) { |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
181 |
if ($f =~ m{^install}ms) { |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
182 |
$subdir_target = 'install-in-subdir'; |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
183 |
} |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
184 |
} |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
185 |
|
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
186 |
# Otherwise get info from the module makefile |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
187 |
my $moduledir = File::Spec->catdir( @dirtree[0..($osdepth+2)] ); |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
188 |
|
851
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
189 |
push @makeargs, $subdir_target, qq{subdir='$startdir'}; |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
190 |
if (scalar(@ARGV) > 0) { |
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
191 |
push @makeargs, join(q{ }, q{subdir_cmd=}, @ARGV); |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
192 |
} |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
193 |
|
810
6f94d3da0552
6889793 enable parallel builds of the X consolidation
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
493
diff
changeset
|
194 |
print join(' ', "(cd $moduledir ;\\\n", $make_cmd, @makeargs), ")\n"; |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
195 |
chdir $moduledir |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
196 |
or die "$0: Can't chdir $moduledir: $OS_ERROR"; |
851
d428083dbbdd
6905171 X11R7.5 / Xorg 1.7.3 integration
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
810
diff
changeset
|
197 |
exec_verbose($make_cmd, @makeargs); |
493
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
198 |
|
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
199 |
__END__ |
f43507b5737d
6735203 open-src Makefile cleanup & enhancements
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
200 |