1 |
williamc |
1.1 |
package BuildFile;
|
2 |
williamc |
1.2 |
require 5.001;
|
3 |
williamc |
1.1 |
require Exporter;
|
4 |
|
|
@ISA = qw(Exporter);
|
5 |
|
|
@EXPORT = qw(CheckBuildFile ParseBuildFile @BlockClassA $DefaultBuildFile);
|
6 |
|
|
|
7 |
|
|
BEGIN {
|
8 |
|
|
use ToolBox;
|
9 |
|
|
$buildfile="BuildFile";
|
10 |
williamc |
1.4 |
$toolbox=ToolBox->new();
|
11 |
williamc |
1.21 |
$Arch=1;
|
12 |
|
|
push @ARCHBLOCK, $Arch;
|
13 |
williamc |
1.1 |
}
|
14 |
|
|
|
15 |
|
|
#Parse the BuildFile
|
16 |
|
|
sub ParseBuildFile {
|
17 |
|
|
my $base=shift;
|
18 |
williamc |
1.21.2.21 |
$path=shift;
|
19 |
williamc |
1.1 |
my $filename=shift @_;
|
20 |
|
|
my $fullfilename="$base/$path/$filename";
|
21 |
|
|
#print "Processing $fullfilename\n";
|
22 |
|
|
# This hash defines which Document Elements we can use
|
23 |
williamc |
1.21.2.21 |
$numbins=0;
|
24 |
|
|
$envnum=0;
|
25 |
|
|
$envlevel=0;
|
26 |
|
|
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
|
27 |
williamc |
1.1 |
my $SupportedTags={
|
28 |
|
|
'Use' => \&OutToMakefile,
|
29 |
|
|
'Use_StartTag' => \&Use_start,
|
30 |
|
|
'Group' => \&OutToMakefile,
|
31 |
|
|
'Group_StartTag' => \&Group_start,
|
32 |
|
|
'External' => \&OutToMakefile,
|
33 |
|
|
'External_StartTag' => \&External_StartTag,
|
34 |
|
|
'ConfigurationClass_StartTag' => \&Class_StartTag,
|
35 |
|
|
'ConfigurationClass' => \&OutToMakefile,
|
36 |
|
|
'AssociateGroup' => \&AssociateGroup,
|
37 |
|
|
'none' => \&OutToMakefile,
|
38 |
williamc |
1.8 |
'Bin' => 'none',
|
39 |
williamc |
1.1 |
'Bin_StartTag' => \&Bin_start,
|
40 |
|
|
'ClassPath' => \&OutToMakefile,
|
41 |
williamc |
1.21 |
'ClassPath_StartTag' => \&setBlockClassPath,
|
42 |
williamc |
1.21.2.21 |
'Environment' => \&OutToMakefile,
|
43 |
|
|
'Environment_StartTag' => \&Environment_start,
|
44 |
|
|
'Environment_EndTag' => \&Environment_end,
|
45 |
williamc |
1.21.2.28 |
'export' => \&OutToMakefile,
|
46 |
|
|
'export_StartTag' => \&export_start,
|
47 |
|
|
'export_EndTag' => \&export_end,
|
48 |
williamc |
1.21 |
'lib' => 'none',
|
49 |
|
|
'lib_StartTag' => \&lib_start,
|
50 |
williamc |
1.21.2.1 |
'lib_EndTag' => 'none',
|
51 |
|
|
'ignore' => 'none',
|
52 |
|
|
'ignore_EndTag' => \&ignoretag_end,
|
53 |
|
|
'ignore_StartTag' => \&ignoretag,
|
54 |
|
|
'Architecture_StartTag' => \&Arch_Start,
|
55 |
|
|
'Architecture_EndTag' => \&Arch_End,
|
56 |
williamc |
1.21.2.6 |
'Architecture' => \&OutToMakefile,
|
57 |
|
|
'LibType_StartTag' => \&LibType_Start,
|
58 |
|
|
'LibType_EndTag' => 'none',
|
59 |
williamc |
1.21.2.15 |
#'LibType' => \&OutToScreen
|
60 |
|
|
'LibType' => \&LibType_text
|
61 |
williamc |
1.1 |
};
|
62 |
williamc |
1.2 |
use Utilities::Switcher;
|
63 |
williamc |
1.1 |
$switch=Switcher->new($SupportedTags, $fullfilename);
|
64 |
|
|
$switch->{Strict_no_cr}='no';
|
65 |
|
|
#open a temporary gnumakefile to store output.
|
66 |
williamc |
1.2 |
use Utilities::AddDir;
|
67 |
williamc |
1.3 |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}");
|
68 |
williamc |
1.21.2.22 |
my $fh=FileHandle->new();
|
69 |
|
|
open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk"
|
70 |
|
|
) or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n';
|
71 |
|
|
@filehandlestack=($fh);
|
72 |
|
|
# make an alias
|
73 |
|
|
# open ( GNUmakefile, ">&=$fh") or die 'Unable to create alias for '.
|
74 |
|
|
# "Filehandle $!\n";
|
75 |
|
|
*GNUmakefile=$fh;
|
76 |
williamc |
1.1 |
if ( -e $ENV{LatestBuildFile} ) {
|
77 |
|
|
print GNUmakefile "include $ENV{LatestBuildFile}\n";
|
78 |
|
|
}
|
79 |
|
|
# print "writing to :\n".
|
80 |
|
|
# "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk\n";
|
81 |
|
|
$ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
|
82 |
|
|
$switch->parse(); # sort out supported tags
|
83 |
williamc |
1.21.2.24 |
if ( $numbins > 0 ) {
|
84 |
|
|
print GNUmakefile <<ENDTEXT;
|
85 |
|
|
ifndef BINMODE
|
86 |
|
|
help::
|
87 |
|
|
\t\@echo Generic Binary targets
|
88 |
|
|
\t\@echo ----------------------
|
89 |
|
|
endif
|
90 |
|
|
ENDTEXT
|
91 |
|
|
foreach $target ( keys %$targettypes ) {
|
92 |
|
|
print GNUmakefile <<ENDTEXT;
|
93 |
|
|
ifndef BINMODE
|
94 |
|
|
help::
|
95 |
|
|
\t\@echo $target
|
96 |
|
|
endif
|
97 |
|
|
ENDTEXT
|
98 |
|
|
}
|
99 |
|
|
}
|
100 |
williamc |
1.1 |
close GNUmakefile;
|
101 |
|
|
}
|
102 |
|
|
|
103 |
williamc |
1.21 |
sub ParseBuildFile_Export {
|
104 |
|
|
my $filename=shift;
|
105 |
|
|
use Tool;
|
106 |
|
|
# This hash defines which Document Elements we can use
|
107 |
|
|
my $SupportedTags={
|
108 |
|
|
'none' => 'none',
|
109 |
|
|
'export' => \&OutToMakefile,
|
110 |
williamc |
1.21.2.30 |
'export_StartTag' => \&use_export_start,
|
111 |
|
|
'export_EndTag' => \&use_export_end,
|
112 |
williamc |
1.21 |
'lib_StartTag' => \&lib_start_export,
|
113 |
williamc |
1.21.2.12 |
'External_StartTag' => \&Ext_start_export,
|
114 |
williamc |
1.21 |
'lib' => 'none'
|
115 |
|
|
};
|
116 |
|
|
use Utilities::Switcher;
|
117 |
|
|
$switchex=Switcher->new($SupportedTags, $filename);
|
118 |
|
|
$switchex->{Strict_no_cr}='no';
|
119 |
|
|
$switchex->parse(); # sort out supported tags
|
120 |
|
|
}
|
121 |
|
|
|
122 |
williamc |
1.1 |
sub initialterms() {
|
123 |
|
|
my $name=shift;
|
124 |
|
|
my @string=@_;
|
125 |
|
|
|
126 |
|
|
$_=join "", @string;
|
127 |
|
|
chomp;
|
128 |
|
|
SWITCH: {
|
129 |
|
|
last SWITCH if /^#/;
|
130 |
|
|
if ( /^.*BlockClassPath.*/i ) {
|
131 |
|
|
s/^.*BlockClassPath *= *//;
|
132 |
|
|
_CutBlock($_);
|
133 |
|
|
last SWITCH;
|
134 |
|
|
}
|
135 |
|
|
} # end SWITCH
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
# Tag routines - called by the Switcher when tag found
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
#-- Override a class type with the <ConfigurationClass type=xxx> tag
|
143 |
|
|
# the type tag will pick up a pre-defined class type from project space.
|
144 |
|
|
|
145 |
|
|
sub Class_StartTag {
|
146 |
|
|
my $name=shift;
|
147 |
|
|
my $hashref;
|
148 |
|
|
my @vars=@_;
|
149 |
|
|
|
150 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
151 |
williamc |
1.21.2.1 |
if ( $Arch ) {
|
152 |
williamc |
1.1 |
if ( defined $$hashref{'type'} ) {
|
153 |
|
|
$ClassName=$$hashref{'type'};
|
154 |
|
|
}
|
155 |
williamc |
1.21.2.1 |
}
|
156 |
williamc |
1.1 |
}
|
157 |
|
|
|
158 |
|
|
sub ClassPath_StartTag {
|
159 |
|
|
my $name=shift;
|
160 |
|
|
my @vars=@_;
|
161 |
|
|
my $hashref;
|
162 |
|
|
|
163 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
164 |
williamc |
1.21.2.1 |
if ( $Arch ) {
|
165 |
williamc |
1.1 |
if ( defined $$hashref{'defaultpath'} ) {
|
166 |
|
|
}
|
167 |
williamc |
1.21.2.1 |
}
|
168 |
williamc |
1.1 |
}
|
169 |
|
|
|
170 |
|
|
sub Bin_start {
|
171 |
|
|
my $name=shift;
|
172 |
|
|
my @vars=@_;
|
173 |
|
|
my $hashref;
|
174 |
|
|
my $fileclass;
|
175 |
|
|
my @tools;
|
176 |
|
|
my $tool;
|
177 |
williamc |
1.12 |
my $filename;
|
178 |
|
|
my $objectname;
|
179 |
williamc |
1.1 |
|
180 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
181 |
|
|
$switch->checkparam($hashref, $name, 'file');
|
182 |
williamc |
1.21.2.1 |
if ( $Arch ) {
|
183 |
williamc |
1.1 |
if ( ! defined $$hashref{name} ) {
|
184 |
|
|
($$hashref{name}=$$hashref{file})=~s/\..*//;
|
185 |
|
|
}
|
186 |
williamc |
1.4 |
# This stuff for later
|
187 |
|
|
#$fileclass=$toolbox->getclass($file);
|
188 |
|
|
#$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
|
189 |
williamc |
1.21.2.21 |
|
190 |
williamc |
1.12 |
($filename=$$hashref{file})=~s/\..*//;
|
191 |
williamc |
1.21.2.21 |
|
192 |
|
|
# Create a new directory for each binary target
|
193 |
|
|
my $dirname="bin_".$$hashref{name};
|
194 |
|
|
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname");
|
195 |
|
|
open (binGNUmakefile,
|
196 |
|
|
">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk") or die "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/".
|
197 |
|
|
"BuildFile.mk $!\n";
|
198 |
|
|
|
199 |
|
|
# Create the link targets
|
200 |
|
|
$numbins++;
|
201 |
williamc |
1.21.2.22 |
my $fh=$filehandlestack[0];
|
202 |
|
|
print $fh <<ENDTEXT;
|
203 |
|
|
|
204 |
|
|
# Link Targets to binary directories
|
205 |
williamc |
1.21.2.32 |
ifdef BINMODE
|
206 |
|
|
# We dont want to build a library here
|
207 |
|
|
override files:=
|
208 |
|
|
endif
|
209 |
williamc |
1.21.2.23 |
ifndef BINMODE
|
210 |
williamc |
1.21.2.22 |
|
211 |
|
|
define stepdown_$$hashref{'name'}
|
212 |
|
|
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\
|
213 |
|
|
cd $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\
|
214 |
williamc |
1.21.2.23 |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk \$\@; \\
|
215 |
williamc |
1.21.2.22 |
fi
|
216 |
|
|
endef
|
217 |
|
|
|
218 |
williamc |
1.21.2.23 |
define stepdown2_$$hashref{'name'}
|
219 |
|
|
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\
|
220 |
|
|
cd $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\
|
221 |
|
|
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk \$\*; \\
|
222 |
|
|
fi
|
223 |
williamc |
1.21.2.24 |
|
224 |
williamc |
1.21.2.23 |
endef
|
225 |
|
|
|
226 |
|
|
bin_$$hashref{'name'}_%:: dummy
|
227 |
|
|
\@\$(stepdown2_$$hashref{'name'})
|
228 |
williamc |
1.21.2.22 |
|
229 |
williamc |
1.21.2.26 |
$$hashref{'name'}_%:: dummy
|
230 |
|
|
\@\$(stepdown_$$hashref{'name'})
|
231 |
|
|
|
232 |
williamc |
1.21.2.24 |
help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
|
233 |
williamc |
1.21.2.22 |
\@\$(stepdown_$$hashref{'name'})
|
234 |
williamc |
1.21.2.27 |
|
235 |
|
|
binfiles+=$$hashref{'file'}
|
236 |
williamc |
1.21.2.21 |
endif
|
237 |
williamc |
1.21.2.27 |
|
238 |
williamc |
1.21.2.21 |
|
239 |
|
|
ENDTEXT
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
# the binary specifics makefile
|
243 |
|
|
print binGNUmakefile "include $currentenv\n";
|
244 |
|
|
print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/${path}\n";
|
245 |
williamc |
1.21.2.22 |
|
246 |
williamc |
1.21.2.21 |
# alias for bin_Insure
|
247 |
|
|
print binGNUmakefile <<ENDTEXT;
|
248 |
williamc |
1.21.2.22 |
|
249 |
williamc |
1.21.2.21 |
bin_insure:bin_Insure
|
250 |
|
|
ifdef MAKETARGET_bin_insure
|
251 |
|
|
MAKETARGET_$$hashref{name}_Insure=1
|
252 |
|
|
endif
|
253 |
williamc |
1.21.2.22 |
|
254 |
|
|
# debuggging target
|
255 |
|
|
$$hashref{'name'}_echo_% :: echo_%
|
256 |
|
|
|
257 |
williamc |
1.21.2.25 |
# help targets
|
258 |
|
|
help::
|
259 |
|
|
\t\@echo Targets For $$hashref{'name'}
|
260 |
|
|
\t\@echo -------------------------------------
|
261 |
|
|
\t\@echo $$hashref{'name'} - default build
|
262 |
|
|
\t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
|
263 |
williamc |
1.21.2.21 |
ENDTEXT
|
264 |
|
|
|
265 |
|
|
# Make generic rules for each type
|
266 |
|
|
$targettypes={
|
267 |
|
|
"bin" => 'o',
|
268 |
|
|
"bin_debug" => 'd',
|
269 |
|
|
"bin_debug_local" => 'l_d',
|
270 |
|
|
"bin_Insure" => 'Insure'
|
271 |
|
|
};
|
272 |
|
|
#
|
273 |
|
|
foreach $target ( keys %$targettypes ) {
|
274 |
|
|
print binGNUmakefile <<ENDTEXT;
|
275 |
|
|
|
276 |
|
|
# Type $target specifics
|
277 |
|
|
ifdef MAKETARGET_$target
|
278 |
|
|
MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
|
279 |
|
|
endif
|
280 |
|
|
$target ::$$hashref{name}_$$targettypes{$target}
|
281 |
|
|
|
282 |
|
|
bintargets+=$$hashref{name}_$$targettypes{$target}
|
283 |
williamc |
1.21.2.24 |
help::
|
284 |
|
|
\t\@echo $$hashref{name}_$$targettypes{$target}
|
285 |
williamc |
1.21.2.21 |
clean::
|
286 |
|
|
\t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
|
287 |
|
|
\techo Removing \$(binarystore)/$$hashref{name}; \\
|
288 |
|
|
\trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
|
289 |
|
|
\tfi
|
290 |
|
|
|
291 |
|
|
ENDTEXT
|
292 |
|
|
($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
|
293 |
|
|
${"objectname_$$targettypes{$target}"}=$objectname;
|
294 |
|
|
print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
|
295 |
|
|
} # end loop
|
296 |
|
|
|
297 |
williamc |
1.21.2.33 |
print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
|
298 |
williamc |
1.21.2.21 |
print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
|
299 |
|
|
print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
|
300 |
|
|
print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
|
301 |
|
|
print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
|
302 |
|
|
print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
|
303 |
|
|
print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
|
304 |
|
|
print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
|
305 |
|
|
print binGNUmakefile "\t\$(CClinkCmd)\n";
|
306 |
|
|
print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
|
307 |
|
|
print binGNUmakefile "-include $$hashref{name}.dep\n";
|
308 |
|
|
print binGNUmakefile <<ENDTEXT;
|
309 |
|
|
clean::
|
310 |
|
|
\t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
|
311 |
|
|
\techo Removing \$(binarystore)/$$hashref{name}; \\
|
312 |
|
|
\trm \$(binarystore)/$$hashref{name}; \\
|
313 |
|
|
\tfi
|
314 |
|
|
|
315 |
williamc |
1.19 |
$$hashref{name}_d.exe:\$(libslocal_d)
|
316 |
williamc |
1.21.2.20 |
$$hashref{name}_o.exe:\$(libslocal)
|
317 |
williamc |
1.21.2.4 |
ifdef MCCABE_DATA_DIR
|
318 |
williamc |
1.21.2.21 |
$$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
|
319 |
williamc |
1.21.2.4 |
endif
|
320 |
williamc |
1.19 |
$$hashref{name}_Insure.exe:\$(libslocal_I)
|
321 |
williamc |
1.17 |
$$hashref{name}_d:$$hashref{name}_d.exe
|
322 |
williamc |
1.21.2.7 |
\@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
|
323 |
williamc |
1.21.2.19 |
$$hashref{name}_l_d:$$hashref{name}_l_d.exe
|
324 |
|
|
\@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
|
325 |
williamc |
1.17 |
$$hashref{name}_Insure:$$hashref{name}_Insure.exe
|
326 |
williamc |
1.21.2.7 |
\@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
|
327 |
williamc |
1.20 |
$$hashref{name}:$$hashref{name}_d.exe
|
328 |
|
|
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
|
329 |
williamc |
1.21.2.20 |
$$hashref{name}_o:$$hashref{name}_o.exe
|
330 |
|
|
\@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
|
331 |
williamc |
1.21.2.4 |
binfiles+=$$hashref{file}
|
332 |
williamc |
1.17 |
ENDTEXT
|
333 |
williamc |
1.21.2.12 |
}
|
334 |
williamc |
1.21.2.22 |
close binGNUmakefile;
|
335 |
williamc |
1.21.2.12 |
}
|
336 |
|
|
|
337 |
|
|
sub Ext_start_export {
|
338 |
|
|
my $name=shift;
|
339 |
|
|
my @vars=@_;
|
340 |
|
|
my $hashref;
|
341 |
|
|
|
342 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
343 |
|
|
if ( $Arch ) {
|
344 |
|
|
if ( $switchex->context('export') ) {
|
345 |
|
|
$$hashref{'ref'}=~tr[A-Z][a-z];
|
346 |
|
|
print GNUmakefile $$hashref{'ref'};
|
347 |
|
|
if ( defined $$hashref{'version'} ) {
|
348 |
|
|
print GNUmakefile "_V_".$$hashref{'version'};
|
349 |
|
|
}
|
350 |
|
|
print GNUmakefile "=true\n";
|
351 |
|
|
}
|
352 |
williamc |
1.21.2.1 |
}
|
353 |
williamc |
1.1 |
}
|
354 |
|
|
|
355 |
|
|
sub External_StartTag {
|
356 |
|
|
my $name=shift;
|
357 |
|
|
my @vars=@_;
|
358 |
|
|
my $hashref;
|
359 |
|
|
|
360 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
361 |
williamc |
1.21 |
if ( $Arch ) {
|
362 |
williamc |
1.6 |
$$hashref{'ref'}=~tr[A-Z][a-z];
|
363 |
williamc |
1.1 |
print GNUmakefile $$hashref{'ref'};
|
364 |
|
|
if ( defined $$hashref{'version'} ) {
|
365 |
|
|
print GNUmakefile "_V_".$$hashref{'version'};
|
366 |
|
|
}
|
367 |
|
|
print GNUmakefile "=true\n";
|
368 |
williamc |
1.21 |
}
|
369 |
williamc |
1.1 |
|
370 |
|
|
}
|
371 |
|
|
|
372 |
|
|
sub Group_start {
|
373 |
|
|
my $name=shift;
|
374 |
|
|
my @vars=@_;
|
375 |
|
|
my $hashref;
|
376 |
|
|
|
377 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
378 |
|
|
$switch->checkparam($hashref, $name, 'name');
|
379 |
williamc |
1.21.2.1 |
if ( $Arch ) {
|
380 |
williamc |
1.1 |
print GNUmakefile "GROUP_".$$hashref{'name'};
|
381 |
|
|
if ( defined $$hashref{'version'} ) {
|
382 |
|
|
print GNUmakefile "_V_".$$hashref{'version'};
|
383 |
|
|
}
|
384 |
|
|
print GNUmakefile "=true\n";
|
385 |
williamc |
1.21.2.1 |
}
|
386 |
williamc |
1.1 |
}
|
387 |
|
|
|
388 |
|
|
sub External {
|
389 |
|
|
my $name=shift;
|
390 |
|
|
my @vars=@_;
|
391 |
|
|
# Will simply collect string into a seperate buffer for processind
|
392 |
|
|
# at the tag closure - used for specifying product defaults
|
393 |
|
|
# --- Oh oh all of string already in external buffer @!
|
394 |
|
|
}
|
395 |
|
|
|
396 |
|
|
sub External_EndTag {
|
397 |
|
|
my $name=shift;
|
398 |
|
|
my @vars=@_;
|
399 |
|
|
|
400 |
|
|
# process buffer and check consistency with product dtd
|
401 |
|
|
}
|
402 |
|
|
|
403 |
|
|
sub Use_start {
|
404 |
|
|
my $name=shift;
|
405 |
|
|
my @vars=@_;
|
406 |
|
|
my $hashref;
|
407 |
|
|
my $filename;
|
408 |
williamc |
1.2 |
use Utilities::SCRAMUtils;
|
409 |
williamc |
1.1 |
|
410 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
411 |
|
|
$switch->checkparam($hashref, $name, "name");
|
412 |
williamc |
1.21.2.1 |
if ( $Arch ) {
|
413 |
williamc |
1.21 |
$filename=SCRAMUtils::checkfile(
|
414 |
|
|
"$ENV{INTsrc}/$$hashref{name}/BuildFile");
|
415 |
|
|
if ( $filename ne "" ) {
|
416 |
|
|
ParseBuildFile_Export( $filename );
|
417 |
williamc |
1.1 |
}
|
418 |
williamc |
1.21.2.1 |
}
|
419 |
williamc |
1.1 |
}
|
420 |
|
|
|
421 |
williamc |
1.5 |
sub CheckBuildFile {
|
422 |
williamc |
1.1 |
my $classdir=shift;
|
423 |
|
|
$ClassName="";
|
424 |
|
|
$thisfile="$classdir/$buildfile";
|
425 |
|
|
|
426 |
|
|
if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
|
427 |
|
|
$DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
|
428 |
|
|
ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
|
429 |
|
|
}
|
430 |
|
|
elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
|
431 |
|
|
$DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
|
432 |
|
|
ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
|
433 |
|
|
}
|
434 |
|
|
return $ClassName;
|
435 |
|
|
}
|
436 |
|
|
|
437 |
|
|
# List association groups between <AssociateGroup> tags
|
438 |
|
|
# seperated by newlines or spaces
|
439 |
|
|
sub AssociateGroup {
|
440 |
|
|
my $name=shift;
|
441 |
|
|
my @vars=@_;
|
442 |
|
|
my $word;
|
443 |
|
|
|
444 |
|
|
foreach $word ( @vars ){
|
445 |
|
|
chomp $word;
|
446 |
|
|
next if /^#/;
|
447 |
|
|
push @groups, $word;
|
448 |
|
|
}
|
449 |
williamc |
1.21.2.1 |
}
|
450 |
|
|
|
451 |
|
|
sub ignoretag {
|
452 |
|
|
my $name=shift;
|
453 |
|
|
my @vars=@_;
|
454 |
|
|
|
455 |
|
|
$Arch=0;
|
456 |
|
|
push @ARCHBLOCK, $Arch;
|
457 |
|
|
}
|
458 |
|
|
|
459 |
|
|
sub ignoretag_end {
|
460 |
|
|
my $name=shift;
|
461 |
|
|
my @vars=@_;
|
462 |
|
|
|
463 |
|
|
pop @ARCHBLOCK;
|
464 |
|
|
$Arch=$ARCHBLOCK[$#ARCHBLOCK];
|
465 |
|
|
}
|
466 |
|
|
|
467 |
|
|
sub Arch_Start {
|
468 |
|
|
my $name=shift;
|
469 |
|
|
my @vars=@_;
|
470 |
|
|
my $hashref;
|
471 |
|
|
|
472 |
|
|
$hashref=$toolswitch->SetupValueHash( \@vars );
|
473 |
|
|
$toolswitch->checkparam($hashref, $name, 'name');
|
474 |
|
|
#( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0;
|
475 |
|
|
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0);
|
476 |
|
|
push @ARCHBLOCK, $Arch;
|
477 |
|
|
}
|
478 |
|
|
sub Arch_End {
|
479 |
|
|
my $name=shift;
|
480 |
|
|
my @vars=@_;
|
481 |
|
|
|
482 |
|
|
pop @ARCHBLOCK;
|
483 |
|
|
$Arch=$ARCHBLOCK[$#ARCHBLOCK];
|
484 |
williamc |
1.1 |
}
|
485 |
|
|
|
486 |
|
|
# Split up the Class Block String into a useable array
|
487 |
williamc |
1.5 |
sub _CutBlock {
|
488 |
williamc |
1.1 |
my $string= shift @_;
|
489 |
|
|
@BlockClassA = split /\//, $string;
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
sub OutToMakefile {
|
493 |
|
|
my $name=shift;
|
494 |
|
|
my @vars=@_;
|
495 |
|
|
|
496 |
williamc |
1.21.2.15 |
if ( $Arch ) {
|
497 |
|
|
print GNUmakefile @vars;
|
498 |
|
|
}
|
499 |
williamc |
1.21.2.14 |
}
|
500 |
|
|
sub OutToScreen {
|
501 |
|
|
my $name=shift;
|
502 |
|
|
my @vars=@_;
|
503 |
|
|
|
504 |
williamc |
1.21.2.15 |
if ( $Arch ) {
|
505 |
|
|
print @vars;
|
506 |
|
|
}
|
507 |
williamc |
1.1 |
}
|
508 |
|
|
sub setBlockClassPath {
|
509 |
|
|
my $name=shift;
|
510 |
|
|
my @vars=@_;
|
511 |
|
|
my $hashref;
|
512 |
|
|
|
513 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
514 |
|
|
$switch->checkparam($hashref, $name, 'path');
|
515 |
|
|
$BlockClassPath=$BlockClassPath.":".$$hashref{path};
|
516 |
|
|
_CutBlock($$hashref{path});
|
517 |
williamc |
1.21 |
}
|
518 |
|
|
|
519 |
williamc |
1.21.2.30 |
sub use_export_start {
|
520 |
williamc |
1.21 |
#Set up a toolfile object
|
521 |
|
|
$exporttool=Tool->new();
|
522 |
williamc |
1.21.2.30 |
}
|
523 |
|
|
|
524 |
|
|
sub use_export_end {
|
525 |
|
|
#Write toolfile object to disk
|
526 |
|
|
$exporttool->envtomake(\*GNUmakefile);
|
527 |
|
|
}
|
528 |
|
|
|
529 |
|
|
sub export_start {
|
530 |
williamc |
1.21.2.31 |
my $name=shift;
|
531 |
|
|
my @vars=@_;
|
532 |
|
|
my $hashref;
|
533 |
|
|
|
534 |
|
|
$hashref=$switch->SetupValueHash(\@vars);
|
535 |
|
|
if ( exists $$hashref{autoexport} ) {
|
536 |
|
|
print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
|
537 |
|
|
}
|
538 |
williamc |
1.21.2.30 |
#Set up a toolfile object
|
539 |
williamc |
1.21.2.28 |
print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
|
540 |
williamc |
1.21 |
}
|
541 |
|
|
|
542 |
|
|
sub export_end {
|
543 |
|
|
#Write toolfile object to disk
|
544 |
williamc |
1.21.2.29 |
print GNUmakefile "endif\n";
|
545 |
williamc |
1.21 |
}
|
546 |
|
|
|
547 |
|
|
#
|
548 |
|
|
# Export Mode Lib Tag
|
549 |
|
|
#
|
550 |
|
|
sub lib_start_export {
|
551 |
|
|
my $name=shift;
|
552 |
|
|
my @vars=@_;
|
553 |
|
|
my $hashref;
|
554 |
|
|
|
555 |
|
|
$hashref=$switchex->SetupValueHash( \@vars );
|
556 |
|
|
$switchex->checkparam($hashref, $name, 'name');
|
557 |
|
|
if ( $Arch ) {
|
558 |
|
|
if ( $switchex->context('export') ) {
|
559 |
|
|
#If export mode then add this env to the export tool
|
560 |
|
|
$exporttool->addenv('lib',$$hashref{name});
|
561 |
|
|
}
|
562 |
|
|
}
|
563 |
|
|
}
|
564 |
|
|
|
565 |
|
|
#
|
566 |
|
|
# Standard lib tag
|
567 |
|
|
#
|
568 |
|
|
sub lib_start {
|
569 |
|
|
my $name=shift;
|
570 |
|
|
my @vars=@_;
|
571 |
|
|
my $hashref;
|
572 |
|
|
|
573 |
|
|
$hashref=$switch->SetupValueHash( \@vars );
|
574 |
|
|
$switch->checkparam($hashref, $name, 'name');
|
575 |
|
|
if ( $Arch ) {
|
576 |
|
|
print GNUmakefile "lib+=$$hashref{name}\n";
|
577 |
|
|
}
|
578 |
williamc |
1.21.2.6 |
}
|
579 |
|
|
|
580 |
|
|
#
|
581 |
|
|
# libtype specification
|
582 |
|
|
#
|
583 |
|
|
sub LibType_Start {
|
584 |
|
|
my $name=shift;
|
585 |
|
|
my @vars=@_;
|
586 |
|
|
my $hashref;
|
587 |
|
|
|
588 |
williamc |
1.21.2.8 |
if ( $Arch ) {
|
589 |
williamc |
1.21.2.6 |
$hashref=$switch->SetupValueHash( \@vars );
|
590 |
|
|
$switch->checkparam($hashref, $name, 'type');
|
591 |
|
|
|
592 |
|
|
print GNUmakefile "# Specify Library Type\n";
|
593 |
|
|
print GNUmakefile "DefaultLibsOff=yes\n";
|
594 |
|
|
if ( $$hashref{'type'}=~/^archive/i ) {
|
595 |
|
|
print GNUmakefile "LibArchive=true\n";
|
596 |
|
|
}
|
597 |
williamc |
1.21.2.11 |
elsif ($$hashref{'type'}=~/debug_archive/i ) {
|
598 |
williamc |
1.21.2.6 |
print GNUmakefile "LibDebugArchive=true\n";
|
599 |
|
|
}
|
600 |
williamc |
1.21.2.11 |
elsif ($$hashref{'type'}=~/debug_shared/i ) {
|
601 |
|
|
print GNUmakefile "LibDebugShared=true\n";
|
602 |
|
|
}
|
603 |
williamc |
1.21.2.6 |
elsif ($$hashref{'type'}=~/shared/i ) {
|
604 |
|
|
print GNUmakefile 'LibShared=true'."\n";
|
605 |
|
|
}
|
606 |
|
|
print GNUmakefile "\n";
|
607 |
williamc |
1.21.2.8 |
}
|
608 |
williamc |
1.1 |
}
|
609 |
williamc |
1.21.2.15 |
sub LibType_text {
|
610 |
|
|
my $name=shift;
|
611 |
|
|
my @vars=@_;
|
612 |
|
|
|
613 |
|
|
if ( $Arch ) {
|
614 |
williamc |
1.21.2.16 |
print GNUmakefile "libmsg::\n\t\@echo Library info: ";
|
615 |
williamc |
1.21.2.15 |
print GNUmakefile @vars;
|
616 |
|
|
print GNUmakefile "\n";
|
617 |
|
|
}
|
618 |
|
|
}
|
619 |
|
|
|
620 |
williamc |
1.21.2.21 |
sub Environment_start {
|
621 |
|
|
my $name=shift;
|
622 |
|
|
my @vars=@_;
|
623 |
|
|
my $hashref;
|
624 |
|
|
|
625 |
|
|
if ( $Arch ) {
|
626 |
|
|
$envnum++;
|
627 |
williamc |
1.21.2.22 |
|
628 |
|
|
# open a new Environment File
|
629 |
|
|
my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk";
|
630 |
williamc |
1.21.2.21 |
use FileHandle;
|
631 |
|
|
my $fh=FileHandle->new();
|
632 |
williamc |
1.21.2.22 |
open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
|
633 |
williamc |
1.21.2.21 |
push @filehandlestack, $fh;
|
634 |
williamc |
1.21.2.22 |
*GNUmakefile=$fh;
|
635 |
williamc |
1.21.2.21 |
|
636 |
|
|
# include the approprate environment file
|
637 |
|
|
if ( $envlevel == 0 ) {
|
638 |
|
|
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
|
639 |
williamc |
1.21.2.22 |
"BuildFile.mk\n";
|
640 |
williamc |
1.21.2.21 |
}
|
641 |
|
|
else {
|
642 |
|
|
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
|
643 |
williamc |
1.21.2.22 |
"Env_$Envlevels[$envlevel]\.mk\n";
|
644 |
williamc |
1.21.2.21 |
}
|
645 |
|
|
$envlevel++;
|
646 |
|
|
$Envlevels[$envlevel]=$envnum;
|
647 |
|
|
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk";
|
648 |
|
|
}
|
649 |
|
|
}
|
650 |
|
|
|
651 |
|
|
sub Environment_end {
|
652 |
|
|
my $fd;
|
653 |
|
|
|
654 |
|
|
if ( $Arch ) {
|
655 |
|
|
$envlevel--;
|
656 |
|
|
if ( $envlevel < 0 ) {
|
657 |
|
|
print "Too many </Environent> Tags on $switch->line()\n";
|
658 |
|
|
exit;
|
659 |
|
|
}
|
660 |
|
|
close GNUmakefile;
|
661 |
|
|
# restore the last filehandle
|
662 |
|
|
$fd=pop @filehandlestack;
|
663 |
|
|
close $fd;
|
664 |
williamc |
1.21.2.22 |
*GNUmakefile=$filehandlestack[$#filehandlestack];
|
665 |
williamc |
1.21.2.21 |
if ( $envlevel < 1 ) {
|
666 |
|
|
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
|
667 |
|
|
}
|
668 |
|
|
else {
|
669 |
|
|
$currentenv=
|
670 |
|
|
"$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$Envlevels[$envlevel]";
|
671 |
|
|
}
|
672 |
|
|
}
|
673 |
|
|
}
|