7 |
|
BEGIN { |
8 |
|
use ToolBox; |
9 |
|
$buildfile="BuildFile"; |
10 |
< |
#$toolbox=ToolBox->new(); |
10 |
> |
$toolbox=ToolBox->new(); |
11 |
> |
$Arch=1; |
12 |
> |
push @ARCHBLOCK, $Arch; |
13 |
|
} |
14 |
|
|
15 |
|
#Parse the BuildFile |
16 |
|
sub ParseBuildFile { |
17 |
|
my $base=shift; |
18 |
< |
my $path=shift; |
18 |
> |
$path=shift; |
19 |
|
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 |
+ |
$numbins=0; |
24 |
+ |
$envnum=0; |
25 |
+ |
$envlevel=0; |
26 |
+ |
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk"; |
27 |
|
my $SupportedTags={ |
28 |
|
'Use' => \&OutToMakefile, |
29 |
|
'Use_StartTag' => \&Use_start, |
35 |
|
'ConfigurationClass' => \&OutToMakefile, |
36 |
|
'AssociateGroup' => \&AssociateGroup, |
37 |
|
'none' => \&OutToMakefile, |
38 |
< |
'Bin' => \&OutToMakefile, |
38 |
> |
'Bin' => 'none', |
39 |
|
'Bin_StartTag' => \&Bin_start, |
40 |
|
'ClassPath' => \&OutToMakefile, |
41 |
< |
'ClassPath_StartTag' => \&setBlockClassPath |
41 |
> |
'ClassPath_StartTag' => \&setBlockClassPath, |
42 |
> |
'Environment' => \&OutToMakefile, |
43 |
> |
'Environment_StartTag' => \&Environment_start, |
44 |
> |
'Environment_EndTag' => \&Environment_end, |
45 |
> |
'export' => \&OutToMakefile, |
46 |
> |
'export_StartTag' => \&export_start, |
47 |
> |
'export_EndTag' => \&export_end, |
48 |
> |
'lib' => 'none', |
49 |
> |
'lib_StartTag' => \&lib_start, |
50 |
> |
'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 |
> |
'Architecture' => \&OutToMakefile, |
57 |
> |
'LibType_StartTag' => \&LibType_Start, |
58 |
> |
'LibType_EndTag' => 'none', |
59 |
> |
#'LibType' => \&OutToScreen |
60 |
> |
'LibType' => \&LibType_text |
61 |
|
}; |
62 |
|
use Utilities::Switcher; |
63 |
|
$switch=Switcher->new($SupportedTags, $fullfilename); |
64 |
|
$switch->{Strict_no_cr}='no'; |
65 |
|
#open a temporary gnumakefile to store output. |
66 |
|
use Utilities::AddDir; |
67 |
< |
adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}"); |
68 |
< |
open ( GNUmakefile, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk") or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n'; |
67 |
> |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}"); |
68 |
> |
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 |
|
if ( -e $ENV{LatestBuildFile} ) { |
77 |
|
print GNUmakefile "include $ENV{LatestBuildFile}\n"; |
78 |
|
} |
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 |
+ |
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 |
|
close GNUmakefile; |
101 |
|
} |
102 |
|
|
103 |
+ |
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 |
+ |
'export_StartTag' => \&export_start, |
111 |
+ |
'export_EndTag' => \&export_end, |
112 |
+ |
'lib_StartTag' => \&lib_start_export, |
113 |
+ |
'External_StartTag' => \&Ext_start_export, |
114 |
+ |
'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 |
|
sub initialterms() { |
123 |
|
my $name=shift; |
124 |
|
my @string=@_; |
148 |
|
my @vars=@_; |
149 |
|
|
150 |
|
$hashref=$switch->SetupValueHash(\@vars); |
151 |
+ |
if ( $Arch ) { |
152 |
|
if ( defined $$hashref{'type'} ) { |
153 |
|
$ClassName=$$hashref{'type'}; |
154 |
|
} |
155 |
+ |
} |
156 |
|
} |
157 |
|
|
158 |
|
sub ClassPath_StartTag { |
161 |
|
my $hashref; |
162 |
|
|
163 |
|
$hashref=$switch->SetupValueHash(\@vars); |
164 |
+ |
if ( $Arch ) { |
165 |
|
if ( defined $$hashref{'defaultpath'} ) { |
166 |
|
} |
167 |
+ |
} |
168 |
|
} |
169 |
|
|
170 |
|
sub Bin_start { |
174 |
|
my $fileclass; |
175 |
|
my @tools; |
176 |
|
my $tool; |
177 |
+ |
my $filename; |
178 |
+ |
my $objectname; |
179 |
|
|
180 |
|
$hashref=$switch->SetupValueHash(\@vars); |
181 |
|
$switch->checkparam($hashref, $name, 'file'); |
182 |
+ |
if ( $Arch ) { |
183 |
|
if ( ! defined $$hashref{name} ) { |
184 |
|
($$hashref{name}=$$hashref{file})=~s/\..*//; |
185 |
|
} |
186 |
< |
$fileclass=getclass($file); |
187 |
< |
$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file ); |
188 |
< |
print GNUmakefile "bin::$file\n\n"; |
186 |
> |
# This stuff for later |
187 |
> |
#$fileclass=$toolbox->getclass($file); |
188 |
> |
#$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file ); |
189 |
> |
|
190 |
> |
($filename=$$hashref{file})=~s/\..*//; |
191 |
> |
|
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 |
> |
my $fh=$filehandlestack[0]; |
202 |
> |
print $fh <<ENDTEXT; |
203 |
> |
|
204 |
> |
# Link Targets to binary directories |
205 |
> |
ifndef BINMODE |
206 |
> |
|
207 |
> |
define stepdown_$$hashref{'name'} |
208 |
> |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\ |
209 |
> |
cd $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\ |
210 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk \$\@; \\ |
211 |
> |
fi |
212 |
> |
endef |
213 |
> |
|
214 |
> |
define stepdown2_$$hashref{'name'} |
215 |
> |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\ |
216 |
> |
cd $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\ |
217 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk \$\*; \\ |
218 |
> |
fi |
219 |
> |
|
220 |
> |
endef |
221 |
> |
|
222 |
> |
bin_$$hashref{'name'}_%:: dummy |
223 |
> |
\@\$(stepdown2_$$hashref{'name'}) |
224 |
> |
|
225 |
> |
$$hashref{'name'}_%:: dummy |
226 |
> |
\@\$(stepdown_$$hashref{'name'}) |
227 |
> |
|
228 |
> |
help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy |
229 |
> |
\@\$(stepdown_$$hashref{'name'}) |
230 |
> |
|
231 |
> |
binfiles+=$$hashref{'file'} |
232 |
> |
endif |
233 |
> |
|
234 |
> |
|
235 |
> |
ENDTEXT |
236 |
> |
|
237 |
> |
|
238 |
> |
# the binary specifics makefile |
239 |
> |
print binGNUmakefile "include $currentenv\n"; |
240 |
> |
print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/${path}\n"; |
241 |
> |
|
242 |
> |
# alias for bin_Insure |
243 |
> |
print binGNUmakefile <<ENDTEXT; |
244 |
> |
|
245 |
> |
bin_insure:bin_Insure |
246 |
> |
ifdef MAKETARGET_bin_insure |
247 |
> |
MAKETARGET_$$hashref{name}_Insure=1 |
248 |
> |
endif |
249 |
> |
|
250 |
> |
# debuggging target |
251 |
> |
$$hashref{'name'}_echo_% :: echo_% |
252 |
> |
|
253 |
> |
# help targets |
254 |
> |
help:: |
255 |
> |
\t\@echo Targets For $$hashref{'name'} |
256 |
> |
\t\@echo ------------------------------------- |
257 |
> |
\t\@echo $$hashref{'name'} - default build |
258 |
> |
\t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning |
259 |
> |
ENDTEXT |
260 |
> |
|
261 |
> |
# Make generic rules for each type |
262 |
> |
$targettypes={ |
263 |
> |
"bin" => 'o', |
264 |
> |
"bin_debug" => 'd', |
265 |
> |
"bin_debug_local" => 'l_d', |
266 |
> |
"bin_Insure" => 'Insure' |
267 |
> |
}; |
268 |
> |
# |
269 |
> |
foreach $target ( keys %$targettypes ) { |
270 |
> |
print binGNUmakefile <<ENDTEXT; |
271 |
> |
|
272 |
> |
# Type $target specifics |
273 |
> |
ifdef MAKETARGET_$target |
274 |
> |
MAKETARGET_$$hashref{name}_$$targettypes{$target}=1 |
275 |
> |
endif |
276 |
> |
$target ::$$hashref{name}_$$targettypes{$target} |
277 |
> |
|
278 |
> |
bintargets+=$$hashref{name}_$$targettypes{$target} |
279 |
> |
help:: |
280 |
> |
\t\@echo $$hashref{name}_$$targettypes{$target} |
281 |
> |
clean:: |
282 |
> |
\t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\ |
283 |
> |
\techo Removing \$(binarystore)/$$hashref{name}; \\ |
284 |
> |
\trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\ |
285 |
> |
\tfi |
286 |
> |
|
287 |
> |
ENDTEXT |
288 |
> |
($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/; |
289 |
> |
${"objectname_$$targettypes{$target}"}=$objectname; |
290 |
> |
print binGNUmakefile "$objectname:$$hashref{name}.dep\n"; |
291 |
> |
} # end loop |
292 |
> |
|
293 |
> |
print binGNUmakefile "$$hashref{name}_Insure:.psrc\n"; |
294 |
> |
print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n"; |
295 |
> |
print binGNUmakefile "\t\$(CClinkCmdDebug)\n"; |
296 |
> |
print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n"; |
297 |
> |
print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n"; |
298 |
> |
print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n"; |
299 |
> |
print binGNUmakefile "\t\$(CClinkCmdInsure)\n"; |
300 |
> |
print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n"; |
301 |
> |
print binGNUmakefile "\t\$(CClinkCmd)\n"; |
302 |
> |
print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n"; |
303 |
> |
print binGNUmakefile "-include $$hashref{name}.dep\n"; |
304 |
> |
print binGNUmakefile <<ENDTEXT; |
305 |
> |
clean:: |
306 |
> |
\t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\ |
307 |
> |
\techo Removing \$(binarystore)/$$hashref{name}; \\ |
308 |
> |
\trm \$(binarystore)/$$hashref{name}; \\ |
309 |
> |
\tfi |
310 |
> |
|
311 |
> |
$$hashref{name}_d.exe:\$(libslocal_d) |
312 |
> |
$$hashref{name}_o.exe:\$(libslocal) |
313 |
> |
ifdef MCCABE_DATA_DIR |
314 |
> |
$$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp |
315 |
> |
endif |
316 |
> |
$$hashref{name}_Insure.exe:\$(libslocal_I) |
317 |
> |
$$hashref{name}_d:$$hashref{name}_d.exe |
318 |
> |
\@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
319 |
> |
$$hashref{name}_l_d:$$hashref{name}_l_d.exe |
320 |
> |
\@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name} |
321 |
> |
$$hashref{name}_Insure:$$hashref{name}_Insure.exe |
322 |
> |
\@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure |
323 |
> |
$$hashref{name}:$$hashref{name}_d.exe |
324 |
> |
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
325 |
> |
$$hashref{name}_o:$$hashref{name}_o.exe |
326 |
> |
\@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name} |
327 |
> |
binfiles+=$$hashref{file} |
328 |
> |
ENDTEXT |
329 |
> |
} |
330 |
> |
close binGNUmakefile; |
331 |
> |
} |
332 |
> |
|
333 |
> |
sub Ext_start_export { |
334 |
> |
my $name=shift; |
335 |
> |
my @vars=@_; |
336 |
> |
my $hashref; |
337 |
> |
|
338 |
> |
$hashref=$switch->SetupValueHash(\@vars); |
339 |
> |
if ( $Arch ) { |
340 |
> |
if ( $switchex->context('export') ) { |
341 |
> |
$$hashref{'ref'}=~tr[A-Z][a-z]; |
342 |
> |
print GNUmakefile $$hashref{'ref'}; |
343 |
> |
if ( defined $$hashref{'version'} ) { |
344 |
> |
print GNUmakefile "_V_".$$hashref{'version'}; |
345 |
> |
} |
346 |
> |
print GNUmakefile "=true\n"; |
347 |
> |
} |
348 |
> |
} |
349 |
|
} |
350 |
|
|
351 |
|
sub External_StartTag { |
354 |
|
my $hashref; |
355 |
|
|
356 |
|
$hashref=$switch->SetupValueHash(\@vars); |
357 |
+ |
if ( $Arch ) { |
358 |
+ |
$$hashref{'ref'}=~tr[A-Z][a-z]; |
359 |
|
print GNUmakefile $$hashref{'ref'}; |
360 |
|
if ( defined $$hashref{'version'} ) { |
361 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
362 |
|
} |
363 |
|
print GNUmakefile "=true\n"; |
364 |
+ |
} |
365 |
|
|
366 |
|
} |
367 |
|
|
372 |
|
|
373 |
|
$hashref=$switch->SetupValueHash(\@vars); |
374 |
|
$switch->checkparam($hashref, $name, 'name'); |
375 |
+ |
if ( $Arch ) { |
376 |
|
print GNUmakefile "GROUP_".$$hashref{'name'}; |
377 |
|
if ( defined $$hashref{'version'} ) { |
378 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
379 |
|
} |
380 |
|
print GNUmakefile "=true\n"; |
381 |
+ |
} |
382 |
|
} |
383 |
|
|
384 |
|
sub External { |
405 |
|
|
406 |
|
$hashref=$switch->SetupValueHash(\@vars); |
407 |
|
$switch->checkparam($hashref, $name, "name"); |
408 |
< |
if ( $filename=checkfile("$ENV{INTsrc}/$$hashref{name}/BuildFile") |
409 |
< |
ne "" ) { |
410 |
< |
print GNUmakefile "ReqDependencies += $filename\n"; |
408 |
> |
if ( $Arch ) { |
409 |
> |
$filename=SCRAMUtils::checkfile( |
410 |
> |
"$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
411 |
> |
if ( $filename ne "" ) { |
412 |
> |
ParseBuildFile_Export( $filename ); |
413 |
> |
} |
414 |
|
} |
172 |
– |
print GNUmakefile "local__$$hashref{name}=true\n"; |
415 |
|
} |
416 |
|
|
417 |
< |
sub CheckBuildFile($directory) { |
417 |
> |
sub CheckBuildFile { |
418 |
|
my $classdir=shift; |
419 |
|
$ClassName=""; |
420 |
|
$thisfile="$classdir/$buildfile"; |
444 |
|
} |
445 |
|
} |
446 |
|
|
447 |
+ |
sub ignoretag { |
448 |
+ |
my $name=shift; |
449 |
+ |
my @vars=@_; |
450 |
+ |
|
451 |
+ |
$Arch=0; |
452 |
+ |
push @ARCHBLOCK, $Arch; |
453 |
+ |
} |
454 |
+ |
|
455 |
+ |
sub ignoretag_end { |
456 |
+ |
my $name=shift; |
457 |
+ |
my @vars=@_; |
458 |
+ |
|
459 |
+ |
pop @ARCHBLOCK; |
460 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
461 |
+ |
} |
462 |
+ |
|
463 |
+ |
sub Arch_Start { |
464 |
+ |
my $name=shift; |
465 |
+ |
my @vars=@_; |
466 |
+ |
my $hashref; |
467 |
+ |
|
468 |
+ |
$hashref=$toolswitch->SetupValueHash( \@vars ); |
469 |
+ |
$toolswitch->checkparam($hashref, $name, 'name'); |
470 |
+ |
#( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0; |
471 |
+ |
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0); |
472 |
+ |
push @ARCHBLOCK, $Arch; |
473 |
+ |
} |
474 |
+ |
sub Arch_End { |
475 |
+ |
my $name=shift; |
476 |
+ |
my @vars=@_; |
477 |
+ |
|
478 |
+ |
pop @ARCHBLOCK; |
479 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
480 |
+ |
} |
481 |
+ |
|
482 |
|
# Split up the Class Block String into a useable array |
483 |
< |
sub _CutBlock($string) { |
483 |
> |
sub _CutBlock { |
484 |
|
my $string= shift @_; |
485 |
|
@BlockClassA = split /\//, $string; |
486 |
|
} |
489 |
|
my $name=shift; |
490 |
|
my @vars=@_; |
491 |
|
|
492 |
< |
print GNUmakefile @vars; |
492 |
> |
if ( $Arch ) { |
493 |
> |
print GNUmakefile @vars; |
494 |
> |
} |
495 |
> |
} |
496 |
> |
sub OutToScreen { |
497 |
> |
my $name=shift; |
498 |
> |
my @vars=@_; |
499 |
> |
|
500 |
> |
if ( $Arch ) { |
501 |
> |
print @vars; |
502 |
> |
} |
503 |
|
} |
504 |
|
sub setBlockClassPath { |
505 |
|
my $name=shift; |
511 |
|
$BlockClassPath=$BlockClassPath.":".$$hashref{path}; |
512 |
|
_CutBlock($$hashref{path}); |
513 |
|
} |
514 |
+ |
|
515 |
+ |
sub export_start { |
516 |
+ |
#Set up a toolfile object |
517 |
+ |
$exporttool=Tool->new(); |
518 |
+ |
print GNUmakefile "ifeq (\$(scram_autoexport),true)\n"; |
519 |
+ |
} |
520 |
+ |
|
521 |
+ |
sub export_end { |
522 |
+ |
#Write toolfile object to disk |
523 |
+ |
$exporttool->envtomake(\*GNUmakefile); |
524 |
+ |
print GNUmakefile "endif\n"; |
525 |
+ |
} |
526 |
+ |
|
527 |
+ |
# |
528 |
+ |
# Export Mode Lib Tag |
529 |
+ |
# |
530 |
+ |
sub lib_start_export { |
531 |
+ |
my $name=shift; |
532 |
+ |
my @vars=@_; |
533 |
+ |
my $hashref; |
534 |
+ |
|
535 |
+ |
$hashref=$switchex->SetupValueHash( \@vars ); |
536 |
+ |
$switchex->checkparam($hashref, $name, 'name'); |
537 |
+ |
if ( $Arch ) { |
538 |
+ |
if ( $switchex->context('export') ) { |
539 |
+ |
#If export mode then add this env to the export tool |
540 |
+ |
$exporttool->addenv('lib',$$hashref{name}); |
541 |
+ |
} |
542 |
+ |
} |
543 |
+ |
} |
544 |
+ |
|
545 |
+ |
# |
546 |
+ |
# Standard lib tag |
547 |
+ |
# |
548 |
+ |
sub lib_start { |
549 |
+ |
my $name=shift; |
550 |
+ |
my @vars=@_; |
551 |
+ |
my $hashref; |
552 |
+ |
|
553 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
554 |
+ |
$switch->checkparam($hashref, $name, 'name'); |
555 |
+ |
if ( $Arch ) { |
556 |
+ |
print GNUmakefile "lib+=$$hashref{name}\n"; |
557 |
+ |
} |
558 |
+ |
} |
559 |
+ |
|
560 |
+ |
# |
561 |
+ |
# libtype specification |
562 |
+ |
# |
563 |
+ |
sub LibType_Start { |
564 |
+ |
my $name=shift; |
565 |
+ |
my @vars=@_; |
566 |
+ |
my $hashref; |
567 |
+ |
|
568 |
+ |
if ( $Arch ) { |
569 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
570 |
+ |
$switch->checkparam($hashref, $name, 'type'); |
571 |
+ |
|
572 |
+ |
print GNUmakefile "# Specify Library Type\n"; |
573 |
+ |
print GNUmakefile "DefaultLibsOff=yes\n"; |
574 |
+ |
if ( $$hashref{'type'}=~/^archive/i ) { |
575 |
+ |
print GNUmakefile "LibArchive=true\n"; |
576 |
+ |
} |
577 |
+ |
elsif ($$hashref{'type'}=~/debug_archive/i ) { |
578 |
+ |
print GNUmakefile "LibDebugArchive=true\n"; |
579 |
+ |
} |
580 |
+ |
elsif ($$hashref{'type'}=~/debug_shared/i ) { |
581 |
+ |
print GNUmakefile "LibDebugShared=true\n"; |
582 |
+ |
} |
583 |
+ |
elsif ($$hashref{'type'}=~/shared/i ) { |
584 |
+ |
print GNUmakefile 'LibShared=true'."\n"; |
585 |
+ |
} |
586 |
+ |
print GNUmakefile "\n"; |
587 |
+ |
} |
588 |
+ |
} |
589 |
+ |
sub LibType_text { |
590 |
+ |
my $name=shift; |
591 |
+ |
my @vars=@_; |
592 |
+ |
|
593 |
+ |
if ( $Arch ) { |
594 |
+ |
print GNUmakefile "libmsg::\n\t\@echo Library info: "; |
595 |
+ |
print GNUmakefile @vars; |
596 |
+ |
print GNUmakefile "\n"; |
597 |
+ |
} |
598 |
+ |
} |
599 |
+ |
|
600 |
+ |
sub Environment_start { |
601 |
+ |
my $name=shift; |
602 |
+ |
my @vars=@_; |
603 |
+ |
my $hashref; |
604 |
+ |
|
605 |
+ |
if ( $Arch ) { |
606 |
+ |
$envnum++; |
607 |
+ |
|
608 |
+ |
# open a new Environment File |
609 |
+ |
my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk"; |
610 |
+ |
use FileHandle; |
611 |
+ |
my $fh=FileHandle->new(); |
612 |
+ |
open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n"; |
613 |
+ |
push @filehandlestack, $fh; |
614 |
+ |
*GNUmakefile=$fh; |
615 |
+ |
|
616 |
+ |
# include the approprate environment file |
617 |
+ |
if ( $envlevel == 0 ) { |
618 |
+ |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/". |
619 |
+ |
"BuildFile.mk\n"; |
620 |
+ |
} |
621 |
+ |
else { |
622 |
+ |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/". |
623 |
+ |
"Env_$Envlevels[$envlevel]\.mk\n"; |
624 |
+ |
} |
625 |
+ |
$envlevel++; |
626 |
+ |
$Envlevels[$envlevel]=$envnum; |
627 |
+ |
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk"; |
628 |
+ |
} |
629 |
+ |
} |
630 |
+ |
|
631 |
+ |
sub Environment_end { |
632 |
+ |
my $fd; |
633 |
+ |
|
634 |
+ |
if ( $Arch ) { |
635 |
+ |
$envlevel--; |
636 |
+ |
if ( $envlevel < 0 ) { |
637 |
+ |
print "Too many </Environent> Tags on $switch->line()\n"; |
638 |
+ |
exit; |
639 |
+ |
} |
640 |
+ |
close GNUmakefile; |
641 |
+ |
# restore the last filehandle |
642 |
+ |
$fd=pop @filehandlestack; |
643 |
+ |
close $fd; |
644 |
+ |
*GNUmakefile=$filehandlestack[$#filehandlestack]; |
645 |
+ |
if ( $envlevel < 1 ) { |
646 |
+ |
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk"; |
647 |
+ |
} |
648 |
+ |
else { |
649 |
+ |
$currentenv= |
650 |
+ |
"$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$Envlevels[$envlevel]"; |
651 |
+ |
} |
652 |
+ |
} |
653 |
+ |
} |