ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildFile.pm
Revision: 1.8
Committed: Fri Sep 29 06:45:51 2000 UTC (24 years, 7 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.7: +75 -3 lines
Log Message:
update from laptop

File Contents

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