Apache-Bootstrap
view release on metacpan or search on metacpan
lib/Apache/Bootstrap.pm view on Meta::CPAN
( $selected == 2 ) ? 'ModPerl::BuildMM' : 'ExtUtils::MakeMaker';
eval "require $build_pkg";
die "could not require package $build_pkg: $@" if $@;
$self->{maker} = $build_pkg;
return $self->{mp_gen} = $selected;
}
# _wanted_mp_generation()
#
# the function looks at %ENV and Makefile.PL option to figure out
# whether a specific mod_perl generation was requested.
# It uses the following logic:
# via options:
# perl Makefile.PL MOD_PERL=2
# or via %ENV:
# env MOD_PERL=1 perl Makefile.PL
#
# return value is:
# 1 or 2 if the specification was found (mp 1 and mp 2 respectively)
# 0 otherwise
# Currently the logic for determining the mod_perl generation
# is as follows.
# If a specific generation was passed as an argument,
# if satisfied
# return the same generation
# else
# die
# else @ARGV and %ENV will be checked for specific orders
# if the specification will be found
# if satisfied
# return the specified generation
# else
# die
# else if any mp generation is found
# return it
# else
# die
sub _wanted_mp_generation {
my $self = shift;
# check if we have a command line specification
# flag: 0: unknown, 1: mp1, 2: mp2
my $flag = 0;
foreach my $key (@ARGV) {
if ( $key =~ /^MOD_PERL=([12])$/ ) {
$flag = $1;
}
}
# check %ENV
my $env = exists $ENV{MOD_PERL} ? $ENV{MOD_PERL} : 0;
# check for contradicting requirements
if ( $env && $flag && $flag != $env ) {
warn <<EOF;
Can\'t decide which mod_perl version should be used, since you have
supplied contradicting requirements:
enviroment variable MOD_PERL=$env
Makefile.PL option MOD_PERL=$flag
EOF
die;
}
my $wanted = 0;
$wanted = 2 if $env == 2 || $flag == 2;
$wanted = 1 if $env == 1 || $flag == 1;
unless ($wanted) {
# if still unknown try to require mod_perl2.pm
eval { require mod_perl2 };
if ($@) {
# if we don't have mp2, check for mp1
eval { require mod_perl } if ($@);
unless ($@) {
$wanted = 1;
}
}
else {
$wanted = 2;
}
}
return $wanted;
}
=head2 apache_major_version()
$apache_major_version = $bootstrap->apache_major_version;
The major version number of the target apache install
=cut
sub apache_major_version {
return ( shift->{mp_gen} == 1 ) ? 'Apache' : 'Apache2';
}
=head2 WriteMakefile()
$bootstrap->write_makefile( %makefile_options );
Writes the makefile using the appropriate make engine depending on what
mod_perl version is in use. Same API as ExtUtils::MakeMaker or ModPerl::BuildMM
=cut
sub WriteMakefile {
my ( $self, %maker_opts ) = @_;
# write the makefile
my $sub = "$self->{maker}\:\:WriteMakefile";
{
no strict 'refs';
$sub->(%maker_opts);
( run in 2.114 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )