是否可以更改 Perl 安装目录

Is it possible to change Perl installation directory

正在尝试从源代码构建 Perl 发行版。在构建之前需要指定安装目录,作为配置实用程序的参数(例如 /usr/local/myperl)。据我了解,如果我想在另一台主机上安装该 Perl 发行版,则必须将其放入同一目录 (/usr/local/myperl)。有没有办法让它与位置无关?我希望能够将它解压到任何目录(由主机所有者指定),设置必要的环境变量(PATH 等),这样它就可以工作了。

编辑: 使用 -Duserelocatableinc 选项创建了 Perl 5.30.0 发行版。 下面是 perl -V 输出:

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

通常在 Perl 安装中有许多硬编码路径。您要查找的是 "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.

另请务必阅读 README.aix 了解特殊的 AIX 说明。