This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backporting work on AmigaOS
[metaconfig.git] / U / perl / d_procselfexe.U
index b9b9719..16e3bb8 100644 (file)
@@ -1,30 +1,60 @@
-?MAKE:d_procselfexe: Oldconfig Setvar rm ls contains issymlink d_readlink
+?MAKE:d_procselfexe procselfexe: \
+       Oldconfig Setvar rm ls contains issymlink d_readlink
 ?MAKE: -pick add $@ %<
 ?S:d_procselfexe:
-?S:    Defined if /proc/self/exe is symlink to executing program.
+?S:    Defined if $procselfexe is symlink to the absolute
+?S:    pathname of the executing program.
+?S:.
+?S:procselfexe:
+?S:    If d_procselfexe is defined, $procselfexe is the filename
+?S:    of the symbolic link pointing to the absolute pathname of
+?S:    the executing program.
 ?S:.
 ?C:HAS_PROCSELFEXE:
-?C:    This symbol is defined if /proc/self/exe is a symlink
-?C:    to the executing program.
+?C:    This symbol is defined if PROCSELFEXE_PATH is a symlink
+?C:    to the absolute pathname of the executing program.
+?C:.
+?C:PROCSELFEXE_PATH:
+?C:    If HAS_PROCSELFEXE is defined this symbol is the filename
+?C:    of the symbolic link pointing to the absolute pathname of
+?C:    the executing program.
 ?C:.
 ?H:#$d_procselfexe HAS_PROCSELFEXE     /**/
+?H:?%<:#if defined(HAS_PROCSELFEXE) && !defined(PROCSELFEXE_PATH)
+?H:?%<:#define PROCSELFEXE_PATH        $procselfexe    /**/
+?H:?%<:#endif
 ?H:.
+?T:try type
 ?LINT: set d_procselfexe
+: Check if exe is symlink to abs path of executing program
 echo " "
-echo "Checking for /proc/self/exe..." >&4
+procselfexe=''
 val="$undef"
-case "$d_readlink" in
-"$define")
-       if $issymlink /proc/self/exe ; then
-               $ls -l /proc/self/exe > reflect
+case "$d_procselfexe" in
+'') case "$d_readlink" in
+    "$define")
+       : NetBSD first as /proc/self is a symlink to /proc/curproc, and it feels
+       : more tidy to avoid an extra level of symlink
+       set NetBSD /proc/curproc/exe Linux /proc/self/exe FreeBSD /proc/curproc/file Solaris /proc/self/path/a.out
+       while test $# -gt 0; do
+           type=$1; try=$2
+           shift; shift
+           if $issymlink $try; then
+               $ls -l $try > reflect
                if $contains /`basename $ls` reflect >/dev/null 2>&1; then
-                       val="$define"
-                       echo "You have Linux-like /proc/self/exe."
+                   echo "You have $type-like $try."
+                   procselfexe='"'$try'"'
+                   val="$define"
+                   : This will break out of the loop
+                   set X; shift
                fi
-               $rm reflect
-       fi
+           fi
+       done
        ;;
+    esac
+    $rm -f reflect
+    set d_procselfexe
+    eval $setvar
+;;
 esac
-set d_procselfexe
-eval $setvar