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.11 by williamc, Thu Nov 2 15:24:09 2000 UTC vs.
Revision 1.30 by sashby, Tue Feb 27 11:59:44 2007 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(ConfigArea)
6 < # ParseBuildFile($base,$path,$file)
7 < # ParseBuildFileExport(filename)
8 < # BlockParse(Block) : perform a parse to modify the block
9 < # BlockClassPath() : Return the class path
10 < # ignore()      : return 1 if directory should be ignored 0 otherwise
11 < # classname()   : get/set the associated class
12 < # buildfile()   : get/set BuildFile location
13 < # makefile()    : get the generated makefile
14 <
9 > # Copyright: 2003 (C) Shaun Ashby
10 > #
11 > #--------------------------------------------------------------------
12   package BuildSystem::BuildFile;
16 use ActiveDoc::SimpleDoc;
17 use BuildSystem::ToolBox;
13   require 5.004;
14 + use Exporter;
15 + use ActiveDoc::SimpleDoc;
16  
17 < BEGIN {
18 < $buildfile="BuildFile";
22 < }
23 <
24 < sub new {
25 <        my $class=shift;
26 <        my $self={};
27 <        bless $self, $class;
28 <        $self->{area}=shift;
29 <        $self->{toolbox}=$self->{area}->toolbox();
30 <        $self->{localtop}=$self->{area}->location();
31 <        # -- set RELEASTOP
32 <        my $rarea=$self->{area}->linkarea();
33 <        if ( ! defined $rarea ) {
34 <          $self->{releasetop}=$self->{localtop};
35 <        }
36 <        else {
37 <          $self->{releasetop}=$rarea->location();
38 <        }
39 <        $self->{releasetop}=$self->{area}->location();
40 <        $self->{Arch}=1;
41 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
42 <        return $self;
43 < }
44 <
45 < sub buildfile {
46 <        my $self=shift;
47 <        if ( @_ ) {
48 <          $self->{buildfile}=shift;
49 <        }
50 <        return $self->{buildfile};
51 < }
52 <
53 < sub makefile {
54 <        my $self=shift;
55 <        if ( @_ ) {
56 <          $self->{makefile}=shift;
57 <        }
58 <        return $self->{makefile};
59 < }
60 <
61 < sub BlockParse {
62 <        my $self=shift;
63 <        $self->{block}=shift;
64 <
65 <        # -- set up the block parse
66 <        my $switch=$self->_initswitcher();
67 <        my $parse="block";
68 <        $switch->newparse($parse);
69 <        $switch->addignoretags($parse);
70 <        $switch->addtag($parse,"BuildParam", \&BuildBlock_start, $self);
71 <        $switch->filetoparse($self->buildfile());
72 <
73 <        # -- parse away
74 <        $self->{switch}=$switch;
75 <        $switch->parse("block");
76 < }
77 <
78 < sub Parsetofh {
79 <        my $self=shift;
80 <        my $fh=shift;
81 <        $self->{buildblock}=shift;
82 <
83 <        # -- set up for parse
84 <        @{$self->{filehandlestack}}=($fh);
85 <        $self->{switch}->filetoparse($self->buildfile());
86 <        *GNUmakefile=$fh;
87 <
88 <        # -- generate makefile
89 <        $self->{switch}->parse("makebuild"); # sort out supported tags
90 <
91 <        # -- Clean up
92 <        close GNUmakefile;
93 < }
94 <
95 < sub ignore {
96 <        my $self=shift;
97 <        return (defined $self->{ignore})?$self->{ignore}:0;
98 < }
99 <
100 < sub _initswitcher {
101 <        my $self=shift;
102 <        my $switch=ActiveDoc::SimpleDoc->new();
103 <        my $parse="makebuild";
104 <        $switch->newparse($parse);
105 <        $switch->addignoretags($parse);
106 <        $self->_commontags($switch,$parse);
107 <        #$switch->addtag($parse,"Build", \&Build_start, $self);
108 <        $switch->addtag($parse,"none",
109 <                                        \&OutToMakefile,$self,
110 <                                        \&OutToMakefile, $self,
111 <                                        "", $self);
112 <        $switch->addtag($parse,"Bin",
113 <                                        \&Bin_start,$self,
114 <                                        \&OutToScreen, $self,
115 <                                        "", $self);
116 <        $switch->addtag($parse,"ProductStore",
117 <                                        \&Store_start,$self,
118 <                                        "", $self,
119 <                                        "", $self);
120 <        $switch->addtag($parse,"LibType",
121 <                                        \&LibType_Start,$self,
122 <                                        \&LibType_text, $self,
123 <                                        \&LibType_end,$self);
124 <        $switch->addtag($parse,"ConfigurationClass",
125 <                                        \&Class_StartTag,$self,
126 <                                        \&OutToMakefile, $self,
127 <                                        "", $self);
128 <        $switch->addtag($parse,"ClassPath",
129 <                                        \&setBlockClassPath,$self,
130 <                                        \&OutToMakefile, $self,
131 <                                        "", $self);
132 <        $switch->addtag($parse,"AssociateGroup",
133 <                                        "",$self,
134 <                                        \&AssociateGroup,$self,
135 <                                        "", $self);
136 <        $switch->addtag($parse,"Environment",
137 <                                        \&Environment_start,$self,
138 <                                        \&OutToMakefile, $self,
139 <                                        \&Environment_end,$self);
140 <        $switch->addtag($parse,"Export",
141 <                                        \&export_start,$self,
142 <                                        \&OutToMakefile, $self,
143 <                                        \&export_end,$self);
144 <        return $switch;
145 < }
146 <
147 < sub _commontags {
148 <        my $self=shift;
149 <        my $switch=shift;
150 <        my $parse=shift;
151 <
152 <        $switch->grouptag("Export",$parse);
153 <        $switch->addtag($parse,"Use",\&Use_start,$self,
154 <                                               \&OutToMakefile, $self,
155 <                                                "", $self);
156 <        $switch->addtag($parse,"Group",\&Group_start,$self,
157 <                                               \&OutToMakefile, $self,
158 <                                                "", $self);
159 <        $switch->grouptag("Group",$parse);
160 <        $switch->addtag($parse,"External",
161 <                                        \&External_StartTag,$self,
162 <                                        \&OutToMakefile, $self,
163 <                                        "", $self);
164 <        $switch->addtag($parse,"lib",
165 <                                        \&lib_start,$self,
166 <                                        \&OutToMakefile, $self,
167 <                                        "", $self);
168 <        $switch->addtag($parse,"Architecture",
169 <                                        \&Arch_Start,$self,
170 <                                        \&OutToMakefile, $self,
171 <                                        \&Arch_End,$self);
172 <        $switch->addtag($parse,"INCLUDE_PATH",
173 <                                        \&IncludePath_Start,$self,
174 <                                        \&OutToMakefile, $self,
175 <                                        "",$self);
176 <        return $switch;
177 < }
178 <
179 < sub GenerateMakefile {
180 <        my $self=shift;
181 <        my $infile=shift;
182 <        my $outfile=shift;
183 <
184 <        $self->{switch}=$self->_initswitcher();
185 <        $self->{switch}->filetoparse($infile);
186 <
187 <        # open a temporary gnumakefile to store output.
188 <        my $fh=FileHandle->new();
189 <        open ( $fh, ">$outfile") or die "Unable to open $outfile for output ".
190 <                                                                "$!\n";
191 <        @{$self->{filehandlestack}}=($fh);
192 <
193 <        #  -- make an alias
194 <        *GNUmakefile=$fh;
195 <        if ( -e $ENV{LatestBuildFile} ) {
196 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
197 <        }
198 <        $self->{switch}->parse("makebuild"); # sort out supported tags
199 <        close GNUmakefile;
200 <        return $outfile;
201 < }
202 <
203 < sub ParseBuildFile {
204 <        my $self=shift;
205 <        my $base=shift;
206 <        my $path=shift;
207 <        my $filename=shift @_;
208 <        my $fullfilename;
209 <        if ( $filename!~/^\// ) {
210 <         $fullfilename="$base/$path/$filename";
211 <        }
212 <        else {
213 <         $fullfilename=$filename;
214 <        }
215 <        $self->{path}=$path;
216 <        #print "Processing $fullfilename\n";
217 <        $numbins=0;
218 <        $self->{envnum}=0;
219 <        $self->{envlevel}=0;
220 <        $self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
221 <                                                                "BuildFile.mk";
222 <        $self->{currentenv}=$self->{makefile};
223 <        $self->{switch}=$self->_initswitcher();
224 <        $self->{switch}->filetoparse($fullfilename);
225 <
226 < #       $self->{switch}->{Strict_no_cr}='no';
227 <        #open a temporary gnumakefile to store output.
228 <        use Utilities::AddDir;
229 <        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
230 <        $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
231 <         $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
232 < }
233 <
234 < sub classname {
235 <        my $self=shift;
236 <        if ( @_ ) {
237 <          $self->{classname}=shift;
238 <        }
239 <        return $self->{classname};
240 < }
241 <
242 < sub ParseBuildFile_Export {
243 <        my $self=shift;
244 <        my $filename=shift;
245 <        my $bf=BuildSystem::BuildFile->new($self->{area});
246 <        if ( defined $self->{remoteproject} ) {
247 <           $bf->{remoteproject}=$self->{remoteproject};
248 <        }
249 <        $bf->_parseexport($filename);
250 <        undef $bf;
251 < }
252 <
253 < sub _location {
254 <        my $self=shift;
255 <        use File::Basename;
256 <
257 <        return dirname($self->{switch}->filetoparse());
258 < }
259 <
260 < sub _parseexport {
261 <        my $self=shift;
262 <        my $filename=shift;
263 <
264 <        my $switchex=ActiveDoc::SimpleDoc->new();
265 <        $switchex->filetoparse($filename);
266 <        $switchex->newparse("export");
267 <        $switchex->addignoretags("export");
268 <        $switchex->addtag("export","Export",
269 <                                        \&export_start_export,$self,
270 <                                        \&OutToMakefile, $self,
271 <                                        \&export_end_export,$self);
272 <        $self->_commontags($switchex,"export");
273 <        $switchex->allowgroup("__export","export");
274 < #       $switchex->{Strict_no_cr}='no';
275 <        $self->{switch}=$switchex;
276 <        $switchex->parse("export"); # sort out supported tags
277 < }
278 <
279 < sub _pushremoteproject {
280 <        my $self=shift;
281 <        my $path=shift;
282 <        
283 <        if ( defined $self->{remoteproject} ) {
284 <          push @{$self->{rpstack}}, $self->{remoteproject};
285 <        }
286 <        $self->{remoteproject}=$path;
287 < }
288 <
289 < sub _popremoteproject {
290 <        my $self=shift;
291 <        if ( $#{$self->{rpstack}} >=0 ) {
292 <          $self->{remoteproject}=pop @{$self->{rpstack}};
293 <        }
294 <        else {
295 <          undef $self->{remoteproject};
296 <        }
297 < }
298 <
299 < sub _toolmapper {
300 <        my $self=shift;
301 <        if ( ! defined $self->{mapper} ) {
302 <           require BuildSystem::ToolMapper;
303 <           $self->{mapper}=BuildSystem::ToolMapper->new();
304 <        }
305 <        return $self->{mapper};
306 < }
307 <
308 <
309 < # ---- Tag routines
310 <
311 < #-- Override a class type with the <ConfigurationClass type=xxx> tag
312 < #   the type tag will pick up a pre-defined class type from project space.
313 <
314 < sub Class_StartTag {
315 <        my $self=shift;
316 <        my $name=shift;
317 <        my $hashref=shift;
318 <        
319 <        if ( $self->{Arch} ) {
320 <         if ( defined $$hashref{'type'} ) {
321 <                $self->classname($$hashref{'type'});
322 <         }
323 <        }
324 < }
325 <
326 < sub IncludePath_Start {
327 <        my $self=shift;
328 <        my $name=shift;
329 <        my $hashref=shift;
330 <
331 <        $self->{switch}->checktag( $name, $hashref, 'path');
332 <        if ( $self->{Arch} ) {
333 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
334 <                                                $$hashref{'path'}."\n";
335 <        }
336 < }
337 <
338 < #
339 < # --- <Build class=> tag
340 < #
341 <
17 > @ISA=qw(Exporter);
18 > @EXPORT_OK=qw( );
19   #
20 < # Parameter collection
21 < #
22 < sub BuildBlock_start {
23 <        my $self=shift;
24 <        my $name=shift;
25 <        my $hashref=shift;
26 <
27 <
28 <        my $blockobjid=$self->__blockobjid($hashref);
29 <
30 <        if ( $self->{Arch} ) {
31 <
32 <           # -- get any objects that match
33 <           my $inheritobj=$self->{block}->getobj($blockobjid);
34 <
35 <           # -- create an object with inherited properties
36 <           my $obj;
37 <           if ( ! defined $inheritobj ) {
38 <               # -- check we have a lookup for the class type
39 <               my $mapper=$self->_toolmapper();
40 <               if ( ! $mapper->exists($$hashref{'class'}) ) {
41 <                 $self->{switch}->parseerror("Unknown class : ".
42 <                                                        $$hashref{'class'});
43 <               }
44 <               $obj=BuildSystem::BuildClass->new();
45 <           }
46 <           else {
47 <               # -- inherit the properties from class with the same id class
48 <               $obj=$inheritobj->child();
49 <           }
50 <
51 <           # -- add changes from our tag
52 <           $obj->paramupdate($hashref);
53 <
54 <           # -- store the new object in the block
55 <           $self->{block}->setobj($obj,$blockobjid);
56 <        }
57 < }
58 <
59 < sub BuilderClass_buildmakefile {
60 <        my $self=shift;
61 <        my $name=shift;
62 <        my $hashref=shift;
63 <
64 <        my $blockobjid=$self->__blockobjid($hashref);
65 <
66 <        if ( $self->{Arch} ) {
67 <           # -- get the matching block object
68 <           my $blockobj=$self->{buildblock}->getobj($blockobjid);
69 <
70 <           # -- top level buildfile
71 <           my $fh=$self->{filehandlestack}[0];
72 <
73 <           # -- var initialisation
74 <           my @deftypes=();
75 <           my $buildname="";
76 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
77 <
78 <           # -- error checking
79 <           if ( ! defined $blockobj->param("default") ) {
80 <             $self->error("No default build parameter defined for ".
81 <                $$hashref{'class'}." ".$$hashref{'id'});
82 <           }
83 <           if ( ! defined $blockobj->param("name") ) {
84 <             $self->error("\"name\" parameter defined for ".
85 <                $$hashref{'class'}." ".$$hashref{'id'});
86 <           }
87 <
88 <
89 <           foreach $param ( $blockobj->paramlist() ) {
90 <             # -- check for params that need special handling
91 <             if ( $param eq "default" ) {
92 <                @deftypes=split /,/, $param;  
93 <             }
94 <             elsif ( $param eq "name" ) {
95 <                $buildname=$blockobj->param($param);
96 <             }
97 <             else {
98 <                # -- simple transfer of block object parameters to makefile
99 <                print $fh $param.":=".$blockobj->param($param)."\n";
100 <             }
101 <           }
102 <          
103 <           # -- construct the targets in the top makefile
104 <           $self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes);
105 <           $self->_generatetypetargets($fh,$$hashref{'class'},$buildname,@types);
106 <        }
107 < }
108 <
109 < sub _blockobjid {
110 <        my $self=shift;
111 <        my $hashref=shift;
112 <
113 <        $self->{switch}->checktag($name,$hashref,'class');
114 <        $self->{switch}->checktag($name,$hashref,'id');
115 <        my $blockobjid="bc_".$$hashref{'class'},"_".$$hashref{'id'};
116 <
117 <        return $blockobjid;
118 < }
119 <
120 < sub _generatedefaulttargets {
121 <        my $self=shift;
122 <        my $fh=shift;
123 <        my $class=shift;
124 <
125 <        my @deftypes=shift;
126 <
127 <        print $fh "# -- Default type targets\n";
128 <        foreach $dtype ( @deftypes ) {
129 <            print $fh $class."::".$class."_".$dtype."\n";
130 <        }
131 <        print $fh "\n";
132 < }
133 <
134 < sub _generatetypetargets {
135 <        my $self=shift;
136 <        my $fh=shift;
137 <        my $class=shift;
138 <        my $name=shift;
139 <
140 <        my @types=shift;
141 <
142 <        print $fh "# -- Generic type targets\n";
143 <        foreach $type ( @types ) {
144 <            my $pattern=$class."_".$type;
145 <            my $dirname=$class."_".$type."_".$name;
146 <            my $makefile=$here."/BuildFile.mk";
147 <
148 <            # -- map to generic name for each type
149 <            print $fh "# ------ $pattern rules ---------------\n";
150 <            print $fh $class."_".$type."::".$class.
151 <                                                        "_".$type."_$name\n\n";
152 <
153 <            print $fh "# -- Link Targets to $type directories\n";
154 <            print $fh "$dirname: make_$dirname\n";
155 <            print $fh "\t\@cd $here; \\\n";
156 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
157 <                        " workdir=$here ".
158 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
159 <
160 <            # -- write target to make makefile for each directory
161 <            print $fh "# -- Build target directories\n";
162 <            print $fh "make_$dirname:\n";
163 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
164 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
165 <            print $fh "\t  mkdir $here; \\\n";
166 <            print $fh "\t fi;\\\n";
167 <            print $fh "\t cd $dirname; \\\n";
168 <            print $fh "\t echo include ".$self->{currentenv}." > ".
169 <                                                        "$makefile; \\\n";
170 <            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
171 <                                        " >> $makefile; \\\n";
172 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
173 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
174 <            if ( defined (my @file=$mapper->rulesfile($class)) ) {
175 <             foreach $f ( @file ) {
176 <              print $fh "\t echo -include $f >> $makefile; \\\n";
177 <             }
178 <            }
179 <            print $fh "\tfi\n";
180 <            print $fh "\n";
181 <
182 <            # -- cleaning targets
183 <            push @targets, "clean_$dirname";
184 <            print $fh "# -- cleaning targets\n";
185 <            print $fh "clean::clean_$dirname\n";
186 <            print $fh "clean_".$dirname."::\n";
187 <            print $fh "\t\@echo cleaning $dirname\n";
188 <            print $fh "\t\@if [ -d $here ]; then \\\n";
189 <            print $fh "\tcd $here; \\\n";
190 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
191 <                        $here." _BuildLink_=1 -f ".
192 <                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
193 <            print $fh "\tfi\n\n";
194 <
195 <        }
196 <        print $fh "\n";
197 < }
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');
39 >   return $self;
40 >   }
41 >
42 > sub parse()
43 >   {
44 >   my $self=shift;
45 >   my ($filename)=@_;
46 >   $self->{scramdoc}->filetoparse($filename);
47 >   $self->{scramdoc}->parse("builder");
48 >   # We're done with the SimpleDoc object so delete it:
49 >   delete $self->{scramdoc};
50 >   }
51 >
52 > sub classpath()
53 >   {
54 >   my ($object,$name,%attributes)=@_;
55 >   # The getter part:
56 >   if (ref($object) eq __PACKAGE__)
57 >      {
58 >      return $self->{content}->{CLASSPATH};
59 >      }
60 >  
61 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{CLASSPATH}}, $attributes{'path'})
62 >      : push(@{$self->{content}->{CLASSPATH}}, $attributes{'path'});
63 >   }
64 >
65 > sub productstore()
66 >   {
67 >   my ($object,$name,%attributes)=@_;
68 >   # The getter part:
69 >   if (ref($object) eq __PACKAGE__)
70 >      {
71 >      # Return an array of ProductStore hashes:
72 >      return $self->{content}->{PRODUCTSTORE};
73 >      }
74 >  
75 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{PRODUCTSTORE}}, \%attributes)
76 >      : push(@{$self->{content}->{PRODUCTSTORE}}, \%attributes) ;
77 >   }
78 >
79 > sub include()
80 >   {
81 >   my $self=shift;
82 >   # Return an array of required includes:
83 >   return $self->{content}->{INCLUDE};
84 >   }
85 >
86 > sub include_path()
87 >   {
88 >   my ($object,$name,%attributes)=@_;
89 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{INCLUDE}}, $attributes{'path'})
90 >      : push(@{$self->{content}->{INCLUDE}}, $attributes{'path'});
91 >   }
92 >
93 > sub use()
94 >   {
95 >   my $object=shift;
96 >   # The getter part:
97 >   if (ref($object) eq __PACKAGE__)
98 >      {
99 >      # Add or return uses (package deps):
100 >      @_ ? push(@{$self->{content}->{USE}},@_)
101 >         : @{$self->{content}->{USE}};
102 >      }
103 >   else
104 >      {
105 >      my ($name,%attributes)=@_;
106 >      $self->{DEPENDENCIES}->{$attributes{'name'}} = 1;
107 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{USE}}, $attributes{'name'})
108 >         : push(@{$self->{content}->{USE}}, $attributes{'name'});
109 >      }
110 >   }
111 >
112 > sub architecture()
113 >   {
114 >   my ($object,$name,%attributes)=@_;
115 >   $self->pushlevel(\%attributes); # Set nested to 1;
116 >   }
117 >
118 > sub architecture_()
119 >   {
120 >   $self->{content}->{ARCH}->{$self->{id}->{'name'}}=$self->{tagcontent};
121 >   $self->poplevel();
122 >   }
123 >
124 > sub export()
125 >   {
126 >   $self->pushlevel(); # Set nested to 1;
127 >   }
128 >
129 > sub export_()
130 >   {
131 >   $self->{content}->{EXPORT} = $self->{tagcontent};
132 >   $self->poplevel();
133 >   }
134 >
135 > sub lib()
136 >   {
137 >   my ($object,$name,%attributes)=@_;
138 >   # The getter part:
139 >   if (ref($object) eq __PACKAGE__)
140 >      {
141 >      # Return an array of required libs:
142 >      return $self->{content}->{LIB};      
143 >      }
144 >  
145 >   my $libname;
146 >  
147 >   if (exists($attributes{'position'}))
148 >      {
149 >      if ($attributes{'position'} eq 'first')
150 >         {
151 >         $libname = "F:".$attributes{'name'};
152 >         }
153 >      else
154 >         {
155 >         # There was a position entry but it didn't make sense:
156 >         $libname = $attributes{'name'};
157 >         }
158 >      }
159 >   else
160 >      {
161 >      $libname = $attributes{'name'};
162 >      }
163 >   # We have a libname, add it to the list:
164 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIB}}, $libname)
165 >      : push(@{$self->{content}->{LIB}}, $libname);
166 >   }
167 >
168 > sub libtype()
169 >   {
170 >   my ($object,$name,%attributes)=@_;
171 >   # The getter part:
172 >   if (ref($object) eq __PACKAGE__)
173 >      {
174 >      # Return an array of required libs:
175 >      return $self->{content}->{LIBTYPE};      
176 >      }
177 >
178 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIBTYPE}}, $attributes{'type'})
179 >      : push(@{$self->{content}->{LIBTYPE}}, $attributes{'type'});
180 >   }
181 >
182 > sub skip()
183 >   {
184 >   my ($object,$name,%attributes)=@_;
185 >   $self->{nested} == 1 ? $self->{tagcontent}->{SKIPPEDDIRS} = [ 1 ]
186 >      : $self->{content}->{SKIPPEDDIRS} = [ 1 ];
187 >   }
188 >
189 > sub skip_message()
190 >   {
191 >   my ($object,$name,@message) = @_;
192 >   # Save any message text between <skip> tags:
193 >   if ($#message > -1)
194 >      {
195 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{SKIPPEDDIRS}}, [ @message ])
196 >         : push(@{$self->{content}->{SKIPPEDDIRS}}, [ @message ]);
197 >      }
198 >   }
199 >
200 > sub skip_()
201 >   {
202 >   my ($object,$name)=@_;
203 >   }
204 >
205 > sub makefile()
206 >   {
207 >   my ($object,$name,%attributes)=@_;
208 >   # The getter part:
209 >   if (ref($object) eq __PACKAGE__)
210 >      {
211 >      # Return Makefile content:
212 >      return $self->{content}->{MAKEFILE};
213 >      }
214 >  
215 >   # Set our own Char handler so we can collect the content
216 >   # of the Makefile tag:
217 >   $object->setHandlers(Char => \&makefile_content);
218 >   $self->{makefilecontent} = [];
219 >   }
220 >
221 > sub makefile_content()
222 >   {
223 >   my ($object, @strings) = @_;
224 >   push(@{$self->{makefilecontent}},@strings);
225 >   }
226 >
227 > sub makefile_()
228 >   {
229 >   my ($object,$name)=@_;
230 >   $self->{nested} == 1 ? push(@{$self->{tagcontent}->{MAKEFILE}}, join('',@{$self->{makefilecontent}}))
231 >      : push(@{$self->{content}->{MAKEFILE}}, join('',@{$self->{makefilecontent}}));
232 >   delete $self->{makefilecontent};
233 >   # Unset the Char handler to revert to the default behaviour:
234 >   $object->setHandlers(Char => 0);
235 >   }
236 >
237 > sub define_group()
238 >   {
239 >   my ($object,$name,%attributes)=@_;
240 >   $self->pushlevel(\%attributes); # Set nested to 1;
241 >   }
242 >
243 > sub define_group_()
244 >   {
245 >   $self->{content}->{DEFINED_GROUP}->{$self->{id}->{'name'}}=$self->{tagcontent};
246 >   $self->poplevel();
247 >   }
248 >
249 > sub group()
250 >   {
251 >   my $object=shift;
252 >   # The getter part:
253 >   if (ref($object) eq __PACKAGE__)
254 >      {
255 >      # Add or return groups:
256 >      @_ ? push(@{$self->{content}->{GROUP}},@_)
257 >         : @{$self->{content}->{GROUP}};
258 >      }
259 >   else
260 >      {
261 >      my ($name,%attributes)=@_;
262 >      $self->{nested} == 1 ? push(@{$self->{tagcontent}->{GROUP}}, $attributes{'name'})
263 >         : push(@{$self->{content}->{GROUP}}, $attributes{'name'});
264 >      }
265 >   }
266 >
267 > sub flags()
268 >   {
269 >   my ($object,$name,%attributes)=@_;
270 >   # The getter part:
271 >   if (ref($object) eq __PACKAGE__)
272 >      {
273 >      # Return an array of ProductStore hashes:
274 >      return $self->{content}->{FLAGS};
275 >      }
276 >  
277 >   # Extract the flag name and its value:
278 >   my ($flagname,$flagvaluestring) = each %attributes;
279 >   $flagname =~ tr/[a-z]/[A-Z]/; # Keep flag name uppercase
280 >   chomp($flagvaluestring);
281 >   # Split the value on whitespace so we can push all
282 >   # individual flags into an array:
283 >   my @flagvalues = split(' ',$flagvaluestring);
284 >   # Is current tag within another tag block?
285 >   if ($self->{nested} == 1)
286 >      {
287 >      # Check to see if the current flag name is already stored in the hash. If so,
288 >      # just add the new values to the array of flag values:
289 >      if (exists ($self->{tagcontent}->{FLAGS}->{$flagname}))
290 >         {
291 >         push(@{$self->{tagcontent}->{FLAGS}->{$flagname}},@flagvalues);
292 >         }
293 >      else
294 >         {
295 >         $self->{tagcontent}->{FLAGS}->{$flagname} = [ @flagvalues ];
296 >         }
297 >      }
298 >   else
299 >      {
300 >      if (exists ($self->{content}->{FLAGS}->{$flagname}))
301 >         {
302 >         push(@{$self->{content}->{FLAGS}->{$flagname}},@flagvalues);
303 >         }
304 >      else
305 >         {
306 >         $self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ];
307 >         }
308 >      }
309 >   }
310  
311 < #
312 < # generic build tag
313 < #
314 < sub Build_start {
315 <        my $self=shift;
316 <        my $name=shift;
317 <        my $hashref=shift;
318 <
319 <        $self->{switch}->checktag($name,$hashref,'class');
320 <        $self->{switch}->checktag($name,$hashref,'id');
321 <        if ( $self->{Arch} ) {
322 <
323 <          # -- determine the build products name
324 <          my $name;
325 <          if ( exists $$hashref{'name'} ) {
326 <            $name=$$hashref{'name'};
327 <          }
328 <          else {
329 <            $self->{switch}->parseerror("No name specified for build product");
541 <            #$name="\$(buildname)";
542 <          }
543 <
544 <          # -- check we have a lookup for the class type
545 <          my $mapper=$self->_toolmapper();
546 <          if ( ! $mapper->exists($$hashref{'class'}) ) {
547 <            $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
548 <          }
549 <          else {
550 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
551 <           my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
552 <
553 <           my $fh=$self->{filehandlestack}[0];
554 <           my @targets=();
555 <
556 <           # -- generate generic targets
557 <           print $fh "ifndef _BuildLink_\n";
558 <           $self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes);
559 <
560 <           push @targets, $$hashref{'class'};
561 <
562 <           # -- generate targets for each type
563 <           foreach $type ( @types ) {
564 <
565 <            # -- generic name for each type
566 <            my $pattern=$$hashref{'class'}."_".$type;
567 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
568 <            print $fh "# ------ $pattern rules ---------------\n";
569 <            print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
570 <                                                        "_".$type."_$name\n\n";
571 <
572 <            # -- create a new directory for each type
573 <            push @targets, $pattern;
574 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
575 <            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}.
576 <                                                                "/".$dirname;
577 <            my $makefile=$here."/BuildFile.mk";
578 < #           AddDir::adddir($here);
579 <
580 <            # -- create link targets to the directory
581 <            push @targets, $dirname;
582 <            print $fh "# -- Link Targets to $type directories\n";
583 <            print $fh "$dirname: make_$dirname\n";
584 <            print $fh "\t\@cd $here; \\\n";
585 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
586 <                        " workdir=$here ".
587 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
588 <
589 <            # -- write target to make makefile for each directory
590 <            print $fh "# -- Build target directories\n";
591 <            print $fh "make_$dirname:\n";
592 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
593 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
594 <            print $fh "\t  mkdir $here; \\\n";
595 <            print $fh "\t fi;\\\n";
596 <            print $fh "\t cd $dirname; \\\n";
597 <            print $fh "\t echo include ".$self->{currentenv}." > ".
598 <                                                        "$makefile; \\\n";
599 <            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
600 <                                        " >> $makefile; \\\n";
601 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
602 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
603 <            if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
604 <             foreach $f ( @file ) {
605 <              print $fh "\t echo -include $f >> $makefile; \\\n";
606 <             }
311 > sub allflags()
312 >   {
313 >   my $self=shift;
314 >   # Return hash data for flags:
315 >   return $self->{content}->{FLAGS};
316 >   }
317 >
318 > sub archspecific()
319 >   {
320 >   my $self=shift;
321 >  
322 >   # Check to see if there is arch-dependent data. If so, return it:
323 >   if ((my $nkeys=keys %{$self->{content}->{ARCH}}) > 0)
324 >      {
325 >      while (my ($k,$v) = each %{$self->{content}->{ARCH}})
326 >         {
327 >         if ( $ENV{SCRAM_ARCH} =~ /$k.*/ )
328 >            {
329 >            return $self->{content}->{ARCH}->{$k};
330              }
608            print $fh "\tfi\n";
609            print $fh "\n";
610 #           print $typefile "$name :\n";
611 #           print $typefile "\t\$(_quietbuild_)";
612 #           print $typefile $mapper->template($$hashref{'class'},$type)."\n";
613 #           print $typefile "\t\$(_quietstamp_)";
614 #           print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n";
615
616            # -- cleaning targets
617            push @targets, "clean_$dirname";
618            print $fh "# -- cleaning targets\n";
619            print $fh "clean::clean_$dirname\n";
620            print $fh "clean_".$dirname."::\n";
621            print $fh "\t\@echo cleaning $dirname\n";
622            print $fh "\t\@if [ -d $here ]; then \\\n";
623            print $fh "\tcd $here; \\\n";
624            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
625                        $here." _BuildLink_=1 -f ".
626                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
627            print $fh "\tfi\n\n";
628
629
630          }
631          # -- help targets
632          print $fh "helpheader::\n";
633          print $fh "\t\@echo Targets available:\n";
634          print $fh "\t\@echo ------------------\n\n";
635          print $fh "help::helpheader\n";
636          foreach $target ( @targets ) {
637            print $fh "help::\n";
638            print $fh "\t\@echo $target\n"
639          }
640          print $fh "endif\n";
641         } # end else
642        }
643 }
644
645 sub Bin_start {
646        my $self=shift;
647        my $name=shift;
648        my $hashref=shift;
649
650        my $fileclass;
651        my @tools;
652        my $tool;
653        my $filename;
654        my $objectname;
655        
656        $self->{switch}->checktag($name,$hashref,'file');
657        if ( $self->{Arch} ) {
658        if ( ! defined $$hashref{name} ) {
659                ($$hashref{name}=$$hashref{file})=~s/\..*//;
660        }
661        ($filename=$$hashref{file})=~s/\..*//;
662
663        # Create a new directory for each binary target
664        my $dirname="bin_".$$hashref{name};
665        AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname");
666        open (binGNUmakefile,
667           ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/".
668           "BuildFile.mk $!\n";
669
670        # Create the link targets
671        $numbins++;
672        my $fh=$self->{filehandlestack}[0];
673        print $fh <<ENDTEXT;
674
675 # Link Targets to binary directories
676 ifdef BINMODE
677 # We dont want to build a library here
678 override files:=
679 endif
680 ifndef BINMODE
681
682 define stepdown_$$hashref{'name'}
683 if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
684 cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
685 \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
686 fi
687 endef
688
689 define stepdown2_$$hashref{'name'}
690 if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
691 cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\
692 \$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
693 fi
694
695 endef
696
697 bin_$$hashref{'name'}_%:: dummy
698        \@\$(stepdown2_$$hashref{'name'})
699
700 $$hashref{'name'}_%:: dummy
701        \@\$(stepdown_$$hashref{'name'})
702
703 help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
704        \@\$(stepdown_$$hashref{'name'})
705
706 binfiles+=$$hashref{'file'}
707 locbinfiles+=$dirname/$$hashref{'file'}
708 endif
709
710
711 ENDTEXT
712
713
714 # the binary specifics makefile
715        print binGNUmakefile "include ".$self->{currentenv}."\n";
716        print binGNUmakefile "VPATH+=".$self->{localtop}."/$self{path}\n";
717
718 # alias for bin_Insure
719        print binGNUmakefile <<ENDTEXT;
720
721 bin_insure:bin_Insure
722 ifdef MAKETARGET_bin_insure
723 MAKETARGET_$$hashref{name}_Insure=1
724 endif
725
726 # debuggging target
727 $$hashref{'name'}_echo_% :: echo_%
728
729 # help targets
730 help::
731 \t\@echo Targets For $$hashref{'name'}
732 \t\@echo -------------------------------------
733 \t\@echo $$hashref{'name'}  - default build
734 \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
735 ENDTEXT
736
737 # Make generic rules for each type
738        $targettypes={
739                "bin" => 'o',
740                "bin_debug" => 'd',
741                "bin_debug_local" => 'l_d',
742                "bin_Insure" => 'Insure'
743        };
744        #
745        foreach $target ( keys %$targettypes ) {
746          print binGNUmakefile <<ENDTEXT;
747
748 # Type $target specifics
749 ifdef MAKETARGET_$target
750 MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
751 endif
752 $target ::$$hashref{name}_$$targettypes{$target}
753
754 bintargets+=$$hashref{name}_$$targettypes{$target}
755 help::
756 \t\@echo $$hashref{name}_$$targettypes{$target}
757 clean::
758 \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
759 \techo Removing \$(binarystore)/$$hashref{name}; \\
760 \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
761 \tfi
762
763 ENDTEXT
764          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
765          ${"objectname_$$targettypes{$target}"}=$objectname;
766          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
767        } # end loop
768
769        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
770        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
771        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
772        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
773        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
774        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
775        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
776        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
777        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
778        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
779        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
780        print binGNUmakefile "\t\$(CClinkCmd)\n";
781        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
782        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
783        print binGNUmakefile "-include $$hashref{name}.dep\n";
784 print binGNUmakefile <<ENDTEXT;
785 clean::
786 \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
787 \techo Removing \$(binarystore)/$$hashref{name}; \\
788 \trm \$(binarystore)/$$hashref{name}; \\
789 \tfi
790
791 $$hashref{name}_d.exe:\$(libslocal_d)
792 $$hashref{name}_o.exe:\$(libslocal)
793 ifdef MCCABE_DATA_DIR
794 $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
795 endif
796 $$hashref{name}_Insure.exe:\$(libslocal_I)
797 $$hashref{name}_d:$$hashref{name}_d.exe
798        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
799 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
800        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
801 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
802        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
803 $$hashref{name}:$$hashref{name}_d.exe
804        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
805 $$hashref{name}_o:$$hashref{name}_o.exe
806        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
807 binfiles+=$$hashref{file}
808 ENDTEXT
809        }
810        close binGNUmakefile;
811 }
812
813 sub External_StartTag {
814        my $self=shift;
815        my $name=shift;
816        my $hashref=shift;
817        
818        my $tool;
819        if ( $self->{Arch} ) {
820        $self->{switch}->checktag($name,$hashref,'ref');
821
822        # -- oo toolbox stuff
823        # - get the appropriate tool object
824        $$hashref{'ref'}=~tr[A-Z][a-z];
825        if ( ! exists $$hashref{'version'} ) {
826         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
827        }
828        else {
829         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
830        }
831        if ( ! defined $tool ) {
832          $self->{switch}->parseerror("Unknown Tool Specified ("
833                                                        .$$hashref{'ref'}.")");
834        }
835
836        # -- old fashioned GNUmakefile stuff
837        print GNUmakefile $$hashref{'ref'};
838        if ( defined $$hashref{'version'} ) {
839                print GNUmakefile "_V_".$$hashref{'version'};
840        }
841        print GNUmakefile "=true\n";
842        
843        # -- Sub system also specified?
844        if ( exists $$hashref{'use'} ) {
845           # -- look for a buildfile
846           my @paths=$tool->getfeature("INCLUDE");
847           my $file="";
848           my ($path,$testfile);
849           foreach $path ( @paths ) {
850             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
851             if ( -f $testfile ) {
852                $file=$testfile;
853                $self->_pushremoteproject($path);
854             }
855           }
856           if ( $file eq "" ) {
857             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
858           }
859           $self->ParseBuildFile_Export($file);
860           $self->_popremoteproject();
331           }
332 <        }
333 < }      
334 <
335 < sub Group_start {
336 <        my $self=shift;
337 <        my $name=shift;
338 <        my $hashref=shift;
339 <        
340 <        $self->{switch}->checktag($name, $hashref, 'name');
341 <        if ( $self->{Arch} ) {
342 <        print GNUmakefile "GROUP_".$$hashref{'name'};
343 <        if ( defined $$hashref{'version'} ) {
344 <                print GNUmakefile "_V_".$$hashref{'version'};
345 <        }
346 <        print GNUmakefile "=true\n";
347 <        }
348 < }      
349 <
350 < sub Use_start {
351 <        my $self=shift;
352 <        my $name=shift;
353 <        my $hashref=shift;
354 <        my $filename;
355 <        use Utilities::SCRAMUtils;
356 <        
357 <        $self->{switch}->checktag($name, $hashref, "name");
358 <        if ( $self->{Arch} ) {
359 <        if ( exists $$hashref{'group'} ) {
360 <          print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
361 <        }
362 <        if ( ! defined $self->{remoteproject} ) {
363 <          $filename=SCRAMUtils::checkfile(
364 <                "/$ENV{INTsrc}/$$hashref{name}/BuildFile");
365 <        }
366 <        else {
367 <          $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
368 <        print "trying $filename\n";
369 <          if ( ! -f $filename ) { $filename=""; };
370 <        }
371 <        if ( $filename ne "" ) {
372 <          $self->ParseBuildFile_Export( $filename );
373 <        }
374 <        else {
375 <           $self->{switch}->parseerror("Unable to detect Appropriate ".
376 <                "decription file for <$name name=".$$hashref{name}.">");
377 <        }
378 <        }
379 < }
380 <
381 < # List association groups between <AssociateGroup> tags
382 < # seperated by newlines or spaces
383 < sub AssociateGroup {
384 <        my $self=shift;
385 <        my $name=shift;
386 <        my $string=shift;
387 <        my $word;
388 <
389 <        if ( $self->{Arch} ) {
390 <        foreach $word ( (split /\s/, $string) ){
391 <                chomp $word;
392 <                next if /^#/;
393 <                if ( $word=~/none/ ) {
394 <                        $self->{ignore}=1;
395 <                }
396 <        }
397 <        }
398 < }
399 <
400 < sub Arch_Start {
401 <        my $self=shift;
402 <        my $name=shift;
403 <        my $hashref=shift;
404 <
405 <        $self->{switch}->checktag($name, $hashref,'name');
406 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
407 <                                                : ($self->{Arch}=0);
408 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
409 < }
410 <
411 < sub Arch_End {
412 <        my $self=shift;
413 <        my $name=shift;
414 <
415 <        pop @{$self->{ARCHBLOCK}};
416 <        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
417 < }
418 <
419 < # Split up the Class Block String into a useable array
420 < sub _CutBlock {
421 <    my $self=shift;
422 <    my $string= shift @_;
423 <    @BlockClassA = split /\//, $string;
424 < }
425 <
426 < sub OutToMakefile {
427 <        my $self=shift;
428 <        my $name=shift;
429 <        my @vars=@_;
430 <
431 <        if ( $self->{Arch} ) {
432 <          print GNUmakefile @vars;
433 <        }
434 < }
435 <
436 < sub OutToScreen {
437 <        my $name=shift;
438 <        my @vars=@_;
439 <
440 <        if ( $self->{Arch} ) {
441 <          print @vars;
442 <        }
443 < }
444 < sub setBlockClassPath {
445 <        my $self=shift;
446 <        my $name=shift;
447 <        my $hashref=shift;
448 <
449 <        $self->{switch}->checktag($name, $hashref, 'path');
450 <        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
451 <        $self->_CutBlock($$hashref{path});
452 < }
453 <
454 < sub BlockClassPath {
455 <        my $self=shift;
456 <        return $self->{BlockClassPath};
457 < }
458 <
459 < sub export_start_export {
460 <        my $self=shift;
461 <        my $name=shift;
462 <        my $hashref=shift;
463 <
464 <        $self->{switch}->opengroup("__export");
465 < }
466 <
467 < sub export_start {
468 <        my $self=shift;
469 <        my $name=shift;
470 <        my $hashref=shift;
471 <
472 <        $self->{switch}->opengroup("__export");
473 <        if ( exists $$hashref{autoexport} ) {
474 <          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
475 <          if ( $$hashref{autoexport}=~/true/ ) {
476 <           $self->{switch}->allowgroup("__export","makebuild");
477 <          }
478 <          else {
479 <           $self->{switch}->disallowgroup("__export","makebuild");
480 <          }
481 <        }
482 <        # -- allow default setting from other makefiles
483 <        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
484 < }
485 <
486 < sub export_end_export {
487 <        my $self=shift;
488 <        $self->{switch}->closegroup("__export");
489 < }
490 <
491 < sub export_end {
492 <        my $self=shift;
493 <        $self->{switch}->closegroup("__export");
494 <        print GNUmakefile "endif\n";
495 < }
332 >      }
333 >   return "";
334 >   }
335 >
336 > sub bin()
337 >   {
338 >   my ($object,$name,%attributes) = @_;
339 >   $self->pushlevel(\%attributes);# Set nested to 1;
340 >   }
341 >
342 > sub bin_()
343 >   {
344 >   # Need unique name for the binary (always use name of product). Either use "name"
345 >   # given, or use "file" value minus the ending:
346 >   if (exists ($self->{id}->{'name'}))
347 >      {
348 >      $name = $self->{id}->{'name'};
349 >      }
350 >   else
351 >      {
352 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
353 >      }
354 >
355 >   # Store the data:
356 >   $self->productcollector($name,'bin','BIN');
357 >   $self->poplevel();
358 >   }
359 >
360 > sub module()
361 >   {
362 >   my ($object,$name,%attributes) = @_;
363 >   $self->pushlevel(\%attributes);# Set nested to 1;
364 >   }
365 >
366 > sub module_()
367 >   {
368 >   # Need unique name for the module (always use name of product). Either use "name"
369 >   # given, or use "file" value minus the ending:
370 >   if (exists ($self->{id}->{'name'}))
371 >      {
372 >      $name = $self->{id}->{'name'};
373 >      }
374 >   else
375 >      {
376 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
377 >      }
378 >
379 >   # Store the data:
380 >   $self->productcollector($name,'mod','MODULE');
381 >   $self->poplevel();
382 >   }
383 >
384 > sub application()
385 >   {
386 >   my ($object,$name,%attributes) = @_;
387 >   $self->pushlevel(\%attributes);# Set nested to 1;
388 >   }
389 >
390 > sub application_()
391 >   {
392 >   # Need unique name for the application (always use name of product). Either use "name"
393 >   # given, or use "file" value minus the ending:
394 >   if (exists ($self->{id}->{'name'}))
395 >      {
396 >      $name = $self->{id}->{'name'};
397 >      }
398 >   else
399 >      {
400 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
401 >      }
402 >
403 >   # Store the data:
404 >   $self->productcollector($name,'app','APPLICATION');
405 >   $self->poplevel();
406 >   }
407 >
408 > sub library()
409 >   {
410 >   my ($object,$name,%attributes) = @_;
411 >   $self->pushlevel(\%attributes);# Set nested to 1;
412 >   }
413 >
414 > sub library_()
415 >   {
416 >   # Need unique name for the library (always use name of product). Either use "name"
417 >   # given, or use "file" value minus the ending:
418 >   if (exists ($self->{id}->{'name'}))
419 >      {
420 >      $name = $self->{id}->{'name'};
421 >      }
422 >   else
423 >      {
424 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
425 >      }
426 >
427 >   # Store the data:
428 >   $self->productcollector($name,'lib','LIBRARY');
429 >   $self->poplevel();
430 >   }
431 >
432 > sub plugin()
433 >   {
434 >   my ($object,$name,%attributes) = @_;
435 >   $self->pushlevel(\%attributes);# Set nested to 1;
436 >   }
437 >
438 > sub plugin_()
439 >   {
440 >   # Need unique name for the plugin (always use name of product). Either use "name"
441 >   # given, or use "file" value minus the ending:
442 >   if (exists ($self->{id}->{'name'}))
443 >      {
444 >      $name = $self->{id}->{'name'};
445 >      }
446 >   else
447 >      {
448 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
449 >      }
450 >
451 >   # Store the data:
452 >   $self->productcollector($name,'plugin','PLUGIN');
453 >   $self->poplevel();
454 >   }
455 >
456 > sub unittest()
457 >   {
458 >   my ($object,$name,%attributes) = @_;
459 >   $self->pushlevel(\%attributes);# Set nested to 1;
460 >   }
461 >
462 > sub unittest_()
463 >   {
464 >   # Need unique name for the unittest (always use name of product). Either use "name"
465 >   # given, or use "file" value minus the ending:
466 >   if (exists ($self->{id}->{'name'}))
467 >      {
468 >      $name = $self->{id}->{'name'};
469 >      }
470 >   else
471 >      {
472 >      ($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/);
473 >      }
474 >
475 >   # Store the data:
476 >   $self->productcollector($name,'unittest','unittest');
477 >   $self->poplevel();
478 >   }
479 >
480 > sub productcollector()
481 >   {
482 >   my $self=shift;
483 >   my ($name,$typeshort,$typefull)=@_;
484 >   # Create a new Product object for storage of data:
485 >   use BuildSystem::Product;
486 >   my $product = BuildSystem::Product->new();
487 >   # Store the name:
488 >   $product->name($name);
489 >   $product->type($typeshort);
490 >   # Store the files. Take the BuildFile path as the initial path for
491 >   # expanding source file globs:
492 >   $product->_files($self->{id}->{'file'},[ $self->{scramdoc}->filetoparse() ]);
493 >   # Store the data content:
494 >   $product->_data($self->{tagcontent});
495 >   # And store in a hash (all build products in same place):
496 >   $self->{content}->{BUILDPRODUCTS}->{$typefull}->{$name} = $product;
497 >   }
498 >
499 > sub pushlevel
500 >   {
501 >   my $self = shift;
502 >   my ($info)=@_;
503 >  
504 >   $self->{id} = $info if (defined $info);
505 >   $self->{nested} = 1;
506 >   $self->{tagcontent}={};
507 >   }
508 >
509 > sub poplevel
510 >   {
511 >   my $self = shift;
512 >   delete $self->{id};
513 >   delete $self->{nested};
514 >   delete $self->{tagcontent};
515 >   }
516 >
517 > sub dependencies()
518 >   {
519 >   my $self=shift;
520 >   # Make a copy of the variable so that
521 >   # we don't have a DEPENDENCIES entry in RAWDATA:
522 >   my %DEPS=%{$self->{DEPENDENCIES}};
523 >   delete $self->{DEPENDENCIES};
524 >   return \%DEPS;
525 >   }
526 >
527 > sub skippeddirs()
528 >   {
529 >   my $self=shift;
530 >   my ($here)=@_;
531 >   my $skipped;
532 >
533 >   if ($self->{content}->{SKIPPEDDIRS}->[0] == 1)
534 >      {
535 >      $skipped = [ @{$self->{content}->{SKIPPEDDIRS}} ];
536 >      delete $self->{content}->{SKIPPEDDIRS};
537 >      }
538 >  
539 >   delete $self->{content}->{SKIPPEDDIRS};
540 >   return $skipped;
541 >   }
542 >
543 > sub hasexport()
544 >   {
545 >   my $self=shift;
546 >   # Check to see if there is a valid export block:
547 >   my $nkeys = $self->exporteddatatypes();
548 >   $nkeys > 0 ? return 1 : return 0;
549 >   }
550 >
551 > sub has()
552 >   {
553 >   my $self=shift;
554 >   my ($datatype)=@_;  
555 >   (exists ($self->{content}->{$datatype})) ? return 1 : return 0;
556 >   }
557 >
558 > sub exported()
559 >   {
560 >   my $self=shift;
561 >   # Return a hash. Keys are type of data provided:
562 >   return ($self->{content}->{EXPORT});
563 >   }
564 >
565 > sub exporteddatatypes()
566 >   {
567 >   my $self=shift;
568 >   # Return exported data types:
569 >   return keys %{$self->{content}->{EXPORT}};
570 >   }
571 >
572 > sub defined_group()
573 >   {
574 >   my $self=shift;
575 >
576 >   if (exists($self->{content}->{DEFINED_GROUP}))
577 >      {  
578 >      # Return a list of keys (group names) for defined groups:
579 >      return [ keys %{$self->{content}->{DEFINED_GROUP}} ];
580 >      }
581 >   else
582 >      {
583 >      return 0;
584 >      }
585 >   }
586 >
587 > sub dataforgroup()
588 >   {
589 >   my $self=shift;
590 >   my ($groupname)=@_;
591 >   # Return hash containing data for defined group
592 >   # $groupname or return undef:
593 >   return $self->{content}->{DEFINED_GROUP}->{$groupname};
594 >   }
595 >
596 > sub buildproducts()
597 >   {
598 >   my $self=shift;
599 >   # Returns hash of build products and their data:
600 >   return $self->{content}->{BUILDPRODUCTS};
601 >   }
602 >
603 > sub values()
604 >   {
605 >   my $self=shift;
606 >   my ($type)=@_;
607 >   # Get a list of values from known types
608 >   return $self->{content}->{BUILDPRODUCTS}->{$type};
609 >   }
610 >
611 > sub basic_tags()
612 >   {
613 >   my $self=shift;
614 >   my $datatags=[];
615 >   my $buildtags=[ qw(BIN LIBRARY APPLICATION MODULE PLUGIN BUILDPRODUCTS) ];
616 >   my $skiptags=[ qw(DEFINED_GROUP ARCH EXPORT GROUP USE CLASSPATH) ];
617 >   my $otherskiptags=[ qw( SKIPPEDDIRS ) ];
618 >   my @all_skip_tags;
619 >  
620 >   push(@all_skip_tags,@$skiptags,@$buildtags,@$otherskiptags);
621 >
622 >   foreach my $t (keys %{$self->{content}})
623 >      {
624 >      push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags));
625 >      }
626 >   return @{$datatags};
627 >   }
628 >
629 > sub clean()
630 >   {
631 >   my $self=shift;
632 >   my (@tags) = @_;
633 >
634 >   # Delete some useless entries:
635 >   delete $self->{makefilecontent};
636 >   delete $self->{simpledoc};
637 >   delete $self->{id};
638 >   delete $self->{tagcontent};
639 >   delete $self->{nested};
640 >
641 >   delete $self->{DEPENDENCIES};
642 >  
643 >   map
644 >      {
645 >      delete $self->{content}->{$_} if (exists($self->{content}->{$_}));
646 >      } @tags;
647 >  
648 >   return $self;
649 >   }
650 >
651 > sub AUTOLOAD()
652 >   {
653 >   my ($xmlparser,$name,%attributes)=@_;
654 >   return if $AUTOLOAD =~ /::DESTROY$/;
655 >   my $name=$AUTOLOAD;
656 >   $name =~ s/.*://;
657 >   }
658  
659 < #
1028 < # Standard lib tag
1029 < #
1030 < sub lib_start {
1031 <        my $self=shift;
1032 <        my $name=shift;
1033 <        my $hashref=shift;
1034 <
1035 <        $self->{switch}->checktag($name, $hashref, 'name');
1036 <        if ( $self->{Arch} ) {
1037 <           print GNUmakefile "lib+=$$hashref{name}\n";
1038 <        }
1039 < }
1040 <
1041 < #
1042 < # libtype specification
1043 < #
1044 < sub LibType_Start {
1045 <        my $self=shift;
1046 <        my $name=shift;
1047 <        my $hashref=shift;
1048 <
1049 <        if ( $self->{Arch} ) {
1050 <        if ( defined $self->{libtype_conext} ) {
1051 <          $self->{switch}->parseerror("<$name> tag cannot be specified".
1052 <                " without a </$name> tag to close previous context");
1053 <        }
1054 <        else {
1055 <        $self->{libtype_conext}=1;
1056 <        $self->{switch}->checktag($name, $hashref, 'type');
1057 <        
1058 <        print GNUmakefile "# Specify Library Type\n";
1059 <        print GNUmakefile "DefaultLibsOff=yes\n";
1060 <        if ( $$hashref{'type'}=~/^archive/i ) {
1061 <          print GNUmakefile "LibArchive=true\n";
1062 <        }
1063 <        elsif ($$hashref{'type'}=~/debug_archive/i ) {
1064 <          print GNUmakefile "LibDebugArchive=true\n";
1065 <        }
1066 <        elsif ($$hashref{'type'}=~/debug_shared/i ) {
1067 <          print GNUmakefile "LibDebugShared=true\n";
1068 <        }
1069 <        elsif ($$hashref{'type'}=~/shared/i ) {
1070 <          print GNUmakefile 'LibShared=true'."\n";
1071 <        }
1072 <        print GNUmakefile "\n";
1073 <        }
1074 <        }
1075 < }
1076 <
1077 < sub LibType_text {
1078 <        my $self=shift;
1079 <        my $name=shift;
1080 <        my $string=shift;
1081 <
1082 <        if ( $self->{Arch} ) {
1083 <          $string=~s/\n/ /g;
1084 <          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
1085 <          print GNUmakefile $string;
1086 <          print GNUmakefile "\n";
1087 <        }
1088 < }
1089 <
1090 < sub LibType_end {
1091 <        my $self=shift;
1092 <        my $name=shift;
1093 <
1094 <        undef $self->{libtype_conext};
1095 < }
1096 <
1097 < sub Environment_start {
1098 <        my $self=shift;
1099 <        my $name=shift;
1100 <        my $hashref=shift;
1101 <
1102 <        if ( $self->{Arch} ) {
1103 <          $self->{envnum}++;
1104 <
1105 <          # open a new Environment File
1106 <          my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_".
1107 <                $self->{envnum}.".mk";
1108 <          use FileHandle;
1109 <          my $fh=FileHandle->new();
1110 <          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
1111 <          push @{$self->{filehandlestack}}, $fh;
1112 <          *GNUmakefile=$fh;
1113 <
1114 <          # include the approprate environment file
1115 <          if ( $self->{envlevel} == 0 ) {
1116 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
1117 <                $self->{path}."/BuildFile.mk\n";
1118 <          }
1119 <          else {
1120 <             print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/".
1121 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
1122 <          }
1123 <          $self->{envlevel}++;
1124 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
1125 <          $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
1126 <        }
1127 < }
1128 <
1129 < sub Environment_end {
1130 <        my $self=shift;
1131 <        my $fd;
1132 <
1133 <        if ( $self->{Arch} ) {
1134 <          $self->{envlevel}--;
1135 <          if ( $self->{envlevel} < 0 ) {
1136 <            print "Too many </Environent> Tags on $self->{switch}->line()\n";
1137 <            exit 1;
1138 <          }
1139 <          close GNUmakefile;
1140 <          # restore the last filehandle
1141 <          $fd=pop @{$self->{filehandlestack}};
1142 <          close $fd;
1143 <          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
1144 <          if ( $self->{envlevel} < 1 ) {
1145 <            $self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/".
1146 <                        "BuildFile.mk";
1147 <          }
1148 <          else {
1149 <            $self->{currentenv}=
1150 <             $self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_".
1151 <                $self->{Envlevels}[$self->{envlevel}];
1152 <          }
1153 <        }
1154 < }
1155 <
1156 < sub Store_start {
1157 <        my $self=shift;
1158 <        my $name=shift;
1159 <        my $hashref=shift;
1160 <
1161 <        if ( $self->{Arch} ) {
1162 <          $self->{switch}->checktag( $name, $hashref, 'name' );
1163 <
1164 <          # -- store creation
1165 <          my $dir=$$hashref{'name'};
1166 <          AddDir::adddir($self->{area}->location()."/".$dir);
1167 <          if ( exists $$hashref{'type'} ) {
1168 <            # -- architecture specific store
1169 <            if ( $$hashref{'type'}=~/^arch/i ) {
1170 <                $dir=$dir."/".$ENV{SCRAM_ARCH};
1171 <                AddDir::adddir($self->{area}->location()."/".$dir);
1172 <            }
1173 <            else {
1174 <                $self->parseerror("Unknown type in <$name> tag");
1175 <            }
1176 <          }
1177 <        
1178 <          # -- set make variables for the store
1179 <          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
1180 <          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
1181 <                                        $self->{localtop}."/".$dir."\n";
1182 <          print GNUmakefile "VPATH+=".$self->{localtop}
1183 <                        ."/".$dir.":".$self->{releasetop}."/".$dir."\n";
1184 <        }
1185 < }
1186 <
1187 < sub DropDown {
1188 <        my $self=shift;
1189 <        my $name=shift;
1190 <        my $hashref=shift;
1191 <
1192 <        if ( $self->{Arch} ) {
1193 <          # - default values must always be specified
1194 <          $self->{switch}->checktag( $name, $hashref, 'defaults' );
1195 <          my @blockdirs=split /,/ , $$hashref{'defaults'};
1196 <          $self->{block}->defaultblocks(@blockdirs);
1197 <        }
1198 < }
659 > 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines