Re: [PATCH] Re: MakeMaker doesn't pasthru DEFINE command-line args to subdirs on...
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Unix.pm
index a59617d..f49c707 100644 (file)
@@ -9,6 +9,7 @@ use Carp;
 use Config         qw(%Config);
 use File::Basename qw(basename dirname fileparse);
 use DirHandle;
+use Text::ParseWords;
 
 use vars qw($VERSION @ISA
             $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Win95  $Is_Dos $Is_VOS
@@ -3111,7 +3112,21 @@ sub pasthru {
     $sep .= "\\\n\t";
 
     foreach $key (qw(LIB LIBPERL_A LINKTYPE PREFIX OPTIMIZE INC DEFINE)) {
-       push @pasthru, "$key=\"\$($key)\"";
+       if ($key eq 'INC' && defined(my $inc = $self->{INC})) {
+           # For INC we need to prepend parent directory but
+           # only iff the parent directory is not absolute.
+           my ($o, $i) = $Is_VMS ? ('/Include=', 'i') : ('-I', '');
+           my $newinc = '';
+           foreach (grep { /\S/ } parse_line(qr/\s*(?$i)$o/, 1, $inc)) {
+               s/^"(.+)"$/$1/o;
+               my $dir = File::Spec->file_name_is_absolute($_) ? $_ : File::Spec->catdir(File::Spec->updir, $_);
+               $dir = qq["$dir"] if $dir =~ / /;
+               $newinc .= " $o$dir";
+           }
+           push @pasthru, "INC=\"$newinc\"";
+       } else {
+           push @pasthru, "$key=\"\$($key)\"";
+       }
     }
 
     # PASTHRU_DEFINE and PASTHRU_INC are defined explicitly