ExtUtils::MakeMaker under Win32 - problem - missing double-quotes

T

tuser

I have a problem with "ExtUtils::MakeMaker" under Win32.
(I am running Activestate Perl v 5.8.7 under Windows XP)

"ExtUtils::MakeMaker" generates a Makefile where spaces can be found in
the filenames, but it does not put double-quotes around the filename,
so the Makefile fails.

I searched the docs and the sourcecode for hours and hours to make
"ExtUtils::MakeMaker" put double-quotes around its components, but I
could not find anything.

I was becoming desperate, so I had to apply drastic measures and
intervene in the program which calls the "WriteMakefile(%options);"
subroutine and artificially modify the Makefile after it had been
generated.

This works, but I am hoping that someone in comp.lang.perl.misc can
point me to a better solution where "ExtUtils::MakeMaker" generates a
correct Makefile in the first place.

**********************************
Here is the background-story:
**********************************

I tried to install "Inline::C" (Inline-0.44.zip) directly from the
Activestate website. (see my other post "Inline::CPP for Windows
ActiveState" on comp.lang.perl.misc)

when I tested "Inline::C", it failed with:

================================================
Use of uninitialized value in -d at C:/Perl/lib/File/Path.pm line 144.
fileparse(): need a valid pathname at C:/Perl/lib/File/Path.pm line 145
NMAKE : fatal error U1077: 'C:\Perl\bin\perl.exe' : return code '0x2'
Stop.
================================================

I inspected the 'Makefile' and I began to understand what was wrong:

Makefile:
================================================
pure_site_install ::
$(NOECHO) $(MOD_INSTALL) \
read $(SITEARCHEXP)\auto\$(FULLEXT)\.packlist \
write $(DESTINSTALLSITEARCH)\auto\$(FULLEXT)\.packlist \
$(INST_LIB) $(DESTINSTALLSITELIB) \
$(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
$(INST_BIN) $(DESTINSTALLSITEBIN) \
$(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
$(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
$(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR) \
$(INST_HTMLDIR) $(DESTINSTALLSITEHTMLDIR)
$(NOECHO) $(WARN_IF_OLD_PACKLIST) \
$(PERL_ARCHLIB)\auto\$(FULLEXT)
================================================

In fact, my current path ("C:\Documents and Settings\....") was stored
in "$(DESTINSTALLSITELIB)", but it was not surrounded by double-quotes
(as it should have been under Win32 where spaces are involved), and
that's what 'Makefile' choked on.

I could easily see that "Makefile" was generated by
"ExtUtils::MakeMaker" and I searched for an option in
"ExtUtils::MakeMaker" to make it put double-quotes around its
components, but I could not find any solution.

I was becoming desperate, so I had to apply drastic measures and
intervene in C:\Perl\site\lib\Inline\C.pm (starting at line 640) to
artificially modify the Makefile after it had been generated:

================================================
sub write_Makefile_PL {

[...]

open MF,
"> ".File::Spec->catfile($o->{API}{build_dir},"Makefile.PL")
or croak;

print MF <<'END';
use ExtUtils::MakeMaker;
my %options = %{
END

local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = 1;
print MF Data::Dumper::Dumper(\ %options);

print MF <<'END';
};
WriteMakefile(%options);

# Help !!! can someone please tell "ExtUtils::MakeMaker"
# to put some quotes around parameters for "pure_*_install"
# under Win32 ??? (not putting quotes around parameters
# breaks the Makefile under Win32)
# ----------------------------------------------------------
# ...if "ExtUtils::MakeMaker" can't be bothered, then I will
# have to put the quotes myself...

# Update 'Makefile' on a temporary 'Makefile.tmp'

open MAKFILE, '<', 'Makefile'
or die "Error 0010 - open input 'Makefile', $!";

open TMPFILE, '>', 'Makefile.tmp'
or die "Error 0020 - open output 'Makefile.tmp', $!";

my $update = 0;

while (<MAKFILE>) { chomp;
if (/^(\w+)/) {
my $keyword = $1;
$update = $keyword =~ /^pure_[a-z]+_install$/;
}
if ($update and /^\t\t(.+)$/) {
my @words = split(/\s+/, $1);
for my $w (@words) {
$w = qq{"$w"}
unless $w eq '\\'
or $w eq 'read'
or $w eq 'write';
}
$_ = "\t\t".join(' ', @words);
}
print TMPFILE "$_\n";
}

close TMPFILE;
close MAKFILE;

# now commit the update back to 'Makefile'

open TMPFILE, '<', 'Makefile.tmp'
or die "Error 0030 - open input 'Makefile.tmp', $!";

open MAKFILE, '>', 'Makefile'
or die "Error 0040 - open output 'Makefile', $!";

while (<TMPFILE>) {
print MAKFILE;
}

close MAKFILE;
close TMPFILE;

**********************************
End of background-story
**********************************

This works, but again, I am hoping that someone in comp.lang.perl.misc
can point me to a better solution where "ExtUtils::MakeMaker" generates
a correct Makefile in the first place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,676
Latest member
ManuelaHol

Latest Threads

Top