1 |
williamc |
1.2 |
# BuildFile
|
2 |
williamc |
1.1 |
#
|
3 |
|
|
# Interface
|
4 |
|
|
# ---------
|
5 |
williamc |
1.13 |
# new(toolbox)
|
6 |
williamc |
1.2 |
# ParseBuildFile($base,$path,$file)
|
7 |
|
|
# ParseBuildFileExport(filename)
|
8 |
|
|
# BlockClassPath() : Return the class path
|
9 |
|
|
# ignore() : return 1 if directory should be ignored 0 otherwise
|
10 |
williamc |
1.1 |
|
11 |
|
|
package BuildSystem::BuildFile;
|
12 |
sashby |
1.15 |
use Utilities::Verbose;
|
13 |
williamc |
1.2 |
use ActiveDoc::SimpleDoc;
|
14 |
|
|
use BuildSystem::ToolBox;
|
15 |
|
|
require 5.004;
|
16 |
sashby |
1.15 |
@ISA=qw(Utilities::Verbose);
|
17 |
williamc |
1.2 |
|
18 |
|
|
BEGIN {
|
19 |
|
|
$buildfile="BuildFile";
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
sub new {
|
23 |
|
|
my $class=shift;
|
24 |
|
|
my $self={};
|
25 |
|
|
bless $self, $class;
|
26 |
williamc |
1.13 |
$self->{toolbox}=shift;
|
27 |
williamc |
1.2 |
$self->{Arch}=1;
|
28 |
|
|
push @{$self->{ARCHBLOCK}}, $self->{Arch};
|
29 |
|
|
return $self;
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
sub ignore {
|
33 |
|
|
my $self=shift;
|
34 |
sashby |
1.15 |
$self->verbose(">> ignore......<<");
|
35 |
|
|
|
36 |
williamc |
1.2 |
return (defined $self->{ignore})?$self->{ignore}:0;
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
sub _initswitcher {
|
40 |
|
|
my $self=shift;
|
41 |
|
|
my $switch=ActiveDoc::SimpleDoc->new();
|
42 |
|
|
my $parse="makebuild";
|
43 |
sashby |
1.15 |
$self->verbose(">> _initswitcher: <<");
|
44 |
williamc |
1.2 |
$switch->newparse($parse);
|
45 |
|
|
$switch->addignoretags($parse);
|
46 |
|
|
$self->_commontags($switch,$parse);
|
47 |
williamc |
1.13 |
$switch->addtag($parse,"Build", \&Build_start, $self);
|
48 |
williamc |
1.2 |
$switch->addtag($parse,"none",
|
49 |
|
|
\&OutToMakefile,$self,
|
50 |
|
|
\&OutToMakefile, $self,
|
51 |
|
|
"", $self);
|
52 |
|
|
$switch->addtag($parse,"Bin",
|
53 |
|
|
\&Bin_start,$self,
|
54 |
|
|
\&OutToScreen, $self,
|
55 |
|
|
"", $self);
|
56 |
williamc |
1.12 |
$switch->addtag($parse,"ProductStore",
|
57 |
|
|
\&Store_start,$self,
|
58 |
|
|
"", $self,
|
59 |
|
|
"", $self);
|
60 |
williamc |
1.2 |
$switch->addtag($parse,"LibType",
|
61 |
|
|
\&LibType_Start,$self,
|
62 |
|
|
\&LibType_text, $self,
|
63 |
|
|
\&LibType_end,$self);
|
64 |
|
|
$switch->addtag($parse,"ConfigurationClass",
|
65 |
|
|
\&Class_StartTag,$self,
|
66 |
|
|
\&OutToMakefile, $self,
|
67 |
|
|
"", $self);
|
68 |
|
|
$switch->addtag($parse,"ClassPath",
|
69 |
|
|
\&setBlockClassPath,$self,
|
70 |
|
|
\&OutToMakefile, $self,
|
71 |
|
|
"", $self);
|
72 |
|
|
$switch->addtag($parse,"AssociateGroup",
|
73 |
|
|
"",$self,
|
74 |
|
|
\&AssociateGroup,$self,
|
75 |
|
|
"", $self);
|
76 |
|
|
$switch->addtag($parse,"Environment",
|
77 |
|
|
\&Environment_start,$self,
|
78 |
|
|
\&OutToMakefile, $self,
|
79 |
|
|
\&Environment_end,$self);
|
80 |
|
|
$switch->addtag($parse,"Export",
|
81 |
|
|
\&export_start,$self,
|
82 |
|
|
\&OutToMakefile, $self,
|
83 |
|
|
\&export_end,$self);
|
84 |
|
|
return $switch;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
sub _commontags {
|
88 |
|
|
my $self=shift;
|
89 |
|
|
my $switch=shift;
|
90 |
|
|
my $parse=shift;
|
91 |
sashby |
1.15 |
|
92 |
|
|
$self->verbose(">> _commontags: SW ".$switch." PARSE ".$parse." <<");
|
93 |
|
|
|
94 |
williamc |
1.2 |
$switch->grouptag("Export",$parse);
|
95 |
|
|
$switch->addtag($parse,"Use",\&Use_start,$self,
|
96 |
|
|
\&OutToMakefile, $self,
|
97 |
|
|
"", $self);
|
98 |
|
|
$switch->addtag($parse,"Group",\&Group_start,$self,
|
99 |
|
|
\&OutToMakefile, $self,
|
100 |
|
|
"", $self);
|
101 |
|
|
$switch->grouptag("Group",$parse);
|
102 |
|
|
$switch->addtag($parse,"External",
|
103 |
|
|
\&External_StartTag,$self,
|
104 |
|
|
\&OutToMakefile, $self,
|
105 |
|
|
"", $self);
|
106 |
|
|
$switch->addtag($parse,"lib",
|
107 |
|
|
\&lib_start,$self,
|
108 |
|
|
\&OutToMakefile, $self,
|
109 |
|
|
"", $self);
|
110 |
|
|
$switch->addtag($parse,"Architecture",
|
111 |
|
|
\&Arch_Start,$self,
|
112 |
|
|
\&OutToMakefile, $self,
|
113 |
|
|
\&Arch_End,$self);
|
114 |
|
|
$switch->addtag($parse,"INCLUDE_PATH",
|
115 |
|
|
\&IncludePath_Start,$self,
|
116 |
|
|
\&OutToMakefile, $self,
|
117 |
|
|
"",$self);
|
118 |
|
|
return $switch;
|
119 |
|
|
}
|
120 |
|
|
|
121 |
|
|
sub ParseBuildFile {
|
122 |
|
|
my $self=shift;
|
123 |
|
|
my $base=shift;
|
124 |
|
|
my $path=shift;
|
125 |
|
|
my $filename=shift @_;
|
126 |
|
|
my $fullfilename;
|
127 |
|
|
if ( $filename!~/^\// ) {
|
128 |
|
|
$fullfilename="$base/$path/$filename";
|
129 |
|
|
}
|
130 |
|
|
else {
|
131 |
|
|
$fullfilename=$filename;
|
132 |
|
|
}
|
133 |
sashby |
1.15 |
|
134 |
|
|
$self->verbose(">> ParseBuildFile: FN ".$fullfilename." <<");
|
135 |
|
|
|
136 |
williamc |
1.2 |
$self->{path}=$path;
|
137 |
|
|
$numbins=0;
|
138 |
|
|
$self->{envnum}=0;
|
139 |
|
|
$self->{envlevel}=0;
|
140 |
williamc |
1.13 |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
|
141 |
|
|
"BuildFile.mk";
|
142 |
williamc |
1.2 |
$self->{switch}=$self->_initswitcher();
|
143 |
|
|
$self->{switch}->filetoparse($fullfilename);
|
144 |
|
|
|
145 |
sashby |
1.14 |
# open a temporary gnumakefile to store output.
|
146 |
williamc |
1.2 |
use Utilities::AddDir;
|
147 |
williamc |
1.13 |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
|
148 |
|
|
my $fh=FileHandle->new();
|
149 |
|
|
open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
|
150 |
|
|
) or die "Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n";
|
151 |
|
|
@{$self->{filehandlestack}}=($fh);
|
152 |
|
|
# make an alias
|
153 |
|
|
*GNUmakefile=$fh;
|
154 |
|
|
if ( -e $ENV{LatestBuildFile} ) {
|
155 |
|
|
print GNUmakefile "include $ENV{LatestBuildFile}\n";
|
156 |
|
|
}
|
157 |
sashby |
1.14 |
|
158 |
williamc |
1.13 |
$ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
|
159 |
|
|
$self->{switch}->parse("makebuild"); # sort out supported tags
|
160 |
|
|
if ( $numbins > 0 ) {
|
161 |
|
|
print GNUmakefile <<ENDTEXT;
|
162 |
|
|
ifndef BINMODE
|
163 |
|
|
help::
|
164 |
|
|
\t\@echo Generic Binary targets
|
165 |
|
|
\t\@echo ----------------------
|
166 |
|
|
endif
|
167 |
|
|
ENDTEXT
|
168 |
|
|
foreach $target ( keys %$targettypes ) {
|
169 |
|
|
print GNUmakefile <<ENDTEXT;
|
170 |
|
|
ifndef BINMODE
|
171 |
|
|
help::
|
172 |
|
|
\t\@echo $target
|
173 |
|
|
endif
|
174 |
|
|
ENDTEXT
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
|
|
close GNUmakefile;
|
178 |
williamc |
1.6 |
}
|
179 |
|
|
|
180 |
williamc |
1.2 |
sub ParseBuildFile_Export {
|
181 |
williamc |
1.1 |
my $self=shift;
|
182 |
williamc |
1.2 |
my $filename=shift;
|
183 |
sashby |
1.15 |
|
184 |
|
|
$self->verbose(">> ParseBuildFile_Export: FN ".$filename." <<");
|
185 |
|
|
|
186 |
williamc |
1.13 |
my $bf=BuildSystem::BuildFile->new($self->{toolbox});
|
187 |
williamc |
1.2 |
if ( defined $self->{remoteproject} ) {
|
188 |
|
|
$bf->{remoteproject}=$self->{remoteproject};
|
189 |
|
|
}
|
190 |
|
|
$bf->_parseexport($filename);
|
191 |
|
|
undef $bf;
|
192 |
|
|
}
|
193 |
williamc |
1.1 |
|
194 |
williamc |
1.2 |
sub _location {
|
195 |
|
|
my $self=shift;
|
196 |
|
|
use File::Basename;
|
197 |
sashby |
1.15 |
$self->verbose(">> _location: <<");
|
198 |
williamc |
1.2 |
return dirname($self->{switch}->filetoparse());
|
199 |
williamc |
1.1 |
}
|
200 |
|
|
|
201 |
williamc |
1.2 |
sub _parseexport {
|
202 |
williamc |
1.1 |
my $self=shift;
|
203 |
williamc |
1.2 |
my $filename=shift;
|
204 |
sashby |
1.15 |
$self->verbose(">> _parseexport: FN ".$filename." <<");
|
205 |
|
|
|
206 |
williamc |
1.2 |
my $switchex=ActiveDoc::SimpleDoc->new();
|
207 |
|
|
$switchex->filetoparse($filename);
|
208 |
|
|
$switchex->newparse("export");
|
209 |
|
|
$switchex->addignoretags("export");
|
210 |
|
|
$switchex->addtag("export","Export",
|
211 |
|
|
\&export_start_export,$self,
|
212 |
|
|
\&OutToMakefile, $self,
|
213 |
|
|
\&export_end_export,$self);
|
214 |
|
|
$self->_commontags($switchex,"export");
|
215 |
|
|
$switchex->allowgroup("__export","export");
|
216 |
|
|
$self->{switch}=$switchex;
|
217 |
|
|
$switchex->parse("export"); # sort out supported tags
|
218 |
|
|
}
|
219 |
williamc |
1.1 |
|
220 |
williamc |
1.2 |
sub _pushremoteproject {
|
221 |
|
|
my $self=shift;
|
222 |
|
|
my $path=shift;
|
223 |
sashby |
1.15 |
|
224 |
|
|
$self->verbose(">> _pushremoteproject: PATH ".$path." <<");
|
225 |
williamc |
1.1 |
|
226 |
williamc |
1.2 |
if ( defined $self->{remoteproject} ) {
|
227 |
|
|
push @{$self->{rpstack}}, $self->{remoteproject};
|
228 |
|
|
}
|
229 |
|
|
$self->{remoteproject}=$path;
|
230 |
williamc |
1.1 |
}
|
231 |
|
|
|
232 |
williamc |
1.2 |
sub _popremoteproject {
|
233 |
|
|
my $self=shift;
|
234 |
sashby |
1.15 |
$self->verbose(">> _popremoteproject: <<");
|
235 |
|
|
|
236 |
williamc |
1.2 |
if ( $#{$self->{rpstack}} >=0 ) {
|
237 |
|
|
$self->{remoteproject}=pop @{$self->{rpstack}};
|
238 |
|
|
}
|
239 |
|
|
else {
|
240 |
|
|
undef $self->{remoteproject};
|
241 |
|
|
}
|
242 |
|
|
}
|
243 |
williamc |
1.1 |
|
244 |
williamc |
1.2 |
sub _toolmapper {
|
245 |
|
|
my $self=shift;
|
246 |
sashby |
1.15 |
|
247 |
williamc |
1.2 |
if ( ! defined $self->{mapper} ) {
|
248 |
|
|
require BuildSystem::ToolMapper;
|
249 |
|
|
$self->{mapper}=BuildSystem::ToolMapper->new();
|
250 |
|
|
}
|
251 |
sashby |
1.15 |
$self->verbose(">> _toolmapper: TM ".$self->{mapper}."<<");
|
252 |
williamc |
1.2 |
return $self->{mapper};
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
# ---- Tag routines
|
257 |
|
|
|
258 |
|
|
#-- Override a class type with the <ConfigurationClass type=xxx> tag
|
259 |
|
|
# the type tag will pick up a pre-defined class type from project space.
|
260 |
|
|
|
261 |
|
|
sub Class_StartTag {
|
262 |
williamc |
1.1 |
my $self=shift;
|
263 |
|
|
my $name=shift;
|
264 |
|
|
my $hashref=shift;
|
265 |
sashby |
1.15 |
|
266 |
|
|
$self->verbose(">> Classs_StartTag: NM ".$name." <<");
|
267 |
williamc |
1.2 |
|
268 |
|
|
if ( $self->{Arch} ) {
|
269 |
|
|
if ( defined $$hashref{'type'} ) {
|
270 |
williamc |
1.13 |
$ClassName=$$hashref{'type'};
|
271 |
williamc |
1.2 |
}
|
272 |
|
|
}
|
273 |
|
|
}
|
274 |
|
|
|
275 |
|
|
sub IncludePath_Start {
|
276 |
|
|
my $self=shift;
|
277 |
|
|
my $name=shift;
|
278 |
|
|
my $hashref=shift;
|
279 |
sashby |
1.15 |
|
280 |
|
|
$self->verbose(">> IncludePath_Start: NM ".$name." <<");
|
281 |
|
|
|
282 |
williamc |
1.2 |
$self->{switch}->checktag( $name, $hashref, 'path');
|
283 |
|
|
if ( $self->{Arch} ) {
|
284 |
|
|
print GNUmakefile "INCLUDE+=".$self->_location()."/".
|
285 |
|
|
$$hashref{'path'}."\n";
|
286 |
|
|
}
|
287 |
|
|
}
|
288 |
|
|
|
289 |
|
|
#
|
290 |
williamc |
1.13 |
# generic build tag
|
291 |
williamc |
1.10 |
#
|
292 |
williamc |
1.2 |
sub Build_start {
|
293 |
|
|
my $self=shift;
|
294 |
|
|
my $name=shift;
|
295 |
|
|
my $hashref=shift;
|
296 |
|
|
|
297 |
sashby |
1.15 |
$self->verbose(">> Build_start: NM ".$name." <<");
|
298 |
|
|
|
299 |
williamc |
1.2 |
$self->{switch}->checktag($name,$hashref,'class');
|
300 |
|
|
if ( $self->{Arch} ) {
|
301 |
|
|
|
302 |
|
|
# -- determine the build products name
|
303 |
|
|
my $name;
|
304 |
|
|
if ( exists $$hashref{'name'} ) {
|
305 |
|
|
$name=$$hashref{'name'};
|
306 |
|
|
}
|
307 |
|
|
else {
|
308 |
|
|
$self->{switch}->parseerror("No name specified for build product");
|
309 |
|
|
}
|
310 |
|
|
|
311 |
|
|
# -- check we have a lookup for the class type
|
312 |
|
|
my $mapper=$self->_toolmapper();
|
313 |
|
|
if ( ! $mapper->exists($$hashref{'class'}) ) {
|
314 |
|
|
$self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
|
315 |
|
|
}
|
316 |
|
|
else {
|
317 |
|
|
my @types=$self->_toolmapper()->types($$hashref{'class'});
|
318 |
|
|
my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
|
319 |
|
|
|
320 |
|
|
my $fh=$self->{filehandlestack}[0];
|
321 |
|
|
my @targets=();
|
322 |
|
|
|
323 |
|
|
# -- generate generic targets
|
324 |
|
|
print $fh "ifndef _BuildLink_\n";
|
325 |
williamc |
1.12 |
print $fh "# -- Generic targets\n";
|
326 |
williamc |
1.2 |
push @targets, $$hashref{'class'};
|
327 |
williamc |
1.12 |
foreach $dtype ( @deftypes ) {
|
328 |
|
|
print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
|
329 |
|
|
$dtype."\n";
|
330 |
|
|
}
|
331 |
|
|
print $fh "\n";
|
332 |
williamc |
1.2 |
|
333 |
|
|
# -- generate targets for each type
|
334 |
|
|
foreach $type ( @types ) {
|
335 |
|
|
|
336 |
|
|
# -- generic name for each type
|
337 |
|
|
my $pattern=$$hashref{'class'}."_".$type;
|
338 |
|
|
my $dirname=$$hashref{'class'}."_".$type."_".$name;
|
339 |
|
|
print $fh "# ------ $pattern rules ---------------\n";
|
340 |
|
|
print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
|
341 |
|
|
"_".$type."_$name\n\n";
|
342 |
|
|
|
343 |
|
|
# -- create a new directory for each type
|
344 |
|
|
push @targets, $pattern;
|
345 |
|
|
my $dirname=$$hashref{'class'}."_".$type."_".$name;
|
346 |
williamc |
1.12 |
my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
|
347 |
williamc |
1.2 |
my $makefile=$here."/BuildFile.mk";
|
348 |
|
|
|
349 |
|
|
# -- create link targets to the directory
|
350 |
|
|
push @targets, $dirname;
|
351 |
|
|
print $fh "# -- Link Targets to $type directories\n";
|
352 |
|
|
print $fh "$dirname: make_$dirname\n";
|
353 |
|
|
print $fh "\t\@cd $here; \\\n";
|
354 |
|
|
print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
|
355 |
|
|
" workdir=$here ".
|
356 |
|
|
" -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
|
357 |
|
|
|
358 |
|
|
# -- write target to make makefile for each directory
|
359 |
|
|
print $fh "# -- Build target directories\n";
|
360 |
|
|
print $fh "make_$dirname:\n";
|
361 |
|
|
print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
|
362 |
|
|
print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
|
363 |
|
|
print $fh "\t mkdir $here; \\\n";
|
364 |
|
|
print $fh "\t fi;\\\n";
|
365 |
|
|
print $fh "\t cd $dirname; \\\n";
|
366 |
|
|
print $fh "\t echo include ".$self->{currentenv}." > ".
|
367 |
|
|
"$makefile; \\\n";
|
368 |
williamc |
1.12 |
print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
|
369 |
williamc |
1.2 |
" >> $makefile; \\\n";
|
370 |
|
|
print $fh "\t echo buildname=$name >> $makefile;\\\n";
|
371 |
|
|
print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
|
372 |
|
|
if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
|
373 |
|
|
foreach $f ( @file ) {
|
374 |
|
|
print $fh "\t echo -include $f >> $makefile; \\\n";
|
375 |
|
|
}
|
376 |
|
|
}
|
377 |
|
|
print $fh "\tfi\n";
|
378 |
|
|
print $fh "\n";
|
379 |
|
|
|
380 |
|
|
# -- cleaning targets
|
381 |
|
|
push @targets, "clean_$dirname";
|
382 |
|
|
print $fh "# -- cleaning targets\n";
|
383 |
|
|
print $fh "clean::clean_$dirname\n";
|
384 |
|
|
print $fh "clean_".$dirname."::\n";
|
385 |
|
|
print $fh "\t\@echo cleaning $dirname\n";
|
386 |
|
|
print $fh "\t\@if [ -d $here ]; then \\\n";
|
387 |
|
|
print $fh "\tcd $here; \\\n";
|
388 |
|
|
print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
|
389 |
|
|
$here." _BuildLink_=1 -f ".
|
390 |
|
|
"\$(TOOL_HOME)/basics.mk clean; \\\n";
|
391 |
|
|
print $fh "\tfi\n\n";
|
392 |
|
|
|
393 |
|
|
|
394 |
|
|
}
|
395 |
|
|
# -- help targets
|
396 |
|
|
print $fh "helpheader::\n";
|
397 |
|
|
print $fh "\t\@echo Targets available:\n";
|
398 |
|
|
print $fh "\t\@echo ------------------\n\n";
|
399 |
|
|
print $fh "help::helpheader\n";
|
400 |
|
|
foreach $target ( @targets ) {
|
401 |
|
|
print $fh "help::\n";
|
402 |
|
|
print $fh "\t\@echo $target\n"
|
403 |
|
|
}
|
404 |
|
|
print $fh "endif\n";
|
405 |
|
|
} # end else
|
406 |
|
|
}
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
sub Bin_start {
|
410 |
|
|
my $self=shift;
|
411 |
|
|
my $name=shift;
|
412 |
|
|
my $hashref=shift;
|
413 |
|
|
|
414 |
|
|
my $fileclass;
|
415 |
|
|
my @tools;
|
416 |
|
|
my $tool;
|
417 |
|
|
my $filename;
|
418 |
|
|
my $objectname;
|
419 |
sashby |
1.15 |
|
420 |
|
|
$self->verbose(">> <<");
|
421 |
williamc |
1.2 |
|
422 |
|
|
$self->{switch}->checktag($name,$hashref,'file');
|
423 |
|
|
if ( $self->{Arch} ) {
|
424 |
|
|
if ( ! defined $$hashref{name} ) {
|
425 |
|
|
($$hashref{name}=$$hashref{file})=~s/\..*//;
|
426 |
|
|
}
|
427 |
|
|
($filename=$$hashref{file})=~s/\..*//;
|
428 |
|
|
|
429 |
|
|
# Create a new directory for each binary target
|
430 |
|
|
my $dirname="bin_".$$hashref{name};
|
431 |
williamc |
1.12 |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
|
432 |
williamc |
1.2 |
open (binGNUmakefile,
|
433 |
williamc |
1.12 |
">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
|
434 |
williamc |
1.2 |
"BuildFile.mk $!\n";
|
435 |
|
|
|
436 |
|
|
# Create the link targets
|
437 |
|
|
$numbins++;
|
438 |
|
|
my $fh=$self->{filehandlestack}[0];
|
439 |
|
|
print $fh <<ENDTEXT;
|
440 |
|
|
|
441 |
|
|
# Link Targets to binary directories
|
442 |
|
|
ifdef BINMODE
|
443 |
|
|
# We dont want to build a library here
|
444 |
|
|
override files:=
|
445 |
|
|
endif
|
446 |
|
|
ifndef BINMODE
|
447 |
|
|
|
448 |
|
|
define stepdown_$$hashref{'name'}
|
449 |
williamc |
1.12 |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
|
450 |
|
|
cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
|
451 |
|
|
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
|
452 |
williamc |
1.2 |
fi
|
453 |
|
|
endef
|
454 |
|
|
|
455 |
|
|
define stepdown2_$$hashref{'name'}
|
456 |
williamc |
1.12 |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
|
457 |
|
|
cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
|
458 |
|
|
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
|
459 |
williamc |
1.2 |
fi
|
460 |
|
|
|
461 |
|
|
endef
|
462 |
|
|
|
463 |
|
|
bin_$$hashref{'name'}_%:: dummy
|
464 |
|
|
\@\$(stepdown2_$$hashref{'name'})
|
465 |
|
|
|
466 |
|
|
$$hashref{'name'}_%:: dummy
|
467 |
|
|
\@\$(stepdown_$$hashref{'name'})
|
468 |
|
|
|
469 |
|
|
help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
|
470 |
|
|
\@\$(stepdown_$$hashref{'name'})
|
471 |
|
|
|
472 |
|
|
binfiles+=$$hashref{'file'}
|
473 |
|
|
locbinfiles+=$dirname/$$hashref{'file'}
|
474 |
|
|
endif
|
475 |
|
|
|
476 |
|
|
|
477 |
|
|
ENDTEXT
|
478 |
|
|
|
479 |
|
|
|
480 |
|
|
# the binary specifics makefile
|
481 |
|
|
print binGNUmakefile "include ".$self->{currentenv}."\n";
|
482 |
williamc |
1.12 |
print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
|
483 |
williamc |
1.2 |
|
484 |
|
|
# alias for bin_Insure
|
485 |
|
|
print binGNUmakefile <<ENDTEXT;
|
486 |
|
|
|
487 |
|
|
bin_insure:bin_Insure
|
488 |
|
|
ifdef MAKETARGET_bin_insure
|
489 |
|
|
MAKETARGET_$$hashref{name}_Insure=1
|
490 |
|
|
endif
|
491 |
|
|
|
492 |
|
|
# debuggging target
|
493 |
|
|
$$hashref{'name'}_echo_% :: echo_%
|
494 |
|
|
|
495 |
|
|
# help targets
|
496 |
|
|
help::
|
497 |
|
|
\t\@echo Targets For $$hashref{'name'}
|
498 |
|
|
\t\@echo -------------------------------------
|
499 |
|
|
\t\@echo $$hashref{'name'} - default build
|
500 |
|
|
\t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
|
501 |
|
|
ENDTEXT
|
502 |
|
|
|
503 |
|
|
# Make generic rules for each type
|
504 |
|
|
$targettypes={
|
505 |
|
|
"bin" => 'o',
|
506 |
|
|
"bin_debug" => 'd',
|
507 |
|
|
"bin_debug_local" => 'l_d',
|
508 |
|
|
"bin_Insure" => 'Insure'
|
509 |
|
|
};
|
510 |
|
|
#
|
511 |
|
|
foreach $target ( keys %$targettypes ) {
|
512 |
|
|
print binGNUmakefile <<ENDTEXT;
|
513 |
|
|
|
514 |
|
|
# Type $target specifics
|
515 |
|
|
ifdef MAKETARGET_$target
|
516 |
|
|
MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
|
517 |
|
|
endif
|
518 |
|
|
$target ::$$hashref{name}_$$targettypes{$target}
|
519 |
|
|
|
520 |
|
|
bintargets+=$$hashref{name}_$$targettypes{$target}
|
521 |
|
|
help::
|
522 |
|
|
\t\@echo $$hashref{name}_$$targettypes{$target}
|
523 |
|
|
clean::
|
524 |
|
|
\t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
|
525 |
|
|
\techo Removing \$(binarystore)/$$hashref{name}; \\
|
526 |
|
|
\trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
|
527 |
|
|
\tfi
|
528 |
|
|
|
529 |
|
|
ENDTEXT
|
530 |
|
|
($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
|
531 |
|
|
${"objectname_$$targettypes{$target}"}=$objectname;
|
532 |
|
|
print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
|
533 |
|
|
} # end loop
|
534 |
|
|
|
535 |
|
|
print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
|
536 |
|
|
print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
|
537 |
|
|
print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
|
538 |
williamc |
1.6 |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
|
539 |
williamc |
1.2 |
print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
|
540 |
|
|
print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
|
541 |
williamc |
1.6 |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
|
542 |
williamc |
1.2 |
print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
|
543 |
|
|
print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
|
544 |
williamc |
1.6 |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
|
545 |
williamc |
1.2 |
print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
|
546 |
|
|
print binGNUmakefile "\t\$(CClinkCmd)\n";
|
547 |
williamc |
1.6 |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
|
548 |
williamc |
1.2 |
print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
|
549 |
|
|
print binGNUmakefile "-include $$hashref{name}.dep\n";
|
550 |
|
|
print binGNUmakefile <<ENDTEXT;
|
551 |
|
|
clean::
|
552 |
|
|
\t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
|
553 |
|
|
\techo Removing \$(binarystore)/$$hashref{name}; \\
|
554 |
|
|
\trm \$(binarystore)/$$hashref{name}; \\
|
555 |
|
|
\tfi
|
556 |
|
|
|
557 |
|
|
$$hashref{name}_d.exe:\$(libslocal_d)
|
558 |
|
|
$$hashref{name}_o.exe:\$(libslocal)
|
559 |
|
|
ifdef MCCABE_DATA_DIR
|
560 |
|
|
$$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
|
561 |
|
|
endif
|
562 |
|
|
$$hashref{name}_Insure.exe:\$(libslocal_I)
|
563 |
|
|
$$hashref{name}_d:$$hashref{name}_d.exe
|
564 |
|
|
\@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
|
565 |
|
|
$$hashref{name}_l_d:$$hashref{name}_l_d.exe
|
566 |
|
|
\@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
|
567 |
|
|
$$hashref{name}_Insure:$$hashref{name}_Insure.exe
|
568 |
|
|
\@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
|
569 |
|
|
$$hashref{name}:$$hashref{name}_d.exe
|
570 |
|
|
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
|
571 |
|
|
$$hashref{name}_o:$$hashref{name}_o.exe
|
572 |
|
|
\@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
|
573 |
|
|
binfiles+=$$hashref{file}
|
574 |
|
|
ENDTEXT
|
575 |
|
|
}
|
576 |
|
|
close binGNUmakefile;
|
577 |
|
|
}
|
578 |
|
|
|
579 |
|
|
sub External_StartTag {
|
580 |
|
|
my $self=shift;
|
581 |
|
|
my $name=shift;
|
582 |
|
|
my $hashref=shift;
|
583 |
sashby |
1.15 |
|
584 |
|
|
$self->verbose(">> External_StartTag: NM ".$name." <<");
|
585 |
williamc |
1.2 |
|
586 |
|
|
my $tool;
|
587 |
|
|
if ( $self->{Arch} ) {
|
588 |
|
|
$self->{switch}->checktag($name,$hashref,'ref');
|
589 |
|
|
|
590 |
|
|
# -- oo toolbox stuff
|
591 |
|
|
# - get the appropriate tool object
|
592 |
|
|
$$hashref{'ref'}=~tr[A-Z][a-z];
|
593 |
|
|
if ( ! exists $$hashref{'version'} ) {
|
594 |
|
|
$tool=$self->{toolbox}->gettool($$hashref{'ref'});
|
595 |
|
|
}
|
596 |
|
|
else {
|
597 |
|
|
$tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
|
598 |
|
|
}
|
599 |
|
|
if ( ! defined $tool ) {
|
600 |
|
|
$self->{switch}->parseerror("Unknown Tool Specified ("
|
601 |
|
|
.$$hashref{'ref'}.")");
|
602 |
|
|
}
|
603 |
|
|
|
604 |
|
|
# -- old fashioned GNUmakefile stuff
|
605 |
|
|
print GNUmakefile $$hashref{'ref'};
|
606 |
|
|
if ( defined $$hashref{'version'} ) {
|
607 |
|
|
print GNUmakefile "_V_".$$hashref{'version'};
|
608 |
|
|
}
|
609 |
|
|
print GNUmakefile "=true\n";
|
610 |
|
|
|
611 |
|
|
# -- Sub system also specified?
|
612 |
|
|
if ( exists $$hashref{'use'} ) {
|
613 |
|
|
# -- look for a buildfile
|
614 |
|
|
my @paths=$tool->getfeature("INCLUDE");
|
615 |
|
|
my $file="";
|
616 |
|
|
my ($path,$testfile);
|
617 |
|
|
foreach $path ( @paths ) {
|
618 |
|
|
$testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
|
619 |
|
|
if ( -f $testfile ) {
|
620 |
|
|
$file=$testfile;
|
621 |
|
|
$self->_pushremoteproject($path);
|
622 |
|
|
}
|
623 |
|
|
}
|
624 |
|
|
if ( $file eq "" ) {
|
625 |
|
|
$self->{switch}->parseerror("Unable to find SubSystem $testfile");
|
626 |
|
|
}
|
627 |
|
|
$self->ParseBuildFile_Export($file);
|
628 |
|
|
$self->_popremoteproject();
|
629 |
|
|
}
|
630 |
|
|
}
|
631 |
|
|
}
|
632 |
|
|
|
633 |
|
|
sub Group_start {
|
634 |
|
|
my $self=shift;
|
635 |
|
|
my $name=shift;
|
636 |
|
|
my $hashref=shift;
|
637 |
|
|
|
638 |
sashby |
1.15 |
$self->verbose(">> Group_start: NM ".$name." <<");
|
639 |
|
|
|
640 |
williamc |
1.2 |
$self->{switch}->checktag($name, $hashref, 'name');
|
641 |
|
|
if ( $self->{Arch} ) {
|
642 |
|
|
print GNUmakefile "GROUP_".$$hashref{'name'};
|
643 |
|
|
if ( defined $$hashref{'version'} ) {
|
644 |
|
|
print GNUmakefile "_V_".$$hashref{'version'};
|
645 |
|
|
}
|
646 |
|
|
print GNUmakefile "=true\n";
|
647 |
|
|
}
|
648 |
|
|
}
|
649 |
williamc |
1.1 |
|
650 |
sashby |
1.15 |
sub Use_start
|
651 |
|
|
{
|
652 |
|
|
my $self=shift;
|
653 |
|
|
my $name=shift;
|
654 |
|
|
my $hashref=shift;
|
655 |
|
|
my $filename;
|
656 |
|
|
use Utilities::SCRAMUtils;
|
657 |
|
|
|
658 |
|
|
$self->verbose(">> Use_start: NM ".$name." <<");
|
659 |
|
|
|
660 |
|
|
$self->{switch}->checktag($name, $hashref, "name");
|
661 |
|
|
if ( $self->{Arch} )
|
662 |
|
|
{
|
663 |
|
|
if ( exists $$hashref{'group'} )
|
664 |
|
|
{
|
665 |
|
|
print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
|
666 |
|
|
}
|
667 |
|
|
if ( ! defined $self->{remoteproject} )
|
668 |
|
|
{
|
669 |
|
|
$filename=SCRAMUtils::checkfile("/$ENV{INTsrc}/$$hashref{name}/BuildFile");
|
670 |
|
|
}
|
671 |
|
|
else
|
672 |
|
|
{
|
673 |
|
|
$filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
|
674 |
|
|
print "Trying $filename\n";
|
675 |
|
|
if ( ! -f $filename ) { $filename=""; };
|
676 |
|
|
}
|
677 |
|
|
if ( $filename ne "" )
|
678 |
|
|
{
|
679 |
|
|
$self->ParseBuildFile_Export( $filename );
|
680 |
|
|
}
|
681 |
|
|
else
|
682 |
|
|
{
|
683 |
|
|
$self->{switch}->parseerror("Unable to detect Appropriate ".
|
684 |
|
|
"decription file for <$name name=".$$hashref{name}.">");
|
685 |
|
|
}
|
686 |
|
|
}
|
687 |
|
|
}
|
688 |
williamc |
1.1 |
|
689 |
williamc |
1.13 |
sub CheckBuildFile {
|
690 |
|
|
my $self=shift;
|
691 |
|
|
my $classdir=shift;
|
692 |
|
|
my $ClassName="";
|
693 |
|
|
my $thisfile="$classdir/$buildfile";
|
694 |
sashby |
1.15 |
|
695 |
williamc |
1.13 |
if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
|
696 |
|
|
$DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
|
697 |
|
|
$self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
|
698 |
|
|
}
|
699 |
|
|
elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
|
700 |
|
|
$DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
|
701 |
|
|
$self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
|
702 |
|
|
}
|
703 |
sashby |
1.15 |
$self->verbose(">> CheckBuildFile: FN ".$thisfile." CN ".$ClassName." <<");
|
704 |
williamc |
1.13 |
return $ClassName;
|
705 |
|
|
}
|
706 |
|
|
|
707 |
williamc |
1.2 |
# List association groups between <AssociateGroup> tags
|
708 |
|
|
# seperated by newlines or spaces
|
709 |
|
|
sub AssociateGroup {
|
710 |
|
|
my $self=shift;
|
711 |
|
|
my $name=shift;
|
712 |
|
|
my $string=shift;
|
713 |
|
|
my $word;
|
714 |
|
|
|
715 |
sashby |
1.15 |
$self->verbose(">> AssociateGroup: NM ".$name." ST ".$string." <<");
|
716 |
|
|
|
717 |
williamc |
1.2 |
if ( $self->{Arch} ) {
|
718 |
|
|
foreach $word ( (split /\s/, $string) ){
|
719 |
|
|
chomp $word;
|
720 |
|
|
next if /^#/;
|
721 |
|
|
if ( $word=~/none/ ) {
|
722 |
|
|
$self->{ignore}=1;
|
723 |
|
|
}
|
724 |
|
|
}
|
725 |
|
|
}
|
726 |
|
|
}
|
727 |
|
|
|
728 |
|
|
sub Arch_Start {
|
729 |
|
|
my $self=shift;
|
730 |
williamc |
1.1 |
my $name=shift;
|
731 |
|
|
my $hashref=shift;
|
732 |
|
|
|
733 |
sashby |
1.15 |
$self->verbose(">> Arch_Start: NM ".$name." <<");
|
734 |
|
|
|
735 |
williamc |
1.2 |
$self->{switch}->checktag($name, $hashref,'name');
|
736 |
|
|
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
|
737 |
|
|
: ($self->{Arch}=0);
|
738 |
|
|
push @{$self->{ARCHBLOCK}}, $self->{Arch};
|
739 |
williamc |
1.1 |
}
|
740 |
|
|
|
741 |
williamc |
1.2 |
sub Arch_End {
|
742 |
williamc |
1.1 |
my $self=shift;
|
743 |
|
|
my $name=shift;
|
744 |
sashby |
1.15 |
|
745 |
|
|
$self->verbose(">> Arch_End: NM ".$name." <<");
|
746 |
williamc |
1.1 |
|
747 |
sashby |
1.15 |
pop @{$self->{ARCHBLOCK}};
|
748 |
williamc |
1.2 |
$self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
|
749 |
|
|
}
|
750 |
|
|
|
751 |
|
|
# Split up the Class Block String into a useable array
|
752 |
|
|
sub _CutBlock {
|
753 |
|
|
my $self=shift;
|
754 |
|
|
my $string= shift @_;
|
755 |
sashby |
1.15 |
|
756 |
|
|
$self->verbose(">> _CutBlock: ST ".$string." <<");
|
757 |
|
|
|
758 |
williamc |
1.2 |
@BlockClassA = split /\//, $string;
|
759 |
|
|
}
|
760 |
|
|
|
761 |
|
|
sub OutToMakefile {
|
762 |
|
|
my $self=shift;
|
763 |
|
|
my $name=shift;
|
764 |
|
|
my @vars=@_;
|
765 |
sashby |
1.15 |
|
766 |
|
|
$self->verbose(">> OutToMakefile: <<");
|
767 |
williamc |
1.2 |
|
768 |
|
|
if ( $self->{Arch} ) {
|
769 |
sashby |
1.16 |
$self->verbose(">> CONT: ".$#vars." lines <<");
|
770 |
williamc |
1.2 |
print GNUmakefile @vars;
|
771 |
|
|
}
|
772 |
|
|
}
|
773 |
|
|
|
774 |
|
|
sub OutToScreen {
|
775 |
|
|
my $name=shift;
|
776 |
|
|
my @vars=@_;
|
777 |
sashby |
1.15 |
|
778 |
williamc |
1.2 |
if ( $self->{Arch} ) {
|
779 |
|
|
print @vars;
|
780 |
|
|
}
|
781 |
|
|
}
|
782 |
|
|
sub setBlockClassPath {
|
783 |
|
|
my $self=shift;
|
784 |
|
|
my $name=shift;
|
785 |
|
|
my $hashref=shift;
|
786 |
|
|
|
787 |
sashby |
1.15 |
$self->verbose(">> setBlockClassPath: NM ".$name." <<");
|
788 |
|
|
|
789 |
williamc |
1.2 |
$self->{switch}->checktag($name, $hashref, 'path');
|
790 |
|
|
$self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
|
791 |
|
|
$self->_CutBlock($$hashref{path});
|
792 |
|
|
}
|
793 |
|
|
|
794 |
|
|
sub BlockClassPath {
|
795 |
|
|
my $self=shift;
|
796 |
sashby |
1.15 |
|
797 |
|
|
$self->verbose(">> BlockClassPath: <<");
|
798 |
|
|
|
799 |
williamc |
1.2 |
return $self->{BlockClassPath};
|
800 |
|
|
}
|
801 |
|
|
|
802 |
|
|
sub export_start_export {
|
803 |
|
|
my $self=shift;
|
804 |
|
|
my $name=shift;
|
805 |
|
|
my $hashref=shift;
|
806 |
|
|
|
807 |
sashby |
1.15 |
$self->verbose(">> export_start_export: NM ".$name." <<");
|
808 |
|
|
|
809 |
williamc |
1.2 |
$self->{switch}->opengroup("__export");
|
810 |
|
|
}
|
811 |
|
|
|
812 |
|
|
sub export_start {
|
813 |
|
|
my $self=shift;
|
814 |
|
|
my $name=shift;
|
815 |
|
|
my $hashref=shift;
|
816 |
|
|
|
817 |
sashby |
1.15 |
$self->verbose(">> export_start: NM ".$name." <<");
|
818 |
|
|
|
819 |
williamc |
1.2 |
$self->{switch}->opengroup("__export");
|
820 |
|
|
if ( exists $$hashref{autoexport} ) {
|
821 |
|
|
print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
|
822 |
|
|
if ( $$hashref{autoexport}=~/true/ ) {
|
823 |
|
|
$self->{switch}->allowgroup("__export","makebuild");
|
824 |
|
|
}
|
825 |
|
|
else {
|
826 |
|
|
$self->{switch}->disallowgroup("__export","makebuild");
|
827 |
|
|
}
|
828 |
|
|
}
|
829 |
|
|
# -- allow default setting from other makefiles
|
830 |
|
|
print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
|
831 |
|
|
}
|
832 |
|
|
|
833 |
|
|
sub export_end_export {
|
834 |
|
|
my $self=shift;
|
835 |
sashby |
1.15 |
$self->verbose(">> export_end_export: <<");
|
836 |
williamc |
1.2 |
$self->{switch}->closegroup("__export");
|
837 |
|
|
}
|
838 |
williamc |
1.1 |
|
839 |
williamc |
1.2 |
sub export_end {
|
840 |
|
|
my $self=shift;
|
841 |
sashby |
1.15 |
$self->verbose(">> export_end: <<");
|
842 |
williamc |
1.2 |
$self->{switch}->closegroup("__export");
|
843 |
|
|
print GNUmakefile "endif\n";
|
844 |
williamc |
1.1 |
}
|
845 |
|
|
|
846 |
williamc |
1.2 |
#
|
847 |
|
|
# Standard lib tag
|
848 |
|
|
#
|
849 |
|
|
sub lib_start {
|
850 |
williamc |
1.1 |
my $self=shift;
|
851 |
|
|
my $name=shift;
|
852 |
|
|
my $hashref=shift;
|
853 |
sashby |
1.15 |
|
854 |
|
|
$self->verbose(">> lib_start: NM ".$name." <<");
|
855 |
|
|
|
856 |
|
|
$self->{switch}->checktag($name, $hashref, 'name');
|
857 |
williamc |
1.1 |
|
858 |
sashby |
1.15 |
if ( $self->{Arch} ) {
|
859 |
williamc |
1.2 |
print GNUmakefile "lib+=$$hashref{name}\n";
|
860 |
|
|
}
|
861 |
|
|
}
|
862 |
|
|
|
863 |
|
|
#
|
864 |
|
|
# libtype specification
|
865 |
|
|
#
|
866 |
|
|
sub LibType_Start {
|
867 |
|
|
my $self=shift;
|
868 |
|
|
my $name=shift;
|
869 |
|
|
my $hashref=shift;
|
870 |
sashby |
1.15 |
|
871 |
|
|
$self->verbose(">> LibType_Start: NM ".$name." <<");
|
872 |
|
|
|
873 |
williamc |
1.2 |
if ( $self->{Arch} ) {
|
874 |
|
|
if ( defined $self->{libtype_conext} ) {
|
875 |
|
|
$self->{switch}->parseerror("<$name> tag cannot be specified".
|
876 |
|
|
" without a </$name> tag to close previous context");
|
877 |
williamc |
1.1 |
}
|
878 |
|
|
else {
|
879 |
williamc |
1.2 |
$self->{libtype_conext}=1;
|
880 |
|
|
$self->{switch}->checktag($name, $hashref, 'type');
|
881 |
|
|
|
882 |
|
|
print GNUmakefile "# Specify Library Type\n";
|
883 |
|
|
print GNUmakefile "DefaultLibsOff=yes\n";
|
884 |
|
|
if ( $$hashref{'type'}=~/^archive/i ) {
|
885 |
|
|
print GNUmakefile "LibArchive=true\n";
|
886 |
|
|
}
|
887 |
|
|
elsif ($$hashref{'type'}=~/debug_archive/i ) {
|
888 |
|
|
print GNUmakefile "LibDebugArchive=true\n";
|
889 |
|
|
}
|
890 |
|
|
elsif ($$hashref{'type'}=~/debug_shared/i ) {
|
891 |
|
|
print GNUmakefile "LibDebugShared=true\n";
|
892 |
|
|
}
|
893 |
|
|
elsif ($$hashref{'type'}=~/shared/i ) {
|
894 |
|
|
print GNUmakefile 'LibShared=true'."\n";
|
895 |
williamc |
1.1 |
}
|
896 |
williamc |
1.2 |
print GNUmakefile "\n";
|
897 |
|
|
}
|
898 |
|
|
}
|
899 |
|
|
}
|
900 |
williamc |
1.1 |
|
901 |
williamc |
1.2 |
sub LibType_text {
|
902 |
williamc |
1.1 |
my $self=shift;
|
903 |
|
|
my $name=shift;
|
904 |
williamc |
1.2 |
my $string=shift;
|
905 |
sashby |
1.15 |
$self->verbose(">> LibType_text: NM ".$name." <<");
|
906 |
williamc |
1.1 |
|
907 |
sashby |
1.15 |
if ( $self->{Arch} ) {
|
908 |
williamc |
1.2 |
$string=~s/\n/ /g;
|
909 |
|
|
print GNUmakefile "libmsg::\n\t\@echo Library info: ";
|
910 |
|
|
print GNUmakefile $string;
|
911 |
|
|
print GNUmakefile "\n";
|
912 |
|
|
}
|
913 |
williamc |
1.1 |
}
|
914 |
|
|
|
915 |
williamc |
1.2 |
sub LibType_end {
|
916 |
williamc |
1.1 |
my $self=shift;
|
917 |
|
|
my $name=shift;
|
918 |
|
|
|
919 |
sashby |
1.15 |
$self->verbose(">> LibType_end: NM ".$name." <<");
|
920 |
|
|
|
921 |
williamc |
1.2 |
undef $self->{libtype_conext};
|
922 |
williamc |
1.1 |
}
|
923 |
|
|
|
924 |
williamc |
1.2 |
sub Environment_start {
|
925 |
williamc |
1.1 |
my $self=shift;
|
926 |
|
|
my $name=shift;
|
927 |
|
|
my $hashref=shift;
|
928 |
williamc |
1.2 |
|
929 |
sashby |
1.15 |
$self->verbose(">> Environment_start: NM ".$name." <<");
|
930 |
|
|
|
931 |
williamc |
1.2 |
if ( $self->{Arch} ) {
|
932 |
|
|
$self->{envnum}++;
|
933 |
|
|
|
934 |
|
|
# open a new Environment File
|
935 |
williamc |
1.13 |
my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
|
936 |
williamc |
1.2 |
$self->{envnum}.".mk";
|
937 |
|
|
use FileHandle;
|
938 |
|
|
my $fh=FileHandle->new();
|
939 |
|
|
open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
|
940 |
|
|
push @{$self->{filehandlestack}}, $fh;
|
941 |
|
|
*GNUmakefile=$fh;
|
942 |
|
|
|
943 |
|
|
# include the approprate environment file
|
944 |
|
|
if ( $self->{envlevel} == 0 ) {
|
945 |
williamc |
1.13 |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
|
946 |
williamc |
1.2 |
$self->{path}."/BuildFile.mk\n";
|
947 |
|
|
}
|
948 |
|
|
else {
|
949 |
williamc |
1.13 |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
|
950 |
williamc |
1.2 |
$self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
|
951 |
|
|
}
|
952 |
|
|
$self->{envlevel}++;
|
953 |
|
|
$self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
|
954 |
williamc |
1.13 |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
|
955 |
williamc |
1.2 |
}
|
956 |
williamc |
1.1 |
}
|
957 |
|
|
|
958 |
williamc |
1.2 |
sub Environment_end {
|
959 |
williamc |
1.1 |
my $self=shift;
|
960 |
williamc |
1.2 |
my $fd;
|
961 |
|
|
|
962 |
sashby |
1.15 |
$self->verbose(">> Environment_end: NM ".$name." <<");
|
963 |
|
|
|
964 |
williamc |
1.2 |
if ( $self->{Arch} ) {
|
965 |
|
|
$self->{envlevel}--;
|
966 |
|
|
if ( $self->{envlevel} < 0 ) {
|
967 |
|
|
print "Too many </Environent> Tags on $self->{switch}->line()\n";
|
968 |
|
|
exit 1;
|
969 |
|
|
}
|
970 |
|
|
close GNUmakefile;
|
971 |
|
|
# restore the last filehandle
|
972 |
|
|
$fd=pop @{$self->{filehandlestack}};
|
973 |
|
|
close $fd;
|
974 |
|
|
*GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
|
975 |
|
|
if ( $self->{envlevel} < 1 ) {
|
976 |
williamc |
1.13 |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
|
977 |
williamc |
1.2 |
"BuildFile.mk";
|
978 |
|
|
}
|
979 |
|
|
else {
|
980 |
|
|
$self->{currentenv}=
|
981 |
williamc |
1.13 |
"$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
|
982 |
williamc |
1.2 |
$self->{Envlevels}[$self->{envlevel}];
|
983 |
|
|
}
|
984 |
williamc |
1.8 |
}
|
985 |
|
|
}
|
986 |
|
|
|
987 |
|
|
sub Store_start {
|
988 |
williamc |
1.12 |
my $self=shift;
|
989 |
|
|
my $name=shift;
|
990 |
williamc |
1.8 |
my $hashref=shift;
|
991 |
|
|
|
992 |
sashby |
1.15 |
$self->verbose(">> Store_start: NM ".$name." <<");
|
993 |
|
|
|
994 |
williamc |
1.12 |
if ( $self->{Arch} ) {
|
995 |
|
|
$self->{switch}->checktag( $name, $hashref, 'name' );
|
996 |
williamc |
1.8 |
|
997 |
williamc |
1.12 |
# -- store creation
|
998 |
|
|
my $dir=$$hashref{'name'};
|
999 |
williamc |
1.13 |
AddDir::adddir($ENV{LOCALTOP}."/".$dir);
|
1000 |
williamc |
1.12 |
if ( exists $$hashref{'type'} ) {
|
1001 |
|
|
# -- architecture specific store
|
1002 |
|
|
if ( $$hashref{'type'}=~/^arch/i ) {
|
1003 |
|
|
$dir=$dir."/".$ENV{SCRAM_ARCH};
|
1004 |
williamc |
1.13 |
AddDir::adddir($ENV{LOCALTOP}."/".$dir);
|
1005 |
williamc |
1.12 |
}
|
1006 |
|
|
else {
|
1007 |
|
|
$self->parseerror("Unknown type in <$name> tag");
|
1008 |
|
|
}
|
1009 |
|
|
}
|
1010 |
|
|
|
1011 |
|
|
# -- set make variables for the store
|
1012 |
|
|
print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
|
1013 |
|
|
print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
|
1014 |
williamc |
1.13 |
$ENV{LOCALTOP}."/".$dir."\n";
|
1015 |
|
|
print GNUmakefile "VPATH+=".$ENV{LOCALTOP}
|
1016 |
|
|
."/".$dir.":".$ENV{RELEASETOP}."/".$dir."\n";
|
1017 |
williamc |
1.12 |
}
|
1018 |
williamc |
1.8 |
}
|