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 => 36;
20 use MakeMaker::Test::Utils;
21 use ExtUtils::MakeMaker;
26 my $Is_VMS = $^O eq 'VMS';
34 my $Makefile = makefile_name;
35 my $Curdir = File::Spec->curdir;
36 my $Updir = File::Spec->updir;
38 ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
39 diag("chdir failed: $!");
41 my $stdout = tie *STDOUT, 'TieOut' or die;
43 my $mm = WriteMakefile(
45 VERSION_FROM => 'lib/Big/Dummy.pm',
47 PERL_CORE => $ENV{PERL_CORE},
50 like( $stdout->read, qr{
51 Writing\ $Makefile\ for\ Big::Liar\n
54 INST_ARCHLIB\ =\ \S+\n
55 Writing\ $Makefile\ for\ Big::Dummy\n
58 isa_ok( $mm, 'ExtUtils::MakeMaker' );
60 is( $mm->{NAME}, 'Big::Dummy', 'NAME' );
61 is( $mm->{VERSION}, 0.01, 'VERSION' );
63 foreach my $prefix (qw(PREFIX PERLPREFIX SITEPREFIX VENDORPREFIX)) {
64 unlike( $mm->{$prefix}, qr/\$\(PREFIX\)/ );
68 my $PREFIX = File::Spec->catdir('foo', 'bar');
71 VERSION_FROM => 'lib/Big/Dummy.pm',
73 PERL_CORE => $ENV{PERL_CORE},
76 like( $stdout->read, qr{
77 Writing\ $Makefile\ for\ Big::Liar\n
80 INST_ARCHLIB\ =\ \S+\n
81 Writing\ $Makefile\ for\ Big::Dummy\n
86 is( $mm->{PREFIX}, $PREFIX, 'PREFIX' );
88 foreach my $prefix (qw(PERLPREFIX SITEPREFIX VENDORPREFIX)) {
89 is( $mm->{$prefix}, '$(PREFIX)', "\$(PREFIX) overrides $prefix" );
92 is( !!$mm->{PERL_CORE}, !!$ENV{PERL_CORE}, 'PERL_CORE' );
94 my($perl_src, $mm_perl_src);
95 if( $ENV{PERL_CORE} ) {
96 $perl_src = File::Spec->catdir($Updir, $Updir);
97 $perl_src = File::Spec->canonpath($perl_src);
98 $mm_perl_src = File::Spec->canonpath($mm->{PERL_SRC});
101 $mm_perl_src = $mm->{PERL_SRC};
104 is( $mm_perl_src, $perl_src, 'PERL_SRC' );
107 # Every INSTALL* variable must start with some PREFIX.
109 PERL => [qw(archlib privlib bin man1dir man3dir script)],
110 SITE => [qw(sitearch sitelib sitebin siteman1dir siteman3dir)],
111 VENDOR => [qw(vendorarch vendorlib vendorbin vendorman1dir vendorman3dir)]
114 while( my($type, $vars) = each %Install_Vars) {
116 SKIP: foreach my $var (@$vars) {
117 skip "VMS must expand macros in INSTALL* vars", scalar @$vars
120 my $prefix = '$('.$type.'PREFIX)';
122 # support for man page skipping
123 $prefix = 'none' if $type eq 'PERL' &&
125 !$Config{"install$var"};
126 like( $mm->{uc "install$var"}, qr/^\Q$prefix\E/, "$prefix + $var" );
130 # Check that when installman*dir isn't set in Config no man pages
133 undef *ExtUtils::MM_Unix::Config;
134 undef *ExtUtils::MM_Unix::Config_Override;
135 %ExtUtils::MM_Unix::Config = %Config;
136 *ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;
138 $ExtUtils::MM_Unix::Config{installman1dir} = '';
139 $ExtUtils::MM_Unix::Config{installman3dir} = '';
141 my $wibble = File::Spec->catdir(qw(wibble and such));
142 my $stdout = tie *STDOUT, 'TieOut' or die;
143 my $mm = WriteMakefile(
144 NAME => 'Big::Dummy',
145 VERSION_FROM => 'lib/Big/Dummy.pm',
147 PERL_CORE => $ENV{PERL_CORE},
149 INSTALLMAN1DIR=> $wibble,
152 is( $mm->{INSTALLMAN1DIR}, $wibble );
153 is( $mm->{INSTALLMAN3DIR}, 'none' );
156 # Check that when installvendorman*dir is set in Config it is honored
159 undef *ExtUtils::MM_Unix::Config;
160 undef *ExtUtils::MM_Unix::Config_Override;
161 undef *ExtUtils::MM_VMS::Config;
163 %ExtUtils::MM_Unix::Config = %Config;
164 *ExtUtils::MM_VMS::Config = \%ExtUtils::MM_Unix::Config;
166 $ExtUtils::MM_Unix::Config{installvendorman1dir} =
167 File::Spec->catdir('foo','bar');
168 $ExtUtils::MM_Unix::Config{installvendorman3dir} = '';
169 $ExtUtils::MM_Unix::Config{usevendorprefix} = 1;
170 $ExtUtils::MM_Unix::Config{vendorprefixexp} = 'something';
172 my $stdout = tie *STDOUT, 'TieOut' or die;
173 my $mm = WriteMakefile(
174 NAME => 'Big::Dummy',
175 VERSION_FROM => 'lib/Big/Dummy.pm',
177 PERL_CORE => $ENV{PERL_CORE},
179 # In case the local installation doesn't have man pages.
180 INSTALLMAN1DIR=> 'foo/bar/baz',
181 INSTALLMAN3DIR=> 'foo/bar/baz',
184 is( $mm->{INSTALLVENDORMAN1DIR}, File::Spec->catdir('foo','bar'),
185 'installvendorman1dir (in %Config) not modified' );
186 isnt( $mm->{INSTALLVENDORMAN3DIR}, '',
187 'installvendorman3dir (not in %Config) set' );