Michael,

  Thank you for your advice. I think I have been successful
  following it, but there was definitely hackery involved. I
  thought I'd run my solution by you in case there is yet a
  better way.
  
  First, in order to allow

     perl Makefile.PL CGI_DIR=/path/to/cgi

  I had to add:
  
    $ExtUtils::MakeMaker::Recognized_Att_Keys{CGI_DIR} = 1;
        
  This is undocumented, and hence potentially breakable. Should
  this be documented, or is there a better way?
  
  Next, while it was clear that in order to use MakeMaker's
  command-line processing, I needed to check somewhere after
  MakeMaker was first invoked, but it was not obvious how to do
  this. My first strategy was to disect WriteMakefile and do 

    my $mm = MM->new(...);
        ..check for CGI_DIR or prompt...
        $mm->flush

  but that didn't work because it's too late. The right answer
  appears to be to check within an overridden method:

        sub MY::postamble {
          my $mm = shift;
          $mm->{CGI_DIR} = prompt( 'Where should cgi scripts be installed? ' )
                unless $mm->{CGI_DIR};
        "
        CGI_DIR=$mm->{CGI_DIR}
        install ::
                cp -vn cgi/CRRun \$(CGI_DIR)/CRRun
        ";
        }
  
  (This query might live better in MY::post_constants(). Sanity
  checking of the entered value is definitely a good idea as
  well!)
  
  This approach is not obvious, at least to a MakeMaker neophyte,
  and hence might be worthy of a mention in the docs, perhaps
  under "Overriding MakeMaker Methods".
  
  If you agree that documentation is the appropriate approach,
  then the only honorable thing for me to do is to offer to
  create the patch.
  
   -Norton Allen
   
Michael G Schwern wrote:
> 
> On Mon, Oct 07, 2002 at 10:05:13AM -0400, Norton Allen wrote:
> > I'm developing a CGI application. It includes a perl module
> > that gets installed in the usual place, some command-line
> > scripts that should go in INSTALLSCRIPT and some CGI scripts
> > that need to go into a cgi-bin directory.
> > 
> > What is my best strategy for handling installation?
> 
> In your Makefile.PL you'll probably want to use
> ExtUtils::MakeMaker::prompt() to ask the user where they want the CGIs
> installed.  A CGI_DIR argument to Makefile.PL (accessable via
> $mm->{CGI_DIR}) might also work.  Both should probably be used with the
> prompt() only happening if there's no CGI_DIR specified.
> 
> After that, stick in an install :: target like discussed later in the
> thread.
> 
> 
> -- 
> 
> Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
> Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
> It's Flypaper Licking time!
> 

Reply via email to