eXile has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'd like to have ExtUtils::MakeMaker generate a Makefile that, in case somebody specifies a PREFIX, the libraries are installed in $PREFIX/lib instead of in $PREFIX/lib/some/long/library path. The manpage on ExtUtils::MakeMaker is quite extensive and there are a lot of options, the ones I've tried this far don't work.

I know I can get this working by doing

perl Makefile.PL PREFIX=/blah LIB=/blah/lib
but I want the location of the libs to be dependant on PREFIX, and not having to specify them explicitly. Anybody knows what Makefile.PL/MakeMaker keywords I have to use for that?

Replies are listed 'Best First'.
Re: ExtUtils::MakeMaker PREFIX and LIB
by PodMaster (Abbot) on Apr 08, 2005 at 22:25 UTC
    If the name of the module is some::long::library, it should end up in $PREFIX/lib/some/long/library and not lib, so what you're asking for is trouble, on the other hand you might want to look into the PM option.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      ok, my question was not very clear, the default I've seen is that libs are installed into something like
      $PREFIX/lib/perl5/5.8.2/some/long/module/name
      instead of
      $PREFIX/lib/some/long/module/name
      Since I'd like to use FindBin to point an executable installed in $PREFIX/bin to the locally installed libs the inbetween 'perl5/5.8.2/site_perl' is kind of awkward in such a situation (while obviously very useful when installing into a default location).

      Anyway, I've added this to my Makefile.PL :

      # if PREFIX is set, set LIB too foreach my $arg (@ARGV) { if ($arg =~ /^PREFIX=(.*)/) { push @ARGV, "LIB=$1/lib"; } }
      not very elegant but kind of works.
        I see. You shouldn't need to worry about that, but you could solve it with something like this (in your program)
        my $lib; BEGIN { my $bin = '$PREFIX/bin'; $bin =~ s~bin$~~; $lib = $Config::Config{sitelib}; $lib =~ s~^\Q$Config::Config{siteprefix}\E~$bin~; } use lib $lib;
        If a user is intelligent enough to make use of the PREFIX argument, he should be intelligent enough to make use of PERL5LIB, definetly something you shouldn't worry about.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.