On Sat, 1 Feb 2003, Stas Bekman wrote:
> 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.
This sounds like a great idea, having it in a module like this
... Until that occurs, and becomes available on CPAN, perhaps
something that could be done is having an h2xs-ish tool that
would provide a template authors could use to, in particular,
have a function to detect the mod_perl version right in
Makefile.PL.
Another thing that might be considered is to have a convention
where mod_perl 2 versions are installed under Apache2/, with
mod_perl 1 verions under Apache/. I did this for Apache-GeoIP -
what happens there is, when the mod_perl version is decided, the
appropriate files in the distribution under Apache2/ or Apache/
(corresponding to mod_perl 2 and 1 versions), are then copied to
a lib/ directory, and MakeMaker takes care of the rest.
--
best regards,
randy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]