@@ -793,6 +793,10 @@ sub AddContrib
793
793
my $proj =$solution -> AddProject($1 ,' exe' ,' contrib' ," $subdir /$n " );
794
794
AdjustContribProj($proj );
795
795
}
796
+ elsif ($mf =~/ ^DATA_TSEARCH\s *=\s *(.*)$ /mg )
797
+ {
798
+ # This is ispell dictionary project
799
+ }
796
800
else
797
801
{
798
802
croak" Could not determine contrib module type for$n \n " ;
@@ -802,50 +806,92 @@ sub AddContrib
802
806
GenerateContribSqlFiles($n ,$mf );
803
807
}
804
808
805
- sub GenerateContribSqlFiles
806
- {
807
- my $n =shift ;
808
- my $mf =shift ;
809
- $mf =~s {\\\r ?\n } {} g ;
810
- if ($mf =~/ ^DATA_built\s *=\s *(.*)$ /mg )
811
- {
812
- my $l =$1 ;
813
-
814
- # Strip out $(addsuffix) rules
815
- if (index ($l ,' $(addsuffix' ) >= 0)
816
- {
817
- my $pcount = 0;
818
- my $i ;
819
- for ($i =index ($l ,' $(addsuffix' ) + 12;$i <length ($l );$i ++)
820
- {
821
- $pcount ++if (substr ($l ,$i , 1)eq ' (' );
822
- $pcount --if (substr ($l ,$i , 1)eq ' )' );
823
- last if ($pcount < 0);
809
+ sub SubstituteMakefileVariables {
810
+ local $_ =shift ;# Line to substitue
811
+ my $mf =shift ;# Makefile text
812
+ while (/ \$\( (\w +)\) / ) {
813
+ my $varname =$1 ;
814
+ if ($mf =~/ ^$varname \s *=\s *(.*)$ /mg ) {
815
+ my $varvalue =$1 ;
816
+ s /\$\( $varname\) / $varvalue / g ;
824
817
}
825
- $l =
826
- substr ($l , 0,index ($l ,' $(addsuffix' )) .substr ($l ,$i + 1);
827
- }
828
-
829
- foreach my $d (split /\s +/,$l )
830
- {
831
- my $in =" $d .in" ;
832
- my $out =" $d " ;
818
+ }
819
+ return $_ ;
820
+ }
833
821
834
- if (Solution::IsNewer(" contrib/$n /$out " ," contrib/$n /$in " ))
835
- {
836
- print " Building$out from$in (contrib/$n )...\n " ;
837
- my $cont = Project::read_file(" contrib/$n /$in " );
838
- my $dn =$out ;
839
- $dn =~s /\. sql$// ;
840
- $cont =~s / MODULE_PATHNAME/ \$ libdir\/ $dn / g ;
822
+ sub GenerateContribSqlFiles
823
+ {
824
+ my $n =shift ;
825
+ my $mf =shift ;
826
+ $mf =~s {\\\r ?\n } {} g ;
827
+ if ($mf =~/ ^DATA_built\s *=\s *(.*)$ /mg )
828
+ {
829
+ my $l =$1 ;
830
+ # Strip out $(addsuffix) rules
831
+ if (index ($l ,' $(addsuffix' ) >= 0)
832
+ {
833
+ my $pcount = 0;
834
+ my $i ;
835
+ for ($i =index ($l ,' $(addsuffix' ) + 12;$i <length ($l );$i ++)
836
+ {
837
+ $pcount ++if (substr ($l ,$i , 1)eq ' (' );
838
+ $pcount --if (substr ($l ,$i , 1)eq ' )' );
839
+ last if ($pcount < 0);
840
+ }
841
+ $l =
842
+ substr ($l , 0,index ($l ,' $(addsuffix' )) .substr ($l ,$i + 1);
843
+ }
844
+ # perform variable substitutions in the makefile
845
+ $l = SubstituteMakefileVariables($l ,$mf );
846
+ foreach my $d (split /\s +/,$l )
847
+ {
848
+ print STDERR " Generating file$d \n " ;
849
+ if (-f " $d .in" ) {
850
+ my $in =" $d .in" ;
851
+ my $out =" $d " ;
852
+ if (Solution::IsNewer(" contrib/$n /$out " ," contrib/$n /$in " ))
853
+ {
854
+ print " Building$out from$in (contrib/$n )...\n " ;
855
+ my $cont = Project::read_file(" contrib/$n /$in " );
856
+ my $dn =$out ;
857
+ $dn =~s /\. sql$// ;
858
+ $cont =~s / MODULE_PATHNAME/ \$ libdir\/ $dn / g ;
859
+ my $o ;
860
+ open ($o ," >contrib/$n /$out " )
861
+ || croak" Could not write to contrib/$n /$d " ;
862
+ print $o $cont ;
863
+ close ($o );
864
+ }
865
+ }else {
866
+ # Search for makefile rule.
867
+ # For now we do not process rule command and assume
868
+ # that we should just concatenate all prerequisites
869
+ #
870
+ my @prereq = ();
871
+ my $target ;
872
+ my @rules =$mf =~/ ^(\S +)\s *:\s *([^=].*)$ /mg ;
873
+ RULE:
874
+ while (@rules ) {
875
+ $target = SubstituteMakefileVariables(shift @rules ,$mf );
876
+ @prereq =split (/ \s +/ ,SubstituteMakefileVariables(shift @rules ,$mf ));
877
+ last RULEif ($target eq $d );
878
+ @prereq = ();
879
+ }
880
+ croak" Don't know how to build contrib/$n /$d " unless @prereq ;
881
+ print STDERR " building$d from@prereq \n " ;
841
882
my $o ;
842
- open ($o ," >contrib/$n /$out " )
843
- || croak" Could not write to contrib/$n /$d " ;
844
- print $o $cont ;
845
- close ($o );
883
+ open $o ," >contrib/$n /$d "
884
+ or croak(" Couldn't write to contrib/$n /$d :$! " );
885
+ for my $in (@prereq ) {
886
+ my $data = Project::read_file(" contrib/$n /$in " );
887
+ print $o $data ;
888
+ close $i ;
889
+ }
890
+ close $o ;
891
+
846
892
}
847
- }
848
- }
893
+ }
894
+ }
849
895
}
850
896
851
897
sub AdjustContribProj