Search code examples
perlaix

Is it possible to change Perl installation directory


Trying to build Perl distribution from sources. Installation directory needs to be specified before the build, as a parameter to Configure utility (e.g. /usr/local/myperl). As far as I understand, if I wanted to install that Perl distribution on another host, it must be put into the same directory (/usr/local/myperl). Is there a way to make it location-independent? I would like to be able to unpack it to any directory (specified by the host owner), set up necessary environment variables (PATH, etc.), so that it would work.

Edit: Created Perl 5.30.0 distribution using -Duserelocatableinc option. Below is perl -V output:

Summary of my perl5 (revision 5 version 30 subversion 0) configuration:

  Platform:
    osname=aix
    osvers=7.1.0.0
    archname=aix-thread-multi-64all
    uname='aix sss040 1 7 00fb05a44c00 '
    config_args='-desr -Dcc=gcc -maix64 -Duserelocatableinc -Dusethreads -Duse64bitall -Dprefix=/G/01/perl/5_30_0 -Aldflags=-L/usr/lib64 -L/opt/freeware/lib64 -L/opt/pware64/lib'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc -maix64 -maix64'
    ccflags ='-D_THREAD_SAFE -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT -fwrapv -fno-strict-aliasing -pipe -maix64 -DUSE_64_BIT_ALL -D_FORTIFY_SOURCE=2'
    optimize='-O'
    cppflags='-D_THREAD_SAFE -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -DUSE_NATIVE_DLOPEN -DNEED_PTHREAD_INIT -fwrapv -fno-strict-aliasing -pipe'
    ccversion=''
    gccversion='6.3.0'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=87654321
    doublekind=4
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=8
    longdblkind=0
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='gcc -maix64 -maix64'
    ldflags =' -Wl,-brtl -Wl,-bdynamic -L/usr/lib64 -L/opt/freeware/lib64 -L/opt/pware64/lib -Wl,-b64'
    libpth=/opt/freeware/lib /opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/6.3.0/include-fixed /usr/lib /lib /usr/ccs/lib /usr/lib64
    libs=-lpthread -lbind -lnsl -lgdbm -ldbm -ldl -lld -lm -lcrypt -lpthreads -lc
    perllibs=-lpthread -lbind -lnsl -ldl -lld -lm -lcrypt -lpthreads -lc
    libc=
    so=a
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_aix.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Xlinker -bE:.../../lib/5.30.0/aix-thread-multi-64all/CORE/perl.exp'
    cccdlflags=' '
    lddlflags='  -Wl,-b64 -Wl,-bhalt:4 -Wl,-G -Wl,-bI:$(PERL_INC)/perl.exp -Wl,-bE:$(BASEEXT).exp -Wl,-bnoentry -lpthreads -lc -lm -L/usr/lib64 -L/opt/freeware/lib64 -L/opt/pware64/lib'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_IMPLICIT_CONTEXT
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
    USE_THREAD_SAFE_LOCALE
  Built under aix
  Compiled at Aug 16 2019 08:41:27
  @INC:
    ../lib/site_perl/5.30.0/aix-thread-multi-64all
    ../lib/site_perl/5.30.0
    ../lib/5.30.0/aix-thread-multi-64all
    ../lib/5.30.0

Solution

  • Normally there's numerous hard coded paths in a Perl installation. What you're looking for is "Relocatable @INC".

    To create a relocatable perl tree, use the following command line:

    sh Configure -Duserelocatableinc
    

    Then the paths in @INC (and everything else in %Config) can be optionally located via the path of the perl executable.

    Also be sure to read README.aix for special AIX instructions.