ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildSystem/BuildFile.pm
(Generate patch)

Comparing COMP/SCRAM/src/BuildSystem/BuildFile.pm (file contents):
Revision 1.9 by williamc, Fri Sep 29 10:32:18 2000 UTC vs.
Revision 1.34 by muzaffar, Tue Oct 18 14:59:26 2011 UTC

# Line 1 | Line 1
1 < # BuildFile
1 > #____________________________________________________________________
2 > # File: BuildFile.pm
3 > #____________________________________________________________________
4 > #  
5 > # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6 > # Copyright: 2003 (C) Shaun Ashby
7   #
8 < # Interface
4 < # ---------
5 < # new(ConfigArea)
6 < # ParseBuildFile($base,$path,$file)
7 < # ParseBuildFileExport(filename)
8 < # blockparse(Block) : perform a parse to modify the block
9 < # BlockClassPath() : Return the class path
10 < # ignore()      : return 1 if directory should be ignored 0 otherwise
11 < # classname()   : get/set the associated class
12 < # buildfile()   : get/set BuildFile location
13 < # makefile()    : get the generated makefile
14 <
8 > #--------------------------------------------------------------------
9   package BuildSystem::BuildFile;
16 use ActiveDoc::SimpleDoc;
17 use BuildSystem::ToolBox;
10   require 5.004;
11 + use Exporter;
12 + use ActiveDoc::SimpleDoc;
13  
14 < BEGIN {
15 < $buildfile="BuildFile";
16 < }
17 <
18 < sub new {
19 <        my $class=shift;
20 <        my $self={};
21 <        bless $self, $class;
22 <        $self->{area}=shift;
23 <        $self->{toolbox}=$self->{area}->toolbox();
24 <        $self->{localtop}=$self->{area}->location();
25 <        # -- set RELEASTOP
26 <        my $rarea=$self->{area}->linkarea();
27 <        if ( ! defined $rarea ) {
28 <          $self->{releasetop}=$self->{localtop};
29 <        }
30 <        else {
31 <          $self->{releasetop}=$rarea->location();
32 <        }
33 <        $self->{releasetop}=$self->{area}->location();
34 <        $self->{Arch}=1;
35 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
36 <        return $self;
37 < }
38 <
39 < sub buildfile {
40 <        my $self=shift;
41 <        if ( @_ ) {
42 <          $self->{buildfile}=shift;
43 <        }
44 <        return $self->{buildfile};
45 < }
46 <
47 < sub makefile {
48 <        my $self=shift;
49 <        if ( @_ ) {
50 <          $self->{makefile}=shift;
51 <        }
52 <        return $self->{makefile};
53 < }
54 <
55 < sub blockparse {
56 <        my $self=shift;
57 <        $self->{block}=shift;
58 <
59 <        $self->{switch}=$self->_initswitcher();
60 <        $self->_initblockparse($self->{switch});
61 < }
62 <
63 < sub ignore {
64 <        my $self=shift;
65 <        return (defined $self->{ignore})?$self->{ignore}:0;
66 < }
67 <
68 < sub _initswitcher {
69 <        my $self=shift;
70 <        my $switch=ActiveDoc::SimpleDoc->new();
71 <        my $parse="makebuild";
72 <        $switch->newparse($parse);
73 <        $switch->addignoretags($parse);
74 <        $self->_commontags($switch,$parse);
75 <        #$switch->addtag($parse,"Build", \&Build_start, $self);
76 <        $switch->addtag($parse,"none",
77 <                                        \&OutToMakefile,$self,
78 <                                        \&OutToMakefile, $self,
79 <                                        "", $self);
80 <        $switch->addtag($parse,"Bin",
81 <                                        \&Bin_start,$self,
82 <                                        \&OutToScreen, $self,
83 <                                        "", $self);
84 <        $switch->addtag($parse,"ProductStore",
85 <                                        \&Store_start,$self,
86 <                                        "", $self,
87 <                                        "", $self);
88 <        $switch->addtag($parse,"LibType",
89 <                                        \&LibType_Start,$self,
90 <                                        \&LibType_text, $self,
91 <                                        \&LibType_end,$self);
92 <        $switch->addtag($parse,"ConfigurationClass",
93 <                                        \&Class_StartTag,$self,
94 <                                        \&OutToMakefile, $self,
95 <                                        "", $self);
96 <        $switch->addtag($parse,"ClassPath",
97 <                                        \&setBlockClassPath,$self,
98 <                                        \&OutToMakefile, $self,
99 <                                        "", $self);
100 <        $switch->addtag($parse,"AssociateGroup",
101 <                                        "",$self,
102 <                                        \&AssociateGroup,$self,
103 <                                        "", $self);
104 <        $switch->addtag($parse,"Environment",
105 <                                        \&Environment_start,$self,
106 <                                        \&OutToMakefile, $self,
107 <                                        \&Environment_end,$self);
108 <        $switch->addtag($parse,"Export",
109 <                                        \&export_start,$self,
110 <                                        \&OutToMakefile, $self,
111 <                                        \&export_end,$self);
112 <        return $switch;
113 < }
114 <
115 < sub _initblockparse {
116 <        my $self=shift;
117 <        my $switch=shift;
118 <
119 <        my $parse="block";
120 <        $switch->newparse($parse);
121 <        $switch->addignoretags($parse);
122 <        $switch->addtag($parse,"DropDown",
123 <                                        \&DropDown_start,$self,
124 <                                        "", $self,
125 <                                        "", $self);
126 <        $switch->addtag($parse,"Build", \&Build_start, $self);
127 < }
128 <
129 < sub _commontags {
130 <        my $self=shift;
131 <        my $switch=shift;
132 <        my $parse=shift;
133 <
134 <        $switch->grouptag("Export",$parse);
135 <        $switch->addtag($parse,"Use",\&Use_start,$self,
136 <                                               \&OutToMakefile, $self,
137 <                                                "", $self);
138 <        $switch->addtag($parse,"Group",\&Group_start,$self,
139 <                                               \&OutToMakefile, $self,
140 <                                                "", $self);
141 <        $switch->grouptag("Group",$parse);
142 <        $switch->addtag($parse,"External",
143 <                                        \&External_StartTag,$self,
144 <                                        \&OutToMakefile, $self,
145 <                                        "", $self);
146 <        $switch->addtag($parse,"lib",
147 <                                        \&lib_start,$self,
148 <                                        \&OutToMakefile, $self,
149 <                                        "", $self);
150 <        $switch->addtag($parse,"Architecture",
151 <                                        \&Arch_Start,$self,
152 <                                        \&OutToMakefile, $self,
153 <                                        \&Arch_End,$self);
154 <        $switch->addtag($parse,"INCLUDE_PATH",
155 <                                        \&IncludePath_Start,$self,
162 <                                        \&OutToMakefile, $self,
163 <                                        "",$self);
164 <        return $switch;
165 < }
166 <
167 < 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 <        return $outfile;
189 < }
190 <
191 < 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 <        $self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
209 <                                                                "BuildFile.mk";
210 <        $self->{currentenv}=$self->{makefile};
211 <        $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 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
218 <        $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
219 <          $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
220 < }
221 <
222 < sub classname {
223 <        my $self=shift;
224 <        if ( @_ ) {
225 <          $self->{classname}=shift;
226 <        }
227 <        return $self->{classname};
228 < }
229 <
230 < sub ParseBuildFile_Export {
231 <        my $self=shift;
232 <        my $filename=shift;
233 <        my $bf=BuildSystem::BuildFile->new($self->{area});
234 <        if ( defined $self->{remoteproject} ) {
235 <           $bf->{remoteproject}=$self->{remoteproject};
236 <        }
237 <        $bf->_parseexport($filename);
238 <        undef $bf;
239 < }
240 <
241 < sub _location {
242 <        my $self=shift;
243 <        use File::Basename;
244 <
245 <        return dirname($self->{switch}->filetoparse());
246 < }
247 <
248 < sub _parseexport {
249 <        my $self=shift;
250 <        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 <
267 < sub _pushremoteproject {
268 <        my $self=shift;
269 <        my $path=shift;
270 <        
271 <        if ( defined $self->{remoteproject} ) {
272 <          push @{$self->{rpstack}}, $self->{remoteproject};
273 <        }
274 <        $self->{remoteproject}=$path;
275 < }
276 <
277 < 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 <
287 < 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 <        my $self=shift;
304 <        my $name=shift;
305 <        my $hashref=shift;
306 <        
307 <        if ( $self->{Arch} ) {
308 <         if ( defined $$hashref{'type'} ) {
309 <                $self->classname($$hashref{'type'});
14 > @ISA=qw(Exporter);
15 > @EXPORT_OK=qw( );
16 > #
17 > sub new()
18 >   ###############################################################
19 >   # new                                                         #
20 >   ###############################################################
21 >   # modified : Wed Dec  3 19:03:22 2003 / SFA                   #
22 >   # params   :                                                  #
23 >   #          :                                                  #
24 >   # function :                                                  #
25 >   #          :                                                  #
26 >   ###############################################################
27 >   {
28 >   my $proto=shift;
29 >   my $class=ref($proto) || $proto;
30 >   $self={};
31 >   bless $self,$class;
32 >   $self->{DEPENDENCIES} = {};
33 >   $self->{content} = {};
34 >   $self->{scramdoc}=ActiveDoc::SimpleDoc->new();
35 >   $self->{scramdoc}->newparse("builder",__PACKAGE__,'Subs',shift);
36 >   return $self;
37 >   }
38 >
39 > sub parse()
40 >   {
41 >   my $self=shift;
42 >   my ($filename)=@_;
43 >   my $fhead='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::BuildFile" version="1.0">';
44 >   my $ftail='</doc>';
45 >   $self->{scramdoc}->filetoparse($filename);
46 >   $self->{scramdoc}->parse("builder",$fhead,$ftail);
47 >   # We're done with the SimpleDoc object so delete it:
48 >   delete $self->{scramdoc};
49 >   }
50 >
51 > sub classpath()
52 >   {
53 >   my ($object,$name,%attributes)=@_;
54 >   # The getter part:
55 >   if (ref($object) eq __PACKAGE__)
56 >      {
57 >      return $self->{content}->{CLASSPATH};
58 >      }
59 >  
60 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{CLASSPATH}}, $attributes{'path'})
61 >      : push(@{$self->{content}->{CLASSPATH}}, $attributes{'path'});
62 >   }
63 >
64 > sub productstore()
65 >   {
66 >   my ($object,$name,%attributes)=@_;
67 >   # The getter part:
68 >   if (ref($object) eq __PACKAGE__)
69 >      {
70 >      # Return an array of ProductStore hashes:
71 >      return $self->{content}->{PRODUCTSTORE};
72 >      }
73 >  
74 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{PRODUCTSTORE}}, \%attributes)
75 >      : push(@{$self->{content}->{PRODUCTSTORE}}, \%attributes) ;
76 >   }
77 >
78 > sub include()
79 >   {
80 >   my $self=shift;
81 >   # Return an array of required includes:
82 >   return $self->{content}->{INCLUDE};
83 >   }
84 >
85 > sub include_path()
86 >   {
87 >   my ($object,$name,%attributes)=@_;
88 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{INCLUDE}}, $attributes{'path'})
89 >      : push(@{$self->{content}->{INCLUDE}}, $attributes{'path'});
90 >   }
91 >
92 > sub use()
93 >   {
94 >   my $object=shift;
95 >   # The getter part:
96 >   if (ref($object) eq __PACKAGE__)
97 >      {
98 >      # Add or return uses (package deps):
99 >      @_ ? push(@{$self->{content}->{USE}},@_)
100 >         : @{$self->{content}->{USE}};
101 >      }
102 >   else
103 >      {
104 >      my ($name,%attributes)=@_;
105 >      $self->{DEPENDENCIES}->{$attributes{'name'}} = 1;
106 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{USE}}, $attributes{'name'})
107 >         : push(@{$self->{content}->{USE}}, $attributes{'name'});
108 >      }
109 >   }
110 >
111 > sub architecture()
112 >   {
113 >   my ($object,$name,%attributes)=@_;
114 >   $self->pushlevel(\%attributes); # Set nested to 1;
115 >   }
116 >
117 > sub architecture_()
118 >   {
119 >   $self->{content}->{ARCH}->{$self->{id}->{'name'}}=$self->{tagcontent};
120 >   $self->poplevel();
121 >   }
122 >
123 > sub export()
124 >   {
125 >   $self->pushlevel(); # Set nested to 1;
126 >   }
127 >
128 > sub export_()
129 >   {
130 >   $self->{content}->{EXPORT} = $self->{tagcontent};
131 >   $self->poplevel();
132 >   }
133 >
134 > sub lib()
135 >   {
136 >   my ($object,$name,%attributes)=@_;
137 >   # The getter part:
138 >   if (ref($object) eq __PACKAGE__)
139 >      {
140 >      # Return an array of required libs:
141 >      return $self->{content}->{LIB};      
142 >      }
143 >  
144 >   my $libname;
145 >  
146 >   if (exists($attributes{'position'}))
147 >      {
148 >      if ($attributes{'position'} eq 'first')
149 >         {
150 >         $libname = "F:".$attributes{'name'};
151 >         }
152 >      else
153 >         {
154 >         # There was a position entry but it didn't make sense:
155 >         $libname = $attributes{'name'};
156           }
157 <        }
158 < }
159 <
160 < sub IncludePath_Start {
161 <        my $self=shift;
162 <        my $name=shift;
163 <        my $hashref=shift;
164 <
165 <        $self->{switch}->checktag( $name, $hashref, 'path');
166 <        if ( $self->{Arch} ) {
167 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
168 <                                                $$hashref{'path'}."\n";
169 <        }
170 < }
157 >      }
158 >   else
159 >      {
160 >      $libname = $attributes{'name'};
161 >      }
162 >   # We have a libname, add it to the list:
163 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIB}}, $libname)
164 >      : push(@{$self->{content}->{LIB}}, $libname);
165 >   }
166 >
167 > sub libtype()
168 >   {
169 >   my ($object,$name,%attributes)=@_;
170 >   # The getter part:
171 >   if (ref($object) eq __PACKAGE__)
172 >      {
173 >      # Return an array of required libs:
174 >      return $self->{content}->{LIBTYPE};      
175 >      }
176 >
177 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIBTYPE}}, $attributes{'type'})
178 >      : push(@{$self->{content}->{LIBTYPE}}, $attributes{'type'});
179 >   }
180 >
181 > sub skip()
182 >   {
183 >   my ($object,$name,%attributes)=@_;
184 >   $self->{nested} == 1 ? $self->{tagcontent}->{SKIPPEDDIRS} = [ 1 ]
185 >      : $self->{content}->{SKIPPEDDIRS} = [ 1 ];
186 >   }
187 >
188 > sub skip_message()
189 >   {
190 >   my ($object,$name,@message) = @_;
191 >   # Save any message text between <skip> tags:
192 >   if ($#message > -1)
193 >      {
194 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{SKIPPEDDIRS}}, [ @message ])
195 >         : push(@{$self->{content}->{SKIPPEDDIRS}}, [ @message ]);
196 >      }
197 >   }
198 >
199 > sub skip_()
200 >   {
201 >   my ($object,$name)=@_;
202 >   }
203 >
204 > sub makefile()
205 >   {
206 >   my ($object,$name,%attributes)=@_;
207 >   # The getter part:
208 >   if (ref($object) eq __PACKAGE__)
209 >      {
210 >      return $self->{content}->{MAKEFILE};
211 >      }
212 >   }
213 >
214 > sub makefile_()
215 >   {
216 >   my ($object,$name,$cdata)=@_;
217 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{MAKEFILE}}, join("\n",@$cdata))
218 >      : push(@{$self->{content}->{MAKEFILE}}, join("\n",@$cdata));
219 >   }
220 >
221 > sub flags()
222 >   {
223 >   my ($object,$name,%attributes)=@_;
224 >   # The getter part:
225 >   if (ref($object) eq __PACKAGE__)
226 >      {
227 >      # Return an array of ProductStore hashes:
228 >      return $self->{content}->{FLAGS};
229 >      }
230 >  
231 >   # Extract the flag name and its value:
232 >   my ($flagname,$flagvaluestring) = each %attributes;
233 >   $flagname =~ tr/[a-z]/[A-Z]/; # Keep flag name uppercase
234 >   chomp($flagvaluestring);
235 >   my @flagvalues = ( $flagvaluestring );
236 >   # Is current tag within another tag block?
237 >   if ($self->{nested} == 1)
238 >      {
239 >      # Check to see if the current flag name is already stored in the hash. If so,
240 >      # just add the new values to the array of flag values:
241 >      if (exists ($self->{tagcontent}->{FLAGS}->{$flagname}))
242 >         {
243 >         push(@{$self->{tagcontent}->{FLAGS}->{$flagname}},@flagvalues);
244 >         }
245 >      else
246 >         {
247 >         $self->{tagcontent}->{FLAGS}->{$flagname} = [ @flagvalues ];
248 >         }
249 >      }
250 >   else
251 >      {
252 >      if (exists ($self->{content}->{FLAGS}->{$flagname}))
253 >         {
254 >         push(@{$self->{content}->{FLAGS}->{$flagname}},@flagvalues);
255 >         }
256 >      else
257 >         {
258 >         $self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ];
259 >         }
260 >      }
261 >   }
262  
263 < #
264 < # generic build tag
265 < #
266 < sub Build_start {
267 <        my $self=shift;
268 <        my $name=shift;
269 <        my $hashref=shift;
270 <
271 <        $self->{switch}->checktag($name,$hashref,'class');
272 <        $self->{switch}->checktag($name,$hashref,'id');
273 <        if ( $self->{Arch} ) {
274 <
275 <          # -- determine the build products name
276 <          my $name;
277 <          if ( exists $$hashref{'name'} ) {
278 <            $name=$$hashref{'name'};
279 <          }
280 <          else {
281 <            $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 <            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname;
384 <            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 <            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
407 <                                        " >> $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 <             }
263 > sub allflags()
264 >   {
265 >   my $self=shift;
266 >   # Return hash data for flags:
267 >   return $self->{content}->{FLAGS};
268 >   }
269 >
270 > sub archspecific()
271 >   {
272 >   my $self=shift;
273 >  
274 >   # Check to see if there is arch-dependent data. If so, return it:
275 >   if ((my $nkeys=keys %{$self->{content}->{ARCH}}) > 0)
276 >      {
277 >      while (my ($k,$v) = each %{$self->{content}->{ARCH}})
278 >         {
279 >         if ( $ENV{SCRAM_ARCH} =~ /$k.*/ )
280 >            {
281 >            return $self->{content}->{ARCH}->{$k};
282              }
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 #           print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
422
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        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname");
473        open (binGNUmakefile,
474           ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/".
475           "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 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 fi
494 endef
495
496 define stepdown2_$$hashref{'name'}
497 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 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        print binGNUmakefile "VPATH+=".$self->{localtop}."/$self{path}\n";
524
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        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
580        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
581        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
582        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
583        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
584        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
585        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
586        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
587        print binGNUmakefile "\t\$(CClinkCmd)\n";
588        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
589        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();
283           }
284 <        }
285 < }      
286 <
287 < sub Group_start {
288 <        my $self=shift;
289 <        my $name=shift;
290 <        my $hashref=shift;
291 <        
292 <        $self->{switch}->checktag($name, $hashref, 'name');
293 <        if ( $self->{Arch} ) {
294 <        print GNUmakefile "GROUP_".$$hashref{'name'};
295 <        if ( defined $$hashref{'version'} ) {
296 <                print GNUmakefile "_V_".$$hashref{'version'};
297 <        }
298 <        print GNUmakefile "=true\n";
299 <        }
300 < }      
301 <
302 < sub Use_start {
303 <        my $self=shift;
304 <        my $name=shift;
305 <        my $hashref=shift;
306 <        my $filename;
307 <        use Utilities::SCRAMUtils;
308 <        
309 <        $self->{switch}->checktag($name, $hashref, "name");
310 <        if ( $self->{Arch} ) {
311 <        if ( exists $$hashref{'group'} ) {
312 <          print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
313 <        }
314 <        if ( ! defined $self->{remoteproject} ) {
315 <          $filename=SCRAMUtils::checkfile(
316 <                "/$ENV{INTsrc}/$$hashref{name}/BuildFile");
317 <        }
318 <        else {
319 <          $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
320 <        print "trying $filename\n";
321 <          if ( ! -f $filename ) { $filename=""; };
322 <        }
323 <        if ( $filename ne "" ) {
324 <          $self->ParseBuildFile_Export( $filename );
325 <        }
326 <        else {
327 <           $self->{switch}->parseerror("Unable to detect Appropriate ".
328 <                "decription file for <$name name=".$$hashref{name}.">");
329 <        }
330 <        }
331 < }
332 <
333 < # List association groups between <AssociateGroup> tags
334 < # seperated by newlines or spaces
335 < sub AssociateGroup {
336 <        my $self=shift;
337 <        my $name=shift;
338 <        my $string=shift;
339 <        my $word;
340 <
341 <        if ( $self->{Arch} ) {
342 <        foreach $word ( (split /\s/, $string) ){
343 <                chomp $word;
344 <                next if /^#/;
345 <                if ( $word=~/none/ ) {
346 <                        $self->{ignore}=1;
347 <                }
348 <        }
349 <        }
350 < }
351 <
352 < sub Arch_Start {
353 <        my $self=shift;
354 <        my $name=shift;
355 <        my $hashref=shift;
356 <
357 <        $self->{switch}->checktag($name, $hashref,'name');
358 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
359 <                                                : ($self->{Arch}=0);
360 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
361 < }
362 <
363 < sub Arch_End {
364 <        my $self=shift;
365 <        my $name=shift;
366 <
367 <        pop @{$self->{ARCHBLOCK}};
368 <        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
369 < }
370 <
371 < # Split up the Class Block String into a useable array
372 < sub _CutBlock {
373 <    my $self=shift;
374 <    my $string= shift @_;
375 <    @BlockClassA = split /\//, $string;
376 < }
377 <
378 < sub OutToMakefile {
379 <        my $self=shift;
380 <        my $name=shift;
381 <        my @vars=@_;
382 <
383 <        if ( $self->{Arch} ) {
384 <          print GNUmakefile @vars;
385 <        }
386 < }
387 <
388 < sub OutToScreen {
389 <        my $name=shift;
390 <        my @vars=@_;
391 <
392 <        if ( $self->{Arch} ) {
393 <          print @vars;
394 <        }
395 < }
396 < sub setBlockClassPath {
397 <        my $self=shift;
398 <        my $name=shift;
399 <        my $hashref=shift;
400 <
401 <        $self->{switch}->checktag($name, $hashref, 'path');
402 <        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
403 <        $self->_CutBlock($$hashref{path});
404 < }
405 <
406 < sub BlockClassPath {
407 <        my $self=shift;
408 <        return $self->{BlockClassPath};
409 < }
410 <
411 < sub export_start_export {
412 <        my $self=shift;
413 <        my $name=shift;
414 <        my $hashref=shift;
415 <
416 <        $self->{switch}->opengroup("__export");
417 < }
418 <
419 < sub export_start {
420 <        my $self=shift;
421 <        my $name=shift;
422 <        my $hashref=shift;
423 <
424 <        $self->{switch}->opengroup("__export");
425 <        if ( exists $$hashref{autoexport} ) {
426 <          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
427 <          if ( $$hashref{autoexport}=~/true/ ) {
428 <           $self->{switch}->allowgroup("__export","makebuild");
429 <          }
430 <          else {
431 <           $self->{switch}->disallowgroup("__export","makebuild");
432 <          }
433 <        }
434 <        # -- allow default setting from other makefiles
435 <        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
436 < }
437 <
438 < sub export_end_export {
439 <        my $self=shift;
440 <        $self->{switch}->closegroup("__export");
441 < }
442 <
443 < sub export_end {
444 <        my $self=shift;
445 <        $self->{switch}->closegroup("__export");
446 <        print GNUmakefile "endif\n";
447 < }
448 <
449 < #
450 < # Standard lib tag
451 < #
452 < sub lib_start {
453 <        my $self=shift;
454 <        my $name=shift;
455 <        my $hashref=shift;
456 <
457 <        $self->{switch}->checktag($name, $hashref, 'name');
458 <        if ( $self->{Arch} ) {
459 <           print GNUmakefile "lib+=$$hashref{name}\n";
460 <        }
461 < }
284 >      }
285 >   return "";
286 >   }
287 >
288 > sub bin()
289 >   {
290 >   my ($object,$name,%attributes) = @_;
291 >   $self->pushlevel(\%attributes);# Set nested to 1;
292 >   }
293 >
294 > sub bin_()
295 >   {
296 >   # Need unique name for the binary (always use name of product). Either use "name"
297 >   # given, or use "file" value minus the ending:
298 >   if (exists ($self->{id}->{'name'}))
299 >      {
300 >      $name = $self->{id}->{'name'};
301 >      }
302 >   else
303 >      {
304 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
305 >      }
306 >
307 >   # Store the data:
308 >   $self->productcollector($name,'bin','BIN');
309 >   $self->poplevel();
310 >   }
311 >
312 > sub library()
313 >   {
314 >   my ($object,$name,%attributes) = @_;
315 >   $self->pushlevel(\%attributes);# Set nested to 1;
316 >   }
317 >
318 > sub library_()
319 >   {
320 >   # Need unique name for the library (always use name of product). Either use "name"
321 >   # given, or use "file" value minus the ending:
322 >   if (exists ($self->{id}->{'name'}))
323 >      {
324 >      $name = $self->{id}->{'name'};
325 >      }
326 >   else
327 >      {
328 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
329 >      }
330 >
331 >   # Store the data:
332 >   $self->productcollector($name,'lib','LIBRARY');
333 >   $self->poplevel();
334 >   }
335 >
336 > sub productcollector()
337 >   {
338 >   my $self=shift;
339 >   my ($name,$typeshort,$typefull)=@_;
340 >   # Create a new Product object for storage of data:
341 >   use BuildSystem::Product;
342 >   my $product = BuildSystem::Product->new();
343 >   # Store the name:
344 >   $product->name($name);
345 >   $product->type($typeshort);
346 >   # Store the files. Take the BuildFile path as the initial path for
347 >   # expanding source file globs:
348 >   $product->_files($self->{id}->{'file'},[ $self->{scramdoc}->filetoparse() ]);
349 >   # Store the data content:
350 >   $product->_data($self->{tagcontent});
351 >   # And store in a hash (all build products in same place):
352 >   $self->{content}->{BUILDPRODUCTS}->{$typefull}->{$name} = $product;
353 >   }
354 >
355 > sub pushlevel
356 >   {
357 >   my $self = shift;
358 >   my ($info)=@_;
359 >  
360 >   $self->{id} = $info if (defined $info);
361 >   $self->{nested} = 1;
362 >   $self->{tagcontent}={};
363 >   }
364 >
365 > sub poplevel
366 >   {
367 >   my $self = shift;
368 >   delete $self->{id};
369 >   delete $self->{nested};
370 >   delete $self->{tagcontent};
371 >   }
372 >
373 > sub dependencies()
374 >   {
375 >   my $self=shift;
376 >   # Make a copy of the variable so that
377 >   # we don't have a DEPENDENCIES entry in RAWDATA:
378 >   my %DEPS=%{$self->{DEPENDENCIES}};
379 >   delete $self->{DEPENDENCIES};
380 >   return \%DEPS;
381 >   }
382 >
383 > sub skippeddirs()
384 >   {
385 >   my $self=shift;
386 >   my ($here)=@_;
387 >   my $skipped;
388 >
389 >   if ($self->{content}->{SKIPPEDDIRS}->[0] == 1)
390 >      {
391 >      $skipped = [ @{$self->{content}->{SKIPPEDDIRS}} ];
392 >      delete $self->{content}->{SKIPPEDDIRS};
393 >      }
394 >  
395 >   delete $self->{content}->{SKIPPEDDIRS};
396 >   return $skipped;
397 >   }
398 >
399 > sub hasexport()
400 >   {
401 >   my $self=shift;
402 >   # Check to see if there is a valid export block:
403 >   my $nkeys = $self->exporteddatatypes();
404 >   $nkeys > 0 ? return 1 : return 0;
405 >   }
406 >
407 > sub has()
408 >   {
409 >   my $self=shift;
410 >   my ($datatype)=@_;  
411 >   (exists ($self->{content}->{$datatype})) ? return 1 : return 0;
412 >   }
413 >
414 > sub exported()
415 >   {
416 >   my $self=shift;
417 >   # Return a hash. Keys are type of data provided:
418 >   return ($self->{content}->{EXPORT});
419 >   }
420 >
421 > sub exporteddatatypes()
422 >   {
423 >   my $self=shift;
424 >   # Return exported data types:
425 >   return keys %{$self->{content}->{EXPORT}};
426 >   }
427 >
428 > sub buildproducts()
429 >   {
430 >   my $self=shift;
431 >   # Returns hash of build products and their data:
432 >   return $self->{content}->{BUILDPRODUCTS};
433 >   }
434 >
435 > sub values()
436 >   {
437 >   my $self=shift;
438 >   my ($type)=@_;
439 >   # Get a list of values from known types
440 >   return $self->{content}->{BUILDPRODUCTS}->{$type};
441 >   }
442 >
443 > sub basic_tags()
444 >   {
445 >   my $self=shift;
446 >   my $datatags=[];
447 >   my $buildtags=[ qw(BIN LIBRARY BUILDPRODUCTS) ];
448 >   my $skiptags=[ qw(ARCH EXPORT USE CLASSPATH) ];
449 >   my $otherskiptags=[ qw( SKIPPEDDIRS ) ];
450 >   my @all_skip_tags;
451 >  
452 >   push(@all_skip_tags,@$skiptags,@$buildtags,@$otherskiptags);
453 >
454 >   foreach my $t (keys %{$self->{content}})
455 >      {
456 >      push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags));
457 >      }
458 >   return @{$datatags};
459 >   }
460 >
461 > sub clean()
462 >   {
463 >   my $self=shift;
464 >   my (@tags) = @_;
465 >
466 >   # Delete some useless entries:
467 >   delete $self->{simpledoc};
468 >   delete $self->{id};
469 >   delete $self->{tagcontent};
470 >   delete $self->{nested};
471 >
472 >   delete $self->{DEPENDENCIES};
473 >  
474 >   map
475 >      {
476 >      delete $self->{content}->{$_} if (exists($self->{content}->{$_}));
477 >      } @tags;
478 >  
479 >   return $self;
480 >   }
481 >
482 > sub AUTOLOAD()
483 >   {
484 >   my ($xmlparser,$name,%attributes)=@_;
485 >   return if $AUTOLOAD =~ /::DESTROY$/;
486 >   my $name=$AUTOLOAD;
487 >   $name =~ s/.*://;
488 >   }
489  
490 < #
849 < # libtype specification
850 < #
851 < sub LibType_Start {
852 <        my $self=shift;
853 <        my $name=shift;
854 <        my $hashref=shift;
855 <
856 <        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 <        }
861 <        else {
862 <        $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 <        }
879 <        print GNUmakefile "\n";
880 <        }
881 <        }
882 < }
883 <
884 < sub LibType_text {
885 <        my $self=shift;
886 <        my $name=shift;
887 <        my $string=shift;
888 <
889 <        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 < }
896 <
897 < sub LibType_end {
898 <        my $self=shift;
899 <        my $name=shift;
900 <
901 <        undef $self->{libtype_conext};
902 < }
903 <
904 < sub Environment_start {
905 <        my $self=shift;
906 <        my $name=shift;
907 <        my $hashref=shift;
908 <
909 <        if ( $self->{Arch} ) {
910 <          $self->{envnum}++;
911 <
912 <          # open a new Environment File
913 <          my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_".
914 <                $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 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
924 <                $self->{path}."/BuildFile.mk\n";
925 <          }
926 <          else {
927 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
928 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
929 <          }
930 <          $self->{envlevel}++;
931 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
932 <          $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
933 <        }
934 < }
935 <
936 < sub Environment_end {
937 <        my $self=shift;
938 <        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 <            $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
953 <                        "BuildFile.mk";
954 <          }
955 <          else {
956 <            $self->{currentenv}=
957 <             $self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
958 <                $self->{Envlevels}[$self->{envlevel}];
959 <          }
960 <        }
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 <        }
1005 < }
490 > 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines