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.20 by sashby, Thu Jul 18 13:49:01 2002 UTC vs.
Revision 1.28 by sashby, Wed Mar 9 19:28:19 2005 UTC

# Line 1 | Line 1
1 < # BuildFile
1 > #____________________________________________________________________
2 > # File: BuildFile.pm
3 > #____________________________________________________________________
4 > #  
5 > # Author: Shaun Ashby <Shaun.Ashby@cern.ch>
6 > # Update: 2003-12-03 19:03:15+0100
7 > # Revision: $Id$
8   #
9 < # Interface
10 < # ---------
11 < # new(toolbox)
6 < # ParseBuildFile($base,$path,$file)
7 < # ParseBuildFileExport(filename)
8 < # BlockClassPath() : Return the class path
9 < # ignore()      : return 1 if directory should be ignored 0 otherwise
10 <
9 > # Copyright: 2003 (C) Shaun Ashby
10 > #
11 > #--------------------------------------------------------------------
12   package BuildSystem::BuildFile;
12 use Utilities::Verbose;
13 use ActiveDoc::SimpleDoc;
14 use BuildSystem::ToolBox;
13   require 5.004;
14 < @ISA=qw(Utilities::Verbose);
14 > use Exporter;
15 > use BuildSystem::TagUtils;
16 > use BuildSystem::BuildDataUtils;
17 > use ActiveDoc::SimpleDoc;
18  
19 < BEGIN {
20 < $buildfile="BuildFile";
20 < }
21 <
22 < sub new {
23 <        my $class=shift;
24 <        my $self={};
25 <        bless $self, $class;
26 <        $self->{toolbox}=shift;
27 <        $self->{Arch}=1;
28 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
29 <        return $self;
30 < }
31 <
32 < sub ignore {
33 <        my $self=shift;
34 <        $self->verbose(">> ignore......<<");
35 <        
36 <        return (defined $self->{ignore})?$self->{ignore}:0;
37 < }
38 <
39 < sub _initswitcher {
40 <        my $self=shift;
41 <        my $switch=ActiveDoc::SimpleDoc->new();
42 <        my $parse="makebuild";
43 <        $self->verbose(">> _initswitcher: <<");
44 <        $switch->newparse($parse);
45 <        $switch->addignoretags($parse);
46 <        $self->_commontags($switch,$parse);
47 <        $switch->addtag($parse,"Build", \&Build_start, $self);
48 <        $switch->addtag($parse,"none",
49 <                                        \&OutToMakefile,$self,
50 <                                        \&OutToMakefile, $self,
51 <                                        "", $self);
52 <        $switch->addtag($parse,"Bin",
53 <                                        \&Bin_start,$self,
54 <                                        \&OutToScreen, $self,
55 <                                        "", $self);
56 <        $switch->addtag($parse,"Module",
57 <                                        \&Module_start,$self,
58 <                                        \&OutToScreen, $self,
59 <                                        "", $self);
60 <
61 <        $switch->addtag($parse,"ProductStore",
62 <                                        \&Store_start,$self,
63 <                                        "", $self,
64 <                                        "", $self);
65 <        $switch->addtag($parse,"LibType",
66 <                                        \&LibType_Start,$self,
67 <                                        \&LibType_text, $self,
68 <                                        \&LibType_end,$self);
69 <        $switch->addtag($parse,"ConfigurationClass",
70 <                                        \&Class_StartTag,$self,
71 <                                        \&OutToMakefile, $self,
72 <                                        "", $self);
73 <        $switch->addtag($parse,"ClassPath",
74 <                                        \&setBlockClassPath,$self,
75 <                                        \&OutToMakefile, $self,
76 <                                        "", $self);
77 <        $switch->addtag($parse,"AssociateGroup",
78 <                                        "",$self,
79 <                                        \&AssociateGroup,$self,
80 <                                        "", $self);
81 <        $switch->addtag($parse,"Environment",
82 <                                        \&Environment_start,$self,
83 <                                        \&OutToMakefile, $self,
84 <                                        \&Environment_end,$self);
85 <        $switch->addtag($parse,"Export",
86 <                                        \&export_start,$self,
87 <                                        \&OutToMakefile, $self,
88 <                                        \&export_end,$self);
89 <        return $switch;
90 < }
19 > @ISA=qw(Exporter BuildSystem::BuildDataUtils);
20 > @EXPORT_OK=qw( );
21  
22 < sub _commontags
22 > #
23 > sub new()
24 >   ###############################################################
25 >   # new                                                         #
26 >   ###############################################################
27 >   # modified : Wed Dec  3 19:03:22 2003 / SFA                   #
28 >   # params   :                                                  #
29 >   #          :                                                  #
30 >   # function :                                                  #
31 >   #          :                                                  #
32 >   ###############################################################
33     {
34 <   my $self=shift;
35 <   my $switch=shift;
36 <   my $parse=shift;
34 >   my $proto=shift;
35 >   my $class=ref($proto) || $proto;
36 >   my $self={};
37    
38 <   $self->verbose(">> _commontags: SW ".$switch." PARSE ".$parse." <<");
39 <  
40 <   $switch->grouptag("Export",$parse);
41 <   $switch->addtag($parse,"Use",
42 <                   \&Use_start,$self,
103 <                   \&OutToMakefile, $self,
104 <                   "", $self);
105 <   $switch->addtag($parse,"Group",
106 <                   \&Group_start,$self,
107 <                   \&OutToMakefile, $self,
108 <                   "", $self);
109 <   $switch->grouptag("Group",$parse);
110 <   $switch->addtag($parse,"External",
111 <                   \&External_StartTag,$self,
112 <                   \&OutToMakefile, $self,
113 <                   "", $self);
114 <   $switch->addtag($parse,"lib",
115 <                   \&lib_start,$self,
116 <                   \&OutToMakefile, $self,"", $self);
117 <   $switch->addtag($parse,"debuglib",
118 <                   \&debuglib_start,$self,
119 <                   \&OutToMakefile, $self,
120 <                   "", $self);
121 <   $switch->addtag($parse,"Architecture",
122 <                   \&Arch_Start,$self,
123 <                   \&OutToMakefile, $self,
124 <                   \&Arch_End,$self);
125 <   $switch->addtag($parse,"INCLUDE_PATH",
126 <                   \&IncludePath_Start,$self,
127 <                   \&OutToMakefile, $self,
128 <                   "",$self);
129 <   return $switch;
38 >   bless $self,$class;
39 >
40 >   $self->{DEPENDENCIES} = {};
41 >   $self->{content} = {};
42 >   return $self;
43     }
44  
45 < sub ParseBuildFile {
133 <        my $self=shift;
134 <        my $base=shift;
135 <        my $path=shift;
136 <        my $filename=shift @_;
137 <        my $fullfilename;
138 <        if ( $filename!~/^\// ) {
139 <         $fullfilename="$base/$path/$filename";
140 <        }
141 <        else {
142 <         $fullfilename=$filename;
143 <        }
144 <
145 <        $self->verbose(">> ParseBuildFile: FN ".$fullfilename." <<");
146 <        
147 <        $self->{path}=$path;
148 <        $numbins=0;
149 <        $self->{envnum}=0;
150 <        $self->{envlevel}=0;
151 <        $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
152 <                                                                "BuildFile.mk";
153 <        $self->{switch}=$self->_initswitcher();
154 <        $self->{switch}->filetoparse($fullfilename);
155 <
156 <        # open a temporary gnumakefile to store output.
157 <        use Utilities::AddDir;
158 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}");
159 <        my $fh=FileHandle->new();
160 <        open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"
161 <          ) or die "Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n";
162 <        @{$self->{filehandlestack}}=($fh);
163 <        # make an alias
164 <        *GNUmakefile=$fh;
165 <        if ( -e $ENV{LatestBuildFile} ) {
166 <          print GNUmakefile "include $ENV{LatestBuildFile}\n";
167 <        }
168 <
169 <        $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk";
170 <        $self->{switch}->parse("makebuild"); # sort out supported tags
171 <        if ( $numbins > 0 ) {
172 <         print GNUmakefile <<ENDTEXT;
173 < ifndef BINMODE
174 < help::
175 < \t\@echo Generic Binary targets
176 < \t\@echo ----------------------
177 < endif
178 < ENDTEXT
179 <         foreach $target ( keys %$targettypes ) {
180 <         print GNUmakefile <<ENDTEXT;
181 < ifndef BINMODE
182 < help::
183 < \t\@echo $target
184 < endif
185 < ENDTEXT
186 <         }
187 <        }
188 <        close GNUmakefile;
189 < }
190 <
191 < sub ParseBuildFile_Export {
192 <        my $self=shift;
193 <        my $filename=shift;
194 <
195 <        $self->verbose(">> ParseBuildFile_Export: FN ".$filename." <<");
196 <        
197 <        my $bf=BuildSystem::BuildFile->new($self->{toolbox});
198 <        if ( defined $self->{remoteproject} ) {
199 <           $bf->{remoteproject}=$self->{remoteproject};
200 <        }
201 <        $bf->_parseexport($filename);
202 <        undef $bf;
203 < }
204 <
205 < sub _location {
206 <        my $self=shift;
207 <        use File::Basename;
208 <        $self->verbose(">> _location: <<");
209 <        return dirname($self->{switch}->filetoparse());
210 < }
211 <
212 < sub _parseexport {
213 <        my $self=shift;
214 <        my $filename=shift;
215 <        $self->verbose(">> _parseexport: FN ".$filename." <<");
216 <        
217 <        my $switchex=ActiveDoc::SimpleDoc->new();
218 <        $switchex->filetoparse($filename);
219 <        $switchex->newparse("export");
220 <        $switchex->addignoretags("export");
221 <        $switchex->addtag("export","Export",
222 <                                        \&export_start_export,$self,
223 <                                        \&OutToMakefile, $self,
224 <                                        \&export_end_export,$self);
225 <        $self->_commontags($switchex,"export");
226 <        $switchex->allowgroup("__export","export");
227 <        $self->{switch}=$switchex;
228 <        $switchex->parse("export"); # sort out supported tags
229 < }
230 <
231 < sub _pushremoteproject {
232 <        my $self=shift;
233 <        my $path=shift;
234 <
235 <        $self->verbose(">> _pushremoteproject: PATH ".$path." <<");
236 <        
237 <        if ( defined $self->{remoteproject} ) {
238 <          push @{$self->{rpstack}}, $self->{remoteproject};
239 <        }
240 <        $self->{remoteproject}=$path;
241 < }
242 <
243 < sub _popremoteproject {
244 <        my $self=shift;
245 <        $self->verbose(">> _popremoteproject:  <<");
246 <        
247 <        if ( $#{$self->{rpstack}} >=0 ) {
248 <          $self->{remoteproject}=pop @{$self->{rpstack}};
249 <        }
250 <        else {
251 <          undef $self->{remoteproject};
252 <        }
253 < }
254 <
255 < sub _toolmapper {
256 <        my $self=shift;
257 <
258 <        if ( ! defined $self->{mapper} ) {
259 <           require BuildSystem::ToolMapper;
260 <           $self->{mapper}=BuildSystem::ToolMapper->new();
261 <        }
262 <        $self->verbose(">> _toolmapper: TM ".$self->{mapper}."<<");
263 <        return $self->{mapper};
264 < }
265 <
266 <
267 < # ---- Tag routines
268 <
269 < #-- Override a class type with the <ConfigurationClass type=xxx> tag
270 < #   the type tag will pick up a pre-defined class type from project space.
271 <
272 < sub Class_StartTag {
273 <        my $self=shift;
274 <        my $name=shift;
275 <        my $hashref=shift;
276 <
277 <        $self->verbose(">> Classs_StartTag: NM ".$name." <<");
278 <        
279 <        if ( $self->{Arch} ) {
280 <         if ( defined $$hashref{'type'} ) {
281 <                $ClassName=$$hashref{'type'};
282 <         }
283 <        }
284 < }
285 <
286 < sub IncludePath_Start
45 > sub _initparser()
46     {
47     my $self=shift;
48 <   my $name=shift;
49 <   my $hashref=shift;
48 >
49 >   $self->{simpledoc}=ActiveDoc::SimpleDoc->new();
50 >   $self->{simpledoc}->newparse("builder");
51 >   $self->{simpledoc}->addignoretags("builder");
52 >
53 >   # For blank lines do nothing:
54 >   $self->{simpledoc}->addtag("builder","none",
55 >                              "", $self,
56 >                              "", $self,
57 >                              "", $self);
58    
59 <   $self->verbose(">> IncludePath_Start: NM ".$name." <<");
59 >   # Define the tags to be used in this class:
60 >   $self->{simpledoc}->addtag("builder","classpath",
61 >                              \&BuildSystem::TagUtils::classpathtagOpen, $self,
62 >                              "", $self,
63 >                              "", $self);
64 >
65 >   $self->{simpledoc}->addtag("builder","productstore",
66 >                              \&BuildSystem::TagUtils::productstoretagOpen, $self,
67 >                              "", $self,
68 >                              "", $self);
69 >
70 >   $self->{simpledoc}->addtag("builder","architecture",
71 >                              \&BuildSystem::TagUtils::archtagOpen, $self,
72 >                              "", $self,
73 >                              \&BuildSystem::TagUtils::archtagClose, $self);
74 >
75 >   $self->{simpledoc}->addtag("builder","include_path",
76 >                              \&BuildSystem::TagUtils::includetagOpen, $self,
77 >                              "", $self,
78 >                              "", $self);
79    
80 <   $self->{switch}->checktag( $name, $hashref, 'path');
81 <   if ( $self->{Arch} )
82 <      {
83 <      print GNUmakefile "INCLUDE+=".$self->_location()."/".$$hashref{'path'}."\n";
84 <      }
80 >   $self->{simpledoc}->addtag("builder","define_group",
81 >                              \&BuildSystem::TagUtils::groupdeftagOpen, $self,
82 >                              "", $self,
83 >                              \&BuildSystem::TagUtils::groupdeftagClose, $self);
84 >  
85 >   $self->{simpledoc}->addtag("builder","group",
86 >                              \&BuildSystem::TagUtils::grouptagOpen, $self,
87 >                              "", $self,
88 >                              "", $self);
89 >  
90 >   $self->{simpledoc}->addtag("builder","lib",
91 >                              \&BuildSystem::TagUtils::libtagOpen, $self,
92 >                              "", $self,
93 >                              "", $self);
94 >
95 >   $self->{simpledoc}->addtag("builder","export",
96 >                              \&BuildSystem::TagUtils::exporttagOpen, $self,
97 >                              "", $self,
98 >                              \&BuildSystem::TagUtils::exporttagClose, $self);
99 >
100 >   $self->{simpledoc}->addtag("builder","use",
101 >                              \&BuildSystem::TagUtils::usetagOpen, $self,
102 >                              "", $self,
103 >                              "", $self);
104 >  
105 >   $self->{simpledoc}->addtag("builder","libtype",
106 >                              \&BuildSystem::TagUtils::libtypetagOpen, $self,
107 >                              "", $self,
108 >                              "", $self);
109 >
110 >   $self->{simpledoc}->addtag("builder","skip",
111 >                              \&BuildSystem::TagUtils::skiptagOpen, $self,
112 >                              \&BuildSystem::TagUtils::skiptagMessage, $self,
113 >                              \&BuildSystem::TagUtils::skiptagClose, $self);
114 >
115 >   $self->{simpledoc}->addtag("builder","makefile",
116 >                              \&BuildSystem::TagUtils::makefiletagOpen, $self,
117 >                              \&BuildSystem::TagUtils::makefiletagContent, $self,
118 >                              \&BuildSystem::TagUtils::makefiletagClose, $self);
119 >
120 >   $self->{simpledoc}->addtag("builder","flags",
121 >                              \&BuildSystem::TagUtils::flagstagOpen, $self,
122 >                              "", $self,
123 >                              "", $self);
124 >  
125 >   $self->{simpledoc}->addtag("builder","bin",
126 >                              \&BuildSystem::TagUtils::binarytagOpen, $self,
127 >                              "", $self,
128 >                              \&BuildSystem::TagUtils::binarytagClose, $self);
129 >  
130 >   $self->{simpledoc}->addtag("builder","module",
131 >                              \&BuildSystem::TagUtils::moduletagOpen, $self,
132 >                              "", $self,
133 >                              \&BuildSystem::TagUtils::moduletagClose, $self);
134 >  
135 >   $self->{simpledoc}->addtag("builder","application",
136 >                              \&BuildSystem::TagUtils::applicationtagOpen, $self,
137 >                              "", $self,
138 >                              \&BuildSystem::TagUtils::applicationtagClose, $self);
139 >
140 >   $self->{simpledoc}->addtag("builder","library",
141 >                              \&BuildSystem::TagUtils::librarytagOpen, $self,
142 >                              "", $self,
143 >                              \&BuildSystem::TagUtils::librarytagClose, $self);
144 >
145 > #    $self->{simpledoc}->addtag("builder"," ",
146 > #                             \&BuildSystem::TagUtils::  ,$self,
147 > #                             \&BuildSystem::TagUtils::  ,$self,
148 > #                             \&BuildSystem::TagUtils::  ,$self);
149 >
150 >   return $self->{simpledoc};
151     }
152  
153 < #
302 < # generic build tag
303 < #
304 < sub Build_start {
305 <        my $self=shift;
306 <        my $name=shift;
307 <        my $hashref=shift;
308 <
309 <        $self->verbose(">> Build_start: NM ".$name." <<");
310 <        
311 <        $self->{switch}->checktag($name,$hashref,'class');
312 <        if ( $self->{Arch} ) {
313 <
314 <          # -- determine the build products name
315 <          my $name;
316 <          if ( exists $$hashref{'name'} ) {
317 <            $name=$$hashref{'name'};
318 <          }
319 <          else {
320 <            $self->{switch}->parseerror("No name specified for build product");
321 <          }
322 <
323 <          # -- check we have a lookup for the class type
324 <          my $mapper=$self->_toolmapper();
325 <          if ( ! $mapper->exists($$hashref{'class'}) ) {
326 <            $self->{switch}->parseerror("Unknown class : ".$$hashref{'class'});
327 <          }
328 <          else {
329 <           my @types=$self->_toolmapper()->types($$hashref{'class'});
330 <           my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'});
331 <
332 <           my $fh=$self->{filehandlestack}[0];
333 <           my @targets=();
334 <
335 <           # -- generate generic targets
336 <           print $fh "ifndef _BuildLink_\n";
337 <           print $fh "# -- Generic targets\n";
338 <           push @targets, $$hashref{'class'};
339 <           foreach $dtype ( @deftypes ) {
340 <            print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
341 <                                                                $dtype."\n";
342 <           }
343 <           print $fh "\n";
344 <
345 <           # -- generate targets for each type
346 <           foreach $type ( @types ) {
347 <
348 <            # -- generic name for each type
349 <            my $pattern=$$hashref{'class'}."_".$type;
350 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
351 <            print $fh "# ------ $pattern rules ---------------\n";
352 <            print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}.
353 <                                                        "_".$type."_$name\n\n";
354 <
355 <            # -- create a new directory for each type
356 <            push @targets, $pattern;
357 <            my $dirname=$$hashref{'class'}."_".$type."_".$name;
358 <            my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname;
359 <            my $makefile=$here."/BuildFile.mk";
360 <
361 <            # -- create link targets to the directory
362 <            push @targets, $dirname;
363 <            print $fh "# -- Link Targets to $type directories\n";
364 <            print $fh "$dirname: make_$dirname\n";
365 <            print $fh "\t\@cd $here; \\\n";
366 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
367 <                        " workdir=$here ".
368 <                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
369 <
370 <            # -- write target to make makefile for each directory
371 <            print $fh "# -- Build target directories\n";
372 <            print $fh "make_$dirname:\n";
373 <            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
374 <            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
375 <            print $fh "\t  mkdir $here; \\\n";
376 <            print $fh "\t fi;\\\n";
377 <            print $fh "\t cd $dirname; \\\n";
378 <            print $fh "\t echo include ".$self->{currentenv}." > ".
379 <                                                        "$makefile; \\\n";
380 <            print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}.
381 <                                        " >> $makefile; \\\n";
382 <            print $fh "\t echo buildname=$name >> $makefile;\\\n";
383 <            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
384 <            if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) {
385 <             foreach $f ( @file ) {
386 <              print $fh "\t echo -include $f >> $makefile; \\\n";
387 <             }
388 <            }
389 <            print $fh "\tfi\n";
390 <            print $fh "\n";
391 <
392 <            # -- cleaning targets
393 <            push @targets, "clean_$dirname";
394 <            print $fh "# -- cleaning targets\n";
395 <            print $fh "clean::clean_$dirname\n";
396 <            print $fh "clean_".$dirname."::\n";
397 <            print $fh "\t\@echo cleaning $dirname\n";
398 <            print $fh "\t\@if [ -d $here ]; then \\\n";
399 <            print $fh "\tcd $here; \\\n";
400 <            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
401 <                        $here." _BuildLink_=1 -f ".
402 <                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
403 <            print $fh "\tfi\n\n";
404 <
405 <
406 <          }
407 <          # -- help targets
408 <          print $fh "helpheader::\n";
409 <          print $fh "\t\@echo Targets available:\n";
410 <          print $fh "\t\@echo ------------------\n\n";
411 <          print $fh "help::helpheader\n";
412 <          foreach $target ( @targets ) {
413 <            print $fh "help::\n";
414 <            print $fh "\t\@echo $target\n"
415 <          }
416 <          print $fh "endif\n";
417 <         } # end else
418 <        }
419 < }
420 <
421 < sub Bin_start {
422 <        my $self=shift;
423 <        my $name=shift;
424 <        my $hashref=shift;
425 <
426 <        my $fileclass;
427 <        my @tools;
428 <        my $tool;
429 <        my $filename;
430 <        my $objectname;
431 <
432 <        $self->verbose(">>          <<");
433 <        
434 <        $self->{switch}->checktag($name,$hashref,'file');
435 <        if ( $self->{Arch} ) {
436 <        if ( ! defined $$hashref{name} ) {
437 <                ($$hashref{name}=$$hashref{file})=~s/\..*//;
438 <        }
439 <        ($filename=$$hashref{file})=~s/\..*//;
440 <
441 <        # Create a new directory for each binary target
442 <        my $dirname="bin_".$$hashref{name};
443 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
444 <        open (binGNUmakefile,
445 <           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
446 <           "BuildFile.mk $!\n";
447 <
448 <        # Create the link targets
449 <        $numbins++;
450 <        my $fh=$self->{filehandlestack}[0];
451 <        print $fh <<ENDTEXT;
452 <
453 < # Link Targets to binary directories
454 < ifdef BINMODE
455 < # We dont want to build a library here
456 < override files:=
457 < endif
458 < ifndef BINMODE
459 <
460 < define stepdown_$$hashref{'name'}
461 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
462 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
463 < \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
464 < fi
465 < endef
466 <
467 < define stepdown2_$$hashref{'name'}
468 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
469 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
470 < \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
471 < fi
472 <
473 < endef
474 <
475 < bin_$$hashref{'name'}_%:: dummy
476 <        \@\$(stepdown2_$$hashref{'name'})
477 <
478 < $$hashref{'name'}_%:: dummy
479 <        \@\$(stepdown_$$hashref{'name'})
480 <
481 < help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
482 <        \@\$(stepdown_$$hashref{'name'})
483 <
484 < binfiles+=$$hashref{'file'}
485 < locbinfiles+=$dirname/$$hashref{'file'}
486 < endif
487 <
488 <
489 < ENDTEXT
490 <
491 <
492 < # the binary specifics makefile
493 <        print binGNUmakefile "include ".$self->{currentenv}."\n";
494 <        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
495 <
496 < # alias for bin_Insure
497 <        print binGNUmakefile <<ENDTEXT;
498 <
499 < bin_insure:bin_Insure
500 < ifdef MAKETARGET_bin_insure
501 < MAKETARGET_$$hashref{name}_Insure=1
502 < endif
503 <
504 < # debuggging target
505 < $$hashref{'name'}_echo_% :: echo_%
506 <
507 < # help targets
508 < help::
509 < \t\@echo Targets For $$hashref{'name'}
510 < \t\@echo -------------------------------------
511 < \t\@echo $$hashref{'name'}  - default build
512 < \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
513 < ENDTEXT
514 <
515 < # Make generic rules for each type
516 <        $targettypes={
517 <                "bin" => 'o',
518 <                "bin_debug" => 'd',
519 <                "bin_debug_local" => 'l_d',
520 <                "bin_Insure" => 'Insure'
521 <        };
522 <        #
523 <        foreach $target ( keys %$targettypes ) {
524 <          print binGNUmakefile <<ENDTEXT;
525 <
526 < # Type $target specifics
527 < ifdef MAKETARGET_$target
528 < MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
529 < endif
530 < $target ::$$hashref{name}_$$targettypes{$target}
531 <
532 < bintargets+=$$hashref{name}_$$targettypes{$target}
533 < help::
534 < \t\@echo $$hashref{name}_$$targettypes{$target}
535 < clean::
536 < \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
537 < \techo Removing \$(binarystore)/$$hashref{name}; \\
538 < \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
539 < \tfi
540 <
541 < ENDTEXT
542 <          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
543 <          ${"objectname_$$targettypes{$target}"}=$objectname;
544 <          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
545 <        } # end loop
546 <
547 <        print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
548 <        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
549 <        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
550 <        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
551 <        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
552 <        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
553 <        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
554 <        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
555 <        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
556 <        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
557 <        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
558 <        print binGNUmakefile "\t\$(CClinkCmd)\n";
559 <        print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
560 <        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
561 <        print binGNUmakefile "-include $$hashref{name}.dep\n";
562 < print binGNUmakefile <<ENDTEXT;
563 < clean::
564 < \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
565 < \techo Removing \$(binarystore)/$$hashref{name}; \\
566 < \trm \$(binarystore)/$$hashref{name}; \\
567 < \tfi
568 <
569 < $$hashref{name}_d.exe:\$(libslocal_d)
570 < $$hashref{name}_o.exe:\$(libslocal)
571 < ifdef MCCABE_DATA_DIR
572 < $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
573 < endif
574 < $$hashref{name}_Insure.exe:\$(libslocal_I)
575 < $$hashref{name}_d:$$hashref{name}_d.exe
576 <        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
577 < $$hashref{name}_l_d:$$hashref{name}_l_d.exe
578 <        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
579 < $$hashref{name}_Insure:$$hashref{name}_Insure.exe
580 <        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
581 < $$hashref{name}:$$hashref{name}_d.exe
582 <        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
583 < $$hashref{name}_o:$$hashref{name}_o.exe
584 <        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
585 < binfiles+=$$hashref{file}
586 < ENDTEXT
587 <        }
588 <        close binGNUmakefile;
589 < }
590 <
591 < sub Module_start {
592 <        my $self=shift;
593 <        my $name=shift;
594 <        my $hashref=shift;
595 <
596 <        my $fileclass;
597 <        my @tools;
598 <        my $tool;
599 <        my $filename;
600 <        my $objectname;
601 <
602 <        $self->verbose(">> In module_start: ".$name." <<");
603 <        
604 <        $self->{switch}->checktag($name,$hashref,'file');
605 <        if ( $self->{Arch} ) {
606 <        if ( ! defined $$hashref{name} ) {
607 <                ($$hashref{name}=$$hashref{file})=~s/\..*//;
608 <        }
609 <        ($filename=$$hashref{file})=~s/\..*//;
610 <
611 <        # Create a new directory for each module target
612 <        my $dirname="module_".$$hashref{name};
613 <        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
614 <        open (moduleGNUmakefile,
615 <           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
616 <           "BuildFile.mk $!\n";
617 <
618 <        # Create the link targets
619 <        $numbins++;
620 <        my $fh=$self->{filehandlestack}[0];
621 <        print $fh <<ENDTEXT;
622 <
623 < # Link Targets to module directories
624 < ifdef MODULEMODE
625 < # We dont want to build a library here
626 < override files:=
627 < endif
628 < ifndef MODULEMODE
629 <
630 < BINMODE=true
631 <  
632 < define stepdown_$$hashref{'name'}
633 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
634 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
635 < \$(MAKE) MODULEMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
636 < fi
637 < endef
638 <
639 < define stepdown2_$$hashref{'name'}
640 < if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
641 < cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
642 < \$(MAKE) MODULEMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
643 < fi
644 <
645 < endef
646 <
647 < module_$$hashref{'name'}_%:: dummy
648 <        \@\$(stepdown2_$$hashref{'name'})
649 <
650 < $$hashref{'name'}_%:: dummy
651 <        \@\$(stepdown_$$hashref{'name'})
652 <
653 < help module module_debug module_debug_local module_insure module_Insure clean $$hashref{'name'}:: dummy
654 <        \@\$(stepdown_$$hashref{'name'})
655 <
656 < modulefiles+=$$hashref{'file'}
657 < locmodulefiles+=$dirname/$$hashref{'file'}
658 < endif
659 <
660 <
661 < ENDTEXT
662 <
663 <
664 < # the module specifics makefile
665 <        print moduleGNUmakefile "include ".$self->{currentenv}."\n";
666 <        print moduleGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
667 <
668 < # alias for bin_Insure
669 <        print moduleGNUmakefile <<ENDTEXT;
670 <
671 < module_insure:module_Insure
672 < ifdef MAKETARGET_module_insure
673 < MAKETARGET_$$hashref{name}_Insure=1
674 < endif
675 <
676 < # debuggging target
677 < $$hashref{'name'}_echo_% :: echo_%
678 <
679 < # help targets
680 < help::
681 < \t\@echo  
682 < \t\@echo Targets For $$hashref{'name'}
683 < \t\@echo -------------------------------------
684 < \t\@echo $$hashref{'name'}  - default build
685 < \t\@echo module_$$hashref{'name'}_clean - executable specific cleaning
686 < ENDTEXT
687 <
688 < # Make generic rules for each type
689 <        $targettypes={
690 <                "module" => 'o',
691 <                "module_debug" => 'd',
692 <                "module_debug_local" => 'l_d',
693 <                "module_Insure" => 'Insure'
694 <        };
695 <        #
696 <        foreach $target ( keys %$targettypes ) {
697 <          print moduleGNUmakefile <<ENDTEXT;
698 <
699 < # Type $target specifics
700 < ifdef MAKETARGET_$target
701 < MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
702 < endif
703 < $target ::$$hashref{name}_$$targettypes{$target}
704 <
705 < moduletargets+=$$hashref{name}_$$targettypes{$target}
706 < help::
707 < \t\@echo $$hashref{name}_$$targettypes{$target}
708 < clean::
709 < \t\@if [ -f \$(modulestore)/$$hashref{name}_$$targettypes{$target} ]; then \\
710 < \techo Removing \$(modulestore)/$$hashref{name}; \\
711 < \trm \$(modulestore)/$$hashref{name}_$$targettypes{$target}; \\
712 < \tfi
713 <
714 < ENDTEXT
715 <          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
716 <          ${"objectname_$$targettypes{$target}"}=$objectname;
717 <          print moduleGNUmakefile "$objectname:$$hashref{name}.dep\n";
718 <        } # end loop
719 <        print moduleGNUmakefile "MDFLAGS= -shared -Wl,-soname,\$\@","\n";
720 <        print moduleGNUmakefile "$$hashref{name}_Insure.so:.psrc\n";
721 <        print moduleGNUmakefile "$$hashref{name}_d.so:$objectname_d\n";
722 <        print moduleGNUmakefile "\t\$(CClinkCmdDebug) \$(MDFLAGS)\n";
723 <        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
724 <        print moduleGNUmakefile "$$hashref{name}_l_d.so:$objectname_d\n";
725 <        print moduleGNUmakefile "\t\$(CClinkCmdDebugLocal) \$(MDFLAGS)\n";
726 <        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
727 <        print moduleGNUmakefile "$$hashref{name}_Insure.so:$objectname_Insure\n";
728 <        print moduleGNUmakefile "\t\$(CClinkCmdInsure) \$(MDFLAGS)\n";
729 <        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
730 <        print moduleGNUmakefile "$$hashref{name}_o.so:$objectname_o\n";
731 <        print moduleGNUmakefile "\t\$(CClinkCmd) \$(MDFLAGS)\n";
732 <        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
733 <        print moduleGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
734 <        print moduleGNUmakefile "-include $$hashref{name}.dep\n";
735 < print moduleGNUmakefile <<ENDTEXT;
736 < clean::
737 < \t\@if [ -f \$(modulestore)/lib$$hashref{name} ]; then \\
738 < \techo Removing \$(modulestore)/lib$$hashref{name}; \\
739 < \trm \$(modulestore)/lib$$hashref{name}; \\
740 < \tfi
741 <
742 <  
743 < $$hashref{name}_d.so:\$(libslocal_d)
744 < $$hashref{name}_o.so:\$(libslocal)
745 < ifdef MCCABE_DATA_DIR
746 < $$hashref{name}_mccabe.so: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
747 < endif
748 < $$hashref{name}_Insure.so:\$(libslocal_I)
749 < $$hashref{name}_d:$$hashref{name}_d.so
750 <        \@cp $$hashref{name}_d.so \$(modulestore)/lib$$hashref{name}
751 < $$hashref{name}_l_d:$$hashref{name}_l_d.so
752 <        \@cp $$hashref{name}_l_d.so \$(modulestore)/lib$$hashref{name}
753 < $$hashref{name}_Insure:$$hashref{name}_Insure.so
754 <        \@cp $$hashref{name}_Insure.so \$(modulestore)/lib$$hashref{name}_Insure
755 < $$hashref{name}:$$hashref{name}_d.so
756 <        \@mv $$hashref{name}_d.so \$(modulestore)/lib$$hashref{name}
757 < $$hashref{name}_o:$$hashref{name}_o.so
758 <        \@mv $$hashref{name}_o.so \$(modulestore)/lib$$hashref{name}.so
759 < modulefiles+=$$hashref{file}
760 < ENDTEXT
761 <        }
762 <        close moduleGNUmakefile;
763 < }
764 <
765 <
766 < sub External_StartTag {
767 <        my $self=shift;
768 <        my $name=shift;
769 <        my $hashref=shift;
770 <
771 <        $self->verbose(">> External_StartTag: NM ".$name." <<");
772 <        
773 <        my $tool;
774 <        if ( $self->{Arch} ) {
775 <        $self->{switch}->checktag($name,$hashref,'ref');
776 <
777 <        # -- oo toolbox stuff
778 <        # - get the appropriate tool object
779 <        $$hashref{'ref'}=~tr[A-Z][a-z];
780 <        if ( ! exists $$hashref{'version'} ) {
781 <         $tool=$self->{toolbox}->gettool($$hashref{'ref'});
782 <        }
783 <        else {
784 <         $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
785 <        }
786 <        if ( ! defined $tool ) {
787 <          $self->{switch}->parseerror("Unknown Tool Specified ("
788 <                                                        .$$hashref{'ref'}.")");
789 <        }
790 <
791 <        # -- old fashioned GNUmakefile stuff
792 <        print GNUmakefile $$hashref{'ref'};
793 <        if ( defined $$hashref{'version'} ) {
794 <                print GNUmakefile "_V_".$$hashref{'version'};
795 <        }
796 <        print GNUmakefile "=true\n";
797 <        
798 <        # -- Sub system also specified?
799 <        if ( exists $$hashref{'use'} ) {
800 <           # -- look for a buildfile
801 <           my @paths=$tool->getfeature("INCLUDE");
802 <           my $file="";
803 <           my ($path,$testfile);
804 <           foreach $path ( @paths ) {
805 <             $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
806 <             if ( -f $testfile ) {
807 <                $file=$testfile;
808 <                $self->_pushremoteproject($path);
809 <             }
810 <           }
811 <           if ( $file eq "" ) {
812 <             $self->{switch}->parseerror("Unable to find SubSystem $testfile");
813 <           }
814 <           $self->ParseBuildFile_Export($file);
815 <           $self->_popremoteproject();
816 <         }
817 <        }
818 < }      
819 <
820 < sub Group_start {
821 <        my $self=shift;
822 <        my $name=shift;
823 <        my $hashref=shift;
824 <        
825 <        $self->verbose(">> Group_start: NM ".$name." <<");
826 <        
827 <        $self->{switch}->checktag($name, $hashref, 'name');
828 <        if ( $self->{Arch} ) {
829 <        print GNUmakefile "GROUP_".$$hashref{'name'};
830 <        if ( defined $$hashref{'version'} ) {
831 <                print GNUmakefile "_V_".$$hashref{'version'};
832 <        }
833 <        print GNUmakefile "=true\n";
834 <        }
835 < }      
836 <
837 < sub Use_start
153 > sub parse()
154     {
155     my $self=shift;
156 <   my $name=shift;
841 <   my $hashref=shift;
842 <   my $filename;
843 <   use Utilities::SCRAMUtils;
156 >   my ($filename)=@_;
157  
158 <   $self->verbose(">> Use_start: NM ".$name." <<");
158 >   $self->{simpledoc}=$self->_initparser();
159 >   $self->{simpledoc}->filetoparse($filename);
160 >   $self->{simpledoc}->parse("builder");
161    
162 <   $self->{switch}->checktag($name, $hashref, "name");
163 <   if ( $self->{Arch} )
849 <      {
850 <      if ( exists $$hashref{'group'} )
851 <         {
852 <         print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n";
853 <         }
854 <      if ( ! defined $self->{remoteproject} )
855 <         {
856 <         $filename=SCRAMUtils::checkfile("/$ENV{INTsrc}/$$hashref{name}/BuildFile");
857 <         }
858 <      else
859 <         {
860 <         $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
861 <         print "Trying $filename\n";
862 <         if ( ! -f $filename ) { $filename=""; };
863 <         }
864 <      if ( $filename ne "" )
865 <         {
866 <         $self->ParseBuildFile_Export( $filename );
867 <         }
868 <      else
869 <         {
870 <         $self->{switch}->parseerror("Unable to detect Appropriate ".
871 <                                     "decription file for <$name name=".$$hashref{name}.">");
872 <         }
873 <      }
162 >   # We're done with the SimpleDoc object so delete it:
163 >   delete $self->{simpledoc};
164     }
165  
166 < sub CheckBuildFile {
877 <         my $self=shift;
878 <         my $classdir=shift;
879 <         my $ClassName="";
880 <         my $thisfile="$classdir/$buildfile";
881 <        
882 <         if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
883 <            $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
884 <            $self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
885 <         }
886 <         elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
887 <            $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
888 <            $self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
889 <         }
890 <         $self->verbose(">> CheckBuildFile: FN ".$thisfile." CN ".$ClassName." <<");
891 <         return $ClassName;
892 < }
893 <
894 < # List association groups between <AssociateGroup> tags
895 < # seperated by newlines or spaces
896 < sub AssociateGroup {
897 <        my $self=shift;
898 <        my $name=shift;
899 <        my $string=shift;
900 <        my $word;
901 <
902 <        $self->verbose(">> AssociateGroup: NM ".$name." ST ".$string." <<");
903 <        
904 <        if ( $self->{Arch} ) {
905 <        foreach $word ( (split /\s/, $string) ){
906 <                chomp $word;
907 <                next if /^#/;
908 <                if ( $word=~/none/ ) {
909 <                        $self->{ignore}=1;
910 <                }
911 <        }
912 <        }
913 < }
914 <
915 < sub Arch_Start {
916 <        my $self=shift;
917 <        my $name=shift;
918 <        my $hashref=shift;
919 <
920 <        $self->verbose(">> Arch_Start: NM ".$name." <<");
921 <        
922 <        $self->{switch}->checktag($name, $hashref,'name');
923 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
924 <                                                : ($self->{Arch}=0);
925 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
926 < }
927 <
928 < sub Arch_End {
929 <        my $self=shift;
930 <        my $name=shift;
931 <        
932 <        $self->verbose(">> Arch_End: NM ".$name." <<");
933 <
934 <        pop @{$self->{ARCHBLOCK}};
935 <        $self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}];
936 < }
937 <
938 < # Split up the Class Block String into a useable array
939 < sub _CutBlock {
940 <    my $self=shift;
941 <    my $string= shift @_;
942 <
943 <    $self->verbose(">> _CutBlock: ST ".$string." <<");
944 <    
945 <    @BlockClassA = split /\//, $string;
946 < }
947 <
948 < sub OutToMakefile {
949 <        my $self=shift;
950 <        my $name=shift;
951 <        my @vars=@_;
952 <        
953 <        $self->verbose(">> OutToMakefile: <<");
954 <
955 <        if ( $self->{Arch} ) {
956 <          $self->verbose(">> CONT: ".$#vars." lines <<");
957 <          print GNUmakefile @vars;
958 <        }
959 < }
960 <
961 < sub OutToScreen {
962 <        my $name=shift;
963 <        my @vars=@_;
964 <        
965 <        if ( $self->{Arch} ) {
966 <          print @vars;
967 <        }
968 < }
969 < sub setBlockClassPath {
970 <        my $self=shift;
971 <        my $name=shift;
972 <        my $hashref=shift;
973 <
974 <        $self->verbose(">> setBlockClassPath: NM ".$name." <<");
975 <        
976 <        $self->{switch}->checktag($name, $hashref, 'path');
977 <        $self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path};
978 <        $self->_CutBlock($$hashref{path});
979 < }
980 <
981 < sub BlockClassPath {
982 <        my $self=shift;
983 <
984 <        $self->verbose(">> BlockClassPath: <<");
985 <
986 <        return $self->{BlockClassPath};
987 < }
988 <
989 < sub export_start_export {
990 <        my $self=shift;
991 <        my $name=shift;
992 <        my $hashref=shift;
993 <
994 <        $self->verbose(">> export_start_export: NM ".$name." <<");
995 <        
996 <        $self->{switch}->opengroup("__export");
997 < }
998 <
999 < sub export_start {
1000 <        my $self=shift;
1001 <        my $name=shift;
1002 <        my $hashref=shift;
1003 <
1004 <        $self->verbose(">> export_start: NM ".$name." <<");
1005 <        
1006 <        $self->{switch}->opengroup("__export");
1007 <        if ( exists $$hashref{autoexport} ) {
1008 <          print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
1009 <          if ( $$hashref{autoexport}=~/true/ ) {
1010 <           $self->{switch}->allowgroup("__export","makebuild");
1011 <          }
1012 <          else {
1013 <           $self->{switch}->disallowgroup("__export","makebuild");
1014 <          }
1015 <        }
1016 <        # -- allow default setting from other makefiles
1017 <        print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
1018 < }
1019 <
1020 < sub export_end_export {
1021 <        my $self=shift;
1022 <        $self->verbose(">> export_end_export: <<");
1023 <        $self->{switch}->closegroup("__export");
1024 < }
1025 <
1026 < sub export_end {
1027 <        my $self=shift;
1028 <        $self->verbose(">> export_end: <<");
1029 <        $self->{switch}->closegroup("__export");
1030 <        print GNUmakefile "endif\n";
1031 < }
1032 <
1033 < #
1034 < # Standard lib tag
1035 < #
1036 < sub lib_start
166 > sub _initbranchparser()
167     {
168     my $self=shift;
169 <   my $name=shift;
170 <   my $hashref=shift;
169 >
170 >   $self->{simpledoc}=ActiveDoc::SimpleDoc->new();
171 >   $self->{simpledoc}->newparse("branchbuilder");
172 >   $self->{simpledoc}->addignoretags("branchbuilder");
173 >
174 >   # For blank lines do nothing:
175 >   $self->{simpledoc}->addtag("branchbuilder","none",
176 >                              "", $self,
177 >                              "", $self,
178 >                              "", $self);
179 >  
180 >   # Define the tags to be used in this class:
181 >   $self->{simpledoc}->addtag("branchbuilder","productstore",
182 >                              \&BuildSystem::TagUtils::productstoretagOpen, $self,
183 >                              "", $self,
184 >                              "", $self);
185    
186 <   $self->verbose(">> lib_start: NM ".$name." <<");
186 >   $self->{simpledoc}->addtag("branchbuilder","architecture",
187 >                              \&BuildSystem::TagUtils::archtagOpen, $self,
188 >                              "", $self,
189 >                              \&BuildSystem::TagUtils::archtagClose, $self);
190 >
191 >   $self->{simpledoc}->addtag("branchbuilder","include_path",
192 >                              \&BuildSystem::TagUtils::includetagOpen, $self,
193 >                              "", $self,
194 >                              "", $self);
195    
196 <   $self->{switch}->checktag($name, $hashref, 'name');
196 >   $self->{simpledoc}->addtag("branchbuilder","export",
197 >                              \&BuildSystem::TagUtils::exporttagOpen, $self,
198 >                              "", $self,
199 >                              \&BuildSystem::TagUtils::exporttagClose, $self);
200 >
201 >   $self->{simpledoc}->addtag("branchbuilder","define_group",
202 >                              \&BuildSystem::TagUtils::groupdeftagOpen, $self,
203 >                              "", $self,
204 >                              \&BuildSystem::TagUtils::groupdeftagClose, $self);
205 >  
206 >   $self->{simpledoc}->addtag("branchbuilder","group",
207 >                              \&BuildSystem::TagUtils::grouptagOpen, $self,
208 >                              "", $self,
209 >                              "", $self);
210 >  
211 >   $self->{simpledoc}->addtag("branchbuilder","lib",
212 >                              \&BuildSystem::TagUtils::libtagOpen, $self,
213 >                              "", $self,
214 >                              "", $self);
215 >
216 >   $self->{simpledoc}->addtag("branchbuilder","use",
217 >                              \&BuildSystem::TagUtils::usetagOpen, $self,
218 >                              "", $self,
219 >                              "", $self);
220 >  
221 >   $self->{simpledoc}->addtag("branchbuilder","libtype",
222 >                              \&BuildSystem::TagUtils::libtypetagOpen, $self,
223 >                              "", $self,
224 >                              "", $self);
225 >  
226 >   $self->{simpledoc}->addtag("branchbuilder","makefile",
227 >                              \&BuildSystem::TagUtils::makefiletagOpen, $self,
228 >                              \&BuildSystem::TagUtils::makefiletagContent, $self,
229 >                              \&BuildSystem::TagUtils::makefiletagClose, $self);
230 >
231 >   $self->{simpledoc}->addtag("branchbuilder","flags",
232 >                              \&BuildSystem::TagUtils::flagstagOpen, $self,
233 >                              "", $self,
234 >                              "", $self);
235 >  
236 >   $self->{simpledoc}->addtag("branchbuilder","bin",
237 >                              \&BuildSystem::TagUtils::binarytagOpen, $self,
238 >                              "", $self,
239 >                              \&BuildSystem::TagUtils::binarytagClose, $self);
240 >  
241 >   $self->{simpledoc}->addtag("branchbuilder","module",
242 >                              \&BuildSystem::TagUtils::moduletagOpen, $self,
243 >                              "", $self,
244 >                              \&BuildSystem::TagUtils::moduletagClose, $self);
245 >  
246 >   $self->{simpledoc}->addtag("branchbuilder","application",
247 >                              \&BuildSystem::TagUtils::applicationtagOpen, $self,
248 >                              "", $self,
249 >                              \&BuildSystem::TagUtils::applicationtagClose, $self);
250 >
251 >   $self->{simpledoc}->addtag("branchbuilder","library",
252 >                              \&BuildSystem::TagUtils::librarytagOpen, $self,
253 >                              "", $self,
254 >                              \&BuildSystem::TagUtils::librarytagClose, $self);
255 >  
256 >   return $self->{simpledoc};
257 >   }
258  
259 <   if ( $self->{Arch} )
260 <      {
261 <      print GNUmakefile "lib+=$$hashref{name}\n";
262 <      }
259 > sub parsebranchfiles()
260 >   {
261 >   my $self=shift;
262 >   my ($filenames)=@_; # array ref
263 >   # List of buildfiles:
264 >   $self->{localpaths}=$filenames;
265 >   $self->{simpledoc}=$self->_initbranchparser();
266 >   # We iterate over an array of files to be read in turn: all
267 >   # build data will be stored in the same BuildFile object:
268 >   $self->{simpledoc}->parsefilelist("branchbuilder",$filenames);
269 >   # We're done with the SimpleDoc object so delete it:
270 >   delete $self->{simpledoc};
271     }
272  
273 < # Standard debug lib tag
1053 < #
1054 < sub debuglib_start
273 > sub productcollector()
274     {
275     my $self=shift;
276 <   my $name=shift;
277 <   my $hashref=shift;
276 >   my ($name,$typeshort,$typefull)=@_;
277 >   # Create a new Product object for storage of data:
278 >   use BuildSystem::Product;
279 >   my $product = BuildSystem::Product->new();
280 >   # Store the name:
281 >   $product->name($name);
282 >   $product->type($typeshort);
283 >   # Store the files:
284 >   $product->_files($self->{id}->{'file'},$self->{localpaths});
285 >   # Store the data content:
286 >   $product->_data($self->{tagcontent});
287 >   # And store in a hash (all build products in same place):
288 >   $self->{content}->{BUILDPRODUCTS}->{$typefull}->{$name} = $product;
289 >   }
290 >
291 > sub pushlevel
292 >   {
293 >   my $self = shift;
294 >   my ($info)=@_;
295    
296 <   $self->verbose(">> debuglib_start: NM ".$name." <<");
297 <   $self->{switch}->checktag($name, $hashref, 'name');
296 >   $self->{id} = $info if (defined $info);
297 >   $self->{nested} = 1;
298 >   $self->{tagcontent}={};
299 >   }
300 >
301 > sub poplevel
302 >   {
303 >   my $self = shift;
304 >   delete $self->{id};
305 >   delete $self->{nested};
306 >   delete $self->{tagcontent};
307 >   }
308 >
309 > sub dependencies()
310 >   {
311 >   my $self=shift;
312 >   # Make a copy of the variable so that
313 >   # we don't have a DEPENDENCIES entry in RAWDATA:
314 >   my %DEPS=%{$self->{DEPENDENCIES}};
315 >   delete $self->{DEPENDENCIES};
316 >   return \%DEPS;
317 >   }
318  
319 <   if ( $self->{Arch} )
319 > sub skippeddirs()
320 >   {
321 >   my $self=shift;
322 >   my ($here)=@_;
323 >   my $skipped;
324 >
325 >   if ($self->{content}->{SKIPPEDDIRS}->[0] == 1)
326        {
327 <      print GNUmakefile "debuglib+=$$hashref{name}\n";
327 >      $skipped = [ @{$self->{content}->{SKIPPEDDIRS}} ];
328 >      delete $self->{content}->{SKIPPEDDIRS};
329        }
330 +  
331 +   delete $self->{content}->{SKIPPEDDIRS};
332 +   return $skipped;
333     }
334  
335   #
336 < # libtype specification
336 > # All data access methods are inherited from BuildDataUtils.
337   #
338 < sub LibType_Start {
1073 <        my $self=shift;
1074 <        my $name=shift;
1075 <        my $hashref=shift;
1076 <        
1077 <        $self->verbose(">> LibType_Start: NM ".$name." <<");
1078 <        
1079 <        if ( $self->{Arch} ) {
1080 <        if ( defined $self->{libtype_conext} ) {
1081 <          $self->{switch}->parseerror("<$name> tag cannot be specified".
1082 <                " without a </$name> tag to close previous context");
1083 <        }
1084 <        else {
1085 <        $self->{libtype_conext}=1;
1086 <        $self->{switch}->checktag($name, $hashref, 'type');
1087 <        
1088 <        print GNUmakefile "# Specify Library Type\n";
1089 <        print GNUmakefile "DefaultLibsOff=yes\n";
1090 <        if ( $$hashref{'type'}=~/^archive/i ) {
1091 <          print GNUmakefile "LibArchive=true\n";
1092 <        }
1093 <        elsif ($$hashref{'type'}=~/debug_archive/i ) {
1094 <          print GNUmakefile "LibDebugArchive=true\n";
1095 <        }
1096 <        elsif ($$hashref{'type'}=~/debug_shared/i ) {
1097 <          print GNUmakefile "LibDebugShared=true\n";
1098 <        }
1099 <        elsif ($$hashref{'type'}=~/shared/i ) {
1100 <          print GNUmakefile 'LibShared=true'."\n";
1101 <        }
1102 <        print GNUmakefile "\n";
1103 <        }
1104 <        }
1105 < }
1106 <
1107 < sub LibType_text {
1108 <        my $self=shift;
1109 <        my $name=shift;
1110 <        my $string=shift;
1111 <        $self->verbose(">> LibType_text: NM ".$name." <<");
1112 <
1113 <        if ( $self->{Arch} ) {
1114 <          $string=~s/\n/ /g;
1115 <          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
1116 <          print GNUmakefile $string;
1117 <          print GNUmakefile "\n";
1118 <        }
1119 < }
1120 <
1121 < sub LibType_end {
1122 <        my $self=shift;
1123 <        my $name=shift;
1124 <
1125 <        $self->verbose(">> LibType_end: NM ".$name." <<");
1126 <
1127 <        undef $self->{libtype_conext};
1128 < }
1129 <
1130 < sub Environment_start {
1131 <        my $self=shift;
1132 <        my $name=shift;
1133 <        my $hashref=shift;
1134 <
1135 <        $self->verbose(">> Environment_start: NM ".$name." <<");
1136 <        
1137 <        if ( $self->{Arch} ) {
1138 <          $self->{envnum}++;
1139 <
1140 <          # open a new Environment File
1141 <          my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
1142 <                $self->{envnum}.".mk";
1143 <          use FileHandle;
1144 <          my $fh=FileHandle->new();
1145 <          open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
1146 <          push @{$self->{filehandlestack}}, $fh;
1147 <          *GNUmakefile=$fh;
1148 <
1149 <          # include the approprate environment file
1150 <          if ( $self->{envlevel} == 0 ) {
1151 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
1152 <                $self->{path}."/BuildFile.mk\n";
1153 <          }
1154 <          else {
1155 <             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/".
1156 <                $self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n";
1157 <          }
1158 <          $self->{envlevel}++;
1159 <          $self->{Envlevels}[$self->{envlevel}]=$self->{envnum};
1160 <          $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk";
1161 <        }
1162 < }
1163 <
1164 < sub Environment_end {
1165 <        my $self=shift;
1166 <        my $fd;
1167 <
1168 <        $self->verbose(">> Environment_end: NM ".$name." <<");
1169 <
1170 <        if ( $self->{Arch} ) {
1171 <          $self->{envlevel}--;
1172 <          if ( $self->{envlevel} < 0 ) {
1173 <            print "Too many </Environent> Tags on $self->{switch}->line()\n";
1174 <            exit 1;
1175 <          }
1176 <          close GNUmakefile;
1177 <          # restore the last filehandle
1178 <          $fd=pop @{$self->{filehandlestack}};
1179 <          close $fd;
1180 <          *GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}];
1181 <          if ( $self->{envlevel} < 1 ) {
1182 <            $self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/".
1183 <                        "BuildFile.mk";
1184 <          }
1185 <          else {
1186 <            $self->{currentenv}=
1187 <             "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_".
1188 <                $self->{Envlevels}[$self->{envlevel}];
1189 <          }
1190 <        }
1191 < }
1192 <
1193 < sub Store_start {
1194 <        my $self=shift;
1195 <        my $name=shift;
1196 <        my $hashref=shift;
1197 <
1198 <        $self->verbose(">> Store_start: NM ".$name." <<");
1199 <
1200 <        if ( $self->{Arch} ) {
1201 <          $self->{switch}->checktag( $name, $hashref, 'name' );
1202 <
1203 <          # -- store creation
1204 <          my $dir=$$hashref{'name'};
1205 <          AddDir::adddir($ENV{LOCALTOP}."/".$dir);
1206 <          if ( exists $$hashref{'type'} ) {
1207 <            # -- architecture specific store
1208 <            if ( $$hashref{'type'}=~/^arch/i ) {
1209 <                $dir=$dir."/".$ENV{SCRAM_ARCH};
1210 <                AddDir::adddir($ENV{LOCALTOP}."/".$dir);
1211 <            }
1212 <            else {
1213 <                $self->parseerror("Unknown type in <$name> tag");
1214 <            }
1215 <          }
1216 <
1217 <          # -- set make variables for the store
1218 <          print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n";
1219 <          print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=".
1220 <                                        $ENV{LOCALTOP}."/".$dir."\n";
1221 <          print GNUmakefile "VPATH+=".$ENV{LOCALTOP}
1222 <                        ."/".$dir.":".$ENV{RELEASETOP}."/".$dir."\n";
1223 <        }
1224 < }
338 > 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines