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.20 by sashby, Thu Jul 18 13:49:01 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 >   return $switch;
130 >   }
131  
132   sub ParseBuildFile {
133          my $self=shift;
# Line 272 | Line 283 | sub Class_StartTag {
283          }
284   }
285  
286 < sub IncludePath_Start {
287 <        my $self=shift;
288 <        my $name=shift;
289 <        my $hashref=shift;
290 <        
291 <        $self->verbose(">> IncludePath_Start: NM ".$name." <<");
292 <        
293 <        $self->{switch}->checktag( $name, $hashref, 'path');
294 <        if ( $self->{Arch} ) {
295 <          print GNUmakefile "INCLUDE+=".$self->_location()."/".
296 <                                                $$hashref{'path'}."\n";
297 <        }
298 < }
286 > sub IncludePath_Start
287 >   {
288 >   my $self=shift;
289 >   my $name=shift;
290 >   my $hashref=shift;
291 >  
292 >   $self->verbose(">> IncludePath_Start: NM ".$name." <<");
293 >  
294 >   $self->{switch}->checktag( $name, $hashref, 'path');
295 >   if ( $self->{Arch} )
296 >      {
297 >      print GNUmakefile "INCLUDE+=".$self->_location()."/".$$hashref{'path'}."\n";
298 >      }
299 >   }
300  
301   #
302   # generic build tag
# Line 576 | Line 588 | ENDTEXT
588          close binGNUmakefile;
589   }
590  
591 + sub Module_start {
592 +        my $self=shift;
593 +        my $name=shift;
594 +        my $hashref=shift;
595 +
596 +        my $fileclass;
597 +        my @tools;
598 +        my $tool;
599 +        my $filename;
600 +        my $objectname;
601 +
602 +        $self->verbose(">> In module_start: ".$name." <<");
603 +        
604 +        $self->{switch}->checktag($name,$hashref,'file');
605 +        if ( $self->{Arch} ) {
606 +        if ( ! defined $$hashref{name} ) {
607 +                ($$hashref{name}=$$hashref{file})=~s/\..*//;
608 +        }
609 +        ($filename=$$hashref{file})=~s/\..*//;
610 +
611 +        # Create a new directory for each module target
612 +        my $dirname="module_".$$hashref{name};
613 +        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname");
614 +        open (moduleGNUmakefile,
615 +           ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/".
616 +           "BuildFile.mk $!\n";
617 +
618 +        # Create the link targets
619 +        $numbins++;
620 +        my $fh=$self->{filehandlestack}[0];
621 +        print $fh <<ENDTEXT;
622 +
623 + # Link Targets to module directories
624 + ifdef MODULEMODE
625 + # We dont want to build a library here
626 + override files:=
627 + endif
628 + ifndef MODULEMODE
629 +
630 + BINMODE=true
631 +  
632 + define stepdown_$$hashref{'name'}
633 + if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
634 + cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
635 + \$(MAKE) MODULEMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\
636 + fi
637 + endef
638 +
639 + define stepdown2_$$hashref{'name'}
640 + if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\
641 + cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\
642 + \$(MAKE) MODULEMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\
643 + fi
644 +
645 + endef
646 +
647 + module_$$hashref{'name'}_%:: dummy
648 +        \@\$(stepdown2_$$hashref{'name'})
649 +
650 + $$hashref{'name'}_%:: dummy
651 +        \@\$(stepdown_$$hashref{'name'})
652 +
653 + help module module_debug module_debug_local module_insure module_Insure clean $$hashref{'name'}:: dummy
654 +        \@\$(stepdown_$$hashref{'name'})
655 +
656 + modulefiles+=$$hashref{'file'}
657 + locmodulefiles+=$dirname/$$hashref{'file'}
658 + endif
659 +
660 +
661 + ENDTEXT
662 +
663 +
664 + # the module specifics makefile
665 +        print moduleGNUmakefile "include ".$self->{currentenv}."\n";
666 +        print moduleGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n";
667 +
668 + # alias for bin_Insure
669 +        print moduleGNUmakefile <<ENDTEXT;
670 +
671 + module_insure:module_Insure
672 + ifdef MAKETARGET_module_insure
673 + MAKETARGET_$$hashref{name}_Insure=1
674 + endif
675 +
676 + # debuggging target
677 + $$hashref{'name'}_echo_% :: echo_%
678 +
679 + # help targets
680 + help::
681 + \t\@echo  
682 + \t\@echo Targets For $$hashref{'name'}
683 + \t\@echo -------------------------------------
684 + \t\@echo $$hashref{'name'}  - default build
685 + \t\@echo module_$$hashref{'name'}_clean - executable specific cleaning
686 + ENDTEXT
687 +
688 + # Make generic rules for each type
689 +        $targettypes={
690 +                "module" => 'o',
691 +                "module_debug" => 'd',
692 +                "module_debug_local" => 'l_d',
693 +                "module_Insure" => 'Insure'
694 +        };
695 +        #
696 +        foreach $target ( keys %$targettypes ) {
697 +          print moduleGNUmakefile <<ENDTEXT;
698 +
699 + # Type $target specifics
700 + ifdef MAKETARGET_$target
701 + MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
702 + endif
703 + $target ::$$hashref{name}_$$targettypes{$target}
704 +
705 + moduletargets+=$$hashref{name}_$$targettypes{$target}
706 + help::
707 + \t\@echo $$hashref{name}_$$targettypes{$target}
708 + clean::
709 + \t\@if [ -f \$(modulestore)/$$hashref{name}_$$targettypes{$target} ]; then \\
710 + \techo Removing \$(modulestore)/$$hashref{name}; \\
711 + \trm \$(modulestore)/$$hashref{name}_$$targettypes{$target}; \\
712 + \tfi
713 +
714 + ENDTEXT
715 +          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
716 +          ${"objectname_$$targettypes{$target}"}=$objectname;
717 +          print moduleGNUmakefile "$objectname:$$hashref{name}.dep\n";
718 +        } # end loop
719 +        print moduleGNUmakefile "MDFLAGS= -shared -Wl,-soname,\$\@","\n";
720 +        print moduleGNUmakefile "$$hashref{name}_Insure.so:.psrc\n";
721 +        print moduleGNUmakefile "$$hashref{name}_d.so:$objectname_d\n";
722 +        print moduleGNUmakefile "\t\$(CClinkCmdDebug) \$(MDFLAGS)\n";
723 +        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
724 +        print moduleGNUmakefile "$$hashref{name}_l_d.so:$objectname_d\n";
725 +        print moduleGNUmakefile "\t\$(CClinkCmdDebugLocal) \$(MDFLAGS)\n";
726 +        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
727 +        print moduleGNUmakefile "$$hashref{name}_Insure.so:$objectname_Insure\n";
728 +        print moduleGNUmakefile "\t\$(CClinkCmdInsure) \$(MDFLAGS)\n";
729 +        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
730 +        print moduleGNUmakefile "$$hashref{name}_o.so:$objectname_o\n";
731 +        print moduleGNUmakefile "\t\$(CClinkCmd) \$(MDFLAGS)\n";
732 +        print moduleGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n";
733 +        print moduleGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
734 +        print moduleGNUmakefile "-include $$hashref{name}.dep\n";
735 + print moduleGNUmakefile <<ENDTEXT;
736 + clean::
737 + \t\@if [ -f \$(modulestore)/lib$$hashref{name} ]; then \\
738 + \techo Removing \$(modulestore)/lib$$hashref{name}; \\
739 + \trm \$(modulestore)/lib$$hashref{name}; \\
740 + \tfi
741 +
742 +  
743 + $$hashref{name}_d.so:\$(libslocal_d)
744 + $$hashref{name}_o.so:\$(libslocal)
745 + ifdef MCCABE_DATA_DIR
746 + $$hashref{name}_mccabe.so: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
747 + endif
748 + $$hashref{name}_Insure.so:\$(libslocal_I)
749 + $$hashref{name}_d:$$hashref{name}_d.so
750 +        \@cp $$hashref{name}_d.so \$(modulestore)/lib$$hashref{name}
751 + $$hashref{name}_l_d:$$hashref{name}_l_d.so
752 +        \@cp $$hashref{name}_l_d.so \$(modulestore)/lib$$hashref{name}
753 + $$hashref{name}_Insure:$$hashref{name}_Insure.so
754 +        \@cp $$hashref{name}_Insure.so \$(modulestore)/lib$$hashref{name}_Insure
755 + $$hashref{name}:$$hashref{name}_d.so
756 +        \@mv $$hashref{name}_d.so \$(modulestore)/lib$$hashref{name}
757 + $$hashref{name}_o:$$hashref{name}_o.so
758 +        \@mv $$hashref{name}_o.so \$(modulestore)/lib$$hashref{name}.so
759 + modulefiles+=$$hashref{file}
760 + ENDTEXT
761 +        }
762 +        close moduleGNUmakefile;
763 + }
764 +
765 +
766   sub External_StartTag {
767          my $self=shift;
768          my $name=shift;
# Line 846 | Line 1033 | sub export_end {
1033   #
1034   # Standard lib tag
1035   #
1036 < sub lib_start {
1037 <        my $self=shift;
1038 <        my $name=shift;
1039 <        my $hashref=shift;
1040 <        
1041 <        $self->verbose(">> lib_start: NM ".$name." <<");
1036 > sub lib_start
1037 >   {
1038 >   my $self=shift;
1039 >   my $name=shift;
1040 >   my $hashref=shift;
1041 >  
1042 >   $self->verbose(">> lib_start: NM ".$name." <<");
1043 >  
1044 >   $self->{switch}->checktag($name, $hashref, 'name');
1045  
1046 <        $self->{switch}->checktag($name, $hashref, 'name');
1046 >   if ( $self->{Arch} )
1047 >      {
1048 >      print GNUmakefile "lib+=$$hashref{name}\n";
1049 >      }
1050 >   }
1051  
1052 <        if ( $self->{Arch} ) {
1053 <           print GNUmakefile "lib+=$$hashref{name}\n";
1054 <        }
1055 < }
1052 > # Standard debug lib tag
1053 > #
1054 > sub debuglib_start
1055 >   {
1056 >   my $self=shift;
1057 >   my $name=shift;
1058 >   my $hashref=shift;
1059 >  
1060 >   $self->verbose(">> debuglib_start: NM ".$name." <<");
1061 >   $self->{switch}->checktag($name, $hashref, 'name');
1062 >
1063 >   if ( $self->{Arch} )
1064 >      {
1065 >      print GNUmakefile "debuglib+=$$hashref{name}\n";
1066 >      }
1067 >   }
1068  
1069   #
1070   # libtype specification

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines