ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
(Generate patch)

Comparing COMP/SCRAM/src/BuildFile.pm (file contents):
Revision 1.21.2.2 by williamc, Tue May 11 09:02:58 1999 UTC vs.
Revision 1.21.2.21 by williamc, Tue Oct 12 16:47:13 1999 UTC

# Line 15 | Line 15 | push @ARCHBLOCK, $Arch;
15   #Parse the BuildFile
16   sub ParseBuildFile {
17          my $base=shift;
18 <        my $path=shift;
18 >        $path=shift;
19          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 +        $numbins=0;
24 +        $envnum=0;
25 +        $envlevel=0;
26 +        $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
27          my $SupportedTags={
28                  'Use' => \&OutToMakefile,
29                  'Use_StartTag' => \&Use_start,
# Line 35 | Line 39 | sub ParseBuildFile {
39                  'Bin_StartTag' => \&Bin_start,
40                  'ClassPath' => \&OutToMakefile,
41                  'ClassPath_StartTag' => \&setBlockClassPath,
42 +                'Environment' => \&OutToMakefile,
43 +                'Environment_StartTag' => \&Environment_start,
44 +                'Environment_EndTag' => \&Environment_end,
45                  'lib' => 'none',
46                  'lib_StartTag' => \&lib_start,
47                  'lib_EndTag' => 'none',
# Line 43 | Line 50 | sub ParseBuildFile {
50                  'ignore_StartTag' => \&ignoretag,
51                  'Architecture_StartTag' => \&Arch_Start,
52                  'Architecture_EndTag' => \&Arch_End,
53 <                'Architecture' => \&OutToMakefile
53 >                'Architecture' => \&OutToMakefile,
54 >                'LibType_StartTag' => \&LibType_Start,
55 >                'LibType_EndTag' => 'none',
56 >                #'LibType' => \&OutToScreen
57 >                'LibType' => \&LibType_text
58          };
59          use Utilities::Switcher;
60          $switch=Switcher->new($SupportedTags, $fullfilename);
# Line 72 | Line 83 | sub ParseBuildFile_Export {
83                  'export_StartTag' => \&export_start,
84                  'export_EndTag' => \&export_end,
85                  'lib_StartTag' => \&lib_start_export,
86 +                'External_StartTag' => \&Ext_start_export,
87                  'lib' => 'none'
88          };
89          use Utilities::Switcher;
# Line 147 | Line 159 | sub Bin_start {
159          # This stuff for later
160          #$fileclass=$toolbox->getclass($file);
161          #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
162 +
163          ($filename=$$hashref{file})=~s/\..*//;
164 <        ($objectname=$$hashref{file})=~s/\..*/\.o/;
165 <        ($objectname_d=$$hashref{file})=~s/\..*/_d\.o/;
166 <        ($objectname_Insure=$$hashref{file})=~s/\..*/_Insure\.o/;
167 <        print GNUmakefile "bin:$$hashref{name}\n";
168 <        print GNUmakefile "bin_debug:$$hashref{name}_d\n";
169 <        print GNUmakefile "bin_insure:$$hashref{name}_Insure\n";
170 <        print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n";
171 <        print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n";
172 <        print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n";
173 <        print GNUmakefile "$$hashref{name}_Insure:.psrc\n";
174 <        print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
175 <        print GNUmakefile "\t\$(CClinkCmdDebug)\n";
176 <        print GNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
177 <        print GNUmakefile "\t\$(CClinkCmdInsure)\n";
178 <        print GNUmakefile "$$hashref{name}.exe:$objectname\n";
179 <        print GNUmakefile "\t\$(CClinkCmd)\n";
180 <        print GNUmakefile "$objectname:$$hashref{name}.dep\n";
181 <        print GNUmakefile "$objectname_d:$$hashref{name}.dep\n";
182 <        print GNUmakefile "$objectname_Insure:$$hashref{name}.dep\n";
183 <        print GNUmakefile "$ENV{LOCALTOP}/\$(workdir)/$$hashref{name}.dep: $(clientmakefile) $$hashref{file}\n";
184 <        print GNUmakefile "-include $ENV{LOCALTOP}/\$(workdir)/$$hashref{name}.dep\n";
185 < #       print GNUmakefile "$$hashref{name}:$$hashref{file}\n";
186 < print GNUmakefile <<ENDTEXT;
164 >
165 >        # Create a new directory for each binary target
166 >        my $dirname="bin_".$$hashref{name};
167 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname");
168 >        open (binGNUmakefile,
169 >           ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/".
170 >           "BuildFile.mk $!\n";
171 >
172 >        # Create the link targets
173 >        $numbins++;
174 >        print GNUmakefile <<ENDTEXT;
175 > ifndef BINMADE
176 > bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
177 > #\t\@echo - Invoking binary makefile \$\@
178 > \t\@if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\
179 > \tchdir $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\
180 > \t\$(MAKE) BINMADE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk \$\@; \\
181 > \tfi
182 > endif
183 >
184 > ENDTEXT
185 >
186 >
187 > # the binary specifics makefile
188 > #       print binGNUmakefile "include $ENV{LatestBuildFile}\n";
189 >        print binGNUmakefile "include $currentenv\n";
190 > #       print binGNUmakefile "include \$(TOOL_HOME)/basics.mk\n";
191 >        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/${path}\n";
192 > # alias for bin_Insure
193 >        print binGNUmakefile <<ENDTEXT;
194 > bin_insure:bin_Insure
195 > ifdef MAKETARGET_bin_insure
196 > MAKETARGET_$$hashref{name}_Insure=1
197 > endif
198 > ENDTEXT
199 >
200 > # Make generic rules for each type
201 >        $targettypes={
202 >                "bin" => 'o',
203 >                "bin_debug" => 'd',
204 >                "bin_debug_local" => 'l_d',
205 >                "bin_Insure" => 'Insure'
206 >        };
207 >        #
208 >        foreach $target ( keys %$targettypes ) {
209 >          print binGNUmakefile <<ENDTEXT;
210 >
211 > # Type $target specifics
212 > ifdef MAKETARGET_$target
213 > MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
214 > endif
215 > $target ::$$hashref{name}_$$targettypes{$target}
216 >
217 > bintargets+=$$hashref{name}_$$targettypes{$target}
218 > clean::
219 > \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
220 > \techo Removing \$(binarystore)/$$hashref{name}; \\
221 > \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
222 > \tfi
223 >
224 > ENDTEXT
225 >          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
226 >          ${"objectname_$$targettypes{$target}"}=$objectname;
227 >          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
228 >        } # end loop
229 >
230 >        print binGNUmakefile "$$hashref{name}_Insure:.psrc\n";
231 >        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
232 >        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
233 >        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
234 >        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
235 >        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
236 >        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
237 >        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
238 >        print binGNUmakefile "\t\$(CClinkCmd)\n";
239 >        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
240 >        print binGNUmakefile "-include $$hashref{name}.dep\n";
241 > print binGNUmakefile <<ENDTEXT;
242 > clean::
243 > \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
244 > \techo Removing \$(binarystore)/$$hashref{name}; \\
245 > \trm \$(binarystore)/$$hashref{name}; \\
246 > \tfi
247 >
248   $$hashref{name}_d.exe:\$(libslocal_d)
249 < $$hashref{name}.exe:\$(libslocal)
249 > $$hashref{name}_o.exe:\$(libslocal)
250 > ifdef MCCABE_DATA_DIR
251 > $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
252 > endif
253   $$hashref{name}_Insure.exe:\$(libslocal_I)
254   $$hashref{name}_d:$$hashref{name}_d.exe
255 <        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
255 >        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
256 > $$hashref{name}_l_d:$$hashref{name}_l_d.exe
257 >        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
258   $$hashref{name}_Insure:$$hashref{name}_Insure.exe
259 <        \@mv $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
259 >        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
260   $$hashref{name}:$$hashref{name}_d.exe
261          \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
262   $$hashref{name}_o:$$hashref{name}_o.exe
263 <        \@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name}
264 < binfiles+=$filename
186 < bintargets+=$$hashref{name} $$hashref{name}_d $$hashref{name}_Insure
263 >        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
264 > binfiles+=$$hashref{file}
265   ENDTEXT
266          }
267   }
268  
269 + sub Ext_start_export {
270 +        my $name=shift;
271 +        my @vars=@_;
272 +        my $hashref;
273 +        
274 +        $hashref=$switch->SetupValueHash(\@vars);
275 +        if ( $Arch ) {
276 +         if ( $switchex->context('export') ) {
277 +          $$hashref{'ref'}=~tr[A-Z][a-z];
278 +          print GNUmakefile $$hashref{'ref'};
279 +          if ( defined $$hashref{'version'} ) {
280 +                print GNUmakefile "_V_".$$hashref{'version'};
281 +          }
282 +          print GNUmakefile "=true\n";
283 +         }
284 +        }
285 + }
286 +
287   sub External_StartTag {
288          my $name=shift;
289          my @vars=@_;
# Line 329 | Line 425 | sub OutToMakefile {
425          my $name=shift;
426          my @vars=@_;
427  
428 <        print GNUmakefile @vars;
428 >        if ( $Arch ) {
429 >          print GNUmakefile @vars;
430 >        }
431 > }
432 > sub OutToScreen {
433 >        my $name=shift;
434 >        my @vars=@_;
435 >
436 >        if ( $Arch ) {
437 >          print @vars;
438 >        }
439   }
440   sub setBlockClassPath {
441          my $name=shift;
# Line 384 | Line 490 | sub lib_start {
490             print GNUmakefile "lib+=$$hashref{name}\n";
491          }
492   }
493 +
494 + #
495 + # libtype specification
496 + #
497 + sub LibType_Start {
498 +        my $name=shift;
499 +        my @vars=@_;
500 +        my $hashref;
501 +
502 +        if ( $Arch ) {
503 +        $hashref=$switch->SetupValueHash( \@vars );
504 +        $switch->checkparam($hashref, $name, 'type');
505 +        
506 +        print GNUmakefile "# Specify Library Type\n";
507 +        print GNUmakefile "DefaultLibsOff=yes\n";
508 +        if ( $$hashref{'type'}=~/^archive/i ) {
509 +          print GNUmakefile "LibArchive=true\n";
510 +        }
511 +        elsif ($$hashref{'type'}=~/debug_archive/i ) {
512 +          print GNUmakefile "LibDebugArchive=true\n";
513 +        }
514 +        elsif ($$hashref{'type'}=~/debug_shared/i ) {
515 +          print GNUmakefile "LibDebugShared=true\n";
516 +        }
517 +        elsif ($$hashref{'type'}=~/shared/i ) {
518 +          print GNUmakefile 'LibShared=true'."\n";
519 +        }
520 +        print GNUmakefile "\n";
521 +        }
522 + }
523 + sub LibType_text {
524 +        my $name=shift;
525 +        my @vars=@_;
526 +
527 +        if ( $Arch ) {
528 +          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
529 +          print GNUmakefile @vars;
530 +          print GNUmakefile "\n";
531 +        }
532 + }
533 +
534 + sub Environment_start {
535 +        my $name=shift;
536 +        my @vars=@_;
537 +        my $hashref;
538 +
539 +        if ( $Arch ) {
540 +          $envnum++;
541 +          # copy the current GNUmakefile Filehandle
542 +          use FileHandle;
543 +          my $fh=FileHandle->new();
544 +          open ($fh,">&GNUmakefile");
545 +          push @filehandlestack, $fh;
546 +
547 +          # open up an environment file
548 +          open ( GNUmakefile,
549 +                "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk");
550 +          # include the approprate environment file
551 +          if ( $envlevel == 0 ) {
552 +             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
553 +                                "BuildFile.mk";
554 +          }
555 +          else {
556 +             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
557 +                                "Env_$Envlevels[$envlevel]";
558 +          }
559 +          $envlevel++;
560 +          $Envlevels[$envlevel]=$envnum;
561 +          $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk";
562 +        }
563 + }
564 +
565 + sub Environment_end {
566 +        my $fd;
567 +
568 +        if ( $Arch ) {
569 +          $envlevel--;
570 +          if ( $envlevel < 0 ) {
571 +            print "Too many </Environent> Tags on $switch->line()\n";
572 +            exit;
573 +          }
574 +          close GNUmakefile;
575 +          # restore the last filehandle
576 +          $fd=pop @filehandlestack;
577 +          open (GNUmakefile, ">&$fd" ) ;
578 +          close $fd;
579 +          if ( $envlevel < 1 ) {
580 +            $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
581 +          }
582 +          else {
583 +            $currentenv=
584 +             "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$Envlevels[$envlevel]";
585 +          }
586 +        }
587 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines