Apache-SizeLimit

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

use strict;

use Config;

my %prereqs = ();
my %mp2 = ( mod_perl2 => 1.99022 );
my %mp1 = ( mod_perl  => 0 );
my $at_min_ver = 1.36;

my $mp_gen;
# MOD_PERL_2_BUILD is set from building from mod_perl Makefile.PL which should
# also set MP_APXS
if ($ENV{MOD_PERL_2_BUILD}) {
    push @ARGV, "-apxs", $ENV{MP_APXS};
    $mp_gen = satisfy_mp_generation(2);
}
else {
    $mp_gen = satisfy_mp_generation();
}

%prereqs = ($mp_gen == 1 ? %mp1 : %mp2);

unless ( $ARGV[0] eq '--dist' || $ENV{MOD_PERL_2_BUILD} ) {
    if ( $Config{'osname'} eq 'linux' ) {
        $prereqs{'Linux::Pid'} = 0;
    }
    elsif ( $Config{'osname'} =~ /(bsd|aix)/i ) {
        $prereqs{'BSD::Resource'} = 0;
    }
    elsif ( $Config{'osname'} eq 'MSWin32' ) {
        $prereqs{'Win32::API'} = 0;
    }
}

my $HAS_APACHE_TEST = check_for_apache_test();

my $VERSION;
set_apache_sizelimit_version();

my %common_opts = (
                   VERSION         => $VERSION,
                   PREREQ_PM       => \%prereqs,
                   dist            => {
                       COMPRESS => 'gzip -9f', SUFFIX => 'gz',
                       PREOP   => 'find $(DISTVNAME) -type d -print|xargs chmod 0755 && ' .
                                  'find $(DISTVNAME) -type f -print|xargs chmod 0644',
                       TO_UNIX => 'find $(DISTVNAME) -type f -print|xargs dos2unix'
                   },
                   clean           => { FILES => 't/TEST' },
                  );

### MAINTAINER_BUILDING_RELEASE is hack
### for the Release Manager's use only.
### We will set it so that the resulting
### distribution will be called Apache-SizeLimit-\d+.tar.gz
### and NOT Apache2-SizeLimit-\d+.tar.gz
### This is for historical reasons and consistency
if ($mp_gen == 1 || $ENV{MAINTAINER_BUILDING_RELEASE}) {
    require ExtUtils::MakeMaker;
    ExtUtils::MakeMaker::WriteMakefile(
                                       %common_opts,
                                       NAME            => "Apache::SizeLimit",
                                       ABSTRACT_FROM   => 'lib/Apache/SizeLimit.pm',
                                      );

}
else {
    require ModPerl::MM;
    ModPerl::MM::WriteMakefile(
                               %common_opts,
                               NAME            => "Apache2::SizeLimit",
                               ABSTRACT_FROM   => 'lib/Apache2/SizeLimit.pm',
                              );
}

sub check_for_apache_test {
    return unless eval {
        require Apache::Test;
        if ($Apache::Test::VERSION < $at_min_ver) {
            die "Apache::Test version is " . $Apache::Test::VERSION . 
                ", minimum version required is $at_min_ver" . 
                ", tests will be skipped\n";
        }
        require Apache::TestMM;
        require Apache::TestRunPerl;
        1;
    };

    Apache::TestMM::filter_args();

    my %args = @Apache::TestMM::Argv;

    Apache::TestRunPerl->generate_script();

    return 1;
}

sub set_apache_sizelimit_version {
    # We cannot require Apache::SizeLimit or Apache2::SizeLimit to access their
    # $VERSIONs because they depend on Apache::Constants / Apache2::Const and at
    # least the latter cannot be loaded in a command-line script (at least not
    # on Windows, where it fails to load because ModPerl/Const/Const.dll cannot
    # be loaded). Even Apache::SizeLimit::Core cannot be loaded on Windows
    # because it is not implemented on that platform. So instead we use MM's
    # parse_version() method to read the $VERSION for us.
    $VERSION = MM->parse_version('lib/Apache/SizeLimit.pm');



( run in 1.779 second using v1.01-cache-2.11-cpan-39bf76dae61 )