Apache-Reload

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

    # 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=(\d)$/) {
            $flag = $1;
        }
    }

    # check %ENV
    my $env = exists $ENV{MOD_PERL} ? $ENV{MOD_PERL} : 0;

    # check for contradicting requirements
    if ($env && $flag && $flag != $env) {
        die <<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
    }

    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_perl.pm
        eval { require mod_perl };
        if ($@) {
            # if we don't have mp1, check for mp2
            # see if we are in the mp2 build structure
            eval { require File::Spec };
            unless ($@) {
                my $mplib = File::Spec->catdir('..', 'lib');
                unshift @INC, $mplib if -e File::Spec->catfile($mplib,'mod_perl2.pm');
                my $atlib = File::Spec->catdir('../', 'Apache-Test', 'lib');
                unshift @INC, $atlib if -d $atlib;
            } 

            eval { require mod_perl2 };
            unless ($@) {
                $wanted = 2;
            }
        }
        else {
            $wanted = 1;
        }
    }

    return $wanted;
}

package MY;

sub postamble {
    my $self = shift;

    my $q = ($^O =~ /MSWin32/i ? '"' : "'");

    my $string = $self->SUPER::postamble;

    $string .= <<"EOF";
tag :
	svn copy -m $q\$(VERSION_SYM) tag$q https://svn.apache.org/repos/asf/perl/Apache-Reload/trunk https://svn.apache.org/repos/asf/perl/Apache-Reload/tags/\$(VERSION_SYM)
EOF

    return $string;
}

sub test {
    my $self = shift;

    eval { require Test::More } or return <<EOF;
test::
\t\@echo sorry, cannot run tests without Test::More
EOF

    return $self->Apache::TestMM::test(@_) if $HAS_APACHE_TEST;

    return <<EOF
test::
\t\@echo
\t\@echo sorry, cannot run tests without a properly
\t\@echo configured Apache-Test environment, mininum
\t\@echo Apache::Test version needed is $at_min_ver
\t\@echo
EOF
}

sub clean {
    my $self = shift;

    return $self->Apache::TestMM::clean(@_) if $HAS_APACHE_TEST;

    return $self->SUPER::clean(@_);
}

sub constants {
    my $self = shift;

    my $string = $self->MM::constants;

    # mp2 installs this into INSTALLSITEARCH, so in order to avoid
    # problems when users forget 'make install UNINST=1', trick MM into
    # installing pure perl modules to the sitearch location, when this is
    # not installed as a part of mp2 build
    if (!$ENV{MOD_PERL_2_BUILD}) {
        $string .= <<'EOI';

# install into the same location as mod_perl 2.0
INSTALLSITELIB = $(INSTALLSITEARCH)
DESTINSTALLSITELIB = $(DESTINSTALLSITEARCH)
EOI
    }

    $string;
}



( run in 2.208 seconds using v1.01-cache-2.11-cpan-0bb4e1dffa6 )