1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
#!/usr/bin/perl -w
# Wherein we ensure the INST_* and INSTALL* variables are set correctly
# when various PREFIX variables are set.
#
# Essentially, this test is a Makefile.PL.
BEGIN {
unshift @INC, 't/lib';
}
use strict;
use warnings;
use Test::More tests => 52;
use MakeMaker::Test::Utils;
use MakeMaker::Test::Setup::BFD;
use ExtUtils::MakeMaker;
use File::Spec;
use TieOut;
use ExtUtils::MakeMaker::Config;
my $Is_VMS = $^O eq 'VMS';
chdir 't';
perl_lib; # sets $ENV{PERL5LIB} relative to t/
use File::Temp qw[tempdir];
my $tmpdir = tempdir( DIR => '../t', CLEANUP => 1 );
use Cwd; my $cwd = getcwd; END { chdir $cwd } # so File::Temp can cleanup
chdir $tmpdir;
$| = 1;
my $Makefile = makefile_name;
my $Curdir = File::Spec->curdir;
my $Updir = File::Spec->updir;
ok( setup_recurs(), 'setup' );
END {
ok( chdir File::Spec->updir );
ok( teardown_recurs(), 'teardown' );
}
ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
diag("chdir failed: $!");
my $stdout = tie *STDOUT, 'TieOut' or die;
my $mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
PREREQ_PM => {},
PERL_CORE => $ENV{PERL_CORE},
);
like( $stdout->read, qr{
(?:Generating\ a\ \w+?-style\ $Makefile\n)?
(?:Writing\ $Makefile\ for\ Big::Liar\n)?
(?:Writing\ MYMETA.yml\ and\ MYMETA.json\n)?
Big::Liar's\ vars\n
INST_LIB\ =\ \S+\n
INST_ARCHLIB\ =\ \S+\n
Generating\ a\ \w+?-style\ $Makefile\n
Writing\ $Makefile\ for\ Big::Dummy\n
(?:Writing\ MYMETA.yml\ and\ MYMETA.json\n)?
}x );
is( $mm->{PREFIX}, '$(SITEPREFIX)', 'PREFIX set based on INSTALLDIRS' );
isa_ok( $mm, 'ExtUtils::MakeMaker' );
is( $mm->{NAME}, 'Big::Dummy', 'NAME' );
is( $mm->{VERSION}, 0.01, 'VERSION' );
foreach my $prefix (qw(PREFIX PERLPREFIX SITEPREFIX VENDORPREFIX)) {
unlike( $mm->{$prefix}, qr/\$\(PREFIX\)/ );
}
my $PREFIX = File::Spec->catdir('foo', 'bar');
$mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
PREREQ_PM => {},
PERL_CORE => $ENV{PERL_CORE},
PREFIX => $PREFIX,
);
like( $stdout->read, qr{
(?:Generating\ a\ \w+?-style\ $Makefile\n)?
(?:Writing\ $Makefile\ for\ Big::Liar\n)?
(?:Writing\ MYMETA.yml\ and\ MYMETA.json\n)?
Big::Liar's\ vars\n
INST_LIB\ =\ \S+\n
INST_ARCHLIB\ =\ \S+\n
Generating\ a\ \w+?-style\ $Makefile\n
Writing\ $Makefile\ for\ Big::Dummy\n
(?:Writing\ MYMETA.yml\ and\ MYMETA.json\n)?
}x );
undef $stdout;
untie *STDOUT;
is( $mm->{PREFIX}, $PREFIX, 'PREFIX' );
foreach my $prefix (qw(PERLPREFIX SITEPREFIX VENDORPREFIX)) {
is( $mm->{$prefix}, '$(PREFIX)', "\$(PREFIX) overrides $prefix" );
}
is( !!$mm->{PERL_CORE}, !!$ENV{PERL_CORE}, 'PERL_CORE' );
my($perl_src, $mm_perl_src);
if( $ENV{PERL_CORE} ) {
$perl_src = File::Spec->catdir($Updir, $Updir, $Updir, $Updir, $Updir);
$perl_src = File::Spec->canonpath($perl_src);
$mm_perl_src = File::Spec->canonpath($mm->{PERL_SRC});
}
else {
$mm_perl_src = $mm->{PERL_SRC};
}
is( $mm_perl_src, $perl_src, 'PERL_SRC' );
# Every INSTALL* variable must start with some PREFIX.
my %Install_Vars = (
PERL => [qw(archlib privlib bin man1dir man3dir script)],
SITE => [qw(sitearch sitelib sitebin siteman1dir siteman3dir)],
VENDOR => [qw(vendorarch vendorlib vendorbin vendorman1dir vendorman3dir)]
);
while( my($type, $vars) = each %Install_Vars) {
SKIP: {
skip "VMS must expand macros in INSTALL* vars", scalar @$vars
if $Is_VMS;
skip '$Config{usevendorprefix} not set', scalar @$vars
if $type eq 'VENDOR' and !$Config{usevendorprefix};
foreach my $var (@$vars) {
my $installvar = "install$var";
my $prefix = '$('.$type.'PREFIX)';
SKIP: {
skip uc($installvar).' set to another INSTALL variable', 1
if $mm->{uc $installvar} =~ /^\$\(INSTALL.*\)$/;
# support for man page skipping
$prefix = 'none' if $type eq 'PERL' &&
$var =~ /man/ &&
!$Config{$installvar};
like( $mm->{uc $installvar}, qr/^\Q$prefix\E/,
"$prefix + $var" );
}
}
}
}
# Check that when installman*dir isn't set in Config no man pages
# are generated.
{
_set_config(installman1dir => '');
_set_config(installman3dir => '');
my $wibble = File::Spec->catdir(qw(wibble and such));
my $stdout = tie *STDOUT, 'TieOut' or die;
my $mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
PREREQ_PM => {},
PERL_CORE => $ENV{PERL_CORE},
PREFIX => $PREFIX,
INSTALLMAN1DIR=> $wibble,
);
is( $mm->{INSTALLMAN1DIR}, $wibble );
is( $mm->{INSTALLMAN3DIR}, 'none' );
}
# Check that when installvendorman*dir is set in Config it is honored
# [rt.cpan.org 2949]
{
_set_config(installvendorman1dir => File::Spec->catdir('foo','bar') );
_set_config(installvendorman3dir => '' );
_set_config(usevendorprefix => 1 );
_set_config(vendorprefixexp => 'something' );
my $stdout = tie *STDOUT, 'TieOut' or die;
my $mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
PREREQ_PM => {},
PERL_CORE => $ENV{PERL_CORE},
# In case the local installation doesn't have man pages.
INSTALLMAN1DIR=> 'foo/bar/baz',
INSTALLMAN3DIR=> 'foo/bar/baz',
);
is( $mm->{INSTALLVENDORMAN1DIR}, File::Spec->catdir('foo','bar'),
'installvendorman1dir (in %Config) not modified' );
isnt( $mm->{INSTALLVENDORMAN3DIR}, '',
'installvendorman3dir (not in %Config) set' );
}
# Check that when installsiteman*dir isn't set in Config it falls back
# to installman*dir
{
_set_config(installman1dir => File::Spec->catdir('foo', 'bar') );
_set_config(installman3dir => File::Spec->catdir('foo', 'baz') );
_set_config(installsiteman1dir => '' );
_set_config(installsiteman3dir => '' );
_set_config(installvendorman1dir => '' );
_set_config(installvendorman3dir => '' );
_set_config(usevendorprefix => 'define' );
_set_config(vendorprefixexp => 'something' );
my $wibble = File::Spec->catdir(qw(wibble and such));
my $stdout = tie *STDOUT, 'TieOut' or die;
my $mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
PERL_CORE => $ENV{PERL_CORE},
);
is( $mm->{INSTALLMAN1DIR}, File::Spec->catdir('foo', 'bar') );
is( $mm->{INSTALLMAN3DIR}, File::Spec->catdir('foo', 'baz') );
SKIP: {
skip "VMS must expand macros in INSTALL* vars", 4 if $Is_VMS;
is( $mm->{INSTALLSITEMAN1DIR}, '$(INSTALLMAN1DIR)' );
is( $mm->{INSTALLSITEMAN3DIR}, '$(INSTALLMAN3DIR)' );
is( $mm->{INSTALLVENDORMAN1DIR}, '$(INSTALLMAN1DIR)' );
is( $mm->{INSTALLVENDORMAN3DIR}, '$(INSTALLMAN3DIR)' );
}
}
# Check that when usevendoprefix and installvendorman*dir aren't set in
# Config it leaves them unset.
{
_set_config(installman1dir => File::Spec->catdir('foo', 'bar') );
_set_config(installman3dir => File::Spec->catdir('foo', 'baz') );
_set_config(installsiteman1dir => '' );
_set_config(installsiteman3dir => '' );
_set_config(installvendorman1dir => '' );
_set_config(installvendorman3dir => '' );
_set_config(usevendorprefix => '' );
_set_config(vendorprefixexp => '' );
my $wibble = File::Spec->catdir(qw(wibble and such));
my $stdout = tie *STDOUT, 'TieOut' or die;
my $mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
PERL_CORE => $ENV{PERL_CORE},
);
is( $mm->{INSTALLMAN1DIR}, File::Spec->catdir('foo', 'bar') );
is( $mm->{INSTALLMAN3DIR}, File::Spec->catdir('foo', 'baz') );
SKIP: {
skip "VMS must expand macros in INSTALL* vars", 2 if $Is_VMS;
is( $mm->{INSTALLSITEMAN1DIR}, '$(INSTALLMAN1DIR)' );
is( $mm->{INSTALLSITEMAN3DIR}, '$(INSTALLMAN3DIR)' );
}
is( $mm->{INSTALLVENDORMAN1DIR}, '' );
is( $mm->{INSTALLVENDORMAN3DIR}, '' );
}
sub _set_config {
my($k,$v) = @_;
(my $k_no_install = $k) =~ s/^install//i;
$Config{$k} = $v;
# Because VMS's config has traditionally been underpopulated, it will
# fall back to the install-less versions in desperation.
$Config{$k_no_install} = $v if $Is_VMS;
return;
}
|