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
|
#!/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 {
if( $ENV{PERL_CORE} ) {
chdir 't' if -d 't';
@INC = ('../lib', 'lib');
}
else {
unshift @INC, 't/lib';
}
}
use strict;
use Test::More tests => 38;
use MakeMaker::Test::Utils;
use ExtUtils::MakeMaker;
use File::Spec;
use TieOut;
use Config;
my $Is_VMS = $^O eq 'VMS';
chdir 't';
perl_lib;
$| = 1;
my $Makefile = makefile_name;
my $Curdir = File::Spec->curdir;
my $Updir = File::Spec->updir;
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{
Writing\ $Makefile\ for\ Big::Liar\n
Big::Liar's\ vars\n
INST_LIB\ =\ \S+\n
INST_ARCHLIB\ =\ \S+\n
Writing\ $Makefile\ for\ Big::Dummy\n
}x );
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\)/ );
like( $mm->{$prefix}, qr/^\$\(DESTDIR\)/,
"\$(DESTDIR) prepended to $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{
Writing\ $Makefile\ for\ Big::Liar\n
Big::Liar's\ vars\n
INST_LIB\ =\ \S+\n
INST_ARCHLIB\ =\ \S+\n
Writing\ $Makefile\ for\ Big::Dummy\n
}x );
undef $stdout;
untie *STDOUT;
is( $mm->{PREFIX}, '$(DESTDIR)'.$PREFIX, 'PREFIX' );
foreach my $prefix (qw(PERLPREFIX SITEPREFIX VENDORPREFIX)) {
is( $mm->{$prefix}, '$(DESTDIR)$(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);
$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: foreach my $var (@$vars) {
skip "VMS must expand macros in INSTALL* vars", scalar @$vars
if $Is_VMS;
my $prefix = '$('.$type.'PREFIX)';
# support for man page skipping
$prefix = 'none' if $type eq 'PERL' &&
$var =~ /man/ &&
!$Config{"install$var"};
like( $mm->{uc "install$var"}, qr/^\Q$prefix\E/, "$prefix + $var" );
}
}
# Check that when installman*dir isn't set in Config no man pages
# are generated.
{
undef *ExtUtils::MM_Unix::Config;
%ExtUtils::MM_Unix::Config = %Config;
$ExtUtils::MM_Unix::Config{installman1dir} = '';
$ExtUtils::MM_Unix::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' );
}
|