This is about as simple an outline of the new MakeMaker
prefixification and installation directory layout logic as I can put
together.  It's as much for my brane as for yours.

Comments appreciated *-->as soon as possible<--*.



DEFAULTS
========

Here's an example of the problem this new logic is trying to solve.
When you supply a Makefile.PL with a PREFIX, the code should wind up
installed under that new prefix, no matter what.  It currently
doesn't:

    installbin      prefix   new prefix                result
    /usr/bin        /usr     /home/schwern             /home/schwern/bin 
    /bin            /usr     /home/schwern             /bin
    /usr/wibble     /usr     /home/schwern             /home/schwern/wibble
    /wof/wibble     /usr     /home/schwern             /wof/wibble

Basically, if MM can't figure out how to prefixify your new paths, it
*won't* intall things under your PREFIX.


Here's the layout of the new prefixification logic.  The logic is in
as simple a form as I can get it.

   $IPrefix = $Config{installprefix}
   $VPrefix = $Config{installvendorprefix}
   $SPrefix = $Config{siteprefix}

   $prefix      = user supplied PREFIX
   $man_prefix  = user supplied MANPREFIX *new*
   $lib         = user supplied LIB

   $libstyle = 'lib/perl5' || 'lib' (discussed below)

   s == search prefix
   r == replace prefix
   d == default suffix

   each key is an install variable.  (bin == installbin, etc...)

   my $layout = 
       (
        bin         => { s => $IPrefix,
                         r => $prefix,
                         d => 'bin' },
        vendorbin   => { s => $VPrefix || $IPrefx,
                         r => $prefix,
                         d => 'bin' },
        sitebin     => { s => $SPrefix,
                         r => $prefix,
                         d => 'bin' },
        script      => { s => $IPrefix,
                         r => $prefix,
                         d => 'bin' },

        man1dir     => { s => $IPrefix,
                         r => $man_prefix || $prefix,
                         d => '$manstyle/man/man1' },
        man3dir     => { s => $IPrefix,
                         r => $man_prefix || $prefix,
                         d => '$manstyle/man/man3' },
        
        vendorarch  => { s => $VPrefix || $IPrefix,
                         r => $lib || $prefix,
                         d => "$libstyle/$Version/$Arch" },
        archlib     => { s => $IPrefix,
                         r => $lib || $prefix,
                         d => "$libstyle/$Version/$Arch" },
        sitearch    => { s => $SPrefix,
                         r => $lib || $prefix,
                         d => "$libstyle/site_perl/$Version/$Arch" },

        privlib     => { s => $IPrefix,
                         r => $lib || $prefix,
                         d => $libstyle },
        vendorlib   => { s => $VPrefix || $IPrefix,
                         r => $lib || $prefix,
                         d => $libstyle },
        sitelib     => { s => $SPrefix,
                         r => $lib || $prefix,
                         d => "$libstyle/site_perl" }

        pod         => { s => '',
                         r => $lib || $prefix,
                         d => "$libstyle/pod"
                       },
       );

Each is run through the MM->prefixify function.  So, for example, bin.

    bin         => { s => $IPrefix,
                     r => $prefix,
                     d => 'bin' },

translates into

    $mm->prefixify('installbin', $IPrefix, $prefix, 'bin');

which roughly says:

    my $path = $Config{installbin};
    $path =~ s/$IPrefix/$prefix/ ||
        $path = "$prefix/bin";

    $mm->{INSTALLBIN} = $path;

so here's some scenarios under the new system, with the new concept of
defaults.

    installbin      prefix   new prefix      default   result
    /usr/bin        /usr     /home/schwern   bin       /home/schwern/bin 
    /bin            /usr     /home/schwern   bin       /home/schwern/bin
    /usr/wibble     /usr     /home/schwern   bin       /home/schwern/wibble
    /wof/wibble     /usr     /home/schwern   bin       /home/schwern/bin

Where possible, prefixify acts to preserve the existing installed
structure by removing the current prefix and plonking on it's own.
Otherwise it will use the default so the code winds up at least
installed under your new prefix in a sensible location.



LIBSTYLE
========

Another nasty problem is Makemaker currently can install libraries as
"lib/perl5" or just "lib" depending on if your PREFIX =~ /perl/, if
PREFIX/lib/perl5 exists, the phase of the moon, and lots of other
variables.

The idea was to be clever and try to figure out if you're using a
prefix specific to Perl (ie. /usr/local/perl5) and not bother with an
extra "perl5" subdirectory.  This often hinders more often than it
helps.

So, the new logic works like this...

     # default style
     $libstyle = lib/perl5
     $manstyle = ''

    if user supplied LIBSTYLE
        $libstyle = LIBSTYLE
        $manstyle = LIBSTYLE eq 'lib/perl5' ? 'lib/perl5' : ''
    else
        # preserve existing directory structure
        if -d PREFIX/lib/perl5
            $libstyle = lib/perl5
        if -d PREFIX/lib/perl5/man
            $manstyle = lib/perl5

This logic gives rpm/dpkg/etc... package maintainers more control and
it also means that existing local structures should be preserved.


MANPREFIX
=========

We have a way to control where libs get installed (the ill named LIB),
why not MANPREFIX for man pages?


VENDOR*
=======

5.6.0 introduced the concept of a seperate Vendor prefix.  Where a
"vendor" is simply someone distributing Perl.  Debian and Redhat are a
vendors.  Unfortunately, no corresponding logic was ever put into
MakeMaker.  Well, the Debian folks patched it in and I'm co-opting
their patch.

Basically, if you say INSTALLDIRS=vendor, the installvendor* stuff
will be used.  Similar to INTALLDIRS=site.


INSTALLPOD
==========

Currently, pod is just plunked whereever your libraries go.  You
currently can't control this directly at all.  Now you will be able to
via INSTALLPOD.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
you're a bleeding-heart
liberal.  LET ME PLUG MY
ASS WITH PASTE RIGHT NOW!
        -- japhy

Reply via email to