On Sun, Aug 03, 2003 at 12:23:02PM -0400, Scott R. Godin wrote:
> 12:14pm {7} pcp01501167pcs:/misc/src/razor-agents-2.34># make
> Makefile:534: *** missing separator.  Stop.

razor-agents has some hacks in its Makefile.PL to build section 5 man
pages.  It overrides constants() to do this counting on being able to
stick its own macros before HTMLEXT, PERM_RW and POD2MAN.  This technique
is inherently flawed as the locations and even existance of those macros
is going to change from version to version.

Part of it was already broken in 6.05 because all the HTMLifying went
away and so did HTMLEXT.  So his MAN5PODS macro never got written, though
it looks like it was never used so things got along without it.

POD2MAN has also gone way, it no longer being necessary.  Looks like razor
was counting on that to be able to stick its own man pages into
manifypods.

Finally, the one that actually broke the Makefile, is that manifypods()
now has # Begin and # End comments meaning you can't simply append
more stuff onto the end of the manifypods macro.  This is a genuine bug,
no other target has those sort of comments.  Must have slipped in while
we were debugging manifypods.

So, what to do?  Well, in general, remove the dependency on other
macros and simply append.  There's no reason the MAN5PODS or INST_MAN5DIR
macros have to go just before HTMLEXT and PERM_RW, so we can knock that
hack out and just stick them at the end of constants().  In top_targets()
there's no reason the new config target has to come before help so we
just stick it at the end.  We can knock out the scan for the perl.h file
path by generating it ourselves (yes, there should be a PERL_H macro, here's
a receipt for that: https://rt.cpan.org/NoAuth/Bug.html?id=3137).

manifypods() is a little trickier.  What we want is to have our man
pages run when manifypods is run.  So instead of inserting a bunch of
new code into manifypods, we'll create a new target and stick that in
as a manifypods dependency.  Much less hackery that way.

The only problem is running POD2MAN.  I should have left in a POD2MAN
macro just for backwards compat.  I'll put it back in.  Here's a receipt for
that:  https://rt.cpan.org/NoAuth/Bug.html?id=3136.  Ok, if we don't
have one we can generate one.

Same deal with install().  Just append it rather than stick it in the middle.
Putting install_razor_agents into the install deps can be done a bit
safer by putting it at the end of the line instead of spelling out all
the other depenencies.  Also, with the addition of the INSTALLSITEMAN*DIR and
INSTALLVENDORMAN*DIR macros, the regex to put the man5 lines into the
various installation targets has to be made a bit more flexible.

So the attached patch should restore razor-agents to building with
6.13, 6.05.  The only thing that doesn't work is installation with a
DESTDIR or in a case where the installation isn't in the user's @INC
This means razor-client won't run.  I'm not sure if starting up the
client autmaticly after an install is a good idea and would recommend
removing it.  Either way, it'll give folks trying to make a package a
headache.

I've also removed the "NOECHO => ''" line which I assume slipped in from
debugging.  Otherwise the output from make is overwhelming.

Patch attached.


-- 
Playstation?  Of course Perl runs on Playstation.
    -- Jarkko Hietaniemi
--- Makefile.PL 2003/08/03 22:11:42     1.1
+++ Makefile.PL 2003/08/03 23:01:26
@@ -17,118 +17,138 @@
     AUTHOR        => 'Vipul Ved Prakash <[EMAIL PROTECTED]>',
     ABSTRACT      => 'Collaborative, content-based spam filtering network.',
     DISTNAME      => 'razor-agents', 
-    NOECHO        => '',
     VERSION_FROM  => 'lib/Razor2/Client/Version.pm', 
     EXE_FILES     => [ qw( bin/razor-client ) ], 
     PREREQ_PM     => { 
-                       'Net::Ping'        => 0, 
-                       'Net::DNS'         => 0, 
+                       'Net::Ping'        => 0,
+                       'Net::DNS'         => 0,
                        'Time::HiRes'      => 0,
-                       'Digest::SHA1'     => 0,  
+                       'Digest::SHA1'     => 0,
                        'Getopt::Long'     => 0,
                        'File::Copy'       => 0,
                        'Digest::Nilsimsa' => 0,
                        'URI::Escape'      => 0,
+                       'File::Spec'       => 0,
                      },
        MAN1PODS      => { 
                        'docs/razor-check.pod'    => '$(INST_MAN1DIR)/razor-check.1',
-                                          'docs/razor-report.pod'   => 
'$(INST_MAN1DIR)/razor-report.1',
+                       'docs/razor-report.pod'   => '$(INST_MAN1DIR)/razor-report.1',
                        'docs/razor-admin.pod'    => '$(INST_MAN1DIR)/razor-admin.1',
                        'docs/razor-revoke.pod'   => '$(INST_MAN1DIR)/razor-revoke.1',
                      },
 );
 
+{
+package MY;
 
 sub MY::constants {
 
-    package MY;
-
     my $self = shift;
     my $inherited = $self->SUPER::constants(@_);
 
-    my $man5pods = "MAN5PODS = docs/razor-agent.conf.pod \\\n" .
-                   "   docs/razor-whitelist.pod\\\n".
-                   "   docs/razor-agents.pod\n".
-                   "";
-
-    $inherited =~ s/^(HTMLEXT =)/$man5pods$1/gm;
+    my $man5 = q{
 
-    my $man5 = "INST_MAN5DIR = blib/man5\n" . 
-               'INSTALLMAN5DIR = $(PREFIX)/man/man5' . "\n" . 
-               "MAN5EXT = 5\n";
+# begin razor-agents
+MAN5PODS = docs/razor-agent.conf.pod \\
+          docs/razor-whitelist.pod  \\
+          docs/razor-agents.pod
+INST_MAN5DIR = blib/man5
+INSTALLMAN5DIR = $(PREFIX)/man/man5
+MAN5EXT = 5
+# end razor-agents
 
-    $inherited =~ s/^(PERM_RW = )/$man5$1/gm;
+};
 
-    $inherited;
+    return $inherited . $man5;
 
 }
 
 
 sub MY::top_targets {
- 
-    package MY;
+
+    use Config;
 
     my $self = shift;
     my $inherited = $self->SUPER::top_targets(@_);
 
-    my ($perlh) = $inherited =~ m"\$\(INST_MAN1DIR\)/\.exists :: (.*)";
- 
-    my $man5 = 'config :: $(INST_MAN5DIR)/.exists' . "\n"    . 
-               '       @$(NOOP)' . "\n\n\n"                     . 
-               '$(INST_MAN5DIR)/.exists :: ' . $perlh . "\n" . 
-               '       @$(MKPATH) $(INST_MAN5DIR)' . "\n"       . 
-               '       @$(EQUALIZE_TIMESTAMP) ' . $perlh . ' $(INST_MAN5DIR)/.exists' 
. "\n\n" . 
-               '       [EMAIL PROTECTED](CHMOD) $(PERM_RWX) $(INST_MAN5DIR)'  . 
"\n\n";
- 
-    $inherited =~ s/^(help:)/$man5$1/gm;
- 
-    $inherited;
- 
+    my ($perlh) = $self->catfile($Config{archlibexp}, 'CORE', "perl.h");
+
+    my $noecho = q{NOECHO = @} unless $inherited =~ /NOECHO/;
+
+    my $man5 = sprintf <<'MAKE_FRAG', $perlh, $perlh;
+
+# begin razor-agents
+config :: $(INST_MAN5DIR)/.exists
+       @$(NOOP)
+
+$(INST_MAN5DIR)/.exists :: %s
+       @$(MKPATH) $(INST_MAN5DIR)
+       @$(EQUALIZE_TIMESTAMP) %s $(INST_MAN5DIR)/.exists
+       [EMAIL PROTECTED](CHMOD) $(PERM_RWX) $(INST_MAN5DIR)
+# end razor-agents
+
+MAKE_FRAG
+
+    return $inherited . $man5;
 }
 
 
 sub MY::manifypods {
-
-    package MY;
     my $self = shift;
     my $inherited = $self->SUPER::manifypods(@_);
 
-    my $deps = " \\\n" .
-               "       docs/razor-agent.conf.pod \\\n" . 
-               "       docs/razor-agents.pod \\\n" . 
-               "       docs/razor-whitelist.pod";
- 
-    $inherited =~ s/(\n\t\$\(POD2MAN\).*)$/$deps$1/gm;
-
-    my $files = ' \\' . "\n" . 
-                '      docs/razor-agent.conf.pod \\' . "\n" . 
-                '      $(INST_MAN5DIR)/razor-agent.conf.$(MAN5EXT) \\' . "\n" .
-                '      docs/razor-agents.pod \\' . "\n" . 
-                '      $(INST_MAN5DIR)/razor-agents.$(MAN5EXT) \\' . "\n" .
-                '      docs/razor-whitelist.pod \\' . "\n" . 
-                '      $(INST_MAN5DIR)/razor-whitelist.$(MAN5EXT)';
+    $inherited =~ s{^(manifypods : .*)\\}{$1 manifypods-razor \\}m;
+
+    # MakeMaker 6.06_x through 6.13 eliminated the POD2MAN macro.
+    my $pod2man = q{POD2MAN = $(POD2MAN_EXE)}
+        unless $inherited =~ /^POD2MAN\b/m;
+
+    my $manifypods_razor = sprintf <<'MAKE_FRAG', $pod2man;
+
+# begin razor-agents
+%s
+
+manifypods-razor : docs/razor-agent.conf.pod \
+       docs/razor-agents.pod                \
+       docs/razor-whitelist.pod
+       $(POD2MAN) \
+       docs/razor-agent.conf.pod \
+       $(INST_MAN5DIR)/razor-agent.conf.$(MAN5EXT) \
+       docs/razor-agents.pod \
+       $(INST_MAN5DIR)/razor-agents.$(MAN5EXT) \
+       docs/razor-whitelist.pod \
+       $(INST_MAN5DIR)/razor-whitelist.$(MAN5EXT)
 
-    $inherited .= $files;
+#end razor-agents
+MAKE_FRAG
 
-    $inherited;
+    return $inherited . "\n" . $manifypods_razor;
 
 }
 
 
 sub MY::install {
 
-  package MY;
-
   my $self = shift;
   my $inherited = $self->SUPER::install(@_);
 
-  my $man5 = " \\\n" . 
-             '         $(INST_MAN5DIR) $(INSTALLMAN5DIR)';
- 
-  $inherited =~ s/(\$\(INSTALLMAN1DIR\))/$1$man5/gm;
-  $inherited =~ s/install :: all pure_install doc_install/install :: all pure_install 
doc_install install_razor_agents/;
-  $inherited .= "\ninstall_razor_agents::\n\t " . '$(INST_SCRIPT)/razor-client'; 
-  $inherited;
+  $inherited =~ s{^(install :: .*)}{$1 install_razor_agents}m;
+
+  my $install_razor_agents = q{
+
+# begin razor-agents
+install_razor_agents ::
+       $(INST_SCRIPT)/razor-client
+# end razor-agents
 
+};
+
+  my $man5 = q{ \\
+               $(INST_MAN5DIR) $(INSTALLMAN5DIR)};
+
+  $inherited =~ s/(\$\(INSTALL\w*MAN1DIR\))/$1$man5/gm;
+
+  return $inherited . $install_razor_agents;
 }
 
+}

Reply via email to