ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.21.2.30
Committed: Tue Oct 19 08:39:43 1999 UTC (25 years, 7 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
CVS Tags: V0_10_0
Changes since 1.21.2.29: +12 -4 lines
Log Message:
No if scram_autoexport when parsing through for Use

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 'lib' => 'none',
49     '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 'lib_StartTag' => \&lib_start_export,
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.23 ifndef BINMODE
206 williamc 1.21.2.22
207     define stepdown_$$hashref{'name'}
208     if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\
209     cd $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\
210 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 \$\@; \\
211 williamc 1.21.2.22 fi
212     endef
213    
214 williamc 1.21.2.23 define stepdown2_$$hashref{'name'}
215     if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\
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 williamc 1.21.2.24
220 williamc 1.21.2.23 endef
221    
222     bin_$$hashref{'name'}_%:: dummy
223     \@\$(stepdown2_$$hashref{'name'})
224 williamc 1.21.2.22
225 williamc 1.21.2.26 $$hashref{'name'}_%:: dummy
226     \@\$(stepdown_$$hashref{'name'})
227    
228 williamc 1.21.2.24 help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
229 williamc 1.21.2.22 \@\$(stepdown_$$hashref{'name'})
230 williamc 1.21.2.27
231     binfiles+=$$hashref{'file'}
232 williamc 1.21.2.21 endif
233 williamc 1.21.2.27
234 williamc 1.21.2.21
235     ENDTEXT
236    
237    
238     # the binary specifics makefile
239     print binGNUmakefile "include $currentenv\n";
240     print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/${path}\n";
241 williamc 1.21.2.22
242 williamc 1.21.2.21 # alias for bin_Insure
243     print binGNUmakefile <<ENDTEXT;
244 williamc 1.21.2.22
245 williamc 1.21.2.21 bin_insure:bin_Insure
246     ifdef MAKETARGET_bin_insure
247     MAKETARGET_$$hashref{name}_Insure=1
248     endif
249 williamc 1.21.2.22
250     # debuggging target
251     $$hashref{'name'}_echo_% :: echo_%
252    
253 williamc 1.21.2.25 # help targets
254     help::
255     \t\@echo Targets For $$hashref{'name'}
256     \t\@echo -------------------------------------
257     \t\@echo $$hashref{'name'} - default build
258     \t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning
259 williamc 1.21.2.21 ENDTEXT
260    
261     # Make generic rules for each type
262     $targettypes={
263     "bin" => 'o',
264     "bin_debug" => 'd',
265     "bin_debug_local" => 'l_d',
266     "bin_Insure" => 'Insure'
267     };
268     #
269     foreach $target ( keys %$targettypes ) {
270     print binGNUmakefile <<ENDTEXT;
271    
272     # Type $target specifics
273     ifdef MAKETARGET_$target
274     MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
275     endif
276     $target ::$$hashref{name}_$$targettypes{$target}
277    
278     bintargets+=$$hashref{name}_$$targettypes{$target}
279 williamc 1.21.2.24 help::
280     \t\@echo $$hashref{name}_$$targettypes{$target}
281 williamc 1.21.2.21 clean::
282     \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
283     \techo Removing \$(binarystore)/$$hashref{name}; \\
284     \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
285     \tfi
286    
287     ENDTEXT
288     ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
289     ${"objectname_$$targettypes{$target}"}=$objectname;
290     print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
291     } # end loop
292    
293     print binGNUmakefile "$$hashref{name}_Insure:.psrc\n";
294     print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
295     print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
296     print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
297     print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
298     print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
299     print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
300     print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
301     print binGNUmakefile "\t\$(CClinkCmd)\n";
302     print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
303     print binGNUmakefile "-include $$hashref{name}.dep\n";
304     print binGNUmakefile <<ENDTEXT;
305     clean::
306     \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
307     \techo Removing \$(binarystore)/$$hashref{name}; \\
308     \trm \$(binarystore)/$$hashref{name}; \\
309     \tfi
310    
311 williamc 1.19 $$hashref{name}_d.exe:\$(libslocal_d)
312 williamc 1.21.2.20 $$hashref{name}_o.exe:\$(libslocal)
313 williamc 1.21.2.4 ifdef MCCABE_DATA_DIR
314 williamc 1.21.2.21 $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
315 williamc 1.21.2.4 endif
316 williamc 1.19 $$hashref{name}_Insure.exe:\$(libslocal_I)
317 williamc 1.17 $$hashref{name}_d:$$hashref{name}_d.exe
318 williamc 1.21.2.7 \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
319 williamc 1.21.2.19 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
320     \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
321 williamc 1.17 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
322 williamc 1.21.2.7 \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
323 williamc 1.20 $$hashref{name}:$$hashref{name}_d.exe
324     \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
325 williamc 1.21.2.20 $$hashref{name}_o:$$hashref{name}_o.exe
326     \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
327 williamc 1.21.2.4 binfiles+=$$hashref{file}
328 williamc 1.17 ENDTEXT
329 williamc 1.21.2.12 }
330 williamc 1.21.2.22 close binGNUmakefile;
331 williamc 1.21.2.12 }
332    
333     sub Ext_start_export {
334     my $name=shift;
335     my @vars=@_;
336     my $hashref;
337    
338     $hashref=$switch->SetupValueHash(\@vars);
339     if ( $Arch ) {
340     if ( $switchex->context('export') ) {
341     $$hashref{'ref'}=~tr[A-Z][a-z];
342     print GNUmakefile $$hashref{'ref'};
343     if ( defined $$hashref{'version'} ) {
344     print GNUmakefile "_V_".$$hashref{'version'};
345     }
346     print GNUmakefile "=true\n";
347     }
348 williamc 1.21.2.1 }
349 williamc 1.1 }
350    
351     sub External_StartTag {
352     my $name=shift;
353     my @vars=@_;
354     my $hashref;
355    
356     $hashref=$switch->SetupValueHash(\@vars);
357 williamc 1.21 if ( $Arch ) {
358 williamc 1.6 $$hashref{'ref'}=~tr[A-Z][a-z];
359 williamc 1.1 print GNUmakefile $$hashref{'ref'};
360     if ( defined $$hashref{'version'} ) {
361     print GNUmakefile "_V_".$$hashref{'version'};
362     }
363     print GNUmakefile "=true\n";
364 williamc 1.21 }
365 williamc 1.1
366     }
367    
368     sub Group_start {
369     my $name=shift;
370     my @vars=@_;
371     my $hashref;
372    
373     $hashref=$switch->SetupValueHash(\@vars);
374     $switch->checkparam($hashref, $name, 'name');
375 williamc 1.21.2.1 if ( $Arch ) {
376 williamc 1.1 print GNUmakefile "GROUP_".$$hashref{'name'};
377     if ( defined $$hashref{'version'} ) {
378     print GNUmakefile "_V_".$$hashref{'version'};
379     }
380     print GNUmakefile "=true\n";
381 williamc 1.21.2.1 }
382 williamc 1.1 }
383    
384     sub External {
385     my $name=shift;
386     my @vars=@_;
387     # Will simply collect string into a seperate buffer for processind
388     # at the tag closure - used for specifying product defaults
389     # --- Oh oh all of string already in external buffer @!
390     }
391    
392     sub External_EndTag {
393     my $name=shift;
394     my @vars=@_;
395    
396     # process buffer and check consistency with product dtd
397     }
398    
399     sub Use_start {
400     my $name=shift;
401     my @vars=@_;
402     my $hashref;
403     my $filename;
404 williamc 1.2 use Utilities::SCRAMUtils;
405 williamc 1.1
406     $hashref=$switch->SetupValueHash(\@vars);
407     $switch->checkparam($hashref, $name, "name");
408 williamc 1.21.2.1 if ( $Arch ) {
409 williamc 1.21 $filename=SCRAMUtils::checkfile(
410     "$ENV{INTsrc}/$$hashref{name}/BuildFile");
411     if ( $filename ne "" ) {
412     ParseBuildFile_Export( $filename );
413 williamc 1.1 }
414 williamc 1.21.2.1 }
415 williamc 1.1 }
416    
417 williamc 1.5 sub CheckBuildFile {
418 williamc 1.1 my $classdir=shift;
419     $ClassName="";
420     $thisfile="$classdir/$buildfile";
421    
422     if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
423     $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
424     ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
425     }
426     elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
427     $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
428     ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
429     }
430     return $ClassName;
431     }
432    
433     # List association groups between <AssociateGroup> tags
434     # seperated by newlines or spaces
435     sub AssociateGroup {
436     my $name=shift;
437     my @vars=@_;
438     my $word;
439    
440     foreach $word ( @vars ){
441     chomp $word;
442     next if /^#/;
443     push @groups, $word;
444     }
445 williamc 1.21.2.1 }
446    
447     sub ignoretag {
448     my $name=shift;
449     my @vars=@_;
450    
451     $Arch=0;
452     push @ARCHBLOCK, $Arch;
453     }
454    
455     sub ignoretag_end {
456     my $name=shift;
457     my @vars=@_;
458    
459     pop @ARCHBLOCK;
460     $Arch=$ARCHBLOCK[$#ARCHBLOCK];
461     }
462    
463     sub Arch_Start {
464     my $name=shift;
465     my @vars=@_;
466     my $hashref;
467    
468     $hashref=$toolswitch->SetupValueHash( \@vars );
469     $toolswitch->checkparam($hashref, $name, 'name');
470     #( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0;
471     ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0);
472     push @ARCHBLOCK, $Arch;
473     }
474     sub Arch_End {
475     my $name=shift;
476     my @vars=@_;
477    
478     pop @ARCHBLOCK;
479     $Arch=$ARCHBLOCK[$#ARCHBLOCK];
480 williamc 1.1 }
481    
482     # Split up the Class Block String into a useable array
483 williamc 1.5 sub _CutBlock {
484 williamc 1.1 my $string= shift @_;
485     @BlockClassA = split /\//, $string;
486     }
487    
488     sub OutToMakefile {
489     my $name=shift;
490     my @vars=@_;
491    
492 williamc 1.21.2.15 if ( $Arch ) {
493     print GNUmakefile @vars;
494     }
495 williamc 1.21.2.14 }
496     sub OutToScreen {
497     my $name=shift;
498     my @vars=@_;
499    
500 williamc 1.21.2.15 if ( $Arch ) {
501     print @vars;
502     }
503 williamc 1.1 }
504     sub setBlockClassPath {
505     my $name=shift;
506     my @vars=@_;
507     my $hashref;
508    
509     $hashref=$switch->SetupValueHash(\@vars);
510     $switch->checkparam($hashref, $name, 'path');
511     $BlockClassPath=$BlockClassPath.":".$$hashref{path};
512     _CutBlock($$hashref{path});
513 williamc 1.21 }
514    
515 williamc 1.21.2.30 sub use_export_start {
516 williamc 1.21 #Set up a toolfile object
517     $exporttool=Tool->new();
518 williamc 1.21.2.30 }
519    
520     sub use_export_end {
521     #Write toolfile object to disk
522     $exporttool->envtomake(\*GNUmakefile);
523     }
524    
525     sub export_start {
526     #Set up a toolfile object
527 williamc 1.21.2.28 print GNUmakefile "ifeq (\$(scram_autoexport),true)\n";
528 williamc 1.21 }
529    
530     sub export_end {
531     #Write toolfile object to disk
532 williamc 1.21.2.29 print GNUmakefile "endif\n";
533 williamc 1.21 }
534    
535     #
536     # Export Mode Lib Tag
537     #
538     sub lib_start_export {
539     my $name=shift;
540     my @vars=@_;
541     my $hashref;
542    
543     $hashref=$switchex->SetupValueHash( \@vars );
544     $switchex->checkparam($hashref, $name, 'name');
545     if ( $Arch ) {
546     if ( $switchex->context('export') ) {
547     #If export mode then add this env to the export tool
548     $exporttool->addenv('lib',$$hashref{name});
549     }
550     }
551     }
552    
553     #
554     # Standard lib tag
555     #
556     sub lib_start {
557     my $name=shift;
558     my @vars=@_;
559     my $hashref;
560    
561     $hashref=$switch->SetupValueHash( \@vars );
562     $switch->checkparam($hashref, $name, 'name');
563     if ( $Arch ) {
564     print GNUmakefile "lib+=$$hashref{name}\n";
565     }
566 williamc 1.21.2.6 }
567    
568     #
569     # libtype specification
570     #
571     sub LibType_Start {
572     my $name=shift;
573     my @vars=@_;
574     my $hashref;
575    
576 williamc 1.21.2.8 if ( $Arch ) {
577 williamc 1.21.2.6 $hashref=$switch->SetupValueHash( \@vars );
578     $switch->checkparam($hashref, $name, 'type');
579    
580     print GNUmakefile "# Specify Library Type\n";
581     print GNUmakefile "DefaultLibsOff=yes\n";
582     if ( $$hashref{'type'}=~/^archive/i ) {
583     print GNUmakefile "LibArchive=true\n";
584     }
585 williamc 1.21.2.11 elsif ($$hashref{'type'}=~/debug_archive/i ) {
586 williamc 1.21.2.6 print GNUmakefile "LibDebugArchive=true\n";
587     }
588 williamc 1.21.2.11 elsif ($$hashref{'type'}=~/debug_shared/i ) {
589     print GNUmakefile "LibDebugShared=true\n";
590     }
591 williamc 1.21.2.6 elsif ($$hashref{'type'}=~/shared/i ) {
592     print GNUmakefile 'LibShared=true'."\n";
593     }
594     print GNUmakefile "\n";
595 williamc 1.21.2.8 }
596 williamc 1.1 }
597 williamc 1.21.2.15 sub LibType_text {
598     my $name=shift;
599     my @vars=@_;
600    
601     if ( $Arch ) {
602 williamc 1.21.2.16 print GNUmakefile "libmsg::\n\t\@echo Library info: ";
603 williamc 1.21.2.15 print GNUmakefile @vars;
604     print GNUmakefile "\n";
605     }
606     }
607    
608 williamc 1.21.2.21 sub Environment_start {
609     my $name=shift;
610     my @vars=@_;
611     my $hashref;
612    
613     if ( $Arch ) {
614     $envnum++;
615 williamc 1.21.2.22
616     # open a new Environment File
617     my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk";
618 williamc 1.21.2.21 use FileHandle;
619     my $fh=FileHandle->new();
620 williamc 1.21.2.22 open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n";
621 williamc 1.21.2.21 push @filehandlestack, $fh;
622 williamc 1.21.2.22 *GNUmakefile=$fh;
623 williamc 1.21.2.21
624     # include the approprate environment file
625     if ( $envlevel == 0 ) {
626     print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
627 williamc 1.21.2.22 "BuildFile.mk\n";
628 williamc 1.21.2.21 }
629     else {
630     print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
631 williamc 1.21.2.22 "Env_$Envlevels[$envlevel]\.mk\n";
632 williamc 1.21.2.21 }
633     $envlevel++;
634     $Envlevels[$envlevel]=$envnum;
635     $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk";
636     }
637     }
638    
639     sub Environment_end {
640     my $fd;
641    
642     if ( $Arch ) {
643     $envlevel--;
644     if ( $envlevel < 0 ) {
645     print "Too many </Environent> Tags on $switch->line()\n";
646     exit;
647     }
648     close GNUmakefile;
649     # restore the last filehandle
650     $fd=pop @filehandlestack;
651     close $fd;
652 williamc 1.21.2.22 *GNUmakefile=$filehandlestack[$#filehandlestack];
653 williamc 1.21.2.21 if ( $envlevel < 1 ) {
654     $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
655     }
656     else {
657     $currentenv=
658     "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$Envlevels[$envlevel]";
659     }
660     }
661     }