ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildFile.pm
Revision: 1.9
Committed: Fri Sep 29 10:32:18 2000 UTC (24 years, 7 months ago) by williamc
Content type: text/plain
Branch: MAIN
Changes since 1.8: +10 -1 lines
Log Message:
Bugfixes

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