# New Ticket Created by  James Keenan 
# Please include the string:  [perl #50390]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=50390 >


In the course of research on http://rt.perl.org/rt3/Ticket/ 
Display.html?id=50056 tonight, use of Parrot::Configure::Trace  
indicated that auxiliary method _handle_darwin_for_fink was adding  
flag '-L/sw/lib' an unnecessary second time to 'linkflags' and  
'ldflags' at config step auto::gdbm (on my box, at least) and was  
adding '-I/sw/include' an unnecessary second time to 'ccflags'.

The attached patch for lib/Parrot/Configure/Step/Methods.pm corrects  
the problem by checking to see whether these flags are already in the  
attribute before adding them.
Index: lib/Parrot/Configure/Step/Methods.pm
===================================================================
--- lib/Parrot/Configure/Step/Methods.pm        (revision 25337)
+++ lib/Parrot/Configure/Step/Methods.pm        (working copy)
@@ -65,9 +65,21 @@
         my $fink_include_dir    = $conf->data->get('fink_include_dir');
         if ( (defined $fink_lib_dir) && (defined $fink_include_dir) ) {
             if ( -f "$fink_include_dir/$file" ) {
-                $conf->data->add( ' ', linkflags => "-L$fink_lib_dir" );
-                $conf->data->add( ' ', ldflags   => "-L$fink_lib_dir" );
-                $conf->data->add( ' ', ccflags   => "-I$fink_include_dir" );
+#                $conf->data->add( ' ', linkflags => "-L$fink_lib_dir" );
+#                $conf->data->add( ' ', ldflags   => "-L$fink_lib_dir" );
+#                $conf->data->add( ' ', ccflags   => "-I$fink_include_dir" );
+                my %intended = (
+                    linkflags => "-L$fink_lib_dir",
+                    ldflags   => "-L$fink_lib_dir",
+                    ccflags   => "-I$fink_include_dir",
+                );
+                foreach my $flag (keys %intended) {
+                    my $flagstr = $conf->data->get($flag);
+                    my @elements = split /\s+/, $flagstr;
+                    my %seen = map {$_, 1} @elements;
+                    $conf->data->add( ' ', $flag => $intended{$flag} )
+                        unless $seen{$intended{$flag}};
+                }
             }
         }
     }

Reply via email to