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

Discussion in 'Perl Misc' started by tuser, May 8, 2006.

  1. tuser

    tuser Guest

    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.
     
    tuser, May 8, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jill
    Replies:
    2
    Views:
    148
    James Willmore
    Jan 27, 2004
  2. felipe200112
    Replies:
    0
    Views:
    274
    felipe200112
    Apr 19, 2004
  3. Irving Kimura

    Anything better than ExtUtils::MakeMaker ?

    Irving Kimura, May 11, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    128
    Jon Ericson
    May 14, 2004
  4. Abdul-Wahid Paterson

    installing extra file through ExtUtils::MakeMaker

    Abdul-Wahid Paterson, Nov 8, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    201
    Anno Siegel
    Nov 9, 2004
  5. Replies:
    4
    Views:
    178
    Sisyphus
    Jul 21, 2006
Loading...

Share This Page