ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.21.2.24
Committed: Wed Oct 13 15:31:18 1999 UTC (25 years, 7 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
Changes since 1.21.2.23: +21 -1 lines
Log Message:
Update build help mechanism

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