[Sorry for this post being long, but its an old, nasty, widespred problem.]


I've begun tackling the thorny problem of PREFIX.

    perl Makefile.PL PREFIX=/what/ever

I'm trying to nail down what its ideal behavior should be.  Here's how
it currently "works":

    PREFIX will default to $Config{prefix}   (ok so far)

    The following variables will always be prefixified
        INSTALLBIN
        INSTALLSCRIPT
        INSTALLMAN1DIR
        INATALLMAN3DIR

    These will be prefixified unless LIB is defined, in which case
    that will be used.
        INSTALLPRIVLIB
        INSTALLARCHLIB
        INSTALLSITELIB
        INSTALLSITEARCH

Makes sense so far, right?  The problem is with how prefixification is
carried out.  It goes something like this:

For INSTALLBIN & INSTALLSCRIPT it effectively does:
    s/$Config{prefix}/$\(PREFIX\)/;

over $Config{installbin} & $Config{installscript}.  So if
$Config{installbin} is /usr/bin and $Config{prefix} is /usr and you
end up with /what/ever/bin.  Which is ok as long as INSTALLBIN and
INSTALLSCRIPT are under the original prefix, which does not have to be
the case but its fairly unlikely.


The problems start with INSTALLMAN1DIR and INSTALLMAN3DIR.  MakeMaker
tries to get clever.  The guessing game goes something like this:

    It starts out with $Config{prefix}/lib/perl5/man.

    If that directory doesn't exist, it tries $Config{prefix}/man
        but doesn't bother to check if that exists.

so that's how it figures out the "search prefix".
    
    It then tries $(PREFIX)/lib/perl5/man. (So /what/ever/lib/perl5/man).

    If that directory doesn't exist, it tries $(PREFIX)/man,
        again, not checking if it exists.

and that's how it figures out the "replace prefix".

It then effectively does s/$search_prefix/$replace_prefix/ on
$Config{installman1dir} and $Config{installman3dir} and that's where
the trouble starts.

On Debian, for example, $Config{installman1dir} is
'/usr/share/man/man1'.  Neither of MakeMaker's guesses is going to
match that.  So the prefixification silently fails and MakeMaker plows
on trying to install man pages into /usr/share/man/man1 which you
probably don't have premissions for.

I won't even get into the logic for figuring out where libraries go.
Its similar but even more complicated.


MakeMaker is valiantly trying to shape the install tree under your
$(PREFIX) to conform to your system's installation tree, but if it
guesses wrong the files won't go into $(PREFIX) at all!  I'm not sure
what the correct behavior is, but no matter what your files should
wind up under $(PREFIX).  So the current behavior is Wrong.


Here's my thoughts on how it should work:

    1) Simply do:  s/^$Config{prefix}/$\(PREFIX\)/ over all the variables.
       So /usr/share/man/man1 becomes /what/ever/share/man/man1.

    2) Completely say the hell with trying to conform to the system's
       installation style and just hard code in sensible subdirectories.
       So man pages go into /what/ever/man/man1 no matter what 
       $Config{installman1dir} was.  (Modified for particular Operating 
       Systems).  Don't like it?  Specify INSTALLMAN1DIR manually.

I think what will wind up happening is MakeMaker will try #1.  If the
s/// should fail to match it will fall back to some variation of #2.


And other suggestions for algorithms that won't get tripped up by
strange config values?  Anyone have particular problems with this
setup?


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
flatulent no more,
I only make large bubbles
of paste from my ass.
        -- japhy

Reply via email to