ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildFile.pm
Revision: 1.1.2.9
Committed: Fri May 19 06:12:25 2000 UTC (24 years, 11 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
Changes since 1.1.2.8: +3 -0 lines
Log Message:
add group in use tag

File Contents

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