makefile semicolon interpreted as command argument

361 Views Asked by At

I have a Makefile for a Perl module installation, and I'm trying to get the installation of a script working properly. It was generated by Makefile.PL, but the author of the module tells me that if I figure out what the Makefile should look like then he can fix Makefile.PL. Anyway, I'm testing it for the author on Windows 7, and it goes haywire. The problem is in targets that look like the following:

pure_perl_install :: all
$(NOECHO) $(PERLRUN) -pi.bak -e "s+^use FindBin;.*++" $(INST_SCRIPT)/dtdto ; \
    $(PERLRUN) -pi.bak -e "s+^my \$$share =[^;]*+my \$$share = qq{$(INSTALLSHAREDIR)}+" $(INST_SCRIPT)/dtdto ; \
    $(CHMOD) $(PERM_RWX) $(INST_SCRIPT)/dtdto

Doing dmake pure_perl_install yields the following:

C:\strawberry\perl\bin\perl.exe -MExtUtils::Command -e cp -- bin/dtdto blib\script\dtdto
pl2bat.bat blib\script\dtdto
Can't open ;: No such file or directory, <> line 297.
Can't open -pi.bak: No such file or directory, <> line 348.
Can't open -e: No such file or directory, <> line 348.
Can't open s+^my \$share =[^;]*+my \$share = qqC:\strawberry\perl\site/share+: Invalid argument, <> line 348.
Can't open ;: No such file or directory, <> line 645.
Can't do inplace edit on C:\strawberry\perl\bin\perl.exe: File exists, <> line 645.
Can't open -MExtUtils::Command: Invalid argument, <> line 645.
Can't open -e: No such file or directory, <> line 645.
Can't open chmod: No such file or directory, <> line 645.
Can't open --: No such file or directory, <> line 645.
Can't open 755: No such file or directory, <> line 645.
Access is denied.
dmake:  Error code 129, while making 'pure_perl_install'

I think the problem lies in the first error. The semicolons are supposed to be used in the Makefile to signal the end of a single command. However, the semicolon is instead being interpreted as just another command argument, and all of the lines are turning into one long command. This then overwrites perl.exe (after creating a backup, thank goodness!), then tries to run perl.exe, which is now impossible, and a message pops up saying that perl.exe isn't even a real program. It's a complete disaster.

My question is: how can I edit this target so that the semicolon is interpreted as the end-of-command within dmake, instead of being sent as another command line argument?

By the way, removing the space before the semicolon tacks it on as part of the dtdto file name, which causes an error because it doesn't exist.

2

There are 2 best solutions below

0
On BEST ANSWER

The solution is to ditch package MY overrides in Makefile.PL and use

File::ShareDir::Install and File::Share

or https://metacpan.org/module/ExtUtils::MakeMaker#PL_FILES

0
On

Probably you can avoid the ";" completely by using multiple lines in the makefile rule:

pure_perl_install :: all
    $(NOECHO) $(PERLRUN) -pi.bak -e "s+^use FindBin;.*++" $(INST_SCRIPT)/dtdto
    $(NOECHO) $(PERLRUN) -pi.bak -e "s+^my \$$share =[^;]*+my \$$share = qq{$(INSTALLSHAREDIR)}+" $(INST_SCRIPT)/dtdto
    $(NOECHO) $(CHMOD) $(PERM_RWX) $(INST_SCRIPT)/dtdto