Skip to content

Commit ec781fb

Browse files
committed
nmake can quote spaces - RT-115534
1 parent e04e45f commit ec781fb

File tree

2 files changed

+114
-29
lines changed

2 files changed

+114
-29
lines changed

lib/ExtUtils/MM_Unix.pm

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ Prints out macros for lots of constants.
410410
=cut
411411

412412
sub constants {
413-
my($self) = @_;
413+
my ($self) = @_;
414414
my @m = ();
415415

416416
$self->{DFSEP} = '$(DIRFILESEP)'; # alias for internal use
@@ -433,17 +433,17 @@ sub constants {
433433
} $self->installvars),
434434
qw(
435435
PERL_LIB
436-
PERL_ARCHLIB PERL_ARCHLIBDEP
436+
PERL_ARCHLIB
437437
LIBPERL_A MYEXTLIB
438438
FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE
439-
PERLMAINCC PERL_SRC PERL_INC PERL_INCDEP
439+
PERLMAINCC PERL_SRC PERL_INC
440440
PERL FULLPERL ABSPERL
441441
PERLRUN FULLPERLRUN ABSPERLRUN
442442
PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST
443443
PERL_CORE
444444
PERM_DIR PERM_RW PERM_RWX
445445
446-
) )
446+
))
447447
{
448448
next unless defined $self->{$macro};
449449

@@ -493,16 +493,6 @@ SDKROOT := $(shell xcrun --show-sdk-path)
493493
PERL_SYSROOT = $(SDKROOT)
494494
} if $Is{ApplCor} && $self->{'PERL_INC'} =~ m!^/System/Library/Perl/!;
495495

496-
push @m, q{
497-
# Where is the Config information that we are using/depend on
498-
CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_SYSROOT)$(PERL_INCDEP)$(DFSEP)config.h
499-
} if $Is{ApplCor};
500-
501-
push @m, q{
502-
# Where is the Config information that we are using/depend on
503-
CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_INCDEP)$(DFSEP)config.h
504-
} if -e $self->catfile( $self->{PERL_INC}, 'config.h' ) && !$Is{ApplCor};
505-
506496
push @m, qq{
507497
# Where to build things
508498
INST_LIBDIR = $self->{INST_LIBDIR}
@@ -520,17 +510,53 @@ INST_BOOT = $self->{INST_BOOT}
520510
# Extra linker info
521511
EXPORT_LIST = $self->{EXPORT_LIST}
522512
PERL_ARCHIVE = $self->{PERL_ARCHIVE}
523-
PERL_ARCHIVEDEP = $self->{PERL_ARCHIVEDEP}
524513
PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}
525514
};
526515

527516
push @m, "
528517
529518
TO_INST_PM = ".$self->wraplist(map $self->quote_dep($_), sort keys %{$self->{PM}})."\n";
530519

531-
join('',@m);
520+
join('', @m) . $self->dep_constants;
532521
}
533522

523+
=item dep_constants (o)
524+
525+
my $make_frag = $mm->dep_constants;
526+
527+
Prints out macros for dependency constants.
528+
529+
=cut
530+
531+
sub dep_constants {
532+
my ($self) = @_;
533+
my @m = ();
534+
for my $macro (qw(PERL_ARCHLIBDEP PERL_INCDEP)) {
535+
next unless defined $self->{$macro};
536+
# pathnames can have sharp signs in them; escape them so
537+
# make doesn't think it is a comment-start character.
538+
$self->{$macro} =~ s/#/\\#/g;
539+
$self->{$macro} = $self->quote_dep($self->{$macro})
540+
if $ExtUtils::MakeMaker::macro_dep{$macro};
541+
push @m, "$macro = $self->{$macro}\n";
542+
}
543+
544+
push @m, qq{
545+
\n# Dependencies info
546+
PERL_ARCHIVEDEP = $self->{PERL_ARCHIVEDEP}
547+
};
548+
549+
push @m, q{
550+
# Where is the Config information that we are using/depend on
551+
CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_SYSROOT)$(PERL_INCDEP)$(DFSEP)config.h
552+
} if $Is{ApplCor};
553+
push @m, q{
554+
# Where is the Config information that we are using/depend on
555+
CONFIGDEP = $(PERL_ARCHLIBDEP)$(DFSEP)Config.pm $(PERL_INCDEP)$(DFSEP)config.h
556+
} if -e $self->catfile( $self->{PERL_INC}, 'config.h' ) && !$Is{ApplCor};
557+
558+
join '', @m;
559+
}
534560

535561
=item depend (o)
536562
@@ -3946,21 +3972,24 @@ sub tool_xsubpp {
39463972

39473973

39483974
$self->{XSPROTOARG} = "" unless defined $self->{XSPROTOARG};
3975+
$self->tool_xsubpp_emit($xsdir, \@tmdeps, \@tmargs);
3976+
}
3977+
3978+
sub tool_xsubpp_emit {
3979+
my ($self, $xsdir, $tmdeps, $tmargs) = @_;
39493980
my $xsdirdep = $self->quote_dep($xsdir);
39503981
# -dep for use when dependency not command
3951-
39523982
return qq{
39533983
XSUBPPDIR = $xsdir
39543984
XSUBPP = "\$(XSUBPPDIR)\$(DFSEP)xsubpp"
39553985
XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
39563986
XSPROTOARG = $self->{XSPROTOARG}
3957-
XSUBPPDEPS = @tmdeps $xsdirdep\$(DFSEP)xsubpp
3958-
XSUBPPARGS = @tmargs
3987+
XSUBPPDEPS = @$tmdeps $xsdirdep\$(DFSEP)xsubpp
3988+
XSUBPPARGS = @$tmargs
39593989
XSUBPP_EXTRA_ARGS =
39603990
};
39613991
}
39623992

3963-
39643993
=item all_target
39653994
39663995
Build man pages, too

lib/ExtUtils/MM_Win32.pm

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,62 @@ MAXLINELENGTH = $size
274274
return $prefix . $make_text;
275275
}
276276

277+
=item dep_constants
278+
279+
Makes dependencies that work for nmake.
280+
281+
=cut
282+
283+
sub dep_constants {
284+
my ($self) = @_;
285+
return $self->SUPER::dep_constants if !$self->is_make_type('nmake');
286+
my @m = ();
287+
for my $macro (qw(PERL_ARCHLIBDEP PERL_INCDEP)) {
288+
next unless defined $self->{$macro};
289+
# pathnames can have sharp signs in them; escape them so
290+
# make doesn't think it is a comment-start character.
291+
$self->{$macro} =~ s/#/\\#/g;
292+
$self->{$macro} = $self->quote_dep($self->{$macro})
293+
if $ExtUtils::MakeMaker::macro_dep{$macro};
294+
push @m, "$macro = $self->{$macro}\n";
295+
}
296+
push @m, qq{
297+
\n# Dependencies info
298+
PERL_ARCHIVEDEP = "$self->{PERL_ARCHIVE}"
299+
};
300+
push @m, qq{
301+
# Where is the Config information that we are using/depend on
302+
CONFIGDEP = "\$(PERL_ARCHLIB)\$(DFSEP)Config.pm" "\$(PERL_INC)\$(DFSEP)config.h"
303+
} if -e $self->catfile($self->{PERL_INC}, 'config.h');
304+
join '', @m;
305+
}
306+
307+
sub _perl_header_files_fragment {
308+
my ($self, $separator) = @_;
309+
return $self->SUPER::_perl_header_files_fragment($separator)
310+
if !$self->is_make_type('nmake');
311+
return join("\\\n",
312+
"PERL_HDRS = ",
313+
map sprintf(" \"\$(PERL_INC)\\%s\" ", $_),
314+
$self->_perl_header_files
315+
) . "\n\n"
316+
. "\$(OBJECT) : \$(PERL_HDRS)\n";
317+
}
318+
319+
sub tool_xsubpp_emit {
320+
my ($self, $xsdir, $tmdeps, $tmargs) = @_;
321+
return $self->SUPER::tool_xsubpp_emit($xsdir, $tmdeps, $tmargs)
322+
if !$self->is_make_type('nmake');
323+
return qq{
324+
XSUBPPDIR = $xsdir
325+
XSUBPP = "\$(XSUBPPDIR)\$(DFSEP)xsubpp"
326+
XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
327+
XSPROTOARG = $self->{XSPROTOARG}
328+
XSUBPPDEPS = @$tmdeps \$(XSUBPP)
329+
XSUBPPARGS = @$tmargs
330+
XSUBPP_EXTRA_ARGS =
331+
};
332+
}
277333

278334
=item special_targets
279335
@@ -409,7 +465,7 @@ sub perl_script {
409465

410466
sub can_dep_space {
411467
my ($self) = @_;
412-
return 1 if $self->is_make_type('gmake'); # GNU Make is fine
468+
return 1 if !$self->is_make_type('dmake'); # GNU & n-make are fine
413469
return 0 unless $self->can_load_xs;
414470
require Win32;
415471
require File::Spec;
@@ -426,17 +482,17 @@ sub can_dep_space {
426482

427483
sub quote_dep {
428484
my ($self, $arg) = @_;
429-
if ($arg =~ / / and not $self->is_make_type('gmake')) {
430-
require Win32;
431-
$arg = Win32::GetShortPathName($arg);
432-
die <<EOF if not defined $arg or $arg =~ / /;
433-
Tried to use make dependency with space for non-GNU make:
485+
return $arg if $arg !~ / /;
486+
return $self->SUPER::quote_dep($arg) if $self->is_make_type('gmake');
487+
return qq{"$arg"} if $self->is_make_type('nmake');
488+
require Win32; # dmake, get 8.3 name
489+
$arg = Win32::GetShortPathName($arg);
490+
die <<EOF if not defined $arg or $arg =~ / /;
491+
Tried to use make dependency with space for dmake:
434492
'$arg'
435493
Fallback to short pathname failed.
436494
EOF
437-
return $arg;
438-
}
439-
return $self->SUPER::quote_dep($arg);
495+
$arg;
440496
}
441497

442498

0 commit comments

Comments
 (0)