8 |
|
use ToolBox; |
9 |
|
$buildfile="BuildFile"; |
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, |
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 |
> |
'lib' => 'none', |
46 |
> |
'lib_StartTag' => \&lib_start, |
47 |
> |
'lib_EndTag' => 'none', |
48 |
> |
'ignore' => 'none', |
49 |
> |
'ignore_EndTag' => \&ignoretag_end, |
50 |
> |
'ignore_StartTag' => \&ignoretag, |
51 |
> |
'Architecture_StartTag' => \&Arch_Start, |
52 |
> |
'Architecture_EndTag' => \&Arch_End, |
53 |
> |
'Architecture' => \&OutToMakefile, |
54 |
> |
'LibType_StartTag' => \&LibType_Start, |
55 |
> |
'LibType_EndTag' => 'none', |
56 |
> |
#'LibType' => \&OutToScreen |
57 |
> |
'LibType' => \&LibType_text |
58 |
|
}; |
59 |
|
use Utilities::Switcher; |
60 |
|
$switch=Switcher->new($SupportedTags, $fullfilename); |
62 |
|
#open a temporary gnumakefile to store output. |
63 |
|
use Utilities::AddDir; |
64 |
|
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}"); |
65 |
< |
open ( GNUmakefile, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk") or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n'; |
65 |
> |
my $fh=FileHandle->new(); |
66 |
> |
open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk" |
67 |
> |
) or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n'; |
68 |
> |
@filehandlestack=($fh); |
69 |
> |
# make an alias |
70 |
> |
# open ( GNUmakefile, ">&=$fh") or die 'Unable to create alias for '. |
71 |
> |
# "Filehandle $!\n"; |
72 |
> |
*GNUmakefile=$fh; |
73 |
|
if ( -e $ENV{LatestBuildFile} ) { |
74 |
|
print GNUmakefile "include $ENV{LatestBuildFile}\n"; |
75 |
|
} |
77 |
|
# "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk\n"; |
78 |
|
$ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk"; |
79 |
|
$switch->parse(); # sort out supported tags |
80 |
+ |
if ( $numbins > 0 ) { |
81 |
+ |
print GNUmakefile <<ENDTEXT; |
82 |
+ |
ifndef BINMODE |
83 |
+ |
help:: |
84 |
+ |
\t\@echo Generic Binary targets |
85 |
+ |
\t\@echo ---------------------- |
86 |
+ |
endif |
87 |
+ |
ENDTEXT |
88 |
+ |
foreach $target ( keys %$targettypes ) { |
89 |
+ |
print GNUmakefile <<ENDTEXT; |
90 |
+ |
ifndef BINMODE |
91 |
+ |
help:: |
92 |
+ |
\t\@echo $target |
93 |
+ |
endif |
94 |
+ |
ENDTEXT |
95 |
+ |
} |
96 |
+ |
} |
97 |
|
close GNUmakefile; |
98 |
|
} |
99 |
|
|
100 |
+ |
sub ParseBuildFile_Export { |
101 |
+ |
my $filename=shift; |
102 |
+ |
use Tool; |
103 |
+ |
# This hash defines which Document Elements we can use |
104 |
+ |
my $SupportedTags={ |
105 |
+ |
'none' => 'none', |
106 |
+ |
'export' => \&OutToMakefile, |
107 |
+ |
'export_StartTag' => \&export_start, |
108 |
+ |
'export_EndTag' => \&export_end, |
109 |
+ |
'lib_StartTag' => \&lib_start_export, |
110 |
+ |
'External_StartTag' => \&Ext_start_export, |
111 |
+ |
'lib' => 'none' |
112 |
+ |
}; |
113 |
+ |
use Utilities::Switcher; |
114 |
+ |
$switchex=Switcher->new($SupportedTags, $filename); |
115 |
+ |
$switchex->{Strict_no_cr}='no'; |
116 |
+ |
$switchex->parse(); # sort out supported tags |
117 |
+ |
} |
118 |
+ |
|
119 |
|
sub initialterms() { |
120 |
|
my $name=shift; |
121 |
|
my @string=@_; |
145 |
|
my @vars=@_; |
146 |
|
|
147 |
|
$hashref=$switch->SetupValueHash(\@vars); |
148 |
+ |
if ( $Arch ) { |
149 |
|
if ( defined $$hashref{'type'} ) { |
150 |
|
$ClassName=$$hashref{'type'}; |
151 |
|
} |
152 |
+ |
} |
153 |
|
} |
154 |
|
|
155 |
|
sub ClassPath_StartTag { |
158 |
|
my $hashref; |
159 |
|
|
160 |
|
$hashref=$switch->SetupValueHash(\@vars); |
161 |
+ |
if ( $Arch ) { |
162 |
|
if ( defined $$hashref{'defaultpath'} ) { |
163 |
|
} |
164 |
+ |
} |
165 |
|
} |
166 |
|
|
167 |
|
sub Bin_start { |
171 |
|
my $fileclass; |
172 |
|
my @tools; |
173 |
|
my $tool; |
174 |
+ |
my $filename; |
175 |
+ |
my $objectname; |
176 |
|
|
177 |
|
$hashref=$switch->SetupValueHash(\@vars); |
178 |
|
$switch->checkparam($hashref, $name, 'file'); |
179 |
+ |
if ( $Arch ) { |
180 |
|
if ( ! defined $$hashref{name} ) { |
181 |
|
($$hashref{name}=$$hashref{file})=~s/\..*//; |
182 |
|
} |
183 |
|
# This stuff for later |
184 |
|
#$fileclass=$toolbox->getclass($file); |
185 |
|
#$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file ); |
186 |
< |
print GNUmakefile "bin::$$hashref{name}\n"; |
187 |
< |
print GNUmakefile "bin_debug::$$hashref{name}\n"; |
188 |
< |
print GNUmakefile "$$hashref{name}::$$hashref{file}\n"; |
186 |
> |
|
187 |
> |
($filename=$$hashref{file})=~s/\..*//; |
188 |
> |
|
189 |
> |
# Create a new directory for each binary target |
190 |
> |
my $dirname="bin_".$$hashref{name}; |
191 |
> |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname"); |
192 |
> |
open (binGNUmakefile, |
193 |
> |
">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk") or die "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/". |
194 |
> |
"BuildFile.mk $!\n"; |
195 |
> |
|
196 |
> |
# Create the link targets |
197 |
> |
$numbins++; |
198 |
> |
my $fh=$filehandlestack[0]; |
199 |
> |
print $fh <<ENDTEXT; |
200 |
> |
|
201 |
> |
# Link Targets to binary directories |
202 |
> |
ifndef BINMODE |
203 |
> |
|
204 |
> |
define stepdown_$$hashref{'name'} |
205 |
> |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\ |
206 |
> |
cd $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\ |
207 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk \$\@; \\ |
208 |
> |
fi |
209 |
> |
endef |
210 |
> |
|
211 |
> |
define stepdown2_$$hashref{'name'} |
212 |
> |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\ |
213 |
> |
cd $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\ |
214 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk \$\*; \\ |
215 |
> |
fi |
216 |
> |
|
217 |
> |
endef |
218 |
> |
|
219 |
> |
bin_$$hashref{'name'}_%:: dummy |
220 |
> |
\@\$(stepdown2_$$hashref{'name'}) |
221 |
> |
|
222 |
> |
echo_%:: dummy |
223 |
> |
\@\$(stepdown_$$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 |
> |
endif |
231 |
> |
|
232 |
> |
ENDTEXT |
233 |
> |
|
234 |
> |
|
235 |
> |
# the binary specifics makefile |
236 |
> |
print binGNUmakefile "include $currentenv\n"; |
237 |
> |
print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/${path}\n"; |
238 |
> |
|
239 |
> |
# alias for bin_Insure |
240 |
> |
print binGNUmakefile <<ENDTEXT; |
241 |
> |
|
242 |
> |
bin_insure:bin_Insure |
243 |
> |
ifdef MAKETARGET_bin_insure |
244 |
> |
MAKETARGET_$$hashref{name}_Insure=1 |
245 |
> |
endif |
246 |
> |
|
247 |
> |
# debuggging target |
248 |
> |
$$hashref{'name'}_echo_% :: echo_% |
249 |
> |
|
250 |
> |
# help targets |
251 |
> |
help:: |
252 |
> |
\t\@echo Targets For $$hashref{'name'} |
253 |
> |
\t\@echo ------------------------------------- |
254 |
> |
\t\@echo $$hashref{'name'} - default build |
255 |
> |
\t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning |
256 |
> |
ENDTEXT |
257 |
> |
|
258 |
> |
# Make generic rules for each type |
259 |
> |
$targettypes={ |
260 |
> |
"bin" => 'o', |
261 |
> |
"bin_debug" => 'd', |
262 |
> |
"bin_debug_local" => 'l_d', |
263 |
> |
"bin_Insure" => 'Insure' |
264 |
> |
}; |
265 |
> |
# |
266 |
> |
foreach $target ( keys %$targettypes ) { |
267 |
> |
print binGNUmakefile <<ENDTEXT; |
268 |
> |
|
269 |
> |
# Type $target specifics |
270 |
> |
ifdef MAKETARGET_$target |
271 |
> |
MAKETARGET_$$hashref{name}_$$targettypes{$target}=1 |
272 |
> |
endif |
273 |
> |
$target ::$$hashref{name}_$$targettypes{$target} |
274 |
> |
|
275 |
> |
bintargets+=$$hashref{name}_$$targettypes{$target} |
276 |
> |
help:: |
277 |
> |
\t\@echo $$hashref{name}_$$targettypes{$target} |
278 |
> |
clean:: |
279 |
> |
\t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\ |
280 |
> |
\techo Removing \$(binarystore)/$$hashref{name}; \\ |
281 |
> |
\trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\ |
282 |
> |
\tfi |
283 |
> |
|
284 |
> |
ENDTEXT |
285 |
> |
($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/; |
286 |
> |
${"objectname_$$targettypes{$target}"}=$objectname; |
287 |
> |
print binGNUmakefile "$objectname:$$hashref{name}.dep\n"; |
288 |
> |
} # end loop |
289 |
> |
|
290 |
> |
print binGNUmakefile "$$hashref{name}_Insure:.psrc\n"; |
291 |
> |
print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n"; |
292 |
> |
print binGNUmakefile "\t\$(CClinkCmdDebug)\n"; |
293 |
> |
print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n"; |
294 |
> |
print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n"; |
295 |
> |
print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n"; |
296 |
> |
print binGNUmakefile "\t\$(CClinkCmdInsure)\n"; |
297 |
> |
print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n"; |
298 |
> |
print binGNUmakefile "\t\$(CClinkCmd)\n"; |
299 |
> |
print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n"; |
300 |
> |
print binGNUmakefile "-include $$hashref{name}.dep\n"; |
301 |
> |
print binGNUmakefile <<ENDTEXT; |
302 |
> |
clean:: |
303 |
> |
\t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\ |
304 |
> |
\techo Removing \$(binarystore)/$$hashref{name}; \\ |
305 |
> |
\trm \$(binarystore)/$$hashref{name}; \\ |
306 |
> |
\tfi |
307 |
> |
|
308 |
> |
$$hashref{name}_d.exe:\$(libslocal_d) |
309 |
> |
$$hashref{name}_o.exe:\$(libslocal) |
310 |
> |
ifdef MCCABE_DATA_DIR |
311 |
> |
$$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp |
312 |
> |
endif |
313 |
> |
$$hashref{name}_Insure.exe:\$(libslocal_I) |
314 |
> |
$$hashref{name}_d:$$hashref{name}_d.exe |
315 |
> |
\@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
316 |
> |
$$hashref{name}_l_d:$$hashref{name}_l_d.exe |
317 |
> |
\@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name} |
318 |
> |
$$hashref{name}_Insure:$$hashref{name}_Insure.exe |
319 |
> |
\@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure |
320 |
> |
$$hashref{name}:$$hashref{name}_d.exe |
321 |
> |
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
322 |
> |
$$hashref{name}_o:$$hashref{name}_o.exe |
323 |
> |
\@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name} |
324 |
> |
binfiles+=$$hashref{file} |
325 |
> |
ENDTEXT |
326 |
> |
} |
327 |
> |
close binGNUmakefile; |
328 |
> |
} |
329 |
> |
|
330 |
> |
sub Ext_start_export { |
331 |
> |
my $name=shift; |
332 |
> |
my @vars=@_; |
333 |
> |
my $hashref; |
334 |
> |
|
335 |
> |
$hashref=$switch->SetupValueHash(\@vars); |
336 |
> |
if ( $Arch ) { |
337 |
> |
if ( $switchex->context('export') ) { |
338 |
> |
$$hashref{'ref'}=~tr[A-Z][a-z]; |
339 |
> |
print GNUmakefile $$hashref{'ref'}; |
340 |
> |
if ( defined $$hashref{'version'} ) { |
341 |
> |
print GNUmakefile "_V_".$$hashref{'version'}; |
342 |
> |
} |
343 |
> |
print GNUmakefile "=true\n"; |
344 |
> |
} |
345 |
> |
} |
346 |
|
} |
347 |
|
|
348 |
|
sub External_StartTag { |
351 |
|
my $hashref; |
352 |
|
|
353 |
|
$hashref=$switch->SetupValueHash(\@vars); |
354 |
+ |
if ( $Arch ) { |
355 |
|
$$hashref{'ref'}=~tr[A-Z][a-z]; |
356 |
|
print GNUmakefile $$hashref{'ref'}; |
357 |
|
if ( defined $$hashref{'version'} ) { |
358 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
359 |
|
} |
360 |
|
print GNUmakefile "=true\n"; |
361 |
+ |
} |
362 |
|
|
363 |
|
} |
364 |
|
|
369 |
|
|
370 |
|
$hashref=$switch->SetupValueHash(\@vars); |
371 |
|
$switch->checkparam($hashref, $name, 'name'); |
372 |
+ |
if ( $Arch ) { |
373 |
|
print GNUmakefile "GROUP_".$$hashref{'name'}; |
374 |
|
if ( defined $$hashref{'version'} ) { |
375 |
|
print GNUmakefile "_V_".$$hashref{'version'}; |
376 |
|
} |
377 |
|
print GNUmakefile "=true\n"; |
378 |
+ |
} |
379 |
|
} |
380 |
|
|
381 |
|
sub External { |
402 |
|
|
403 |
|
$hashref=$switch->SetupValueHash(\@vars); |
404 |
|
$switch->checkparam($hashref, $name, "name"); |
405 |
< |
if ( $filename=checkfile("$ENV{INTsrc}/$$hashref{name}/BuildFile") |
406 |
< |
ne "" ) { |
407 |
< |
print GNUmakefile "ReqDependencies += $filename\n"; |
405 |
> |
if ( $Arch ) { |
406 |
> |
$filename=SCRAMUtils::checkfile( |
407 |
> |
"$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
408 |
> |
if ( $filename ne "" ) { |
409 |
> |
ParseBuildFile_Export( $filename ); |
410 |
> |
} |
411 |
|
} |
176 |
– |
print GNUmakefile "local__$$hashref{name}=true\n"; |
412 |
|
} |
413 |
|
|
414 |
|
sub CheckBuildFile { |
441 |
|
} |
442 |
|
} |
443 |
|
|
444 |
+ |
sub ignoretag { |
445 |
+ |
my $name=shift; |
446 |
+ |
my @vars=@_; |
447 |
+ |
|
448 |
+ |
$Arch=0; |
449 |
+ |
push @ARCHBLOCK, $Arch; |
450 |
+ |
} |
451 |
+ |
|
452 |
+ |
sub ignoretag_end { |
453 |
+ |
my $name=shift; |
454 |
+ |
my @vars=@_; |
455 |
+ |
|
456 |
+ |
pop @ARCHBLOCK; |
457 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
458 |
+ |
} |
459 |
+ |
|
460 |
+ |
sub Arch_Start { |
461 |
+ |
my $name=shift; |
462 |
+ |
my @vars=@_; |
463 |
+ |
my $hashref; |
464 |
+ |
|
465 |
+ |
$hashref=$toolswitch->SetupValueHash( \@vars ); |
466 |
+ |
$toolswitch->checkparam($hashref, $name, 'name'); |
467 |
+ |
#( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0; |
468 |
+ |
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0); |
469 |
+ |
push @ARCHBLOCK, $Arch; |
470 |
+ |
} |
471 |
+ |
sub Arch_End { |
472 |
+ |
my $name=shift; |
473 |
+ |
my @vars=@_; |
474 |
+ |
|
475 |
+ |
pop @ARCHBLOCK; |
476 |
+ |
$Arch=$ARCHBLOCK[$#ARCHBLOCK]; |
477 |
+ |
} |
478 |
+ |
|
479 |
|
# Split up the Class Block String into a useable array |
480 |
|
sub _CutBlock { |
481 |
|
my $string= shift @_; |
486 |
|
my $name=shift; |
487 |
|
my @vars=@_; |
488 |
|
|
489 |
< |
print GNUmakefile @vars; |
489 |
> |
if ( $Arch ) { |
490 |
> |
print GNUmakefile @vars; |
491 |
> |
} |
492 |
> |
} |
493 |
> |
sub OutToScreen { |
494 |
> |
my $name=shift; |
495 |
> |
my @vars=@_; |
496 |
> |
|
497 |
> |
if ( $Arch ) { |
498 |
> |
print @vars; |
499 |
> |
} |
500 |
|
} |
501 |
|
sub setBlockClassPath { |
502 |
|
my $name=shift; |
508 |
|
$BlockClassPath=$BlockClassPath.":".$$hashref{path}; |
509 |
|
_CutBlock($$hashref{path}); |
510 |
|
} |
511 |
+ |
|
512 |
+ |
sub export_start { |
513 |
+ |
#Set up a toolfile object |
514 |
+ |
$exporttool=Tool->new(); |
515 |
+ |
} |
516 |
+ |
|
517 |
+ |
sub export_end { |
518 |
+ |
#Write toolfile object to disk |
519 |
+ |
$exporttool->envtomake(\*GNUmakefile); |
520 |
+ |
} |
521 |
+ |
|
522 |
+ |
# |
523 |
+ |
# Export Mode Lib Tag |
524 |
+ |
# |
525 |
+ |
sub lib_start_export { |
526 |
+ |
my $name=shift; |
527 |
+ |
my @vars=@_; |
528 |
+ |
my $hashref; |
529 |
+ |
|
530 |
+ |
$hashref=$switchex->SetupValueHash( \@vars ); |
531 |
+ |
$switchex->checkparam($hashref, $name, 'name'); |
532 |
+ |
if ( $Arch ) { |
533 |
+ |
if ( $switchex->context('export') ) { |
534 |
+ |
#If export mode then add this env to the export tool |
535 |
+ |
$exporttool->addenv('lib',$$hashref{name}); |
536 |
+ |
} |
537 |
+ |
} |
538 |
+ |
} |
539 |
+ |
|
540 |
+ |
# |
541 |
+ |
# Standard lib tag |
542 |
+ |
# |
543 |
+ |
sub lib_start { |
544 |
+ |
my $name=shift; |
545 |
+ |
my @vars=@_; |
546 |
+ |
my $hashref; |
547 |
+ |
|
548 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
549 |
+ |
$switch->checkparam($hashref, $name, 'name'); |
550 |
+ |
if ( $Arch ) { |
551 |
+ |
print GNUmakefile "lib+=$$hashref{name}\n"; |
552 |
+ |
} |
553 |
+ |
} |
554 |
+ |
|
555 |
+ |
# |
556 |
+ |
# libtype specification |
557 |
+ |
# |
558 |
+ |
sub LibType_Start { |
559 |
+ |
my $name=shift; |
560 |
+ |
my @vars=@_; |
561 |
+ |
my $hashref; |
562 |
+ |
|
563 |
+ |
if ( $Arch ) { |
564 |
+ |
$hashref=$switch->SetupValueHash( \@vars ); |
565 |
+ |
$switch->checkparam($hashref, $name, 'type'); |
566 |
+ |
|
567 |
+ |
print GNUmakefile "# Specify Library Type\n"; |
568 |
+ |
print GNUmakefile "DefaultLibsOff=yes\n"; |
569 |
+ |
if ( $$hashref{'type'}=~/^archive/i ) { |
570 |
+ |
print GNUmakefile "LibArchive=true\n"; |
571 |
+ |
} |
572 |
+ |
elsif ($$hashref{'type'}=~/debug_archive/i ) { |
573 |
+ |
print GNUmakefile "LibDebugArchive=true\n"; |
574 |
+ |
} |
575 |
+ |
elsif ($$hashref{'type'}=~/debug_shared/i ) { |
576 |
+ |
print GNUmakefile "LibDebugShared=true\n"; |
577 |
+ |
} |
578 |
+ |
elsif ($$hashref{'type'}=~/shared/i ) { |
579 |
+ |
print GNUmakefile 'LibShared=true'."\n"; |
580 |
+ |
} |
581 |
+ |
print GNUmakefile "\n"; |
582 |
+ |
} |
583 |
+ |
} |
584 |
+ |
sub LibType_text { |
585 |
+ |
my $name=shift; |
586 |
+ |
my @vars=@_; |
587 |
+ |
|
588 |
+ |
if ( $Arch ) { |
589 |
+ |
print GNUmakefile "libmsg::\n\t\@echo Library info: "; |
590 |
+ |
print GNUmakefile @vars; |
591 |
+ |
print GNUmakefile "\n"; |
592 |
+ |
} |
593 |
+ |
} |
594 |
+ |
|
595 |
+ |
sub Environment_start { |
596 |
+ |
my $name=shift; |
597 |
+ |
my @vars=@_; |
598 |
+ |
my $hashref; |
599 |
+ |
|
600 |
+ |
if ( $Arch ) { |
601 |
+ |
$envnum++; |
602 |
+ |
|
603 |
+ |
# open a new Environment File |
604 |
+ |
my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk"; |
605 |
+ |
use FileHandle; |
606 |
+ |
my $fh=FileHandle->new(); |
607 |
+ |
open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n"; |
608 |
+ |
push @filehandlestack, $fh; |
609 |
+ |
*GNUmakefile=$fh; |
610 |
+ |
|
611 |
+ |
# include the approprate environment file |
612 |
+ |
if ( $envlevel == 0 ) { |
613 |
+ |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/". |
614 |
+ |
"BuildFile.mk\n"; |
615 |
+ |
} |
616 |
+ |
else { |
617 |
+ |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/". |
618 |
+ |
"Env_$Envlevels[$envlevel]\.mk\n"; |
619 |
+ |
} |
620 |
+ |
$envlevel++; |
621 |
+ |
$Envlevels[$envlevel]=$envnum; |
622 |
+ |
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk"; |
623 |
+ |
} |
624 |
+ |
} |
625 |
+ |
|
626 |
+ |
sub Environment_end { |
627 |
+ |
my $fd; |
628 |
+ |
|
629 |
+ |
if ( $Arch ) { |
630 |
+ |
$envlevel--; |
631 |
+ |
if ( $envlevel < 0 ) { |
632 |
+ |
print "Too many </Environent> Tags on $switch->line()\n"; |
633 |
+ |
exit; |
634 |
+ |
} |
635 |
+ |
close GNUmakefile; |
636 |
+ |
# restore the last filehandle |
637 |
+ |
$fd=pop @filehandlestack; |
638 |
+ |
close $fd; |
639 |
+ |
*GNUmakefile=$filehandlestack[$#filehandlestack]; |
640 |
+ |
if ( $envlevel < 1 ) { |
641 |
+ |
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk"; |
642 |
+ |
} |
643 |
+ |
else { |
644 |
+ |
$currentenv= |
645 |
+ |
"$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$Envlevels[$envlevel]"; |
646 |
+ |
} |
647 |
+ |
} |
648 |
+ |
} |