I'm porting Apache::Peek to 2.0 (which is pretty much done, but relies on various patches to the mod_perl core, which aren't in).

The final distribution package will work with 1.0 and 2.0. At the build time it has to know for which mod_perl we are building it. It'd be nice to devise a common way to do this choice for all 3rd party module writers and even have mod_perl 2.0 provide an API for that.

Currently I do:

Makefile.PL:
------------
[...]
my %args = map {split /=/, $_ } @ARGV;
if ($ENV{MOD_PERL2} || $args{MOD_PERL2}) {
#warn "Looking for mod_perl 2.0";
require Apache2;
require mod_perl;
if ($mod_perl::VERSION < 1.99) {
die "You don't seem to have mod_perl 2.0 installed";
}
$mp_version = 2;
} else {
require mod_perl;
$mp_version = 1;
}
[...]
-------------

so if you run:

perl Makefile.PL MOD_PERL2=1

or have an env var MOD_PERL2=1 set the 2.0 version will be attempted to be built.

If we all use the same convention, a user can define the env var and than things like CPAN.pm will work automatically.

So the above code could be wrapped into an API, which will return the version it should build for and a new version will look like:

Makefile.PL
------------
my $mp_version = ModPerl::MM::build_version();

I don't know whether to require to pass @ARGV. we could make it receive an optional string.

Further build_version() can be smarter and check for both mod_perl versions. And then ask the user which one he wants to use if both present.

The bummer is that 1.0 won't have ModPerl::MM::build_version, but this can be remedied by releasing it on CPAN.

We can go further and write the whole module that will perform WriteMakefile as well for 1.0 and 2.0 transparently for the user and include it in 2.0 and on CPAN for 1.0 users.

The only drawback is that CPAN.pm won't be able to pick it up automatically, since it needs to be installed before WriteMakefile is called.

__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to