? diff ? modperldoc ? out ? docs/Makefile ? docs/Makefile.PL ? docs/api/Makefile ? docs/api/Makefile.PL Index: Makefile.PL =================================================================== RCS file: /home/cvs/modperl-2.0/Makefile.PL,v retrieving revision 1.91 diff -u -r1.91 Makefile.PL --- Makefile.PL 31 Jan 2003 00:52:21 -0000 1.91 +++ Makefile.PL 1 Feb 2003 15:16:47 -0000 @@ -64,6 +64,12 @@ 'lib/Apache2.pm' => 'blib/lib/Apache2.pm', ); +# need to tell MM, which methods we have already overriden, so it +# won't overwrite them +my @overriden_methods = + qw(top_targets install clean test postamble + tool_autosplit manifypods pasthru dist_basics); + ModPerl::MM::WriteMakefile( NAME => 'mod_perl', VERSION => $VERSION, @@ -85,6 +91,7 @@ DIST_DEFAULT => 'mydist', COMPRESS=> 'gzip -9f', SUFFIX=>'gz', }, + overriden_methods => \@overriden_methods, ); post_configure(); @@ -399,7 +406,7 @@ sub MY::top_targets { my $self = shift; - my $string = $self->MM::top_targets; + my $string = $self->ModPerl::MM::MY::top_targets; ModPerl::MM::add_dep(\$string, pure_all => 'modperl_lib'); @@ -468,13 +475,18 @@ } sub MY::postamble { - return <<'EOF'; + my $self = shift; + + my $string = $self->ModPerl::MM::MY::postamble; + $string .= <<'EOF'; + mydist : manifest tardist cvs_tag : cvs tag MODPERL_$(VERSION_SYM) . @echo update mod_perl.pm VERSION now EOF + return $string; } sub MY::tool_autosplit { Index: ModPerl-Registry/Makefile.PL =================================================================== RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/Makefile.PL,v retrieving revision 1.6 diff -u -r1.6 Makefile.PL --- ModPerl-Registry/Makefile.PL 14 May 2002 15:57:14 -0000 1.6 +++ ModPerl-Registry/Makefile.PL 1 Feb 2003 15:16:47 -0000 @@ -26,8 +26,10 @@ PREREQ_PM => \%require, clean => { FILES => "@{ clean_files() }", + overriden_methods => [qw(test clean)], }); sub clean_files { return [@scripts]; } + Index: lib/ModPerl/MM.pm =================================================================== RCS file: /home/cvs/modperl-2.0/lib/ModPerl/MM.pm,v retrieving revision 1.21 diff -u -r1.21 MM.pm --- lib/ModPerl/MM.pm 23 Jun 2002 21:46:54 -0000 1.21 +++ lib/ModPerl/MM.pm 1 Feb 2003 15:16:47 -0000 @@ -6,6 +6,7 @@ use ExtUtils::Install (); use Cwd (); use Apache::Build (); +use File::Spec; our %PM; #add files to installation @@ -17,7 +18,17 @@ sub add_dep { my($string, $targ, $add) = @_; - $$string =~ s/($targ\s+::)/$1 $add /; + $$string =~ s/($targ\s+::)/$1 $add/; +} + +sub add_dep_before { + my($string, $targ, $before_targ, $add) = @_; + $$string =~ s/($targ\s+::.*?) ($before_targ)/$1 $add $2/; +} + +sub add_dep_after { + my($string, $targ, $after_targ, $add) = @_; + $$string =~ s/($targ\s+::.*?$after_targ)/$1 $add/; } sub build_config { @@ -42,13 +53,19 @@ ExtUtils::Install::install($hash, @_); } -#the parent WriteMakefile moves MY:: methods into a different class -#so alias them each time WriteMakefile is called in a subdir - +# the parent WriteMakefile moves MY:: methods into a different class +# so alias them each time WriteMakefile is called in a subdir. +# +# though make sure that we don't override methods which were already +# overriden in Makefile.PL. +# sub my_import { + my %methods = map {$_ => 1} @{+shift}; no strict 'refs'; my $stash = \%{__PACKAGE__ . '::MY::'}; for my $sym (keys %$stash) { + # the caller Makefile.PL may have overriden this method + next if $methods{$sym}; next unless *{$stash->{$sym}}{CODE}; my $name = "MY::$sym"; undef &$name if defined &$name; @@ -56,10 +73,23 @@ } } +# +# a special attribute 'overriden_methods => \@overriden_methods' needs +# to be passed for all MM methods overriden in Makefile.PL. This is to +# prevent their overwriting with ModPerl::MM global methods. Most likely +# the custom overriden MM methods in Makefile.PL should call: +# my $string = $self->ModPerl::MM::MY::"method" (sort of subclassing it) +# +# You should list all the overriden methods, even if at the moment +# they don't exist in ModPerl::MM, they could be added later. sub WriteMakefile { - my $build = build_config(); - my_import(); + my %args = @_; + my $overriden_methods = []; + $overriden_methods = delete $args{overriden_methods} + if exists $args{overriden_methods}; + my_import($overriden_methods); + my $build = build_config(); my $inc = $build->inc; if (my $glue_inc = $build->{MP_XS_GLUE_DIR}) { for (split /\s+/, $glue_inc) { @@ -89,7 +119,12 @@ } push @opts, TYPEMAPS => \@typemaps if @typemaps; - ExtUtils::MakeMaker::WriteMakefile(@opts, @_); + my $clean_files = (exists $args{clean} && exists $args{clean}{FILES}) ? + $args{clean}{FILES} : ''; + $clean_files .= " glue_pods"; # cleanup the dependency target + $args{clean}{FILES} = $clean_files; + + ExtUtils::MakeMaker::WriteMakefile(@opts, %args); } my %always_dynamic = map { $_, 1 } @@ -132,6 +167,86 @@ $self->MM::constants; } +sub ModPerl::MM::MY::top_targets { + my $self = shift; + my $string = $self->MM::top_targets(); + + add_dep_after(\$string, "pure_all", pm_to_blib => 'glue_pods'); + + return $string; +} + +sub ModPerl::MM::MY::postamble { + my $self = shift; + + my $build = build_config(); + + my $root = $build->{cwd}; + + my $doc_root = File::Spec->catdir($root, "docs", "api"); + + my $lib_dir = File::Spec->catdir($root, "lib"); + + my @targets = (); + my @target; + + # add the code to glue the existing pods to the .pm files in blib + + @target = ('glue_pods:'); + + if (-d $doc_root) { + while (my ($pm, $blib) = each %{$self->{PM}}) { + my $pod = File::Spec->catdir( + (File::Spec->splitdir($blib))[-2 .. -1]); + $pod =~ s/\.pm/\.pod/; + my $podpath = File::Spec->catfile($doc_root, $pod); + next unless -r $podpath; + + push @target, + "\$(FULLPERLRUN) -Mlib=$lib_dir -MModPerl::MM " . + "-e ModPerl::MM::glue_pod $pm $podpath $blib"; + } + + push @target, $self->{NOECHO} . '$(TOUCH) $@'; + } + else { + # we don't have the docs sub-cvs repository extracted, skip + # the docs gluing + push @target, $self->{NOECHO} . '$(NOOP)'; + } + push @targets, join "\n\t", @target; + +# # next target: cleanup the dependency file +# @target = ('glue_pods_clean:'); +# push @target, '$(RM_F) glue_pods'; +# push @targets, join "\n\t", @target; + + return join "\n\n", @targets, ''; +} + +sub glue_pod { + + die "expecting 3 arguments: pm, pod, dst" unless @ARGV == 3; + my($pm, $pod, $dst) = @ARGV; + + # have we already glued the doc? + exit 0 unless -s $pm == -s $dst; + + # ExtUtils::Install::pm_to_blib removes the 'w' perms, so we can't + # just append the doc there + my $orig_mode = (stat $dst)[2]; + my $rw_mode = 0666; + + chmod $rw_mode, $dst or die "Can't chmod $rw_mode $dst: $!"; + open my $pod_fh, "<$pod" or die "Can't open $pod: $!"; + open my $dst_fh, ">>$dst" or die "Can't open $dst: $!"; + print $dst_fh (<$pod_fh>); + close $pod_fh; + close $dst_fh; + # restore the perms + chmod $orig_mode, $dst or die "Can't chmod $orig_mode $dst: $!"; + +} sub ModPerl::MM::MY::post_initialize { my $self = shift; Index: xs/ModPerl/Const/Makefile.PL =================================================================== RCS file: /home/cvs/modperl-2.0/xs/ModPerl/Const/Makefile.PL,v retrieving revision 1.2 diff -u -r1.2 Makefile.PL --- xs/ModPerl/Const/Makefile.PL 21 Oct 2001 23:01:54 -0000 1.2 +++ xs/ModPerl/Const/Makefile.PL 1 Feb 2003 15:16:47 -0000 @@ -18,10 +18,17 @@ VERSION_FROM => 'Const.pm', OBJECT => "Const.o @obj", clean => { FILES => "@clean" }, + overriden_methods => [qw(postamble)], ); sub MY::postamble { - join '', map { + my $self = shift; + + my $string = $self->ModPerl::MM::MY::postamble; + + $string .= join '', map { "$_: $src{$_}\n\t\$(CP) $src{$_} .\n"; } keys %src; + + return $string; }