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.2 by williamc, Mon Aug 28 08:23:08 2000 UTC vs.
Revision 1.33 by muzaffar, Fri Jan 14 17:36:42 2011 UTC

# Line 1 | Line 1
1 < # BuildFile
1 > #____________________________________________________________________
2 > # File: BuildFile.pm
3 > #____________________________________________________________________
4 > #  
5 > # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6 > # Update: 2003-12-03 19:03:15+0100
7 > # Revision: $Id$
8   #
9 < # Interface
10 < # ---------
11 < # new(toolbox)
6 < # ParseBuildFile($base,$path,$file)
7 < # ParseBuildFileExport(filename)
8 < # BlockClassPath() : Return the class path
9 < # ignore()      : return 1 if directory should be ignored 0 otherwise
10 <
9 > # Copyright: 2003 (C) Shaun Ashby
10 > #
11 > #--------------------------------------------------------------------
12   package BuildSystem::BuildFile;
12 use ActiveDoc::SimpleDoc;
13 use BuildSystem::ToolBox;
13   require 5.004;
14 + use Exporter;
15 + use ActiveDoc::SimpleDoc;
16  
17 < BEGIN {
18 < $buildfile="BuildFile";
19 < }
20 <
21 < sub new {
22 <        my $class=shift;
23 <        my $self={};
24 <        bless $self, $class;
25 <        $self->{toolbox}=shift;
26 <        $self->{Arch}=1;
27 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
28 <        return $self;
29 < }
30 <
31 < sub ignore {
32 <        my $self=shift;
33 <        return (defined $self->{ignore})?$self->{ignore}:0;
34 < }
35 <
36 < sub _initswitcher {
37 <        my $self=shift;
38 <        my $switch=ActiveDoc::SimpleDoc->new();
39 <        my $parse="makebuild";
40 <        $switch->newparse($parse);
41 <        $switch->addignoretags($parse);
42 <        $self->_commontags($switch,$parse);
43 <        $switch->addtag($parse,"Build", \&Build_start, $self);
44 <        $switch->addtag($parse,"none",
45 <                                        \&OutToMakefile,$self,
46 <                                        \&OutToMakefile, $self,
47 <                                        "", $self);
48 <        $switch->addtag($parse,"Bin",
49 <                                        \&Bin_start,$self,
50 <                                        \&OutToScreen, $self,
51 <                                        "", $self);
52 <        $switch->addtag($parse,"LibType",
53 <                                        \&LibType_Start,$self,
54 <                                        \&LibType_text, $self,
55 <                                        \&LibType_end,$self);
56 <        $switch->addtag($parse,"ConfigurationClass",
57 <                                        \&Class_StartTag,$self,
58 <                                        \&OutToMakefile, $self,
59 <                                        "", $self);
60 <        $switch->addtag($parse,"ClassPath",
61 <                                        \&setBlockClassPath,$self,
62 <                                        \&OutToMakefile, $self,
63 <                                        "", $self);
64 <        $switch->addtag($parse,"AssociateGroup",
65 <                                        "",$self,
66 <                                        \&AssociateGroup,$self,
67 <                                        "", $self);
68 <        $switch->addtag($parse,"Environment",
69 <                                        \&Environment_start,$self,
70 <                                        \&OutToMakefile, $self,
71 <                                        \&Environment_end,$self);
72 <        $switch->addtag($parse,"Export",
73 <                                        \&export_start,$self,
74 <                                        \&OutToMakefile, $self,
75 <                                        \&export_end,$self);
76 <        return $switch;
77 < }
78 <
79 < sub _commontags {
80 <        my $self=shift;
81 <        my $switch=shift;
82 <        my $parse=shift;
83 <
84 <        $switch->grouptag("Export",$parse);
85 <        $switch->addtag($parse,"Use",\&Use_start,$self,
86 <                                               \&OutToMakefile, $self,
87 <                                                "", $self);
88 <        $switch->addtag($parse,"Group",\&Group_start,$self,
89 <                                               \&OutToMakefile, $self,
90 <                                                "", $self);
91 <        $switch->grouptag("Group",$parse);
92 <        $switch->addtag($parse,"External",
93 <                                        \&External_StartTag,$self,
94 <                                        \&OutToMakefile, $self,
95 <                                        "", $self);
96 <        $switch->addtag($parse,"lib",
97 <                                        \&lib_start,$self,
98 <                                        \&OutToMakefile, $self,
99 <                                        "", $self);
100 <        $switch->addtag($parse,"Architecture",
101 <                                        \&Arch_Start,$self,
102 <                                        \&OutToMakefile, $self,
103 <                                        \&Arch_End,$self);
104 <        $switch->addtag($parse,"INCLUDE_PATH",
105 <                                        \&IncludePath_Start,$self,
106 <                                        \&OutToMakefile, $self,
107 <                                        "",$self);
108 <        return $switch;
109 < }
110 <
111 < sub ParseBuildFile {
112 <        my $self=shift;
113 <        my $base=shift;
114 <        my $path=shift;
115 <        my $filename=shift @_;
116 <        my $fullfilename;
117 <        if ( $filename!~/^\// ) {
118 <         $fullfilename="$base/$path/$filename";
119 <        }
120 <        else {
121 <         $fullfilename=$filename;
122 <        }
123 <        $self->{path}=$path;
124 <        #print "Processing $fullfilename\n";
125 <        $numbins=0;
126 <        $self->{envnum}=0;
127 <        $self->{envlevel}=0;
128 <        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
129 <                                                                "BuildFile.mk";
130 <        $self->{switch}=$self->_initswitcher();
131 <        $self->{switch}->filetoparse($fullfilename);
132 <
133 < #       $self->{switch}->{Strict_no_cr}='no';
134 <        #open a temporary gnumakefile to store output.
135 <        use Utilities::AddDir;
136 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
137 <        my $fh=FileHandle->new();
138 <        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
139 <          ) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n';
140 <        @{$self->{filehandlestack}}=($fh);
141 <        # make an alias
142 <        *GNUmakefile=$fh;
143 <        if ( -e $ENV{LatestBuildFile} ) {
144 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
145 <        }
146 < #       print "writing to :\n".
147 < #               "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
148 <        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
149 <        $self->{switch}->parse("makebuild"); # sort out supported tags
150 <        if ( $numbins > 0 ) {
151 <         print GNUmakefile <<ENDTEXT;
152 < ifndef BINMODE
153 < help::
154 < \t\@echo Generic Binary targets
155 < \t\@echo ----------------------
156 < endif
157 < ENDTEXT
158 <         foreach $target ( keys %$targettypes ) {
159 <         print GNUmakefile <<ENDTEXT;
160 < ifndef BINMODE
161 < help::
162 < \t\@echo $target
163 < endif
164 < ENDTEXT
17 > @ISA=qw(Exporter);
18 > @EXPORT_OK=qw( );
19 > #
20 > sub new()
21 >   ###############################################################
22 >   # new                                                         #
23 >   ###############################################################
24 >   # modified : Wed Dec  3 19:03:22 2003 / SFA                   #
25 >   # params   :                                                  #
26 >   #          :                                                  #
27 >   # function :                                                  #
28 >   #          :                                                  #
29 >   ###############################################################
30 >   {
31 >   my $proto=shift;
32 >   my $class=ref($proto) || $proto;
33 >   $self={};
34 >   bless $self,$class;
35 >   $self->{DEPENDENCIES} = {};
36 >   $self->{content} = {};
37 >   $self->{scramdoc}=ActiveDoc::SimpleDoc->new();
38 >   $self->{scramdoc}->newparse("builder",__PACKAGE__,'Subs',shift);
39 >   return $self;
40 >   }
41 >
42 > sub parse()
43 >   {
44 >   my $self=shift;
45 >   my ($filename)=@_;
46 >   my $fhead='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::BuildFile" version="1.0">';
47 >   my $ftail='</doc>';
48 >   $self->{scramdoc}->filetoparse($filename);
49 >   $self->{scramdoc}->parse("builder",$fhead,$ftail);
50 >   # We're done with the SimpleDoc object so delete it:
51 >   delete $self->{scramdoc};
52 >   }
53 >
54 > sub classpath()
55 >   {
56 >   my ($object,$name,%attributes)=@_;
57 >   # The getter part:
58 >   if (ref($object) eq __PACKAGE__)
59 >      {
60 >      return $self->{content}->{CLASSPATH};
61 >      }
62 >  
63 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{CLASSPATH}}, $attributes{'path'})
64 >      : push(@{$self->{content}->{CLASSPATH}}, $attributes{'path'});
65 >   }
66 >
67 > sub productstore()
68 >   {
69 >   my ($object,$name,%attributes)=@_;
70 >   # The getter part:
71 >   if (ref($object) eq __PACKAGE__)
72 >      {
73 >      # Return an array of ProductStore hashes:
74 >      return $self->{content}->{PRODUCTSTORE};
75 >      }
76 >  
77 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{PRODUCTSTORE}}, \%attributes)
78 >      : push(@{$self->{content}->{PRODUCTSTORE}}, \%attributes) ;
79 >   }
80 >
81 > sub include()
82 >   {
83 >   my $self=shift;
84 >   # Return an array of required includes:
85 >   return $self->{content}->{INCLUDE};
86 >   }
87 >
88 > sub include_path()
89 >   {
90 >   my ($object,$name,%attributes)=@_;
91 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{INCLUDE}}, $attributes{'path'})
92 >      : push(@{$self->{content}->{INCLUDE}}, $attributes{'path'});
93 >   }
94 >
95 > sub use()
96 >   {
97 >   my $object=shift;
98 >   # The getter part:
99 >   if (ref($object) eq __PACKAGE__)
100 >      {
101 >      # Add or return uses (package deps):
102 >      @_ ? push(@{$self->{content}->{USE}},@_)
103 >         : @{$self->{content}->{USE}};
104 >      }
105 >   else
106 >      {
107 >      my ($name,%attributes)=@_;
108 >      $self->{DEPENDENCIES}->{$attributes{'name'}} = 1;
109 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{USE}}, $attributes{'name'})
110 >         : push(@{$self->{content}->{USE}}, $attributes{'name'});
111 >      }
112 >   }
113 >
114 > sub architecture()
115 >   {
116 >   my ($object,$name,%attributes)=@_;
117 >   $self->pushlevel(\%attributes); # Set nested to 1;
118 >   }
119 >
120 > sub architecture_()
121 >   {
122 >   $self->{content}->{ARCH}->{$self->{id}->{'name'}}=$self->{tagcontent};
123 >   $self->poplevel();
124 >   }
125 >
126 > sub export()
127 >   {
128 >   $self->pushlevel(); # Set nested to 1;
129 >   }
130 >
131 > sub export_()
132 >   {
133 >   $self->{content}->{EXPORT} = $self->{tagcontent};
134 >   $self->poplevel();
135 >   }
136 >
137 > sub lib()
138 >   {
139 >   my ($object,$name,%attributes)=@_;
140 >   # The getter part:
141 >   if (ref($object) eq __PACKAGE__)
142 >      {
143 >      # Return an array of required libs:
144 >      return $self->{content}->{LIB};      
145 >      }
146 >  
147 >   my $libname;
148 >  
149 >   if (exists($attributes{'position'}))
150 >      {
151 >      if ($attributes{'position'} eq 'first')
152 >         {
153 >         $libname = "F:".$attributes{'name'};
154 >         }
155 >      else
156 >         {
157 >         # There was a position entry but it didn't make sense:
158 >         $libname = $attributes{'name'};
159 >         }
160 >      }
161 >   else
162 >      {
163 >      $libname = $attributes{'name'};
164 >      }
165 >   # We have a libname, add it to the list:
166 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIB}}, $libname)
167 >      : push(@{$self->{content}->{LIB}}, $libname);
168 >   }
169 >
170 > sub libtype()
171 >   {
172 >   my ($object,$name,%attributes)=@_;
173 >   # The getter part:
174 >   if (ref($object) eq __PACKAGE__)
175 >      {
176 >      # Return an array of required libs:
177 >      return $self->{content}->{LIBTYPE};      
178 >      }
179 >
180 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIBTYPE}}, $attributes{'type'})
181 >      : push(@{$self->{content}->{LIBTYPE}}, $attributes{'type'});
182 >   }
183 >
184 > sub skip()
185 >   {
186 >   my ($object,$name,%attributes)=@_;
187 >   $self->{nested} == 1 ? $self->{tagcontent}->{SKIPPEDDIRS} = [ 1 ]
188 >      : $self->{content}->{SKIPPEDDIRS} = [ 1 ];
189 >   }
190 >
191 > sub skip_message()
192 >   {
193 >   my ($object,$name,@message) = @_;
194 >   # Save any message text between <skip> tags:
195 >   if ($#message > -1)
196 >      {
197 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{SKIPPEDDIRS}}, [ @message ])
198 >         : push(@{$self->{content}->{SKIPPEDDIRS}}, [ @message ]);
199 >      }
200 >   }
201 >
202 > sub skip_()
203 >   {
204 >   my ($object,$name)=@_;
205 >   }
206 >
207 > sub makefile()
208 >   {
209 >   my ($object,$name,%attributes)=@_;
210 >   # The getter part:
211 >   if (ref($object) eq __PACKAGE__)
212 >      {
213 >      return $self->{content}->{MAKEFILE};
214 >      }
215 >   }
216 >
217 > sub makefile_()
218 >   {
219 >   my ($object,$name,$cdata)=@_;
220 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{MAKEFILE}}, join("\n",@$cdata))
221 >      : push(@{$self->{content}->{MAKEFILE}}, join("\n",@$cdata));
222 >   }
223 >
224 > sub flags()
225 >   {
226 >   my ($object,$name,%attributes)=@_;
227 >   # The getter part:
228 >   if (ref($object) eq __PACKAGE__)
229 >      {
230 >      # Return an array of ProductStore hashes:
231 >      return $self->{content}->{FLAGS};
232 >      }
233 >  
234 >   # Extract the flag name and its value:
235 >   my ($flagname,$flagvaluestring) = each %attributes;
236 >   $flagname =~ tr/[a-z]/[A-Z]/; # Keep flag name uppercase
237 >   chomp($flagvaluestring);
238 >   my @flagvalues = ( $flagvaluestring );
239 >   # Is current tag within another tag block?
240 >   if ($self->{nested} == 1)
241 >      {
242 >      # Check to see if the current flag name is already stored in the hash. If so,
243 >      # just add the new values to the array of flag values:
244 >      if (exists ($self->{tagcontent}->{FLAGS}->{$flagname}))
245 >         {
246 >         push(@{$self->{tagcontent}->{FLAGS}->{$flagname}},@flagvalues);
247 >         }
248 >      else
249 >         {
250 >         $self->{tagcontent}->{FLAGS}->{$flagname} = [ @flagvalues ];
251 >         }
252 >      }
253 >   else
254 >      {
255 >      if (exists ($self->{content}->{FLAGS}->{$flagname}))
256 >         {
257 >         push(@{$self->{content}->{FLAGS}->{$flagname}},@flagvalues);
258           }
259 <        }
260 <        close GNUmakefile;
261 < }
168 <
169 < sub ParseBuildFile_Export {
170 <        my $self=shift;
171 <        my $filename=shift;
172 <        my $bf=BuildSystem::BuildFile->new($self->{toolbox});
173 <        if ( defined $self->{remoteproject} ) {
174 <           $bf->{remoteproject}=$self->{remoteproject};
175 <        }
176 <        $bf->_parseexport($filename);
177 <        undef $bf;
178 < }
179 <
180 < sub _location {
181 <        my $self=shift;
182 <        use File::Basename;
183 <
184 <        return dirname($self->{switch}->filetoparse());
185 < }
186 <
187 < sub _parseexport {
188 <        my $self=shift;
189 <        my $filename=shift;
190 <
191 <        my $switchex=ActiveDoc::SimpleDoc->new();
192 <        $switchex->filetoparse($filename);
193 <        $switchex->newparse("export");
194 <        $switchex->addignoretags("export");
195 <        $switchex->addtag("export","Export",
196 <                                        \&export_start_export,$self,
197 <                                        \&OutToMakefile, $self,
198 <                                        \&export_end_export,$self);
199 <        $self->_commontags($switchex,"export");
200 <        $switchex->allowgroup("__export","export");
201 < #       $switchex->{Strict_no_cr}='no';
202 <        $self->{switch}=$switchex;
203 <        $switchex->parse("export"); # sort out supported tags
204 < }
205 <
206 < sub _pushremoteproject {
207 <        my $self=shift;
208 <        my $path=shift;
209 <        
210 <        if ( defined $self->{remoteproject} ) {
211 <          push @{$self->{rpstack}}, $self->{remoteproject};
212 <        }
213 <        $self->{remoteproject}=$path;
214 < }
215 <
216 < sub _popremoteproject {
217 <        my $self=shift;
218 <        if ( $#{$self->{rpstack}} >=0 ) {
219 <          $self->{remoteproject}=pop @{$self->{rpstack}};
220 <        }
221 <        else {
222 <          undef $self->{remoteproject};
223 <        }
224 < }
225 <
226 < sub _toolmapper {
227 <        my $self=shift;
228 <        if ( ! defined $self->{mapper} ) {
229 <           require BuildSystem::ToolMapper;
230 <           $self->{mapper}=BuildSystem::ToolMapper->new();
231 <        }
232 <        return $self->{mapper};
233 < }
234 <
235 <
236 < # ---- Tag routines
237 <
238 < #-- Override a class type with the <ConfigurationClass type=xxx> tag
239 < #   the type tag will pick up a pre-defined class type from project space.
240 <
241 < sub Class_StartTag {
242 <        my $self=shift;
243 <        my $name=shift;
244 <        my $hashref=shift;
245 <        
246 <        if ( $self->{Arch} ) {
247 <         if ( defined $$hashref{'type'} ) {
248 <                $ClassName=$$hashref{'type'};
259 >      else
260 >         {
261 >         $self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ];
262           }
263 <        }
264 < }
252 <
253 < sub IncludePath_Start {
254 <        my $self=shift;
255 <        my $name=shift;
256 <        my $hashref=shift;
257 <
258 <        $self->{switch}->checktag( $name, $hashref, 'path');
259 <        if ( $self->{Arch} ) {
260 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
261 <                                                $$hashref{'path'}."\n";
262 <        }
263 < }
263 >      }
264 >   }
265  
266 < #
267 < # generic build tag
268 < #
269 < sub Build_start {
270 <        my $self=shift;
271 <        my $name=shift;
272 <        my $hashref=shift;
273 <
274 <        $self->{switch}->checktag($name,$hashref,'class');
275 <        if ( $self->{Arch} ) {
276 <
277 <          # -- determine the build products name
278 <          my $name;
279 <          if ( exists $$hashref{'name'} ) {
280 <            $name=$$hashref{'name'};
281 <          }
282 <          else {
283 <            $self->{switch}->parseerror("No name specified for build product");
284 <            #$name="\$(buildname)";
284 <          }
285 <
286 <          # -- check we have a lookup for the class type
287 <          my $mapper=$self->_toolmapper();
288 <          if ( ! $mapper->exists($$hashref{'class'}) ) {
289 <            $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
290 <          }
291 <          else {
292 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
293 <           my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
294 <
295 <           my $fh=$self->{filehandlestack}[0];
296 <           my @targets=();
297 <
298 <           # -- generate generic targets
299 <           print $fh "ifndef _BuildLink_\n";
300 <           print $fh "# -- Generic targets\n";
301 <           push @targets, $$hashref{'class'};
302 <           foreach $dtype ( @deftypes ) {
303 <            print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
304 <                                                                $dtype."\n";
305 <           }
306 <           print $fh "\n";
307 <
308 <           # -- generate targets for each type
309 <           foreach $type ( @types ) {
310 <
311 <            # -- generic name for each type
312 <            my $pattern=$$hashref{'class'}."_".$type;
313 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
314 <            print $fh "# ------ $pattern rules ---------------\n";
315 <            print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
316 <                                                        "_".$type."_$name\n\n";
317 <
318 <            # -- create a new directory for each type
319 <            push @targets, $pattern;
320 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
321 <            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
322 <            my $makefile=$here."/BuildFile.mk";
323 < #           AddDir::adddir($here);
324 <
325 <            # -- create link targets to the directory
326 <            push @targets, $dirname;
327 <            print $fh "# -- Link Targets to $type directories\n";
328 <            print $fh "$dirname: make_$dirname\n";
329 <            print $fh "\t\@cd $here; \\\n";
330 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
331 <                        " workdir=$here ".
332 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
333 <
334 <            # -- write target to make makefile for each directory
335 <            print $fh "# -- Build target directories\n";
336 <            print $fh "make_$dirname:\n";
337 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
338 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
339 <            print $fh "\t  mkdir $here; \\\n";
340 <            print $fh "\t fi;\\\n";
341 <            print $fh "\t cd $dirname; \\\n";
342 <            print $fh "\t echo include ".$self->{currentenv}." > ".
343 <                                                        "$makefile; \\\n";
344 <            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
345 <                                        " >> $makefile; \\\n";
346 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
347 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
348 <            if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
349 <             foreach $f ( @file ) {
350 <              print $fh "\t echo -include $f >> $makefile; \\\n";
351 <             }
266 > sub allflags()
267 >   {
268 >   my $self=shift;
269 >   # Return hash data for flags:
270 >   return $self->{content}->{FLAGS};
271 >   }
272 >
273 > sub archspecific()
274 >   {
275 >   my $self=shift;
276 >  
277 >   # Check to see if there is arch-dependent data. If so, return it:
278 >   if ((my $nkeys=keys %{$self->{content}->{ARCH}}) > 0)
279 >      {
280 >      while (my ($k,$v) = each %{$self->{content}->{ARCH}})
281 >         {
282 >         if ( $ENV{SCRAM_ARCH} =~ /$k.*/ )
283 >            {
284 >            return $self->{content}->{ARCH}->{$k};
285              }
353            print $fh "\tfi\n";
354            print $fh "\n";
355 #           print $typefile "$name :\n";
356 #           print $typefile "\t\$(_quietbuild_)";
357 #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
358 #           print $typefile "\t\$(_quietstamp_)";
359 #           print $typefile "$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
360
361            # -- cleaning targets
362            push @targets, "clean_$dirname";
363            print $fh "# -- cleaning targets\n";
364            print $fh "clean::clean_$dirname\n";
365            print $fh "clean_".$dirname."::\n";
366            print $fh "\t\@echo cleaning $dirname\n";
367            print $fh "\t\@if [ -d $here ]; then \\\n";
368            print $fh "\tcd $here; \\\n";
369            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
370                        $here." _BuildLink_=1 -f ".
371                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
372            print $fh "\tfi\n\n";
373
374
375          }
376          # -- help targets
377          print $fh "helpheader::\n";
378          print $fh "\t\@echo Targets available:\n";
379          print $fh "\t\@echo ------------------\n\n";
380          print $fh "help::helpheader\n";
381          foreach $target ( @targets ) {
382            print $fh "help::\n";
383            print $fh "\t\@echo $target\n"
384          }
385          print $fh "endif\n";
386         } # end else
387        }
388 }
389
390 sub Bin_start {
391        my $self=shift;
392        my $name=shift;
393        my $hashref=shift;
394
395        my $fileclass;
396        my @tools;
397        my $tool;
398        my $filename;
399        my $objectname;
400        
401        $self->{switch}->checktag($name,$hashref,'file');
402        if ( $self->{Arch} ) {
403        if ( ! defined $$hashref{name} ) {
404                ($$hashref{name}=$$hashref{file})=~s/\..*//;
405        }
406        ($filename=$$hashref{file})=~s/\..*//;
407
408        # Create a new directory for each binary target
409        my $dirname="bin_".$$hashref{name};
410        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
411        open (binGNUmakefile,
412           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
413           "BuildFile.mk $!\n";
414
415        # Create the link targets
416        $numbins++;
417        my $fh=$self->{filehandlestack}[0];
418        print $fh <<ENDTEXT;
419
420 # Link Targets to binary directories
421 ifdef BINMODE
422 # We dont want to build a library here
423 override files:=
424 endif
425 ifndef BINMODE
426
427 define stepdown_$$hashref{'name'}
428 if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
429 cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
430 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
431 fi
432 endef
433
434 define stepdown2_$$hashref{'name'}
435 if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
436 cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
437 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
438 fi
439
440 endef
441
442 bin_$$hashref{'name'}_%:: dummy
443        \@\$(stepdown2_$$hashref{'name'})
444
445 $$hashref{'name'}_%:: dummy
446        \@\$(stepdown_$$hashref{'name'})
447
448 help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
449        \@\$(stepdown_$$hashref{'name'})
450
451 binfiles+=$$hashref{'file'}
452 locbinfiles+=$dirname/$$hashref{'file'}
453 endif
454
455
456 ENDTEXT
457
458
459 # the binary specifics makefile
460        print binGNUmakefile "include ".$self->{currentenv}."\n";
461        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
462
463 # alias for bin_Insure
464        print binGNUmakefile <<ENDTEXT;
465
466 bin_insure:bin_Insure
467 ifdef MAKETARGET_bin_insure
468 MAKETARGET_$$hashref{name}_Insure=1
469 endif
470
471 # debuggging target
472 $$hashref{'name'}_echo_% :: echo_%
473
474 # help targets
475 help::
476 \t\@echo Targets For $$hashref{'name'}
477 \t\@echo -------------------------------------
478 \t\@echo $$hashref{'name'}  - default build
479 \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
480 ENDTEXT
481
482 # Make generic rules for each type
483        $targettypes={
484                "bin" => 'o',
485                "bin_debug" => 'd',
486                "bin_debug_local" => 'l_d',
487                "bin_Insure" => 'Insure'
488        };
489        #
490        foreach $target ( keys %$targettypes ) {
491          print binGNUmakefile <<ENDTEXT;
492
493 # Type $target specifics
494 ifdef MAKETARGET_$target
495 MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
496 endif
497 $target ::$$hashref{name}_$$targettypes{$target}
498
499 bintargets+=$$hashref{name}_$$targettypes{$target}
500 help::
501 \t\@echo $$hashref{name}_$$targettypes{$target}
502 clean::
503 \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
504 \techo Removing \$(binarystore)/$$hashref{name}; \\
505 \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
506 \tfi
507
508 ENDTEXT
509          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
510          ${"objectname_$$targettypes{$target}"}=$objectname;
511          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
512        } # end loop
513
514        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
515        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
516        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
517        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
518        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
519        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
520        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
521        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
522        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
523        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
524        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
525        print binGNUmakefile "\t\$(CClinkCmd)\n";
526        print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
527        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
528        print binGNUmakefile "-include $$hashref{name}.dep\n";
529 print binGNUmakefile <<ENDTEXT;
530 clean::
531 \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
532 \techo Removing \$(binarystore)/$$hashref{name}; \\
533 \trm \$(binarystore)/$$hashref{name}; \\
534 \tfi
535
536 $$hashref{name}_d.exe:\$(libslocal_d)
537 $$hashref{name}_o.exe:\$(libslocal)
538 ifdef MCCABE_DATA_DIR
539 $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
540 endif
541 $$hashref{name}_Insure.exe:\$(libslocal_I)
542 $$hashref{name}_d:$$hashref{name}_d.exe
543        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
544 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
545        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
546 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
547        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
548 $$hashref{name}:$$hashref{name}_d.exe
549        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
550 $$hashref{name}_o:$$hashref{name}_o.exe
551        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
552 binfiles+=$$hashref{file}
553 ENDTEXT
554        }
555        close binGNUmakefile;
556 }
557
558 sub External_StartTag {
559        my $self=shift;
560        my $name=shift;
561        my $hashref=shift;
562        
563        my $tool;
564        if ( $self->{Arch} ) {
565        $self->{switch}->checktag($name,$hashref,'ref');
566
567        # -- oo toolbox stuff
568        # - get the appropriate tool object
569        $$hashref{'ref'}=~tr[A-Z][a-z];
570        if ( ! exists $$hashref{'version'} ) {
571         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
572        }
573        else {
574         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
575        }
576        if ( ! defined $tool ) {
577          $self->{switch}->parseerror("Unknown Tool Specified ("
578                                                        .$$hashref{'ref'}.")");
579        }
580
581        # -- old fashioned GNUmakefile stuff
582        print GNUmakefile $$hashref{'ref'};
583        if ( defined $$hashref{'version'} ) {
584                print GNUmakefile "_V_".$$hashref{'version'};
585        }
586        print GNUmakefile "=true\n";
587        
588        # -- Sub system also specified?
589        if ( exists $$hashref{'use'} ) {
590           # -- look for a buildfile
591           my @paths=$tool->getfeature("INCLUDE");
592           my $file="";
593           my ($path,$testfile);
594           foreach $path ( @paths ) {
595             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
596             if ( -f $testfile ) {
597                $file=$testfile;
598                $self->_pushremoteproject($path);
599             }
600           }
601           if ( $file eq "" ) {
602             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
603           }
604           $self->ParseBuildFile_Export($file);
605           $self->_popremoteproject();
286           }
287 <        }
288 < }      
289 <
290 < sub Group_start {
291 <        my $self=shift;
292 <        my $name=shift;
293 <        my $hashref=shift;
294 <        
295 <        $self->{switch}->checktag($name, $hashref, 'name');
296 <        if ( $self->{Arch} ) {
297 <        print GNUmakefile "GROUP_".$$hashref{'name'};
298 <        if ( defined $$hashref{'version'} ) {
299 <                print GNUmakefile "_V_".$$hashref{'version'};
300 <        }
301 <        print GNUmakefile "=true\n";
302 <        }
303 < }      
304 <
305 < sub Use_start {
306 <        my $self=shift;
307 <        my $name=shift;
308 <        my $hashref=shift;
309 <        my $filename;
310 <        use Utilities::SCRAMUtils;
311 <        
312 <        $self->{switch}->checktag($name, $hashref, "name");
313 <        if ( $self->{Arch} ) {
314 <        if ( exists $$hashref{'group'} ) {
315 <          print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
316 <        }
317 <        if ( ! defined $self->{remoteproject} ) {
318 <          $filename=SCRAMUtils::checkfile(
319 <                "/$ENV{INTsrc}/$$hashref{name}/BuildFile");
320 <        }
321 <        else {
322 <          $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
323 <        print "trying $filename\n";
324 <          if ( ! -f $filename ) { $filename=""; };
325 <        }
326 <        if ( $filename ne "" ) {
327 <          $self->ParseBuildFile_Export( $filename );
328 <        }
329 <        else {
330 <           $self->{switch}->parseerror("Unable to detect Appropriate ".
331 <                "decription file for <$name name=".$$hashref{name}.">");
332 <        }
333 <        }
334 < }
335 <
336 < sub CheckBuildFile {
337 <         my $self=shift;
338 <         my $classdir=shift;
339 <         my $ClassName="";
340 <         my $thisfile="$classdir/$buildfile";
341 <
342 <         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
343 <            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
344 <            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
345 <         }
346 <         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
347 <            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
348 <            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
349 <         }
350 <         return $ClassName;
351 < }
352 <
353 < # List association groups between <AssociateGroup> tags
354 < # seperated by newlines or spaces
355 < sub AssociateGroup {
356 <        my $self=shift;
357 <        my $name=shift;
358 <        my $string=shift;
359 <        my $word;
360 <
361 <        if ( $self->{Arch} ) {
362 <        foreach $word ( (split /\s/, $string) ){
363 <                chomp $word;
364 <                next if /^#/;
365 <                if ( $word=~/none/ ) {
366 <                        $self->{ignore}=1;
367 <                }
368 <        }
369 <        }
370 < }
371 <
372 < sub Arch_Start {
373 <        my $self=shift;
374 <        my $name=shift;
375 <        my $hashref=shift;
376 <
377 <        $self->{switch}->checktag($name, $hashref,'name');
378 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
379 <                                                : ($self->{Arch}=0);
380 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
381 < }
382 <
383 < sub Arch_End {
384 <        my $self=shift;
385 <        my $name=shift;
386 <
387 <        pop @{$self->{ARCHBLOCK}};
388 <        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
389 < }
390 <
391 < # Split up the Class Block String into a useable array
392 < sub _CutBlock {
393 <    my $self=shift;
394 <    my $string= shift @_;
395 <    @BlockClassA = split /\//, $string;
396 < }
397 <
398 < sub OutToMakefile {
399 <        my $self=shift;
400 <        my $name=shift;
401 <        my @vars=@_;
402 <
403 <        if ( $self->{Arch} ) {
404 <          print GNUmakefile @vars;
405 <        }
406 < }
407 <
408 < sub OutToScreen {
409 <        my $name=shift;
410 <        my @vars=@_;
411 <
412 <        if ( $self->{Arch} ) {
413 <          print @vars;
414 <        }
415 < }
416 < sub setBlockClassPath {
417 <        my $self=shift;
418 <        my $name=shift;
419 <        my $hashref=shift;
420 <
421 <        $self->{switch}->checktag($name, $hashref, 'path');
422 <        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
423 <        $self->_CutBlock($$hashref{path});
424 < }
425 <
426 < sub BlockClassPath {
427 <        my $self=shift;
428 <        return $self->{BlockClassPath};
429 < }
430 <
431 < sub export_start_export {
432 <        my $self=shift;
433 <        my $name=shift;
434 <        my $hashref=shift;
435 <
436 <        $self->{switch}->opengroup("__export");
437 < }
438 <
439 < sub export_start {
440 <        my $self=shift;
441 <        my $name=shift;
442 <        my $hashref=shift;
443 <
444 <        $self->{switch}->opengroup("__export");
445 <        if ( exists $$hashref{autoexport} ) {
446 <          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
447 <          if ( $$hashref{autoexport}=~/true/ ) {
448 <           $self->{switch}->allowgroup("__export","makebuild");
449 <          }
450 <          else {
451 <           $self->{switch}->disallowgroup("__export","makebuild");
452 <          }
453 <        }
454 <        # -- allow default setting from other makefiles
455 <        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
456 < }
457 <
458 < sub export_end_export {
459 <        my $self=shift;
460 <        $self->{switch}->closegroup("__export");
461 < }
462 <
463 < sub export_end {
464 <        my $self=shift;
465 <        $self->{switch}->closegroup("__export");
466 <        print GNUmakefile "endif\n";
467 < }
468 <
469 < #
470 < # Standard lib tag
471 < #
472 < sub lib_start {
473 <        my $self=shift;
474 <        my $name=shift;
475 <        my $hashref=shift;
476 <
477 <        $self->{switch}->checktag($name, $hashref, 'name');
478 <        if ( $self->{Arch} ) {
479 <           print GNUmakefile "lib+=$$hashref{name}\n";
480 <        }
481 < }
287 >      }
288 >   return "";
289 >   }
290 >
291 > sub bin()
292 >   {
293 >   my ($object,$name,%attributes) = @_;
294 >   $self->pushlevel(\%attributes);# Set nested to 1;
295 >   }
296 >
297 > sub bin_()
298 >   {
299 >   # Need unique name for the binary (always use name of product). Either use "name"
300 >   # given, or use "file" value minus the ending:
301 >   if (exists ($self->{id}->{'name'}))
302 >      {
303 >      $name = $self->{id}->{'name'};
304 >      }
305 >   else
306 >      {
307 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
308 >      }
309 >
310 >   # Store the data:
311 >   $self->productcollector($name,'bin','BIN');
312 >   $self->poplevel();
313 >   }
314 >
315 > sub library()
316 >   {
317 >   my ($object,$name,%attributes) = @_;
318 >   $self->pushlevel(\%attributes);# Set nested to 1;
319 >   }
320 >
321 > sub library_()
322 >   {
323 >   # Need unique name for the library (always use name of product). Either use "name"
324 >   # given, or use "file" value minus the ending:
325 >   if (exists ($self->{id}->{'name'}))
326 >      {
327 >      $name = $self->{id}->{'name'};
328 >      }
329 >   else
330 >      {
331 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
332 >      }
333 >
334 >   # Store the data:
335 >   $self->productcollector($name,'lib','LIBRARY');
336 >   $self->poplevel();
337 >   }
338 >
339 > sub productcollector()
340 >   {
341 >   my $self=shift;
342 >   my ($name,$typeshort,$typefull)=@_;
343 >   # Create a new Product object for storage of data:
344 >   use BuildSystem::Product;
345 >   my $product = BuildSystem::Product->new();
346 >   # Store the name:
347 >   $product->name($name);
348 >   $product->type($typeshort);
349 >   # Store the files. Take the BuildFile path as the initial path for
350 >   # expanding source file globs:
351 >   $product->_files($self->{id}->{'file'},[ $self->{scramdoc}->filetoparse() ]);
352 >   # Store the data content:
353 >   $product->_data($self->{tagcontent});
354 >   # And store in a hash (all build products in same place):
355 >   $self->{content}->{BUILDPRODUCTS}->{$typefull}->{$name} = $product;
356 >   }
357 >
358 > sub pushlevel
359 >   {
360 >   my $self = shift;
361 >   my ($info)=@_;
362 >  
363 >   $self->{id} = $info if (defined $info);
364 >   $self->{nested} = 1;
365 >   $self->{tagcontent}={};
366 >   }
367 >
368 > sub poplevel
369 >   {
370 >   my $self = shift;
371 >   delete $self->{id};
372 >   delete $self->{nested};
373 >   delete $self->{tagcontent};
374 >   }
375 >
376 > sub dependencies()
377 >   {
378 >   my $self=shift;
379 >   # Make a copy of the variable so that
380 >   # we don't have a DEPENDENCIES entry in RAWDATA:
381 >   my %DEPS=%{$self->{DEPENDENCIES}};
382 >   delete $self->{DEPENDENCIES};
383 >   return \%DEPS;
384 >   }
385 >
386 > sub skippeddirs()
387 >   {
388 >   my $self=shift;
389 >   my ($here)=@_;
390 >   my $skipped;
391 >
392 >   if ($self->{content}->{SKIPPEDDIRS}->[0] == 1)
393 >      {
394 >      $skipped = [ @{$self->{content}->{SKIPPEDDIRS}} ];
395 >      delete $self->{content}->{SKIPPEDDIRS};
396 >      }
397 >  
398 >   delete $self->{content}->{SKIPPEDDIRS};
399 >   return $skipped;
400 >   }
401 >
402 > sub hasexport()
403 >   {
404 >   my $self=shift;
405 >   # Check to see if there is a valid export block:
406 >   my $nkeys = $self->exporteddatatypes();
407 >   $nkeys > 0 ? return 1 : return 0;
408 >   }
409 >
410 > sub has()
411 >   {
412 >   my $self=shift;
413 >   my ($datatype)=@_;  
414 >   (exists ($self->{content}->{$datatype})) ? return 1 : return 0;
415 >   }
416 >
417 > sub exported()
418 >   {
419 >   my $self=shift;
420 >   # Return a hash. Keys are type of data provided:
421 >   return ($self->{content}->{EXPORT});
422 >   }
423 >
424 > sub exporteddatatypes()
425 >   {
426 >   my $self=shift;
427 >   # Return exported data types:
428 >   return keys %{$self->{content}->{EXPORT}};
429 >   }
430 >
431 > sub buildproducts()
432 >   {
433 >   my $self=shift;
434 >   # Returns hash of build products and their data:
435 >   return $self->{content}->{BUILDPRODUCTS};
436 >   }
437 >
438 > sub values()
439 >   {
440 >   my $self=shift;
441 >   my ($type)=@_;
442 >   # Get a list of values from known types
443 >   return $self->{content}->{BUILDPRODUCTS}->{$type};
444 >   }
445 >
446 > sub basic_tags()
447 >   {
448 >   my $self=shift;
449 >   my $datatags=[];
450 >   my $buildtags=[ qw(BIN LIBRARY BUILDPRODUCTS) ];
451 >   my $skiptags=[ qw(ARCH EXPORT USE CLASSPATH) ];
452 >   my $otherskiptags=[ qw( SKIPPEDDIRS ) ];
453 >   my @all_skip_tags;
454 >  
455 >   push(@all_skip_tags,@$skiptags,@$buildtags,@$otherskiptags);
456 >
457 >   foreach my $t (keys %{$self->{content}})
458 >      {
459 >      push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags));
460 >      }
461 >   return @{$datatags};
462 >   }
463 >
464 > sub clean()
465 >   {
466 >   my $self=shift;
467 >   my (@tags) = @_;
468 >
469 >   # Delete some useless entries:
470 >   delete $self->{simpledoc};
471 >   delete $self->{id};
472 >   delete $self->{tagcontent};
473 >   delete $self->{nested};
474 >
475 >   delete $self->{DEPENDENCIES};
476 >  
477 >   map
478 >      {
479 >      delete $self->{content}->{$_} if (exists($self->{content}->{$_}));
480 >      } @tags;
481 >  
482 >   return $self;
483 >   }
484 >
485 > sub AUTOLOAD()
486 >   {
487 >   my ($xmlparser,$name,%attributes)=@_;
488 >   return if $AUTOLOAD =~ /::DESTROY$/;
489 >   my $name=$AUTOLOAD;
490 >   $name =~ s/.*://;
491 >   }
492  
493 < #
804 < # libtype specification
805 < #
806 < sub LibType_Start {
807 <        my $self=shift;
808 <        my $name=shift;
809 <        my $hashref=shift;
810 <
811 <        if ( $self->{Arch} ) {
812 <        if ( defined $self->{libtype_conext} ) {
813 <          $self->{switch}->parseerror("<$name> tag cannot be specified".
814 <                " without a </$name> tag to close previous context");
815 <        }
816 <        else {
817 <        $self->{libtype_conext}=1;
818 <        $self->{switch}->checktag($name, $hashref, 'type');
819 <        
820 <        print GNUmakefile "# Specify Library Type\n";
821 <        print GNUmakefile "DefaultLibsOff=yes\n";
822 <        if ( $$hashref{'type'}=~/^archive/i ) {
823 <          print GNUmakefile "LibArchive=true\n";
824 <        }
825 <        elsif ($$hashref{'type'}=~/debug_archive/i ) {
826 <          print GNUmakefile "LibDebugArchive=true\n";
827 <        }
828 <        elsif ($$hashref{'type'}=~/debug_shared/i ) {
829 <          print GNUmakefile "LibDebugShared=true\n";
830 <        }
831 <        elsif ($$hashref{'type'}=~/shared/i ) {
832 <          print GNUmakefile 'LibShared=true'."\n";
833 <        }
834 <        print GNUmakefile "\n";
835 <        }
836 <        }
837 < }
838 <
839 < sub LibType_text {
840 <        my $self=shift;
841 <        my $name=shift;
842 <        my $string=shift;
843 <
844 <        if ( $self->{Arch} ) {
845 <          $string=~s/\n/ /g;
846 <          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
847 <          print GNUmakefile $string;
848 <          print GNUmakefile "\n";
849 <        }
850 < }
851 <
852 < sub LibType_end {
853 <        my $self=shift;
854 <        my $name=shift;
855 <
856 <        undef $self->{libtype_conext};
857 < }
858 <
859 < sub Environment_start {
860 <        my $self=shift;
861 <        my $name=shift;
862 <        my $hashref=shift;
863 <
864 <        if ( $self->{Arch} ) {
865 <          $self->{envnum}++;
866 <
867 <          # open a new Environment File
868 <          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
869 <                $self->{envnum}.".mk";
870 <          use FileHandle;
871 <          my $fh=FileHandle->new();
872 <          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
873 <          push @{$self->{filehandlestack}}, $fh;
874 <          *GNUmakefile=$fh;
875 <
876 <          # include the approprate environment file
877 <          if ( $self->{envlevel} == 0 ) {
878 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
879 <                $self->{path}."/BuildFile.mk\n";
880 <          }
881 <          else {
882 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
883 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
884 <          }
885 <          $self->{envlevel}++;
886 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
887 <          $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
888 <        }
889 < }
890 <
891 < sub Environment_end {
892 <        my $self=shift;
893 <        my $fd;
894 <
895 <        if ( $self->{Arch} ) {
896 <          $self->{envlevel}--;
897 <          if ( $self->{envlevel} < 0 ) {
898 <            print "Too many </Environent> Tags on $self->{switch}->line()\n";
899 <            exit 1;
900 <          }
901 <          close GNUmakefile;
902 <          # restore the last filehandle
903 <          $fd=pop @{$self->{filehandlestack}};
904 <          close $fd;
905 <          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
906 <          if ( $self->{envlevel} < 1 ) {
907 <            $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
908 <                        "BuildFile.mk";
909 <          }
910 <          else {
911 <            $self->{currentenv}=
912 <             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
913 <                $self->{Envlevels}[$self->{envlevel}];
914 <          }
915 <        }
916 < }
493 > 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines