Revision: 9
Author: phred_moyer
Date: 2006-03-31 00:01:03 -0800 (Fri, 31 Mar 2006)
ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=9&view=rev
Log Message:
-----------
Add mp2 compatiblity. Use different approaches for mp1 and mp2, mp2
approache inspired by Apache::Peek. Merge these compatibility changes
with an updated mp1 Makefile.PL from Thomas Klausner.
Modified Paths:
--------------
trunk/Makefile.PL
Modified: trunk/Makefile.PL
===================================================================
--- trunk/Makefile.PL 2006-03-31 07:50:07 UTC (rev 8)
+++ trunk/Makefile.PL 2006-03-31 08:01:03 UTC (rev 9)
@@ -1,129 +1,145 @@
-package Apache::Dispatch;
+#!perl
-use ExtUtils::MakeMaker;
-
require 5.005;
-eval {
- require Apache::ExtUtils;
- require Apache::src;
-};
+use strict;
+use warnings FATAL => 'all';
-my %makefile_params=(
- 'NAME' => __PACKAGE__,
- 'VERSION_FROM' => 'Dispatch.pm',
- );
+## which mp version ( 1.2x or 2.0.x)
+my ($mp_wanted, $mp_ver) = &get_mp_ver();
-
+print STDERR "Using mod_perl/$mp_ver\n\n";
-if ($@ || $ENV{DISPATCH_PUREPERL}) {
- print "\nBuilding without Custom Apache Directives, use 'PerlSetVar' for configuration.\n\n";
+my %prereq = ('Apache::Test' => "1.23");
- $makefile_params{'PL_FILES'}={'set_pureperl.PL'=>'1'};
- $makefile_params{'C'}=[];
-
-} else {
- print "\nBuilding with Custom Apache Directives ('DispatchPrefix'). You
+my %makefile_params = (
+ 'VERSION' => '0.10',
+ 'PREREQ_PM' => \%prereq,
+ );
+
+# enable "make test"
+require Apache::TestMM;
+Apache::TestMM->import(qw(test clean));
+
+# accept configs from command line.
+Apache::TestMM::filter_args();
+
+my @scripts = qw(t/TEST);
+Apache::TestMM::generate_script(@scripts);
+
+$makefile_params{clean} = {FILES => "@scripts"};
+
+if ($mp_wanted == 2) { # mod_perl2 specific makefile
+ $prereq{'mod_perl'} = 1.99023; # this covers the naming change
+ $makefile_params{'NAME'} = 'Apache2::Dispatch';
+
+ require ModPerl::MM;
+ ModPerl::MM::WriteMakefile(%makefile_params);
+}
+
+elsif ($mp_wanted != 2) { # mod_perl1 specific makefile
+
+ eval {
+ require Apache::ExtUtils;
+ require Apache::src;
+ };
+
+ if ($@ || $ENV{DISPATCH_PUREPERL}) {
+ print
+"\nBuilding without Custom Apache Directives, use 'PerlSetVar' for configuration.\n\n";
+
+ $makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '1'};
+ $makefile_params{'C'} = [];
+
+ }
+ else {
+ print "\nBuilding with Custom Apache Directives ('DispatchPrefix'). You
will need a C compiler and Apache/mod_perl sources.\n\n";
-
- import Apache::ExtUtils qw(command_table);
-
- my @directives = (
- #------------------------------------------------------------------
- # DispatchPrefix defines the base class for a given <Location>
- #------------------------------------------------------------------
- { name => 'DispatchPrefix',
- errmsg => 'a class to be used as the base class',
- args_how => 'TAKE1',
- req_override => 'OR_ALL', },
+ import Apache::ExtUtils qw(command_table);
- #------------------------------------------------------------------
- # DispatchExtras defines the extra dispatch methods to enable
- #------------------------------------------------------------------
- { name => 'DispatchExtras',
- errmsg => 'choose any of: Pre, Post, or Error',
- args_how => 'ITERATE',
- req_override => 'OR_ALL', },
+ require Apache::Dispatch;
+ my $directives = Apache::Dispatch->directives;
+ Apache::Extutils::command_table($directives);
- #------------------------------------------------------------------
- # DispatchStat enables module testing and subsequent reloading
- #------------------------------------------------------------------
- { name => 'DispatchStat',
- errmsg => 'choose one of On, Off, or ISA',
- args_how => 'TAKE1',
- req_override => 'OR_ALL', },
+ my $inc = Apache::src->new->inc;
+ die "Can't find mod_perl header files installed" unless $inc;
- #------------------------------------------------------------------
- # DispatchAUTOLOAD defines AutoLoader behavior
- #------------------------------------------------------------------
- { name => 'DispatchAUTOLOAD',
- errmsg => 'choose one of On or Off',
- args_how => 'FLAG',
- req_override => 'OR_ALL', },
+ $makefile_params{'INC'} = $inc;
+ $makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '0'};
+ $makefile_params{'PREREQ_PM'} = {mod_perl => 1.2401,};
+ $makefile_params{'clean'} = {FILES => '*.xs*'};
+ $makefile_params{'NAME'} = 'Apache2::Dispatch';
- #------------------------------------------------------------------
- # DispatchDebug defines debugging verbosity
- #------------------------------------------------------------------
- { name => 'DispatchDebug',
- errmsg => 'numeric verbosity level',
- args_how => 'TAKE1',
- req_override => 'OR_ALL', },
+ require ExtUtils::MakeMaker;
+ ExtUtils::MakeMaker::WriteMakefile(
+ INC => $inc,
+ LIBS => [''],
+ %makefile_params,
+ );
+ }
+}
- #------------------------------------------------------------------
- # DispatchISA is a list of modules your module should inherit from
- #------------------------------------------------------------------
- { name => 'DispatchISA',
- errmsg => 'a list of parent modules',
- args_how => 'ITERATE',
- req_override => 'OR_ALL', },
+# The next sub inspired by Apache::Peek 1.05
- #------------------------------------------------------------------
- # DispatchLocation allows you to redefine the <Location>
- #------------------------------------------------------------------
- { name => 'DispatchLocation',
- errmsg => 'a location to replace the current <Location>',
- args_how => 'TAKE1',
- req_override => 'OR_ALL', },
+sub get_mp_ver {
- #------------------------------------------------------------------
- # DispatchRequire require()s the class
- #------------------------------------------------------------------
- { name => 'DispatchRequire',
- errmsg => 'choose one of On or Off',
- args_how => 'FLAG',
- req_override => 'OR_ALL', },
+ my $flag = 0;
+ my @args = ();
- #------------------------------------------------------------------
- # DispatchFilter makes the dispatched handler Apache::Filter aware
- #------------------------------------------------------------------
- { name => 'DispatchFilter',
- errmsg => 'choose one of On or Off',
- args_how => 'FLAG',
- req_override => 'OR_ALL', },
+ while (my $arg = shift @ARGV) {
+ if ($arg =~ /^MOD_PERL=([12])$/) {
+ $flag = $1;
+ }
+ else {
+ push @args, $arg;
+ }
+ }
+ @ARGV = @args;
- #------------------------------------------------------------------
- # DispatchUppercase converts the first char of a class to uppercase
- #------------------------------------------------------------------
- { name => 'DispatchUpperCase',
- errmsg => 'choose one of On or Off',
- args_how => 'FLAG',
- req_override => 'OR_ALL', },
+ # 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 = 2; ## default to wanting mp2
+ $wanted = 1 if $env == 1 || $flag == 1;
- command_table(\@directives);
+ my $mp_ver;
- $makefile_params{'PL_FILES'}={'set_pureperl.PL'=>'0'};
-
- $makefile_params{'INC'}=Apache::src->new->inc;
- $makefile_params{'PREREQ_PM'}={ mod_perl => 1.2401, };
- $makefile_params{'clean'}={ FILES => '*.xs*' };
+ if ($wanted == 2) {
+ eval { require mod_perl2 };
+ my $req_ver = 1.999022;
+ if ($mod_perl2::VERSION < $req_ver || $@) {
+ die
+"mod_perl2 required version is $req_ver, you have $mod_perl2::VERSION. Please upgrade to continue.";
+ }
+ else {
+ $mp_ver = $mod_perl2::VERSION;
+ }
+ }
+ else {
+ eval { require mod_perl };
+ no warnings qw(uninitialized);
+ if ($mod_perl::VERSION > 1.99 || $@) {
+ die "You don't seem to have mod_perl 1.0 installed";
+ }
+ else {
+ $mp_ver = $mod_perl::VERSION;
+ }
+ }
+
+ return ($wanted, $mp_ver);
}
-WriteMakefile(%makefile_params);
-
__END__
open (FH,catfile(qw(blib lib Apache Dispatch.pm))) || die "cannot read Dispatch.pm: $!";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|