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.6 by williamc, Fri Sep 15 11:18:21 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 < # BlockClassPath() : Return the class path
9 < # ignore()      : return 1 if directory should be ignored 0 otherwise
10 < # classname()   : get/set the associated class
11 < # buildfile()   : get/set BuildFile location
12 <
8 > #--------------------------------------------------------------------
9   package BuildSystem::BuildFile;
14 use ActiveDoc::SimpleDoc;
15 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 <        $self->{Arch}=1;
26 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
27 <        return $self;
28 < }
29 <
30 < sub buildfile {
31 <        my $self=shift;
32 <        if ( @_ ) {
33 <          $self->{buildfile}=shift;
34 <        }
35 <        return $self->{buildfile};
36 < }
37 <
38 < sub ignore {
39 <        my $self=shift;
40 <        return (defined $self->{ignore})?$self->{ignore}:0;
41 < }
42 <
43 < sub _initswitcher {
44 <        my $self=shift;
45 <        my $switch=ActiveDoc::SimpleDoc->new();
46 <        my $parse="makebuild";
47 <        $switch->newparse($parse);
48 <        $switch->addignoretags($parse);
49 <        $self->_commontags($switch,$parse);
50 <        $switch->addtag($parse,"Build", \&Build_start, $self);
51 <        $switch->addtag($parse,"none",
52 <                                        \&OutToMakefile,$self,
53 <                                        \&OutToMakefile, $self,
54 <                                        "", $self);
55 <        $switch->addtag($parse,"Bin",
56 <                                        \&Bin_start,$self,
57 <                                        \&OutToScreen, $self,
58 <                                        "", $self);
59 <        $switch->addtag($parse,"LibType",
60 <                                        \&LibType_Start,$self,
61 <                                        \&LibType_text, $self,
62 <                                        \&LibType_end,$self);
63 <        $switch->addtag($parse,"ConfigurationClass",
64 <                                        \&Class_StartTag,$self,
65 <                                        \&OutToMakefile, $self,
66 <                                        "", $self);
67 <        $switch->addtag($parse,"ClassPath",
68 <                                        \&setBlockClassPath,$self,
69 <                                        \&OutToMakefile, $self,
70 <                                        "", $self);
71 <        $switch->addtag($parse,"AssociateGroup",
72 <                                        "",$self,
73 <                                        \&AssociateGroup,$self,
74 <                                        "", $self);
75 <        $switch->addtag($parse,"Environment",
76 <                                        \&Environment_start,$self,
77 <                                        \&OutToMakefile, $self,
78 <                                        \&Environment_end,$self);
79 <        $switch->addtag($parse,"Export",
80 <                                        \&export_start,$self,
81 <                                        \&OutToMakefile, $self,
82 <                                        \&export_end,$self);
83 <        return $switch;
84 < }
85 <
86 < sub _commontags {
87 <        my $self=shift;
88 <        my $switch=shift;
89 <        my $parse=shift;
90 <
91 <        $switch->grouptag("Export",$parse);
92 <        $switch->addtag($parse,"Use",\&Use_start,$self,
93 <                                               \&OutToMakefile, $self,
94 <                                                "", $self);
95 <        $switch->addtag($parse,"Group",\&Group_start,$self,
96 <                                               \&OutToMakefile, $self,
97 <                                                "", $self);
98 <        $switch->grouptag("Group",$parse);
99 <        $switch->addtag($parse,"External",
100 <                                        \&External_StartTag,$self,
101 <                                        \&OutToMakefile, $self,
102 <                                        "", $self);
103 <        $switch->addtag($parse,"lib",
104 <                                        \&lib_start,$self,
105 <                                        \&OutToMakefile, $self,
106 <                                        "", $self);
107 <        $switch->addtag($parse,"Architecture",
108 <                                        \&Arch_Start,$self,
109 <                                        \&OutToMakefile, $self,
110 <                                        \&Arch_End,$self);
111 <        $switch->addtag($parse,"INCLUDE_PATH",
112 <                                        \&IncludePath_Start,$self,
113 <                                        \&OutToMakefile, $self,
114 <                                        "",$self);
115 <        return $switch;
116 < }
117 <
118 < sub GenerateMakefile {
119 <        my $self=shift;
120 <        my $infile=shift;
121 <        my $outfile=shift;
122 <
123 <        $self->{switch}=$self->_initswitcher();
124 <        $self->{switch}->filetoparse($infile);
125 <
126 <        # open a temporary gnumakefile to store output.
127 <        my $fh=FileHandle->new();
128 <        open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
129 <                                                                "$!\n";
130 <        @{$self->{filehandlestack}}=($fh);
131 <
132 <        #  -- make an alias
133 <        *GNUmakefile=$fh;
134 <        if ( -e $ENV{LatestBuildFile} ) {
135 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
136 <        }
137 <        $ENV{LatestBuildFile}=$outfile;
138 <        $self->{switch}->parse("makebuild"); # sort out supported tags
139 <        close GNUmakefile;
140 < }
141 <
142 < sub ParseBuildFile {
143 <        my $self=shift;
144 <        my $base=shift;
145 <        my $path=shift;
146 <        my $filename=shift @_;
147 <        my $fullfilename;
148 <        if ( $filename!~/^\// ) {
149 <         $fullfilename="$base/$path/$filename";
150 <        }
151 <        else {
152 <         $fullfilename=$filename;
153 <        }
154 <        $self->{path}=$path;
155 <        #print "Processing $fullfilename\n";
156 <        $numbins=0;
157 <        $self->{envnum}=0;
158 <        $self->{envlevel}=0;
159 <        $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
160 <                                                                "BuildFile.mk";
161 <        $self->{switch}=$self->_initswitcher();
162 <        $self->{switch}->filetoparse($fullfilename);
163 <
164 < #       $self->{switch}->{Strict_no_cr}='no';
165 <        #open a temporary gnumakefile to store output.
166 <        use Utilities::AddDir;
167 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
168 <        my $fh=FileHandle->new();
169 <        open ( $fh, ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
170 <          ) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n';
171 <        @{$self->{filehandlestack}}=($fh);
172 <        # make an alias
173 <        *GNUmakefile=$fh;
174 <        if ( -e $ENV{LatestBuildFile} ) {
175 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
176 <        }
177 < #       print "writing to :\n".
178 < #               "$self->{localtop}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n";
179 <        $ENV{LatestBuildFile}="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
180 <        $self->{switch}->parse("makebuild"); # sort out supported tags
181 <        if ( $numbins > 0 ) {
182 <         print GNUmakefile <<ENDTEXT;
183 < ifndef BINMODE
184 < help::
185 < \t\@echo Generic Binary targets
186 < \t\@echo ----------------------
187 < endif
188 < ENDTEXT
189 <         foreach $target ( keys %$targettypes ) {
190 <         print GNUmakefile <<ENDTEXT;
191 < ifndef BINMODE
192 < help::
193 < \t\@echo $target
194 < endif
195 < ENDTEXT
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 >   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 <        }
257 <        close GNUmakefile;
258 < }
204 <
205 < sub classname {
206 <        my $self=shift;
207 <        if ( @_ ) {
208 <          $self->{classname}=shift;
209 <        }
210 <        return $self->{classname};
211 < }
212 <
213 < sub ParseBuildFile_Export {
214 <        my $self=shift;
215 <        my $filename=shift;
216 <        my $bf=BuildSystem::BuildFile->new($self->{area});
217 <        if ( defined $self->{remoteproject} ) {
218 <           $bf->{remoteproject}=$self->{remoteproject};
219 <        }
220 <        $bf->_parseexport($filename);
221 <        undef $bf;
222 < }
223 <
224 < sub _location {
225 <        my $self=shift;
226 <        use File::Basename;
227 <
228 <        return dirname($self->{switch}->filetoparse());
229 < }
230 <
231 < sub _parseexport {
232 <        my $self=shift;
233 <        my $filename=shift;
234 <
235 <        my $switchex=ActiveDoc::SimpleDoc->new();
236 <        $switchex->filetoparse($filename);
237 <        $switchex->newparse("export");
238 <        $switchex->addignoretags("export");
239 <        $switchex->addtag("export","Export",
240 <                                        \&export_start_export,$self,
241 <                                        \&OutToMakefile, $self,
242 <                                        \&export_end_export,$self);
243 <        $self->_commontags($switchex,"export");
244 <        $switchex->allowgroup("__export","export");
245 < #       $switchex->{Strict_no_cr}='no';
246 <        $self->{switch}=$switchex;
247 <        $switchex->parse("export"); # sort out supported tags
248 < }
249 <
250 < sub _pushremoteproject {
251 <        my $self=shift;
252 <        my $path=shift;
253 <        
254 <        if ( defined $self->{remoteproject} ) {
255 <          push @{$self->{rpstack}}, $self->{remoteproject};
256 <        }
257 <        $self->{remoteproject}=$path;
258 < }
259 <
260 < sub _popremoteproject {
261 <        my $self=shift;
262 <        if ( $#{$self->{rpstack}} >=0 ) {
263 <          $self->{remoteproject}=pop @{$self->{rpstack}};
264 <        }
265 <        else {
266 <          undef $self->{remoteproject};
267 <        }
268 < }
269 <
270 < sub _toolmapper {
271 <        my $self=shift;
272 <        if ( ! defined $self->{mapper} ) {
273 <           require BuildSystem::ToolMapper;
274 <           $self->{mapper}=BuildSystem::ToolMapper->new();
275 <        }
276 <        return $self->{mapper};
277 < }
278 <
279 <
280 < # ---- Tag routines
281 <
282 < #-- Override a class type with the <ConfigurationClass type=xxx> tag
283 < #   the type tag will pick up a pre-defined class type from project space.
284 <
285 < sub Class_StartTag {
286 <        my $self=shift;
287 <        my $name=shift;
288 <        my $hashref=shift;
289 <        
290 <        if ( $self->{Arch} ) {
291 <         if ( defined $$hashref{'type'} ) {
292 <                $self->classname($$hashref{'type'});
256 >      else
257 >         {
258 >         $self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ];
259           }
260 <        }
261 < }
296 <
297 < sub IncludePath_Start {
298 <        my $self=shift;
299 <        my $name=shift;
300 <        my $hashref=shift;
301 <
302 <        $self->{switch}->checktag( $name, $hashref, 'path');
303 <        if ( $self->{Arch} ) {
304 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
305 <                                                $$hashref{'path'}."\n";
306 <        }
307 < }
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 <        if ( $self->{Arch} ) {
273 <
274 <          # -- determine the build products name
275 <          my $name;
276 <          if ( exists $$hashref{'name'} ) {
277 <            $name=$$hashref{'name'};
278 <          }
279 <          else {
280 <            $self->{switch}->parseerror("No name specified for build product");
281 <            #$name="\$(buildname)";
328 <          }
329 <
330 <          # -- check we have a lookup for the class type
331 <          my $mapper=$self->_toolmapper();
332 <          if ( ! $mapper->exists($$hashref{'class'}) ) {
333 <            $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
334 <          }
335 <          else {
336 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
337 <           my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
338 <
339 <           my $fh=$self->{filehandlestack}[0];
340 <           my @targets=();
341 <
342 <           # -- generate generic targets
343 <           print $fh "ifndef _BuildLink_\n";
344 <           print $fh "# -- Generic targets\n";
345 <           push @targets, $$hashref{'class'};
346 <           foreach $dtype ( @deftypes ) {
347 <            print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
348 <                                                                $dtype."\n";
349 <           }
350 <           print $fh "\n";
351 <
352 <           # -- generate targets for each type
353 <           foreach $type ( @types ) {
354 <
355 <            # -- generic name for each type
356 <            my $pattern=$$hashref{'class'}."_".$type;
357 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
358 <            print $fh "# ------ $pattern rules ---------------\n";
359 <            print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
360 <                                                        "_".$type."_$name\n\n";
361 <
362 <            # -- create a new directory for each type
363 <            push @targets, $pattern;
364 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
365 <            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname;
366 <            my $makefile=$here."/BuildFile.mk";
367 < #           AddDir::adddir($here);
368 <
369 <            # -- create link targets to the directory
370 <            push @targets, $dirname;
371 <            print $fh "# -- Link Targets to $type directories\n";
372 <            print $fh "$dirname: make_$dirname\n";
373 <            print $fh "\t\@cd $here; \\\n";
374 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
375 <                        " workdir=$here ".
376 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
377 <
378 <            # -- write target to make makefile for each directory
379 <            print $fh "# -- Build target directories\n";
380 <            print $fh "make_$dirname:\n";
381 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
382 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
383 <            print $fh "\t  mkdir $here; \\\n";
384 <            print $fh "\t fi;\\\n";
385 <            print $fh "\t cd $dirname; \\\n";
386 <            print $fh "\t echo include ".$self->{currentenv}." > ".
387 <                                                        "$makefile; \\\n";
388 <            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
389 <                                        " >> $makefile; \\\n";
390 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
391 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
392 <            if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
393 <             foreach $f ( @file ) {
394 <              print $fh "\t echo -include $f >> $makefile; \\\n";
395 <             }
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              }
397            print $fh "\tfi\n";
398            print $fh "\n";
399 #           print $typefile "$name :\n";
400 #           print $typefile "\t\$(_quietbuild_)";
401 #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
402 #           print $typefile "\t\$(_quietstamp_)";
403 #           print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
404
405            # -- cleaning targets
406            push @targets, "clean_$dirname";
407            print $fh "# -- cleaning targets\n";
408            print $fh "clean::clean_$dirname\n";
409            print $fh "clean_".$dirname."::\n";
410            print $fh "\t\@echo cleaning $dirname\n";
411            print $fh "\t\@if [ -d $here ]; then \\\n";
412            print $fh "\tcd $here; \\\n";
413            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
414                        $here." _BuildLink_=1 -f ".
415                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
416            print $fh "\tfi\n\n";
417
418
419          }
420          # -- help targets
421          print $fh "helpheader::\n";
422          print $fh "\t\@echo Targets available:\n";
423          print $fh "\t\@echo ------------------\n\n";
424          print $fh "help::helpheader\n";
425          foreach $target ( @targets ) {
426            print $fh "help::\n";
427            print $fh "\t\@echo $target\n"
428          }
429          print $fh "endif\n";
430         } # end else
431        }
432 }
433
434 sub Bin_start {
435        my $self=shift;
436        my $name=shift;
437        my $hashref=shift;
438
439        my $fileclass;
440        my @tools;
441        my $tool;
442        my $filename;
443        my $objectname;
444        
445        $self->{switch}->checktag($name,$hashref,'file');
446        if ( $self->{Arch} ) {
447        if ( ! defined $$hashref{name} ) {
448                ($$hashref{name}=$$hashref{file})=~s/\..*//;
449        }
450        ($filename=$$hashref{file})=~s/\..*//;
451
452        # Create a new directory for each binary target
453        my $dirname="bin_".$$hashref{name};
454        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname");
455        open (binGNUmakefile,
456           ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/".
457           "BuildFile.mk $!\n";
458
459        # Create the link targets
460        $numbins++;
461        my $fh=$self->{filehandlestack}[0];
462        print $fh <<ENDTEXT;
463
464 # Link Targets to binary directories
465 ifdef BINMODE
466 # We dont want to build a library here
467 override files:=
468 endif
469 ifndef BINMODE
470
471 define stepdown_$$hashref{'name'}
472 if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
473 cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
474 \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
475 fi
476 endef
477
478 define stepdown2_$$hashref{'name'}
479 if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
480 cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
481 \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
482 fi
483
484 endef
485
486 bin_$$hashref{'name'}_%:: dummy
487        \@\$(stepdown2_$$hashref{'name'})
488
489 $$hashref{'name'}_%:: dummy
490        \@\$(stepdown_$$hashref{'name'})
491
492 help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
493        \@\$(stepdown_$$hashref{'name'})
494
495 binfiles+=$$hashref{'file'}
496 locbinfiles+=$dirname/$$hashref{'file'}
497 endif
498
499
500 ENDTEXT
501
502
503 # the binary specifics makefile
504        print binGNUmakefile "include ".$self->{currentenv}."\n";
505        print binGNUmakefile "VPATH+=$self->{localtop}/$self{path}\n";
506
507 # alias for bin_Insure
508        print binGNUmakefile <<ENDTEXT;
509
510 bin_insure:bin_Insure
511 ifdef MAKETARGET_bin_insure
512 MAKETARGET_$$hashref{name}_Insure=1
513 endif
514
515 # debuggging target
516 $$hashref{'name'}_echo_% :: echo_%
517
518 # help targets
519 help::
520 \t\@echo Targets For $$hashref{'name'}
521 \t\@echo -------------------------------------
522 \t\@echo $$hashref{'name'}  - default build
523 \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
524 ENDTEXT
525
526 # Make generic rules for each type
527        $targettypes={
528                "bin" => 'o',
529                "bin_debug" => 'd',
530                "bin_debug_local" => 'l_d',
531                "bin_Insure" => 'Insure'
532        };
533        #
534        foreach $target ( keys %$targettypes ) {
535          print binGNUmakefile <<ENDTEXT;
536
537 # Type $target specifics
538 ifdef MAKETARGET_$target
539 MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
540 endif
541 $target ::$$hashref{name}_$$targettypes{$target}
542
543 bintargets+=$$hashref{name}_$$targettypes{$target}
544 help::
545 \t\@echo $$hashref{name}_$$targettypes{$target}
546 clean::
547 \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
548 \techo Removing \$(binarystore)/$$hashref{name}; \\
549 \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
550 \tfi
551
552 ENDTEXT
553          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
554          ${"objectname_$$targettypes{$target}"}=$objectname;
555          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
556        } # end loop
557
558        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
559        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
560        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
561        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
562        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
563        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
564        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
565        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
566        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
567        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
568        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
569        print binGNUmakefile "\t\$(CClinkCmd)\n";
570        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
571        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
572        print binGNUmakefile "-include $$hashref{name}.dep\n";
573 print binGNUmakefile <<ENDTEXT;
574 clean::
575 \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
576 \techo Removing \$(binarystore)/$$hashref{name}; \\
577 \trm \$(binarystore)/$$hashref{name}; \\
578 \tfi
579
580 $$hashref{name}_d.exe:\$(libslocal_d)
581 $$hashref{name}_o.exe:\$(libslocal)
582 ifdef MCCABE_DATA_DIR
583 $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
584 endif
585 $$hashref{name}_Insure.exe:\$(libslocal_I)
586 $$hashref{name}_d:$$hashref{name}_d.exe
587        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
588 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
589        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
590 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
591        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
592 $$hashref{name}:$$hashref{name}_d.exe
593        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
594 $$hashref{name}_o:$$hashref{name}_o.exe
595        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
596 binfiles+=$$hashref{file}
597 ENDTEXT
598        }
599        close binGNUmakefile;
600 }
601
602 sub External_StartTag {
603        my $self=shift;
604        my $name=shift;
605        my $hashref=shift;
606        
607        my $tool;
608        if ( $self->{Arch} ) {
609        $self->{switch}->checktag($name,$hashref,'ref');
610
611        # -- oo toolbox stuff
612        # - get the appropriate tool object
613        $$hashref{'ref'}=~tr[A-Z][a-z];
614        if ( ! exists $$hashref{'version'} ) {
615         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
616        }
617        else {
618         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
619        }
620        if ( ! defined $tool ) {
621          $self->{switch}->parseerror("Unknown Tool Specified ("
622                                                        .$$hashref{'ref'}.")");
623        }
624
625        # -- old fashioned GNUmakefile stuff
626        print GNUmakefile $$hashref{'ref'};
627        if ( defined $$hashref{'version'} ) {
628                print GNUmakefile "_V_".$$hashref{'version'};
629        }
630        print GNUmakefile "=true\n";
631        
632        # -- Sub system also specified?
633        if ( exists $$hashref{'use'} ) {
634           # -- look for a buildfile
635           my @paths=$tool->getfeature("INCLUDE");
636           my $file="";
637           my ($path,$testfile);
638           foreach $path ( @paths ) {
639             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
640             if ( -f $testfile ) {
641                $file=$testfile;
642                $self->_pushremoteproject($path);
643             }
644           }
645           if ( $file eq "" ) {
646             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
647           }
648           $self->ParseBuildFile_Export($file);
649           $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 < #
831 < # libtype specification
832 < #
833 < sub LibType_Start {
834 <        my $self=shift;
835 <        my $name=shift;
836 <        my $hashref=shift;
837 <
838 <        if ( $self->{Arch} ) {
839 <        if ( defined $self->{libtype_conext} ) {
840 <          $self->{switch}->parseerror("<$name> tag cannot be specified".
841 <                " without a </$name> tag to close previous context");
842 <        }
843 <        else {
844 <        $self->{libtype_conext}=1;
845 <        $self->{switch}->checktag($name, $hashref, 'type');
846 <        
847 <        print GNUmakefile "# Specify Library Type\n";
848 <        print GNUmakefile "DefaultLibsOff=yes\n";
849 <        if ( $$hashref{'type'}=~/^archive/i ) {
850 <          print GNUmakefile "LibArchive=true\n";
851 <        }
852 <        elsif ($$hashref{'type'}=~/debug_archive/i ) {
853 <          print GNUmakefile "LibDebugArchive=true\n";
854 <        }
855 <        elsif ($$hashref{'type'}=~/debug_shared/i ) {
856 <          print GNUmakefile "LibDebugShared=true\n";
857 <        }
858 <        elsif ($$hashref{'type'}=~/shared/i ) {
859 <          print GNUmakefile 'LibShared=true'."\n";
860 <        }
861 <        print GNUmakefile "\n";
862 <        }
863 <        }
864 < }
865 <
866 < sub LibType_text {
867 <        my $self=shift;
868 <        my $name=shift;
869 <        my $string=shift;
870 <
871 <        if ( $self->{Arch} ) {
872 <          $string=~s/\n/ /g;
873 <          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
874 <          print GNUmakefile $string;
875 <          print GNUmakefile "\n";
876 <        }
877 < }
878 <
879 < sub LibType_end {
880 <        my $self=shift;
881 <        my $name=shift;
882 <
883 <        undef $self->{libtype_conext};
884 < }
885 <
886 < sub Environment_start {
887 <        my $self=shift;
888 <        my $name=shift;
889 <        my $hashref=shift;
890 <
891 <        if ( $self->{Arch} ) {
892 <          $self->{envnum}++;
893 <
894 <          # open a new Environment File
895 <          my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_".
896 <                $self->{envnum}.".mk";
897 <          use FileHandle;
898 <          my $fh=FileHandle->new();
899 <          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
900 <          push @{$self->{filehandlestack}}, $fh;
901 <          *GNUmakefile=$fh;
902 <
903 <          # include the approprate environment file
904 <          if ( $self->{envlevel} == 0 ) {
905 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
906 <                $self->{path}."/BuildFile.mk\n";
907 <          }
908 <          else {
909 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
910 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
911 <          }
912 <          $self->{envlevel}++;
913 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
914 <          $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
915 <        }
916 < }
917 <
918 < sub Environment_end {
919 <        my $self=shift;
920 <        my $fd;
921 <
922 <        if ( $self->{Arch} ) {
923 <          $self->{envlevel}--;
924 <          if ( $self->{envlevel} < 0 ) {
925 <            print "Too many </Environent> Tags on $self->{switch}->line()\n";
926 <            exit 1;
927 <          }
928 <          close GNUmakefile;
929 <          # restore the last filehandle
930 <          $fd=pop @{$self->{filehandlestack}};
931 <          close $fd;
932 <          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
933 <          if ( $self->{envlevel} < 1 ) {
934 <            $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
935 <                        "BuildFile.mk";
936 <          }
937 <          else {
938 <            $self->{currentenv}=
939 <             $self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
940 <                $self->{Envlevels}[$self->{envlevel}];
941 <          }
942 <        }
943 < }
490 > 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines