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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines