ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.21.2.36
Committed: Wed Dec 1 15:42:15 1999 UTC (25 years, 5 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
CVS Tags: V0_10_11, V0_10_10, V0_10_9, V0_10_8, V0_10_7, V0_10_6
Changes since 1.21.2.35: +4 -4 lines
Log Message:
make silent scramdsbuild calls

File Contents

# User Rev Content
1 williamc 1.1 package BuildFile;
2 williamc 1.2 require 5.001;
3 williamc 1.1 require Exporter;
4     @ISA = qw(Exporter);
5     @EXPORT = qw(CheckBuildFile ParseBuildFile @BlockClassA $DefaultBuildFile);
6    
7     BEGIN {
8     use ToolBox;
9     $buildfile="BuildFile";
10 williamc 1.4 $toolbox=ToolBox->new();
11 williamc 1.21 $Arch=1;
12     push @ARCHBLOCK, $Arch;
13 williamc 1.1 }
14    
15     #Parse the BuildFile
16     sub ParseBuildFile {
17     my $base=shift;
18 williamc 1.21.2.21 $path=shift;
19 williamc 1.1 my $filename=shift @_;
20     my $fullfilename="$base/$path/$filename";
21     #print "Processing $fullfilename\n";
22     # This hash defines which Document Elements we can use
23 williamc 1.21.2.21 $numbins=0;
24     $envnum=0;
25     $envlevel=0;
26     $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
27 williamc 1.1 my $SupportedTags={
28     'Use' => \&OutToMakefile,
29     'Use_StartTag' => \&Use_start,
30     'Group' => \&OutToMakefile,
31     'Group_StartTag' => \&Group_start,
32     'External' => \&OutToMakefile,
33     'External_StartTag' => \&External_StartTag,
34     'ConfigurationClass_StartTag' => \&Class_StartTag,
35     'ConfigurationClass' => \&OutToMakefile,
36     'AssociateGroup' => \&AssociateGroup,
37     'none' => \&OutToMakefile,
38 williamc 1.8 'Bin' => 'none',
39 williamc 1.1 'Bin_StartTag' => \&Bin_start,
40     'ClassPath' => \&OutToMakefile,
41 williamc 1.21 'ClassPath_StartTag' => \&setBlockClassPath,
42 williamc 1.21.2.21 'Environment' => \&OutToMakefile,
43     'Environment_StartTag' => \&Environment_start,
44     'Environment_EndTag' => \&Environment_end,
45 williamc 1.21.2.28 'export' => \&OutToMakefile,
46     'export_StartTag' => \&export_start,
47     'export_EndTag' => \&export_end,
48 williamc 1.21.2.34 'lib' => \&OutToMakefile,
49 williamc 1.21 'lib_StartTag' => \&lib_start,
50 williamc 1.21.2.1 'lib_EndTag' => 'none',
51     'ignore' => 'none',
52     'ignore_EndTag' => \&ignoretag_end,
53     'ignore_StartTag' => \&ignoretag,
54     'Architecture_StartTag' => \&Arch_Start,
55     'Architecture_EndTag' => \&Arch_End,
56 williamc 1.21.2.6 'Architecture' => \&OutToMakefile,
57     'LibType_StartTag' => \&LibType_Start,
58     'LibType_EndTag' => 'none',
59 williamc 1.21.2.15 #'LibType' => \&OutToScreen
60     'LibType' => \&LibType_text
61 williamc 1.1 };
62 williamc 1.2 use Utilities::Switcher;
63 williamc 1.1 $switch=Switcher->new($SupportedTags, $fullfilename);
64     $switch->{Strict_no_cr}='no';
65     #open a temporary gnumakefile to store output.
66 williamc 1.2 use Utilities::AddDir;
67 williamc 1.3 AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}");
68 williamc 1.21.2.22 my $fh=FileHandle->new();
69     open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk"
70     ) or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n';
71     @filehandlestack=($fh);
72     # make an alias
73     # open ( GNUmakefile, ">&=$fh") or die 'Unable to create alias for '.
74     # "Filehandle $!\n";
75     *GNUmakefile=$fh;
76 williamc 1.1 if ( -e $ENV{LatestBuildFile} ) {
77     print GNUmakefile "include $ENV{LatestBuildFile}\n";
78     }
79     # print "writing to :\n".
80     # "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk\n";
81     $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
82     $switch->parse(); # sort out supported tags
83 williamc 1.21.2.24 if ( $numbins > 0 ) {
84     print GNUmakefile <<ENDTEXT;
85     ifndef BINMODE
86     help::
87     \t\@echo Generic Binary targets
88     \t\@echo ----------------------
89     endif
90     ENDTEXT
91     foreach $target ( keys %$targettypes ) {
92     print GNUmakefile <<ENDTEXT;
93     ifndef BINMODE
94     help::
95     \t\@echo $target
96     endif
97     ENDTEXT
98     }
99     }
100 williamc 1.1 close GNUmakefile;
101     }
102    
103 williamc 1.21 sub ParseBuildFile_Export {
104     my $filename=shift;
105     use Tool;
106     # This hash defines which Document Elements we can use
107     my $SupportedTags={
108     'none' => 'none',
109     'export' => \&OutToMakefile,
110 williamc 1.21.2.30 'export_StartTag' => \&use_export_start,
111     'export_EndTag' => \&use_export_end,
112 williamc 1.21.2.34 'lib_StartTag' => \&lib_start,
113 williamc 1.21.2.12 'External_StartTag' => \&Ext_start_export,
114 williamc 1.21 'lib' => 'none'
115     };
116     use Utilities::Switcher;
117     $switchex=Switcher->new($SupportedTags, $filename);
118     $switchex->{Strict_no_cr}='no';
119     $switchex->parse(); # sort out supported tags
120     }
121    
122 williamc 1.1 sub initialterms() {
123     my $name=shift;
124     my @string=@_;
125    
126     $_=join "", @string;
127     chomp;
128     SWITCH: {
129     last SWITCH if /^#/;
130     if ( /^.*BlockClassPath.*/i ) {
131     s/^.*BlockClassPath *= *//;
132     _CutBlock($_);
133     last SWITCH;
134     }
135     } # end SWITCH
136     }
137    
138     # Tag routines - called by the Switcher when tag found
139    
140    
141    
142     #-- Override a class type with the <ConfigurationClass type=xxx> tag
143     # the type tag will pick up a pre-defined class type from project space.
144    
145     sub Class_StartTag {
146     my $name=shift;
147     my $hashref;
148     my @vars=@_;
149    
150     $hashref=$switch->SetupValueHash(\@vars);
151 williamc 1.21.2.1 if ( $Arch ) {
152 williamc 1.1 if ( defined $$hashref{'type'} ) {
153     $ClassName=$$hashref{'type'};
154     }
155 williamc 1.21.2.1 }
156 williamc 1.1 }
157    
158     sub ClassPath_StartTag {
159     my $name=shift;
160     my @vars=@_;
161     my $hashref;
162    
163     $hashref=$switch->SetupValueHash(\@vars);
164 williamc 1.21.2.1 if ( $Arch ) {
165 williamc 1.1 if ( defined $$hashref{'defaultpath'} ) {
166     }
167 williamc 1.21.2.1 }
168 williamc 1.1 }
169    
170     sub Bin_start {
171     my $name=shift;
172     my @vars=@_;
173     my $hashref;
174     my $fileclass;
175     my @tools;
176     my $tool;
177 williamc 1.12 my $filename;
178     my $objectname;
179 williamc 1.1
180     $hashref=$switch->SetupValueHash(\@vars);
181     $switch->checkparam($hashref, $name, 'file');
182 williamc 1.21.2.1 if ( $Arch ) {
183 williamc 1.1 if ( ! defined $$hashref{name} ) {
184     ($$hashref{name}=$$hashref{file})=~s/\..*//;
185     }
186 williamc 1.4 # This stuff for later
187     #$fileclass=$toolbox->getclass($file);
188     #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
189 williamc 1.21.2.21
190 williamc 1.12 ($filename=$$hashref{file})=~s/\..*//;
191 williamc 1.21.2.21
192     # Create a new directory for each binary target
193     my $dirname="bin_".$$hashref{name};
194     AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname");
195     open (binGNUmakefile,
196     ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk") or die "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/".
197     "BuildFile.mk $!\n";
198    
199     # Create the link targets
200     $numbins++;
201 williamc 1.21.2.22 my $fh=$filehandlestack[0];
202     print $fh <<ENDTEXT;
203    
204     # Link Targets to binary directories
205 williamc 1.21.2.32 ifdef BINMODE
206     # We dont want to build a library here
207     override files:=
208     endif
209 williamc 1.21.2.23 ifndef BINMODE
210 williamc 1.21.2.22
211     define stepdown_$$hashref{'name'}
212     if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\
213     cd $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\
214 williamc 1.21.2.35 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
215 williamc 1.21.2.22 fi
216     endef
217    
218 williamc 1.21.2.23 define stepdown2_$$hashref{'name'}
219     if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\
220     cd $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\
221 williamc 1.21.2.35 \$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
222 williamc 1.21.2.23 fi
223 williamc 1.21.2.24
224 williamc 1.21.2.23 endef
225    
226     bin_$$hashref{'name'}_%:: dummy
227     \@\$(stepdown2_$$hashref{'name'})
228 williamc 1.21.2.22
229 williamc 1.21.2.26 $$hashref{'name'}_%:: dummy
230     \@\$(stepdown_$$hashref{'name'})
231    
232 williamc 1.21.2.24 help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
233 williamc 1.21.2.22 \@\$(stepdown_$$hashref{'name'})
234 williamc 1.21.2.27
235     binfiles+=$$hashref{'file'}
236 williamc 1.21.2.21 endif
237 williamc 1.21.2.27
238 williamc 1.21.2.21
239     ENDTEXT
240    
241    
242     # the binary specifics makefile
243     print binGNUmakefile "include $currentenv\n";
244     print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/${path}\n";
245 williamc 1.21.2.22
246 williamc 1.21.2.21 # alias for bin_Insure
247     print binGNUmakefile <<ENDTEXT;
248 williamc 1.21.2.22
249 williamc 1.21.2.21 bin_insure:bin_Insure
250     ifdef MAKETARGET_bin_insure
251     MAKETARGET_$$hashref{name}_Insure=1
252     endif
253 williamc 1.21.2.22
254     # debuggging target
255     $$hashref{'name'}_echo_% :: echo_%
256    
257 williamc 1.21.2.25 # help targets
258     help::
259     \t\@echo Targets For $$hashref{'name'}
260     \t\@echo -------------------------------------
261     \t\@echo $$hashref{'name'} - default build
262     \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
263 williamc 1.21.2.21 ENDTEXT
264    
265     # Make generic rules for each type
266     $targettypes={
267     "bin" => 'o',
268     "bin_debug" => 'd',
269     "bin_debug_local" => 'l_d',
270     "bin_Insure" => 'Insure'
271     };
272     #
273     foreach $target ( keys %$targettypes ) {
274     print binGNUmakefile <<ENDTEXT;
275    
276     # Type $target specifics
277     ifdef MAKETARGET_$target
278     MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
279     endif
280     $target ::$$hashref{name}_$$targettypes{$target}
281    
282     bintargets+=$$hashref{name}_$$targettypes{$target}
283 williamc 1.21.2.24 help::
284     \t\@echo $$hashref{name}_$$targettypes{$target}
285 williamc 1.21.2.21 clean::
286     \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
287     \techo Removing \$(binarystore)/$$hashref{name}; \\
288     \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
289     \tfi
290    
291     ENDTEXT
292     ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
293     ${"objectname_$$targettypes{$target}"}=$objectname;
294     print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
295     } # end loop
296    
297 williamc 1.21.2.33 print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n";
298 williamc 1.21.2.21 print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
299     print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
300 williamc 1.21.2.36 print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
301 williamc 1.21.2.21 print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
302     print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
303 williamc 1.21.2.36 print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
304 williamc 1.21.2.21 print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
305     print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
306 williamc 1.21.2.36 print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
307 williamc 1.21.2.21 print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
308     print binGNUmakefile "\t\$(CClinkCmd)\n";
309 williamc 1.21.2.36 print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
310 williamc 1.21.2.21 print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
311     print binGNUmakefile "-include $$hashref{name}.dep\n";
312     print binGNUmakefile <<ENDTEXT;
313     clean::
314     \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
315     \techo Removing \$(binarystore)/$$hashref{name}; \\
316     \trm \$(binarystore)/$$hashref{name}; \\
317     \tfi
318    
319 williamc 1.19 $$hashref{name}_d.exe:\$(libslocal_d)
320 williamc 1.21.2.20 $$hashref{name}_o.exe:\$(libslocal)
321 williamc 1.21.2.4 ifdef MCCABE_DATA_DIR
322 williamc 1.21.2.21 $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
323 williamc 1.21.2.4 endif
324 williamc 1.19 $$hashref{name}_Insure.exe:\$(libslocal_I)
325 williamc 1.17 $$hashref{name}_d:$$hashref{name}_d.exe
326 williamc 1.21.2.7 \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
327 williamc 1.21.2.19 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
328     \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
329 williamc 1.17 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
330 williamc 1.21.2.7 \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
331 williamc 1.20 $$hashref{name}:$$hashref{name}_d.exe
332     \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
333 williamc 1.21.2.20 $$hashref{name}_o:$$hashref{name}_o.exe
334     \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
335 williamc 1.21.2.4 binfiles+=$$hashref{file}
336 williamc 1.17 ENDTEXT
337 williamc 1.21.2.12 }
338 williamc 1.21.2.22 close binGNUmakefile;
339 williamc 1.21.2.12 }
340    
341     sub Ext_start_export {
342     my $name=shift;
343     my @vars=@_;
344     my $hashref;
345    
346     $hashref=$switch->SetupValueHash(\@vars);
347     if ( $Arch ) {
348     if ( $switchex->context('export') ) {
349     $$hashref{'ref'}=~tr[A-Z][a-z];
350     print GNUmakefile $$hashref{'ref'};
351     if ( defined $$hashref{'version'} ) {
352     print GNUmakefile "_V_".$$hashref{'version'};
353     }
354     print GNUmakefile "=true\n";
355     }
356 williamc 1.21.2.1 }
357 williamc 1.1 }
358    
359     sub External_StartTag {
360     my $name=shift;
361     my @vars=@_;
362     my $hashref;
363    
364     $hashref=$switch->SetupValueHash(\@vars);
365 williamc 1.21 if ( $Arch ) {
366 williamc 1.6 $$hashref{'ref'}=~tr[A-Z][a-z];
367 williamc 1.1 print GNUmakefile $$hashref{'ref'};
368     if ( defined $$hashref{'version'} ) {
369     print GNUmakefile "_V_".$$hashref{'version'};
370     }
371     print GNUmakefile "=true\n";
372 williamc 1.21 }
373 williamc 1.1
374     }
375    
376     sub Group_start {
377     my $name=shift;
378     my @vars=@_;
379     my $hashref;
380    
381     $hashref=$switch->SetupValueHash(\@vars);
382     $switch->checkparam($hashref, $name, 'name');
383 williamc 1.21.2.1 if ( $Arch ) {
384 williamc 1.1 print GNUmakefile "GROUP_".$$hashref{'name'};
385     if ( defined $$hashref{'version'} ) {
386     print GNUmakefile "_V_".$$hashref{'version'};
387     }
388     print GNUmakefile "=true\n";
389 williamc 1.21.2.1 }
390 williamc 1.1 }
391    
392     sub External {
393     my $name=shift;
394     my @vars=@_;
395     # Will simply collect string into a seperate buffer for processind
396     # at the tag closure - used for specifying product defaults
397     # --- Oh oh all of string already in external buffer @!
398     }
399    
400     sub External_EndTag {
401     my $name=shift;
402     my @vars=@_;
403    
404     # process buffer and check consistency with product dtd
405     }
406    
407     sub Use_start {
408     my $name=shift;
409     my @vars=@_;
410     my $hashref;
411     my $filename;
412 williamc 1.2 use Utilities::SCRAMUtils;
413 williamc 1.1
414     $hashref=$switch->SetupValueHash(\@vars);
415     $switch->checkparam($hashref, $name, "name");
416 williamc 1.21.2.1 if ( $Arch ) {
417 williamc 1.21 $filename=SCRAMUtils::checkfile(
418     "$ENV{INTsrc}/$$hashref{name}/BuildFile");
419     if ( $filename ne "" ) {
420     ParseBuildFile_Export( $filename );
421 williamc 1.1 }
422 williamc 1.21.2.1 }
423 williamc 1.1 }
424    
425 williamc 1.5 sub CheckBuildFile {
426 williamc 1.1 my $classdir=shift;
427     $ClassName="";
428     $thisfile="$classdir/$buildfile";
429    
430     if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
431     $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
432     ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
433     }
434     elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
435     $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
436     ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
437     }
438     return $ClassName;
439     }
440    
441     # List association groups between <AssociateGroup> tags
442     # seperated by newlines or spaces
443     sub AssociateGroup {
444     my $name=shift;
445     my @vars=@_;
446     my $word;
447    
448     foreach $word ( @vars ){
449     chomp $word;
450     next if /^#/;
451     push @groups, $word;
452     }
453 williamc 1.21.2.1 }
454    
455     sub ignoretag {
456     my $name=shift;
457     my @vars=@_;
458    
459     $Arch=0;
460     push @ARCHBLOCK, $Arch;
461     }
462    
463     sub ignoretag_end {
464     my $name=shift;
465     my @vars=@_;
466    
467     pop @ARCHBLOCK;
468     $Arch=$ARCHBLOCK[$#ARCHBLOCK];
469     }
470    
471     sub Arch_Start {
472     my $name=shift;
473     my @vars=@_;
474     my $hashref;
475    
476     $hashref=$toolswitch->SetupValueHash( \@vars );
477     $toolswitch->checkparam($hashref, $name, 'name');
478     #( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0;
479     ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0);
480     push @ARCHBLOCK, $Arch;
481     }
482     sub Arch_End {
483     my $name=shift;
484     my @vars=@_;
485    
486     pop @ARCHBLOCK;
487     $Arch=$ARCHBLOCK[$#ARCHBLOCK];
488 williamc 1.1 }
489    
490     # Split up the Class Block String into a useable array
491 williamc 1.5 sub _CutBlock {
492 williamc 1.1 my $string= shift @_;
493     @BlockClassA = split /\//, $string;
494     }
495    
496     sub OutToMakefile {
497     my $name=shift;
498     my @vars=@_;
499    
500 williamc 1.21.2.15 if ( $Arch ) {
501     print GNUmakefile @vars;
502     }
503 williamc 1.21.2.14 }
504     sub OutToScreen {
505     my $name=shift;
506     my @vars=@_;
507    
508 williamc 1.21.2.15 if ( $Arch ) {
509     print @vars;
510     }
511 williamc 1.1 }
512     sub setBlockClassPath {
513     my $name=shift;
514     my @vars=@_;
515     my $hashref;
516    
517     $hashref=$switch->SetupValueHash(\@vars);
518     $switch->checkparam($hashref, $name, 'path');
519     $BlockClassPath=$BlockClassPath.":".$$hashref{path};
520     _CutBlock($$hashref{path});
521 williamc 1.21 }
522    
523 williamc 1.21.2.30 sub use_export_start {
524 williamc 1.21 #Set up a toolfile object
525     $exporttool=Tool->new();
526 williamc 1.21.2.30 }
527    
528     sub use_export_end {
529     #Write toolfile object to disk
530     $exporttool->envtomake(\*GNUmakefile);
531     }
532    
533     sub export_start {
534 williamc 1.21.2.31 my $name=shift;
535     my @vars=@_;
536     my $hashref;
537    
538     $hashref=$switch->SetupValueHash(\@vars);
539     if ( exists $$hashref{autoexport} ) {
540     print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n";
541     }
542 williamc 1.21.2.30 #Set up a toolfile object
543 williamc 1.21.2.28 print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
544 williamc 1.21 }
545    
546     sub export_end {
547     #Write toolfile object to disk
548 williamc 1.21.2.29 print GNUmakefile "endif\n";
549 williamc 1.21 }
550    
551     #
552 williamc 1.21.2.34 # Export Mode Lib Tag --- NO LONGER IN USE
553 williamc 1.21 #
554     sub lib_start_export {
555     my $name=shift;
556     my @vars=@_;
557     my $hashref;
558    
559     $hashref=$switchex->SetupValueHash( \@vars );
560     $switchex->checkparam($hashref, $name, 'name');
561     if ( $Arch ) {
562     if ( $switchex->context('export') ) {
563     #If export mode then add this env to the export tool
564     $exporttool->addenv('lib',$$hashref{name});
565     }
566     }
567     }
568    
569     #
570     # Standard lib tag
571     #
572     sub lib_start {
573     my $name=shift;
574     my @vars=@_;
575     my $hashref;
576    
577     $hashref=$switch->SetupValueHash( \@vars );
578     $switch->checkparam($hashref, $name, 'name');
579     if ( $Arch ) {
580     print GNUmakefile "lib+=$$hashref{name}\n";
581     }
582 williamc 1.21.2.6 }
583    
584     #
585     # libtype specification
586     #
587     sub LibType_Start {
588     my $name=shift;
589     my @vars=@_;
590     my $hashref;
591    
592 williamc 1.21.2.8 if ( $Arch ) {
593 williamc 1.21.2.6 $hashref=$switch->SetupValueHash( \@vars );
594     $switch->checkparam($hashref, $name, 'type');
595    
596     print GNUmakefile "# Specify Library Type\n";
597     print GNUmakefile "DefaultLibsOff=yes\n";
598     if ( $$hashref{'type'}=~/^archive/i ) {
599     print GNUmakefile "LibArchive=true\n";
600     }
601 williamc 1.21.2.11 elsif ($$hashref{'type'}=~/debug_archive/i ) {
602 williamc 1.21.2.6 print GNUmakefile "LibDebugArchive=true\n";
603     }
604 williamc 1.21.2.11 elsif ($$hashref{'type'}=~/debug_shared/i ) {
605     print GNUmakefile "LibDebugShared=true\n";
606     }
607 williamc 1.21.2.6 elsif ($$hashref{'type'}=~/shared/i ) {
608     print GNUmakefile 'LibShared=true'."\n";
609     }
610     print GNUmakefile "\n";
611 williamc 1.21.2.8 }
612 williamc 1.1 }
613 williamc 1.21.2.15 sub LibType_text {
614     my $name=shift;
615     my @vars=@_;
616    
617     if ( $Arch ) {
618 williamc 1.21.2.16 print GNUmakefile "libmsg::\n\t\@echo Library info: ";
619 williamc 1.21.2.15 print GNUmakefile @vars;
620     print GNUmakefile "\n";
621     }
622     }
623    
624 williamc 1.21.2.21 sub Environment_start {
625     my $name=shift;
626     my @vars=@_;
627     my $hashref;
628    
629     if ( $Arch ) {
630     $envnum++;
631 williamc 1.21.2.22
632     # open a new Environment File
633     my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk";
634 williamc 1.21.2.21 use FileHandle;
635     my $fh=FileHandle->new();
636 williamc 1.21.2.22 open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
637 williamc 1.21.2.21 push @filehandlestack, $fh;
638 williamc 1.21.2.22 *GNUmakefile=$fh;
639 williamc 1.21.2.21
640     # include the approprate environment file
641     if ( $envlevel == 0 ) {
642     print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
643 williamc 1.21.2.22 "BuildFile.mk\n";
644 williamc 1.21.2.21 }
645     else {
646     print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
647 williamc 1.21.2.22 "Env_$Envlevels[$envlevel]\.mk\n";
648 williamc 1.21.2.21 }
649     $envlevel++;
650     $Envlevels[$envlevel]=$envnum;
651     $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk";
652     }
653     }
654    
655     sub Environment_end {
656     my $fd;
657    
658     if ( $Arch ) {
659     $envlevel--;
660     if ( $envlevel < 0 ) {
661     print "Too many </Environent> Tags on $switch->line()\n";
662     exit;
663     }
664     close GNUmakefile;
665     # restore the last filehandle
666     $fd=pop @filehandlestack;
667     close $fd;
668 williamc 1.21.2.22 *GNUmakefile=$filehandlestack[$#filehandlestack];
669 williamc 1.21.2.21 if ( $envlevel < 1 ) {
670     $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
671     }
672     else {
673     $currentenv=
674     "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$Envlevels[$envlevel]";
675     }
676     }
677     }