Hmm.. I'm not sure what all the fuss is about in this thread. It's a pretty simple problem, and almost all of it is handled for you by perl itself...

First you need a directory for each platform to hold its binaries. Personally, I like to hide them:

cd ~/perl mkdir bin mkdir .platforms cd .platforms mkdir SunOS5.8 Linux2.4.14 cd ..

Make as many directories as you have architechtures. I suggest using names that are a combination of uname -s and -r output, but whatever scheme you like is fine.

Make a source directory or whatever and put the perl source in it.

mkdir source cd source tar xzvf ~/stable.tar.gz (or wherever it is)

Now, on each platform simply compile perl as you normally would, with only one change. When asked 'Pathname where the public executables will reside?', answer:

~/perl/.platforms/SunOS5.8 (or whichever platform you're on.)

Now all the architechture dependent executables, like 'perl' will be installed in that directory. Next, just write a shell script (sh is probably most universal) that does something like this:

#!/bin/sh system=`uname -s` release=`uname -r` exec $HOME/perl/.platform/$system$release/$0 "$@"

You can obviously make the wrapper much fancier if you like. When you have it how you'd like it, place it in ~/perl/bin and call it .wrapper. Then just create symbolic links for each item in .platform/SunOS5.8 or whatever that point to .wrapper. For example:

cd ~/perl/bin ln -s .wrapper perl

Now whenever you execute ~/perl/bin/perl, it will exec the version of perl for your platform. Since the normal perl installation takes care of what to do for architechture specific library files and so on, that should be all you need to do.

When installing perl modules that are pure perl, you should really only have to do it on one platform. For modules that actually compile C code or whatever though, you will probably have to build them on each platform.

The other option, rather than a wrapper, is to simply make sure that the appropriate architecture's bin directory in in your PATH.

Now, I should admit that I haven't done this in quote some time, so your mileage may vary. But in principle, that's all there is to it.


In reply to Re: Running perl on multiple platforms by Orsmo
in thread Running perl on multiple platforms by the pusher robot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.