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

Comparing COMP/SCRAM/src/BuildSystem/BuildFile.pm (file contents):
Revision 1.16 by sashby, Fri Apr 12 16:42:08 2002 UTC vs.
Revision 1.24 by sashby, Wed Nov 6 17:31:04 2002 UTC

# Line 53 | Line 53 | sub _initswitcher {
53                                          \&Bin_start,$self,
54                                          \&OutToScreen, $self,
55                                          "", $self);
56 <         $switch->addtag($parse,"ProductStore",
56 >        $switch->addtag($parse,"Module",
57 >                                        \&Module_start,$self,
58 >                                        \&OutToScreen, $self,
59 >                                        "", $self);
60 >
61 >        $switch->addtag($parse,"ProductStore",
62                                          \&Store_start,$self,
63                                          "", $self,
64                                          "", $self);
# Line 84 | Line 89 | sub _initswitcher {
89          return $switch;
90   }
91  
92 < sub _commontags {
93 <        my $self=shift;
94 <        my $switch=shift;
95 <        my $parse=shift;
96 <        
97 <        $self->verbose(">> _commontags: SW ".$switch." PARSE ".$parse." <<");
98 <        
99 <        $switch->grouptag("Export",$parse);
100 <        $switch->addtag($parse,"Use",\&Use_start,$self,
101 <                                               \&OutToMakefile, $self,
102 <                                                "", $self);
103 <        $switch->addtag($parse,"Group",\&Group_start,$self,
104 <                                               \&OutToMakefile, $self,
105 <                                                "", $self);
106 <        $switch->grouptag("Group",$parse);
107 <        $switch->addtag($parse,"External",
108 <                                        \&External_StartTag,$self,
109 <                                        \&OutToMakefile, $self,
110 <                                        "", $self);
111 <        $switch->addtag($parse,"lib",
112 <                                        \&lib_start,$self,
113 <                                        \&OutToMakefile, $self,
114 <                                        "", $self);
115 <        $switch->addtag($parse,"Architecture",
116 <                                        \&Arch_Start,$self,
117 <                                        \&OutToMakefile, $self,
118 <                                        \&Arch_End,$self);
119 <        $switch->addtag($parse,"INCLUDE_PATH",
120 <                                        \&IncludePath_Start,$self,
121 <                                        \&OutToMakefile, $self,
122 <                                        "",$self);
123 <        return $switch;
124 < }
92 > sub _commontags
93 >   {
94 >   my $self=shift;
95 >   my $switch=shift;
96 >   my $parse=shift;
97 >  
98 >   $self->verbose(">> _commontags: SW ".$switch." PARSE ".$parse." <<");
99 >  
100 >   $switch->grouptag("Export",$parse);
101 >   $switch->addtag($parse,"Use",
102 >                   \&Use_start,$self,
103 >                   \&OutToMakefile, $self,
104 >                   "", $self);
105 >   $switch->addtag($parse,"Group",
106 >                   \&Group_start,$self,
107 >                   \&OutToMakefile, $self,
108 >                   "", $self);
109 >   $switch->grouptag("Group",$parse);
110 >   $switch->addtag($parse,"External",
111 >                   \&External_StartTag,$self,
112 >                   \&OutToMakefile, $self,
113 >                   "", $self);
114 >   $switch->addtag($parse,"lib",
115 >                   \&lib_start,$self,
116 >                   \&OutToMakefile, $self,"", $self);
117 >   $switch->addtag($parse,"debuglib",
118 >                   \&debuglib_start,$self,
119 >                   \&OutToMakefile, $self,
120 >                   "", $self);
121 >   $switch->addtag($parse,"Architecture",
122 >                   \&Arch_Start,$self,
123 >                   \&OutToMakefile, $self,
124 >                   \&Arch_End,$self);
125 >   $switch->addtag($parse,"INCLUDE_PATH",
126 >                   \&IncludePath_Start,$self,
127 >                   \&OutToMakefile, $self,
128 >                   "",$self);
129 >   $switch->addtag($parse,"CompilerMap",
130 >                   \&CompilerMap_Start,$self,
131 >                   \&OutToMakefile, $self,
132 >                   "",$self);
133 >   return $switch;
134 >   }
135  
136   sub ParseBuildFile {
137          my $self=shift;
# Line 272 | Line 287 | sub Class_StartTag {
287          }
288   }
289  
290 < sub IncludePath_Start {
291 <        my $self=shift;
292 <        my $name=shift;
293 <        my $hashref=shift;
294 <        
295 <        $self->verbose(">> IncludePath_Start: NM ".$name." <<");
296 <        
297 <        $self->{switch}->checktag( $name, $hashref, 'path');
298 <        if ( $self->{Arch} ) {
299 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
300 <                                                $$hashref{'path'}."\n";
301 <        }
302 < }
290 > sub IncludePath_Start
291 >   {
292 >   my $self=shift;
293 >   my $name=shift;
294 >   my $hashref=shift;
295 >  
296 >   $self->verbose(">> IncludePath_Start: NM ".$name." <<");
297 >  
298 >   $self->{switch}->checktag( $name, $hashref, 'path');
299 >   if ( $self->{Arch} )
300 >      {
301 >      print GNUmakefile "INCLUDE+=".$self->_location()."/".$$hashref{'path'}."\n";
302 >      }
303 >   }
304  
305   #
306   # generic build tag
# Line 576 | Line 592 | ENDTEXT
592          close binGNUmakefile;
593   }
594  
595 + sub Module_start {
596 +        my $self=shift;
597 +        my $name=shift;
598 +        my $hashref=shift;
599 +
600 +        my $fileclass;
601 +        my @tools;
602 +        my $tool;
603 +        my $filename;
604 +        my $objectname;
605 +
606 +        $self->verbose(">> In module_start: ".$name." <<");
607 +        
608 +        $self->{switch}->checktag($name,$hashref,'file');
609 +        if ( $self->{Arch} ) {
610 +        if ( ! defined $$hashref{name} ) {
611 +                ($$hashref{name}=$$hashref{file})=~s/\..*//;
612 +        }
613 +        ($filename=$$hashref{file})=~s/\..*//;
614 +
615 +        # Create a new directory for each module target
616 +        my $dirname="module_".$$hashref{name};
617 +        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
618 +        open (moduleGNUmakefile,
619 +           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
620 +           "BuildFile.mk $!\n";
621 +
622 +        # Create the link targets
623 +        $numbins++;
624 +        my $fh=$self->{filehandlestack}[0];
625 +        print $fh <<ENDTEXT;
626 +
627 + # Link Targets to module directories
628 + ifdef MODULEMODE
629 + # We dont want to build a library here
630 + override files:=
631 + endif
632 + ifndef MODULEMODE
633 +
634 + BINMODE=true
635 +  
636 + define stepdown_$$hashref{'name'}
637 + if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
638 + cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
639 + \$(MAKE) MODULEMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
640 + fi
641 + endef
642 +
643 + define stepdown2_$$hashref{'name'}
644 + if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
645 + cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
646 + \$(MAKE) MODULEMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
647 + fi
648 +
649 + endef
650 +
651 + module_$$hashref{'name'}_%:: dummy
652 +        \@\$(stepdown2_$$hashref{'name'})
653 +
654 + $$hashref{'name'}_%:: dummy
655 +        \@\$(stepdown_$$hashref{'name'})
656 +
657 + help module module_debug module_debug_local module_insure module_Insure clean $$hashref{'name'}:: dummy
658 +        \@\$(stepdown_$$hashref{'name'})
659 +
660 + modulefiles+=$$hashref{'file'}
661 + locmodulefiles+=$dirname/$$hashref{'file'}
662 + endif
663 +
664 +
665 + ENDTEXT
666 +
667 +
668 + # the module specifics makefile
669 +        print moduleGNUmakefile "include ".$self->{currentenv}."\n";
670 +        print moduleGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
671 +
672 + # alias for bin_Insure
673 +        print moduleGNUmakefile <<ENDTEXT;
674 +
675 + module_insure:module_Insure
676 + ifdef MAKETARGET_module_insure
677 + MAKETARGET_$$hashref{name}_Insure=1
678 + endif
679 +
680 + # debuggging target
681 + $$hashref{'name'}_echo_% :: echo_%
682 +
683 + # help targets
684 + help::
685 + \t\@echo  
686 + \t\@echo Targets For $$hashref{'name'}
687 + \t\@echo -------------------------------------
688 + \t\@echo $$hashref{'name'}  - default build
689 + \t\@echo module_$$hashref{'name'}_clean - executable specific cleaning
690 + ENDTEXT
691 +
692 + # Make generic rules for each type
693 +        $targettypes={
694 +                "module" => 'o',
695 +                "module_debug" => 'd',
696 +                "module_debug_local" => 'l_d',
697 +                "module_Insure" => 'Insure'
698 +        };
699 +        #
700 +        foreach $target ( keys %$targettypes ) {
701 +          print moduleGNUmakefile <<ENDTEXT;
702 +
703 + # Type $target specifics
704 + ifdef MAKETARGET_$target
705 + MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
706 + endif
707 + $target ::$$hashref{name}_$$targettypes{$target}
708 +
709 + moduletargets+=$$hashref{name}_$$targettypes{$target}
710 + help::
711 + \t\@echo $$hashref{name}_$$targettypes{$target}
712 + clean::
713 + \t\@if [ -f \$(modulestore)/$$hashref{name}_$$targettypes{$target} ]; then \\
714 + \techo Removing \$(modulestore)/$$hashref{name}; \\
715 + \trm \$(modulestore)/$$hashref{name}_$$targettypes{$target}; \\
716 + \tfi
717 +
718 + ENDTEXT
719 +          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
720 +          ${"objectname_$$targettypes{$target}"}=$objectname;
721 +          print moduleGNUmakefile "$objectname:$$hashref{name}.dep\n";
722 +        } # end loop
723 +        print moduleGNUmakefile "MDFLAGS= -shared -Wl,-soname,\$\@","\n";
724 +        print moduleGNUmakefile "$$hashref{name}_Insure.so:.psrc\n";
725 +        print moduleGNUmakefile "$$hashref{name}_d.so:$objectname_d\n";
726 +        print moduleGNUmakefile "\t\$(CClinkCmdDebug) \$(MDFLAGS)\n";
727 +        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
728 +        print moduleGNUmakefile "$$hashref{name}_l_d.so:$objectname_d\n";
729 +        print moduleGNUmakefile "\t\$(CClinkCmdDebugLocal) \$(MDFLAGS)\n";
730 +        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
731 +        print moduleGNUmakefile "$$hashref{name}_Insure.so:$objectname_Insure\n";
732 +        print moduleGNUmakefile "\t\$(CClinkCmdInsure) \$(MDFLAGS)\n";
733 +        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
734 +        print moduleGNUmakefile "$$hashref{name}_o.so:$objectname_o\n";
735 +        print moduleGNUmakefile "\t\$(CClinkCmd) \$(MDFLAGS)\n";
736 +        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
737 +        print moduleGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
738 +        print moduleGNUmakefile "-include $$hashref{name}.dep\n";
739 + print moduleGNUmakefile <<ENDTEXT;
740 + clean::
741 + \t\@if [ -f \$(modulestore)/lib$$hashref{name} ]; then \\
742 + \techo Removing \$(modulestore)/lib$$hashref{name}; \\
743 + \trm \$(modulestore)/lib$$hashref{name}; \\
744 + \tfi
745 +
746 +  
747 + $$hashref{name}_d.so:\$(libslocal_d)
748 + $$hashref{name}_o.so:\$(libslocal)
749 + ifdef MCCABE_DATA_DIR
750 + $$hashref{name}_mccabe.so: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
751 + endif
752 + $$hashref{name}_Insure.so:\$(libslocal_I)
753 + $$hashref{name}_d:$$hashref{name}_d.so
754 +        \@cp $$hashref{name}_d.so \$(modulestore)/lib$$hashref{name}
755 + $$hashref{name}_l_d:$$hashref{name}_l_d.so
756 +        \@cp $$hashref{name}_l_d.so \$(modulestore)/lib$$hashref{name}
757 + $$hashref{name}_Insure:$$hashref{name}_Insure.so
758 +        \@cp $$hashref{name}_Insure.so \$(modulestore)/lib$$hashref{name}_Insure
759 + $$hashref{name}:$$hashref{name}_d.so
760 +        \@mv $$hashref{name}_d.so \$(modulestore)/lib$$hashref{name}
761 + $$hashref{name}_o:$$hashref{name}_o.so
762 +        \@mv $$hashref{name}_o.so \$(modulestore)/lib$$hashref{name}.so
763 + modulefiles+=$$hashref{file}
764 + ENDTEXT
765 +        }
766 +        close moduleGNUmakefile;
767 + }
768 +
769 +
770   sub External_StartTag {
771          my $self=shift;
772          my $name=shift;
# Line 671 | Line 862 | sub Use_start
862        else
863           {
864           $filename=$self->{remoteproject}."/$$hashref{name}/BuildFile";
865 <         print "Trying $filename\n";
865 >         # Not sure how useful this statement is, so I'll remove it for now:
866 >         # print STDERR "Trying $filename\n";
867           if ( ! -f $filename ) { $filename=""; };
868           }
869        if ( $filename ne "" )
# Line 725 | Line 917 | sub AssociateGroup {
917          }
918   }
919  
920 < sub Arch_Start {
921 <        my $self=shift;
922 <        my $name=shift;
923 <        my $hashref=shift;
924 <
925 <        $self->verbose(">> Arch_Start: NM ".$name." <<");
926 <        
927 <        $self->{switch}->checktag($name, $hashref,'name');
928 <        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
929 <                                                : ($self->{Arch}=0);
930 <        push @{$self->{ARCHBLOCK}}, $self->{Arch};
931 < }
920 > sub Arch_Start
921 >   {
922 >   my $self=shift;
923 >   my $name=shift;
924 >   my $hashref=shift;
925 >  
926 >   $self->verbose(">> Arch_Start: NM ".$name." <<");
927 >  
928 >   $self->{switch}->checktag($name, $hashref,'name');
929 >  
930 > #   if ($ENV{SCRAM_ARCH} =~ /$$hashref{name}$/)
931 >   if ( $$hashref{name} eq $ENV{SCRAM_ARCH} )
932 >      {
933 > #      print "HASHREFNAME= ",$$hashref{name},"\n";     # The tag read from BuildFile
934 > #      print "Scram arch()? ",$ENV{SCRAM_ARCH},"\n";   # Also SCRAM_ARCH
935 >      $self->{Arch}=1;
936 >      }
937 >   else
938 >      {
939 >      $self->{Arch}=0;
940 >      }
941 > #   ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1)
942 > #      : ($self->{Arch}=0);
943 >  
944 >   $self->verbose(($self->{Arch}?"OK":"skipping")." ".$$hashref{name});
945 >   push @{$self->{ARCHBLOCK}}, $self->{Arch};
946 >   }
947  
948   sub Arch_End {
949          my $self=shift;
# Line 846 | Line 1053 | sub export_end {
1053   #
1054   # Standard lib tag
1055   #
1056 < sub lib_start {
1057 <        my $self=shift;
1058 <        my $name=shift;
1059 <        my $hashref=shift;
1060 <        
1061 <        $self->verbose(">> lib_start: NM ".$name." <<");
1056 > sub lib_start
1057 >   {
1058 >   my $self=shift;
1059 >   my $name=shift;
1060 >   my $hashref=shift;
1061 >  
1062 >   $self->verbose(">> lib_start: NM ".$name." <<");
1063 >  
1064 >   $self->{switch}->checktag($name, $hashref, 'name');
1065  
1066 <        $self->{switch}->checktag($name, $hashref, 'name');
1066 >   if ( $self->{Arch} )
1067 >      {
1068 >      print GNUmakefile "lib+=$$hashref{name}\n";
1069 >      }
1070 >   }
1071  
1072 <        if ( $self->{Arch} ) {
1073 <           print GNUmakefile "lib+=$$hashref{name}\n";
1074 <        }
1075 < }
1072 > # Standard debug lib tag
1073 > #
1074 > sub debuglib_start
1075 >   {
1076 >   my $self=shift;
1077 >   my $name=shift;
1078 >   my $hashref=shift;
1079 >  
1080 >   $self->verbose(">> debuglib_start: NM ".$name." <<");
1081 >   $self->{switch}->checktag($name, $hashref, 'name');
1082 >
1083 >   if ( $self->{Arch} )
1084 >      {
1085 >      print GNUmakefile "debuglib+=$$hashref{name}\n";
1086 >      }
1087 >   }
1088  
1089   #
1090   # libtype specification
# Line 1016 | Line 1242 | sub Store_start {
1242                          ."/".$dir.":".$ENV{RELEASETOP}."/".$dir."\n";
1243          }
1244   }
1245 +
1246 + sub CompilerMap_Start
1247 +   {
1248 +   ###############################################################
1249 +   # CompilerMap_Start                                           #
1250 +   ###############################################################
1251 +   # modified : Fri Oct  4 15:08:39 2002 / SFA                   #
1252 +   # params   :                                                  #
1253 +   #          :                                                  #
1254 +   #          :                                                  #
1255 +   #          :                                                  #
1256 +   # function : Create a map between a SUBARCH and specific      #
1257 +   #          : compiler and version.                            #
1258 +   #          :                                                  #
1259 +   #          :                                                  #
1260 +   ###############################################################
1261 +   my $self=shift;
1262 +   my $name=shift;
1263 +   my $hashref=shift;
1264 +
1265 +   $self->verbose(">> CompilerMap_Start: NM ".$name." <<");
1266 +   # We can only map compilers to already-defined architectures, so
1267 +   # we check for 'Arch':
1268 +   if ( $self->{Arch} )
1269 +      {
1270 +      my @tagnames=keys %{$hashref};
1271 +      my @tagvalues=values %{$hashref};
1272 +      
1273 +      foreach my $tag ( @tagnames )
1274 +         {
1275 +         $self->{switch}->checktag($name,$hashref,$tag);
1276 +         print GNUmakefile $tag."=".$$hashref{$tag}."\n";
1277 +
1278 +         if ( defined $$hashref{'version'} )
1279 +            {
1280 +            print GNUmakefile "_V_".$$hashref{'version'};
1281 +            }
1282 +         print GNUmakefile "=true\n";
1283 +         }
1284 + #        $self->{switch}->checktag($name,$hashref,'ref');
1285 +
1286 + #       # -- oo toolbox stuff
1287 + #       # - get the appropriate tool object
1288 + #       $$hashref{'ref'}=~tr[A-Z][a-z];
1289 + #       if ( ! exists $$hashref{'version'} ) {
1290 + #        $tool=$self->{toolbox}->gettool($$hashref{'ref'});
1291 + #       }
1292 + #       else {
1293 + #        $tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'});
1294 + #       }
1295 + #       if ( ! defined $tool ) {
1296 + #         $self->{switch}->parseerror("Unknown Tool Specified ("
1297 + #                                                       .$$hashref{'ref'}.")");
1298 + #       }
1299 +
1300 + #       # -- old fashioned GNUmakefile stuff
1301 + #       print GNUmakefile $$hashref{'ref'};
1302 + #       if ( defined $$hashref{'version'} ) {
1303 + #               print GNUmakefile "_V_".$$hashref{'version'};
1304 + #       }
1305 + #       print GNUmakefile "=true\n";
1306 +        
1307 + #       # -- Sub system also specified?
1308 + #       if ( exists $$hashref{'use'} ) {
1309 + #          # -- look for a buildfile
1310 + #          my @paths=$tool->getfeature("INCLUDE");
1311 + #          my $file="";
1312 + #          my ($path,$testfile);
1313 + #          foreach $path ( @paths ) {
1314 + #            $testfile=$path."/".$$hashref{'use'}."/BuildFile" ;
1315 + #            if ( -f $testfile ) {
1316 + #               $file=$testfile;
1317 + #               $self->_pushremoteproject($path);
1318 + #            }
1319 + #          }
1320 + #          if ( $file eq "" ) {
1321 + #            $self->{switch}->parseerror("Unable to find SubSystem $testfile");
1322 + #          }
1323 + #          $self->ParseBuildFile_Export($file);
1324 + #          $self->_popremoteproject();
1325 + #        }
1326 +      }
1327 +   else
1328 +      {
1329 +      return;
1330 +      }
1331 +   }
1332 +
1333 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines