Skip to content

Commit fc03f82

Browse files
committed
WriteEmptyMakefile rmtree _eumm, clean target removes Makefile
1 parent e2b48f8 commit fc03f82

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/ExtUtils/MakeMaker.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,10 @@ sub WriteEmptyMakefile {
818818
croak "WriteEmptyMakefile: Need an even number of args" if @_ % 2;
819819

820820
my %att = @_;
821+
$att{NAME} = 'Dummy' unless $att{NAME}; # eliminate pointless warnings
821822
my $self = MM->new(\%att);
823+
require File::Path;
824+
File::Path::rmtree '_eumm'; # because MM->new does too much stuff
822825

823826
my $new = $self->{MAKEFILE};
824827
my $old = $self->{MAKEFILE_OLD};
@@ -829,7 +832,7 @@ sub WriteEmptyMakefile {
829832
_rename($new, $old) or warn "rename $new => $old: $!"
830833
}
831834
open my $mfh, '>', $new or die "open $new for write: $!";
832-
print $mfh <<'EOP';
835+
printf $mfh <<'EOP', $self->{RM_F}, $self->{MAKEFILE};
833836
all :
834837
835838
pure_nolink :
@@ -838,7 +841,10 @@ dynamic :
838841
839842
static :
840843
844+
realclean : clean
845+
841846
clean :
847+
%s %s
842848
843849
install :
844850

t/WriteEmptyMakefile.t

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ use Cwd; my $cwd = getcwd; END { chdir $cwd } # so File::Temp can cleanup
1212
chdir $tmpdir;
1313

1414
use strict;
15-
use Test::More tests => 5;
15+
use Test::More tests => 6;
1616

1717
use ExtUtils::MakeMaker qw(WriteEmptyMakefile);
1818
use TieOut;
1919

2020
can_ok __PACKAGE__, 'WriteEmptyMakefile';
2121

2222
eval { WriteEmptyMakefile("something"); };
23-
like $@, qr/Need an even number of args/;
24-
23+
like $@, qr/Need an even number of args/, 'correct exception';
2524

2625
{
27-
ok( my $stdout = tie *STDOUT, 'TieOut' );
26+
ok( (my $stdout = tie *STDOUT, 'TieOut' ), 'tie stdout');
2827

29-
ok !-e 'wibble';
28+
ok !-e 'wibble', 'no wibble';
3029
END { 1 while unlink 'wibble' }
3130

3231
WriteEmptyMakefile(
3332
NAME => "Foo",
3433
FIRST_MAKEFILE => "wibble",
3534
);
36-
ok -e 'wibble';
35+
ok -e 'wibble', 'yes wibble';
36+
ok !-d '_eumm', 'no _eumm lying around';
3737
}

0 commit comments

Comments
 (0)