3 # Wherein we ensure the INST_* and INSTALL* variables are set correctly
4 # when various PREFIX variables are set.
6 # Essentially, this test is a Makefile.PL.
9 if( $ENV{PERL_CORE} ) {
11 @INC = ('../lib', 'lib');
14 unshift @INC, 't/lib';
19 use Test::More tests => 52;
20 use MakeMaker::Test::Utils;
21 use MakeMaker::Test::Setup::BFD;
22 use ExtUtils::MakeMaker;
27 my $Is_VMS = $^O eq 'VMS';
35 my $Makefile = makefile_name;
36 my $Curdir = File::Spec->curdir;
37 my $Updir = File::Spec->updir;
39 ok( setup_recurs(), 'setup' );
41 ok( chdir File::Spec->updir );
42 ok( teardown_recurs(), 'teardown' );
45 ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
46 diag("chdir failed: $!");
48 my $stdout = tie *STDOUT, 'TieOut' or die;
50 my $mm = WriteMakefile(
52 VERSION_FROM => 'lib/Big/Dummy.pm',
54 PERL_CORE => $ENV{PERL_CORE},
57 like( $stdout->read, qr{
58 Writing\ $Makefile\ for\ Big::Liar\n
61 INST_ARCHLIB\ =\ \S+\n
62 Writing\ $Makefile\ for\ Big::Dummy\n
65 is( $mm->{PREFIX}, '$(SITEPREFIX)', 'PREFIX set based on INSTALLDIRS' );
67 isa_ok( $mm, 'ExtUtils::MakeMaker' );
69 is( $mm->{NAME}, 'Big::Dummy', 'NAME' );
70 is( $mm->{VERSION}, 0.01, 'VERSION' );
72 foreach my $prefix (qw(PREFIX PERLPREFIX SITEPREFIX VENDORPREFIX)) {
73 unlike( $mm->{$prefix}, qr/\$\(PREFIX\)/ );
77 my $PREFIX = File::Spec->catdir('foo', 'bar');
80 VERSION_FROM => 'lib/Big/Dummy.pm',
82 PERL_CORE => $ENV{PERL_CORE},
85 like( $stdout->read, qr{
86 Writing\ $Makefile\ for\ Big::Liar\n
89 INST_ARCHLIB\ =\ \S+\n
90 Writing\ $Makefile\ for\ Big::Dummy\n
95 is( $mm->{PREFIX}, $PREFIX, 'PREFIX' );
97 foreach my $prefix (qw(PERLPREFIX SITEPREFIX VENDORPREFIX)) {
98 is( $mm->{$prefix}, '$(PREFIX)', "\$(PREFIX) overrides $prefix" );
101 is( !!$mm->{PERL_CORE}, !!$ENV{PERL_CORE}, 'PERL_CORE' );
103 my($perl_src, $mm_perl_src);
104 if( $ENV{PERL_CORE} ) {
105 $perl_src = File::Spec->catdir($Updir, $Updir);
106 $perl_src = File::Spec->canonpath($perl_src);
107 $mm_perl_src = File::Spec->canonpath($mm->{PERL_SRC});
110 $mm_perl_src = $mm->{PERL_SRC};
113 is( $mm_perl_src, $perl_src, 'PERL_SRC' );
116 # Every INSTALL* variable must start with some PREFIX.
118 PERL => [qw(archlib privlib bin man1dir man3dir script)],
119 SITE => [qw(sitearch sitelib sitebin siteman1dir siteman3dir)],
120 VENDOR => [qw(vendorarch vendorlib vendorbin vendorman1dir vendorman3dir)]
123 while( my($type, $vars) = each %Install_Vars) {
125 skip "VMS must expand macros in INSTALL* vars", scalar @$vars
127 skip '$Config{usevendorprefix} not set', scalar @$vars
128 if $type eq 'VENDOR' and !$Config{usevendorprefix};
130 foreach my $var (@$vars) {
131 my $installvar = "install$var";
132 my $prefix = '$('.$type.'PREFIX)';
135 skip uc($installvar).' set to another INSTALL variable', 1
136 if $mm->{uc $installvar} =~ /^\$\(INSTALL.*\)$/;
138 # support for man page skipping
139 $prefix = 'none' if $type eq 'PERL' &&
141 !$Config{$installvar};
142 like( $mm->{uc $installvar}, qr/^\Q$prefix\E/,
149 # Check that when installman*dir isn't set in Config no man pages
152 undef *ExtUtils::MM_Unix::Config;
153 undef *ExtUtils::MM_Unix::Config_Override;
154 %ExtUtils::MM_Unix::Config = %Config;
155 *ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;
157 _set_config(installman1dir => '');
158 _set_config(installman3dir => '');
160 my $wibble = File::Spec->catdir(qw(wibble and such));
161 my $stdout = tie *STDOUT, 'TieOut' or die;
162 my $mm = WriteMakefile(
163 NAME => 'Big::Dummy',
164 VERSION_FROM => 'lib/Big/Dummy.pm',
166 PERL_CORE => $ENV{PERL_CORE},
168 INSTALLMAN1DIR=> $wibble,
171 is( $mm->{INSTALLMAN1DIR}, $wibble );
172 is( $mm->{INSTALLMAN3DIR}, 'none' );
175 # Check that when installvendorman*dir is set in Config it is honored
178 undef *ExtUtils::MM_Unix::Config;
179 undef *ExtUtils::MM_Unix::Config_Override;
180 undef *ExtUtils::MM_VMS::Config;
182 %ExtUtils::MM_Unix::Config = %Config;
183 *ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;
185 _set_config(installvendorman1dir => File::Spec->catdir('foo','bar') );
186 _set_config(installvendorman3dir => '' );
187 _set_config(usevendorprefix => 1 );
188 _set_config(vendorprefixexp => 'something' );
190 my $stdout = tie *STDOUT, 'TieOut' or die;
191 my $mm = WriteMakefile(
192 NAME => 'Big::Dummy',
193 VERSION_FROM => 'lib/Big/Dummy.pm',
195 PERL_CORE => $ENV{PERL_CORE},
197 # In case the local installation doesn't have man pages.
198 INSTALLMAN1DIR=> 'foo/bar/baz',
199 INSTALLMAN3DIR=> 'foo/bar/baz',
202 is( $mm->{INSTALLVENDORMAN1DIR}, File::Spec->catdir('foo','bar'),
203 'installvendorman1dir (in %Config) not modified' );
204 isnt( $mm->{INSTALLVENDORMAN3DIR}, '',
205 'installvendorman3dir (not in %Config) set' );
208 # Check that when installsiteman*dir isn't set in Config it falls back
211 undef *ExtUtils::MM_Unix::Config;
212 undef *ExtUtils::MM_Unix::Config_Override;
213 %ExtUtils::MM_Unix::Config = %Config;
214 *ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;
216 _set_config(installman1dir => File::Spec->catdir('foo', 'bar') );
217 _set_config(installman3dir => File::Spec->catdir('foo', 'baz') );
218 _set_config(installsiteman1dir => '' );
219 _set_config(installsiteman3dir => '' );
220 _set_config(installvendorman1dir => '' );
221 _set_config(installvendorman3dir => '' );
222 _set_config(usevendorprefix => 'define' );
223 _set_config(vendorprefixexp => 'something' );
225 my $wibble = File::Spec->catdir(qw(wibble and such));
226 my $stdout = tie *STDOUT, 'TieOut' or die;
227 my $mm = WriteMakefile(
228 NAME => 'Big::Dummy',
229 VERSION_FROM => 'lib/Big/Dummy.pm',
230 PERL_CORE => $ENV{PERL_CORE},
233 is( $mm->{INSTALLMAN1DIR}, File::Spec->catdir('foo', 'bar') );
234 is( $mm->{INSTALLMAN3DIR}, File::Spec->catdir('foo', 'baz') );
236 skip "VMS must expand macros in INSTALL* vars", 4 if $Is_VMS;
237 is( $mm->{INSTALLSITEMAN1DIR}, '$(INSTALLMAN1DIR)' );
238 is( $mm->{INSTALLSITEMAN3DIR}, '$(INSTALLMAN3DIR)' );
239 is( $mm->{INSTALLVENDORMAN1DIR}, '$(INSTALLMAN1DIR)' );
240 is( $mm->{INSTALLVENDORMAN3DIR}, '$(INSTALLMAN3DIR)' );
245 # Check that when usevendoprefix and installvendorman*dir aren't set in
246 # Config it leaves them unset.
248 undef *ExtUtils::MM_Unix::Config;
249 undef *ExtUtils::MM_Unix::Config_Override;
250 %ExtUtils::MM_Unix::Config = %Config;
251 *ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;
253 _set_config(installman1dir => File::Spec->catdir('foo', 'bar') );
254 _set_config(installman3dir => File::Spec->catdir('foo', 'baz') );
255 _set_config(installsiteman1dir => '' );
256 _set_config(installsiteman3dir => '' );
257 _set_config(installvendorman1dir => '' );
258 _set_config(installvendorman3dir => '' );
259 _set_config(usevendorprefix => '' );
260 _set_config(vendorprefixexp => '' );
262 my $wibble = File::Spec->catdir(qw(wibble and such));
263 my $stdout = tie *STDOUT, 'TieOut' or die;
264 my $mm = WriteMakefile(
265 NAME => 'Big::Dummy',
266 VERSION_FROM => 'lib/Big/Dummy.pm',
267 PERL_CORE => $ENV{PERL_CORE},
270 is( $mm->{INSTALLMAN1DIR}, File::Spec->catdir('foo', 'bar') );
271 is( $mm->{INSTALLMAN3DIR}, File::Spec->catdir('foo', 'baz') );
273 skip "VMS must expand macros in INSTALL* vars", 2 if $Is_VMS;
274 is( $mm->{INSTALLSITEMAN1DIR}, '$(INSTALLMAN1DIR)' );
275 is( $mm->{INSTALLSITEMAN3DIR}, '$(INSTALLMAN3DIR)' );
277 is( $mm->{INSTALLVENDORMAN1DIR}, '' );
278 is( $mm->{INSTALLVENDORMAN3DIR}, '' );
284 (my $k_no_install = $k) =~ s/^install//i;
285 $ExtUtils::MM_Unix::Config{$k} = $v;
287 # Because VMS's config has traditionally been underpopulated, it will
288 # fall back to the install-less versions in desperation.
289 $ExtUtils::MM_Unix::Config{$k_no_install} = $v if $Is_VMS;