ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.21.2.23
Committed: Wed Oct 13 14:12:07 1999 UTC (25 years, 7 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
Changes since 1.21.2.22: +13 -4 lines
Log Message:
Add bin_binaryname_xxx rule for invoking basic functions in the binary context

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