ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildFile.pm
Revision: 1.1.2.26
Committed: Thu Jun 22 10:02:40 2000 UTC (24 years, 10 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
Changes since 1.1.2.25: +4 -3 lines
Log Message:
Initiaialise with a configarea rather than just the toolbox

File Contents

# Content
1 # BuildFile
2 #
3 # Interface
4 # ---------
5 # new(ConfigArea)
6 # 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 # CheckBuildFile(dir) : return the BuildFile if it exists
11
12 package BuildSystem::BuildFile;
13 use ActiveDoc::SimpleDoc;
14 use BuildSystem::ToolBox;
15 require 5.004;
16
17 BEGIN {
18 $buildfile="BuildFile";
19 }
20
21 sub new {
22 my $class=shift;
23 my $self={};
24 bless $self, $class;
25 $self->{area}=shift;
26 $self->{toolbox}=$self->{area}->toolbox();
27 $self->{Arch}=1;
28 push @{$self->{ARCHBLOCK}}, $self->{Arch};
29 return $self;
30 }
31
32 sub ignore {
33 my $self=shift;
34 return (defined $self->{ignore})?$self->{ignore}:0;
35 }
36
37 sub _initswitcher {
38 my $self=shift;
39 my $switch=ActiveDoc::SimpleDoc->new();
40 my $parse="makebuild";
41 $switch->newparse($parse);
42 $switch->addignoretags($parse);
43 $self->_commontags($switch,$parse);
44 $switch->addtag($parse,"Build", \&Build_start, $self);
45 $switch->addtag($parse,"none",
46 \&OutToMakefile,$self,
47 \&OutToMakefile, $self,
48 "", $self);
49 $switch->addtag($parse,"Bin",
50 \&Bin_start,$self,
51 \&OutToScreen, $self,
52 "", $self);
53 $switch->addtag($parse,"LibType",
54 \&LibType_Start,$self,
55 \&LibType_text, $self,
56 \&LibType_end,$self);
57 $switch->addtag($parse,"ConfigurationClass",
58 \&Class_StartTag,$self,
59 \&OutToMakefile, $self,
60 "", $self);
61 $switch->addtag($parse,"ClassPath",
62 \&setBlockClassPath,$self,
63 \&OutToMakefile, $self,
64 "", $self);
65 $switch->addtag($parse,"AssociateGroup",
66 "",$self,
67 \&AssociateGroup,$self,
68 "", $self);
69 $switch->addtag($parse,"Environment",
70 \&Environment_start,$self,
71 \&OutToMakefile, $self,
72 \&Environment_end,$self);
73 $switch->addtag($parse,"Export",
74 \&export_start,$self,
75 \&OutToMakefile, $self,
76 \&export_end,$self);
77 return $switch;
78 }
79
80 sub _commontags {
81 my $self=shift;
82 my $switch=shift;
83 my $parse=shift;
84
85 $switch->grouptag("Export",$parse);
86 $switch->addtag($parse,"Use",\&Use_start,$self,
87 \&OutToMakefile, $self,
88 "", $self);
89 $switch->addtag($parse,"Group",\&Group_start,$self,
90 \&OutToMakefile, $self,
91 "", $self);
92 $switch->grouptag("Group",$parse);
93 $switch->addtag($parse,"External",
94 \&External_StartTag,$self,
95 \&OutToMakefile, $self,
96 "", $self);
97 $switch->addtag($parse,"lib",
98 \&lib_start,$self,
99 \&OutToMakefile, $self,
100 "", $self);
101 $switch->addtag($parse,"Architecture",
102 \&Arch_Start,$self,
103 \&OutToMakefile, $self,
104 \&Arch_End,$self);
105 $switch->addtag($parse,"INCLUDE_PATH",
106 \&IncludePath_Start,$self,
107 \&OutToMakefile, $self,
108 "",$self);
109 return $switch;
110 }
111
112 sub GenerateMakefile {
113 my $self=shift;
114 my $infile=shift;
115 my $outfile=shift;
116
117 $self->{switch}=$self->_initswitcher();
118 $self->{switch}->filetoparse($infile);
119
120 # open a temporary gnumakefile to store output.
121 my $fh=FileHandle->new();
122 open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
123 "$!\n";
124 @{$self->{filehandlestack}}=($fh);
125
126 # -- make an alias
127 *GNUmakefile=$fh;
128 if ( -e $ENV{LatestBuildFile} ) {
129 print GNUmakefile "include $ENV{LatestBuildFile}\n";
130 }
131 $ENV{LatestBuildFile}=$outfile;
132 $self->{switch}->parse("makebuild"); # sort out supported tags
133 close GNUmakefile;
134 }
135
136 sub ParseBuildFile {
137 my $self=shift;
138 my $base=shift;
139 my $path=shift;
140 my $filename=shift @_;
141 my $fullfilename;
142 if ( $filename!~/^\// ) {
143 $fullfilename="$base/$path/$filename";
144 }
145 else {
146 $fullfilename=$filename;
147 }
148 $self->{path}=$path;
149 #print "Processing $fullfilename\n";
150 $numbins=0;
151 $self->{envnum}=0;
152 $self->{envlevel}=0;
153 $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
154 "BuildFile.mk";
155 $ENV{SCRAM_CURRENTENV}=$self->{currentenv};
156
157 # open a temporary gnumakefile to store output.
158 use Utilities::AddDir;
159 AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
160 $self->GenerateMakefile($fullfilename,
161 $ENV{LOCALTOP}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
162 }
163
164 sub ParseBuildFile_Export {
165 my $self=shift;
166 my $filename=shift;
167 my $bf=BuildSystem::BuildFile->new($self->{area});
168 if ( defined $self->{remoteproject} ) {
169 $bf->{remoteproject}=$self->{remoteproject};
170 }
171 $bf->_parseexport($filename);
172 undef $bf;
173 }
174
175 sub _location {
176 my $self=shift;
177 use File::Basename;
178
179 return dirname($self->{switch}->filetoparse());
180 }
181
182 sub _parseexport {
183 my $self=shift;
184 my $filename=shift;
185
186 my $switchex=ActiveDoc::SimpleDoc->new();
187 $switchex->filetoparse($filename);
188 $switchex->newparse("export");
189 $switchex->addignoretags("export");
190 $switchex->addtag("export","Export",
191 \&export_start_export,$self,
192 \&OutToMakefile, $self,
193 \&export_end_export,$self);
194 $self->_commontags($switchex,"export");
195 $switchex->allowgroup("__export","export");
196 # $switchex->{Strict_no_cr}='no';
197 $self->{switch}=$switchex;
198 $switchex->parse("export"); # sort out supported tags
199 }
200
201 sub _pushremoteproject {
202 my $self=shift;
203 my $path=shift;
204
205 if ( defined $self->{remoteproject} ) {
206 push @{$self->{rpstack}}, $self->{remoteproject};
207 }
208 $self->{remoteproject}=$path;
209 }
210
211 sub _popremoteproject {
212 my $self=shift;
213 if ( $#{$self->{rpstack}} >=0 ) {
214 $self->{remoteproject}=pop @{$self->{rpstack}};
215 }
216 else {
217 undef $self->{remoteproject};
218 }
219 }
220
221 sub _toolmapper {
222 my $self=shift;
223 if ( ! defined $self->{mapper} ) {
224 require BuildSystem::ToolMapper;
225 $self->{mapper}=BuildSystem::ToolMapper->new();
226 }
227 if ( @_ ) { #if a class is supplied then supply the map directly
228 my $class=shift;
229 return $self->{mapper}->getmap($class);
230 }
231 return $self->{mapper};
232 }
233
234
235 # ---- Tag routines
236
237 # -- Override a class type with the <ConfigurationClass type=xxx> tag
238 # the type tag will pick up a pre-defined class type from project space.
239
240 sub Class_StartTag {
241 my $self=shift;
242 my $name=shift;
243 my $hashref=shift;
244
245 if ( $self->{Arch} ) {
246 if ( defined $$hashref{'type'} ) {
247 $ClassName=$$hashref{'type'};
248 }
249 }
250 }
251
252 sub IncludePath_Start {
253 my $self=shift;
254 my $name=shift;
255 my $hashref=shift;
256
257 $self->{switch}->checktag( $name, $hashref, 'path');
258 if ( $self->{Arch} ) {
259 print GNUmakefile "INCLUDE+=".$self->_location()."/".
260 $$hashref{'path'}."\n";
261 }
262 }
263
264 #
265 # generic build tag
266 #
267 sub Build_start {
268 my $self=shift;
269 my $name=shift;
270 my $hashref=shift;
271
272
273 $self->{switch}->checktag($name,$hashref,'class');
274 if ( $self->{Arch} ) {
275 my $fh=$self->{filehandlestack}[0];
276 # -- get the mapper object
277 my $mapper=$self->_toolmapper($$hashref{'class'});
278 if ( ! defined $mapper ) {
279 $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
280 }
281 else {
282 # -- get default types
283 my @deftypes;
284 if ( ! exists $$hashref{'default'} ) {
285 @deftypes=$mapper->defaulttypes();
286 }
287 else {
288 @deftypes=split /,/, $$hashref{'default'};
289 print $fh "# -- default override\n";
290 print $fh "Sorigdefault_".$$hashref{'class'}.":=".
291 "\$(Sdefault_".$$hashref{'class'}.")\n";
292 print $fh "Sdefault_".$$hashref{'class'}.":=\n\n";
293 }
294
295 # -- no src parameter so it must be a default setting tag
296 if ( ! exists $$hashref{src} ) {
297 # -- general default setting
298 $self->{switch}->checktag($name,$hashref,'default');
299 $mapper->defaulttypes(@deftypes);
300 $self->_makegenerictargets($fh, $$hashref{'class'},@deftypes);
301 }
302 else {
303 $self->{switch}->checktag($name,$hashref,'src');
304 $self->{switch}->checktag($name,$hashref,'name');
305 my $name=$$hashref{'name'};
306 my @types=$mapper->types();
307
308
309 my @targets=();
310
311 # -- generate generic targets
312 print $fh "ifndef _BuildLink_\n";
313 push @targets, ($self->_makegenerictargets($fh,$$hashref{'class'},
314 @deftypes));
315 print $fh $$hashref{'class'}."::\$(Sdefault_".$$hashref{'class'}
316 .")\n";
317 print $fh "Sdefault_".$$hashref{'class'}."_".$$hashref{'name'}.
318 "=\$(addsuffix _".$$hashref{'name'}.",\$(Sdefault_".
319 $$hashref{'class'}."))\n";
320 print $fh $$hashref{'class'}."_".$$hashref{'name'}."::\$(".
321 "Sdefault_".$$hashref{'class'}."_".$$hashref{'name'}.")\n";
322 push @targets, $$hashref{'class'}."_".$$hashref{'name'};
323
324 # -- generate targets for each type
325 foreach $type ( @types ) {
326
327 # -- generic name for each type
328 my $pattern=$$hashref{'class'}."_".$type;
329 my $dirname=$$hashref{'class'}."_".$type."_".$name;
330 print $fh "# ------ $pattern rules ---------------\n";
331 print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
332 "_".$type."_$name\n\n";
333
334 # -- create a new directory rule for each type
335 push @targets, $pattern;
336 my $here="$ENV{LOCALTOP}/$ENV{INTwork}/\$(THISDIR)/".$dirname;
337 my $work=$ENV{INTwork}."/\$(THISDIR)/".$dirname;
338 my $makefile=$here."/BuildFile.mk";
339
340 # -- create link targets to the directory
341 push @targets, $dirname;
342 print $fh "# -- Link Targets to $type directories\n";
343 print $fh "$dirname: make_$dirname\n";
344 print $fh "\t\@cd $here; \\\n";
345 print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
346 " workdir=$work ".
347 " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
348
349 # -- write target to make makefile for each directory
350 print $fh "# -- Build target directories\n";
351 print $fh "make_$dirname:\n";
352 print $fh "\t\@if [ ! -f \"$makefile\" ]; then \\\n";
353 print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
354 print $fh "\t mkdir $here; \\\n";
355 print $fh "\t fi;\\\n";
356 #print $fh "\t echo include ".$self->{currentenv}." > ".
357 print $fh "\t echo include \$(SCRAM_CURRENTENV) > ".
358 "$makefile; \\\n";
359 print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".${THISPATH}.
360 " >> $makefile; \\\n";
361 print $fh "\t echo buildsrcfiles:=".$$hashref{'src'}.
362 " >> $makefile; \\\n";
363 print $fh "\t echo buildname=$name >> $makefile;\\\n";
364 print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
365 print $fh "\t echo ifdef DefaultBuildFile >> $makefile; \\\n";
366 print $fh "\t echo include \$(DefaultBuildFile) >> $makefile; \\\n";
367 print $fh "\t echo DefaultBuildFileIn=true >> $makefile; \\\n";
368 print $fh "\t echo endif >> $makefile; \\\n";
369 if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
370 foreach $f ( @file ) {
371 print $fh "\t echo -include $f >> $makefile; \\\n";
372 }
373 }
374 print $fh "\tfi\n";
375 print $fh "\n";
376 # print $typefile "$name :\n";
377 # print $typefile "\t\$(_quietbuild_)";
378 # print $typefile $mapper->template($$hashref{'class'},$type)."\n";
379 # print $typefile "\t\$(_quietstamp_)";
380 # print $typefile "$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
381
382 # -- debug targets
383 print $fh "# -- debug targets\n";
384 print $fh $dirname."_echo_% : make_$dirname\n";
385 print $fh "\t\@cd $here; \n";
386 print $fh "\t\@\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
387 " workdir=$work ".
388 " -f \$(TOOL_HOME)/basics.mk ".
389 "echo_\$(subst ".$dirname."_echo_,,\$\@) ; \n\n";
390 push @targets, $dirname."_echo_VAR";
391
392 # -- cleaning targets
393 push @targets, "clean_$dirname";
394 print $fh "# -- cleaning targets\n";
395 print $fh "clean::clean_$dirname\n";
396 print $fh "clean_".$dirname."::\n";
397 print $fh "\t\@if [ -d $here ]; then \\\n";
398 print $fh "\techo cleaning $dirname; \\\n";
399 print $fh "\tcd $here; \\\n";
400 print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
401 $work." _BuildLink_=1 -f ".
402 "\$(TOOL_HOME)/basics.mk clean; \\\n";
403 print $fh "\tfi\n\n";
404
405
406 }
407 # -- cleanup
408 print $fh "Sdefault_".$$hashref{'class'}.
409 ":=\$(Sorigdefault_".$$hashref{'class'}.")\n";
410 # -- help targets
411 print $fh "helpheader::\n";
412 print $fh "\t\@echo Targets available:\n";
413 print $fh "\t\@echo ------------------\n\n";
414 print $fh "help::helpheader\n";
415 foreach $target ( @targets ) {
416 print $fh "help::\n";
417 print $fh "\t\@echo $target\n"
418 }
419 print $fh "endif\n";
420 } # end else
421 }
422 }
423 }
424
425 sub _makegenerictargets {
426 my $self=shift;
427 my $fh=shift;
428 my $class=shift;
429 my @deftypes=@_;
430
431 my @targets=();
432 # -- generate generic targets
433 print $fh "# -- Generic targets\n";
434 push @targets, $class;
435 foreach $dtype ( @deftypes ) {
436 print $fh "Sdefault_".$class."+=".$class."_".$dtype."\n";
437 }
438 #print $fh $class."::\$(Sdefault_".$class.")\n";
439 print $fh "\n\n";
440 return @targets;
441 }
442
443 sub Bin_start {
444 my $self=shift;
445 my $name=shift;
446 my $hashref=shift;
447
448 my $fileclass;
449 my @tools;
450 my $tool;
451 my $filename;
452 my $objectname;
453
454 $self->{switch}->checktag($name,$hashref,'file');
455 if ( $self->{Arch} ) {
456 if ( ! defined $$hashref{name} ) {
457 ($$hashref{name}=$$hashref{file})=~s/\..*//;
458 }
459 ($filename=$$hashref{file})=~s/^\///; # make sure full paths dont work
460 my $arghash={ "class" => "bin",
461 "src" => $filename,
462 "name" => $$hashref{'name'}};
463 if ( exists $$hashref{'default'} ) {
464 $arghash->{'default'}=$$hashref{'default'};
465 }
466 $self->Build_start($name, $arghash);
467 }
468 }
469
470 sub External_StartTag {
471 my $self=shift;
472 my $name=shift;
473 my $hashref=shift;
474
475 my $tool;
476 if ( $self->{Arch} ) {
477 $self->{switch}->checktag($name,$hashref,'ref');
478
479 # -- oo toolbox stuff
480 # - get the appropriate tool object
481 $$hashref{'ref'}=~tr[A-Z][a-z];
482 if ( ! exists $$hashref{'version'} ) {
483 $tool=$self->{toolbox}->gettool($$hashref{'ref'});
484 }
485 else {
486 $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
487 }
488 if ( ! defined $tool ) {
489 $self->{switch}->parseerror("Unknown Tool Specified ("
490 .$$hashref{'ref'}.")");
491 }
492
493 # -- old fashioned GNUmakefile stuff
494 print GNUmakefile $$hashref{'ref'};
495 if ( defined $$hashref{'version'} ) {
496 print GNUmakefile "_V_".$$hashref{'version'};
497 }
498 print GNUmakefile "=true\n";
499
500 # -- Sub system also specified?
501 if ( exists $$hashref{'use'} ) {
502 # -- look for a buildfile
503 my @paths=$tool->getfeature("INCLUDE");
504 my $file="";
505 my ($path,$testfile);
506 foreach $path ( @paths ) {
507 $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
508 if ( -f $testfile ) {
509 $file=$testfile;
510 $self->_pushremoteproject($path);
511 }
512 }
513 if ( $file eq "" ) {
514 $self->{switch}->parseerror("Unable to find SubSystem $testfile");
515 }
516 $self->ParseBuildFile_Export($file);
517 $self->_popremoteproject();
518 }
519 }
520 }
521
522 sub Test_start {
523 my $self=shift;
524 my $name=shift;
525 my $hashref=shift;
526
527 # -- make sure we have the test binary
528 $self->{switch}->checktag($name, $hashref, 'exe');
529 system($ENV{SCRAM_HOME}."/src/scram","build",$$hashref{'exe'});
530
531 # -- a name for the test
532 $self->{switch}->checktag($name, $hashref, 'name');
533
534 # -- set up a tester object
535 push @{$self->{testcontext}}, $$hashref{'name'};
536 my $tester=BuildSystem::Tester->new();
537 if ( ! exists $self->{testers}{$$hashref{'name'}} ) {
538 $self->{testers}{$$hashref{'name'}}=$tester;
539 }
540 else {
541 $self->{switch}->parseerror("Second definition of $name "
542 .$$hashref{'name'});
543 }
544 }
545
546 sub Test_end {
547 my $self=shift;
548 my $name=shift;
549 my $hashref=shift;
550
551 my $tester=$self->{testers}{pop @{$self->{testcontext}}};
552 $tester->run();
553 }
554
555 sub Group_start {
556 my $self=shift;
557 my $name=shift;
558 my $hashref=shift;
559
560 $self->{switch}->checktag($name, $hashref, 'name');
561 if ( $self->{Arch} ) {
562 print GNUmakefile "GROUP_".$$hashref{'name'};
563 if ( defined $$hashref{'version'} ) {
564 print GNUmakefile "_V_".$$hashref{'version'};
565 }
566 print GNUmakefile "=true\n";
567 }
568 }
569
570 sub Use_start {
571 my $self=shift;
572 my $name=shift;
573 my $hashref=shift;
574 my $filename;
575 use Utilities::SCRAMUtils;
576
577 $self->{switch}->checktag($name, $hashref, "name");
578 if ( $self->{Arch} ) {
579 if ( exists $$hashref{'group'} ) {
580 print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
581 }
582 if ( ! defined $self->{remoteproject} ) {
583 $filename=SCRAMUtils::checkfile(
584 "/$ENV{INTsrc}/$$hashref{name}/BuildFile");
585 }
586 else {
587 $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
588 print "trying $filename\n";
589 if ( ! -f $filename ) { $filename=""; };
590 }
591 if ( $filename ne "" ) {
592 $self->ParseBuildFile_Export( $filename );
593 }
594 else {
595 $self->{switch}->parseerror("Unable to detect Appropriate ".
596 "decription file for <$name name=".$$hashref{name}.">");
597 }
598 }
599 }
600
601 sub CheckBuildFile {
602 my $self=shift;
603 my $classdir=shift;
604 my $ClassName="";
605 my $thisfile="$classdir/$buildfile";
606
607 if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
608 $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
609 $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
610 }
611 elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
612 $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
613 $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
614 }
615 return $ClassName;
616 }
617
618 # List association groups between <AssociateGroup> tags
619 # seperated by newlines or spaces
620 sub AssociateGroup {
621 my $self=shift;
622 my $name=shift;
623 my $string=shift;
624 my $word;
625
626 foreach $word ( (split /\s/, $string) ){
627 chomp $word;
628 next if /^#/;
629 if ( $word=~/none/ ) {
630 $self->{ignore}=1;
631 }
632 }
633 }
634
635 sub Arch_Start {
636 my $self=shift;
637 my $name=shift;
638 my $hashref=shift;
639
640 $self->{switch}->checktag($name, $hashref,'name');
641 ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
642 : ($self->{Arch}=0);
643 push @{$self->{ARCHBLOCK}}, $self->{Arch};
644 }
645
646 sub Arch_End {
647 my $self=shift;
648 my $name=shift;
649
650 pop @{$self->{ARCHBLOCK}};
651 $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
652 }
653
654 # Split up the Class Block String into a useable array
655 sub _CutBlock {
656 my $self=shift;
657 my $string= shift @_;
658 @BlockClassA = split /\//, $string;
659 }
660
661 sub OutToMakefile {
662 my $self=shift;
663 my $name=shift;
664 my @vars=@_;
665
666 if ( $self->{Arch} ) {
667 print GNUmakefile @vars;
668 }
669 }
670
671 sub OutToScreen {
672 my $name=shift;
673 my @vars=@_;
674
675 if ( $self->{Arch} ) {
676 print @vars;
677 }
678 }
679 sub setBlockClassPath {
680 my $self=shift;
681 my $name=shift;
682 my $hashref=shift;
683
684 $self->{switch}->checktag($name, $hashref, 'path');
685 $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
686 $self->_CutBlock($$hashref{path});
687 }
688
689 sub BlockClassPath {
690 my $self=shift;
691 return $self->{BlockClassPath};
692 }
693
694 sub export_start_export {
695 my $self=shift;
696 my $name=shift;
697 my $hashref=shift;
698
699 $self->{switch}->opengroup("__export");
700 }
701
702 sub export_start {
703 my $self=shift;
704 my $name=shift;
705 my $hashref=shift;
706
707 $self->{switch}->opengroup("__export");
708 if ( exists $$hashref{autoexport} ) {
709 print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
710 if ( $$hashref{autoexport}=~/true/ ) {
711 $self->{switch}->allowgroup("__export","makebuild");
712 }
713 else {
714 $self->{switch}->disallowgroup("__export","makebuild");
715 }
716 }
717 # -- allow default setting from other makefiles
718 print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
719 }
720
721 sub export_end_export {
722 my $self=shift;
723 $self->{switch}->closegroup("__export");
724 }
725
726 sub export_end {
727 my $self=shift;
728 $self->{switch}->closegroup("__export");
729 print GNUmakefile "endif\n";
730 }
731
732 #
733 # Standard lib tag
734 #
735 sub lib_start {
736 my $self=shift;
737 my $name=shift;
738 my $hashref=shift;
739
740 $self->{switch}->checktag($name, $hashref, 'name');
741 if ( $self->{Arch} ) {
742 print GNUmakefile "lib+=$$hashref{name}\n";
743 }
744 }
745
746 #
747 # libtype specification
748 #
749 sub LibType_Start {
750 my $self=shift;
751 my $name=shift;
752 my $hashref=shift;
753
754 if ( $self->{Arch} ) {
755 if ( defined $self->{libtype_conext} ) {
756 $self->{switch}->parseerror("<$name> tag cannot be specified".
757 " without a </$name> tag to close previous context");
758 }
759 else {
760 $self->{libtype_conext}=1;
761 $self->{switch}->checktag($name, $hashref, 'type');
762
763 my $string=$$hashref{'type'};
764 # -- do some translation for backwards compatability
765 if ($$hashref{'type'}=~/debug_archive/i ) {
766 $string="archive_debug";
767 }
768 elsif ($$hashref{'type'}=~/debug_shared/i ) {
769 $string="shared_debug";
770 }
771 # -- call the Build defaults method
772 $self->Build_start($name, {"class" => "lib", "default" => $string });
773 }
774 }
775 }
776
777 sub LibType_text {
778 my $self=shift;
779 my $name=shift;
780 my $string=shift;
781
782 if ( $self->{Arch} ) {
783 $string=~s/\n/ /g;
784 print GNUmakefile "libmsg::\n\t\@echo Library info: ";
785 print GNUmakefile $string;
786 print GNUmakefile "\n";
787 }
788 }
789
790 sub LibType_end {
791 my $self=shift;
792 my $name=shift;
793
794 undef $self->{libtype_conext};
795 }
796
797 sub Environment_start {
798 my $self=shift;
799 my $name=shift;
800 my $hashref=shift;
801
802 if ( $self->{Arch} ) {
803 $self->{envnum}++;
804
805 # open a new Environment File
806 my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
807 $self->{envnum}.".mk";
808 use FileHandle;
809 my $fh=FileHandle->new();
810 open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
811 push @{$self->{filehandlestack}}, $fh;
812 *GNUmakefile=$fh;
813
814 # include the approprate environment file
815 if ( $self->{envlevel} == 0 ) {
816 print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
817 $self->{path}."/BuildFile.mk\n";
818 }
819 else {
820 print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
821 $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
822 }
823 $self->{envlevel}++;
824 $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
825 $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
826 }
827 $ENV{SCRAM_CURRENTENV}=$self->{currentenv};
828 }
829
830 sub Environment_end {
831 my $self=shift;
832 my $fd;
833
834 if ( $self->{Arch} ) {
835 $self->{envlevel}--;
836 if ( $self->{envlevel} < 0 ) {
837 print "Too many </Environent> Tags on $self->{switch}->line()\n";
838 exit 1;
839 }
840 close GNUmakefile;
841 # restore the last filehandle
842 $fd=pop @{$self->{filehandlestack}};
843 close $fd;
844 *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
845 if ( $self->{envlevel} < 1 ) {
846 $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
847 "BuildFile.mk";
848 }
849 else {
850 $self->{currentenv}=
851 "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
852 $self->{Envlevels}[$self->{envlevel}];
853 }
854 $ENV{SCRAM_CURRENTENV}=$self->{currentenv};
855 }
856 }