This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix .gitignore: only ignore 'perl' in root of repo, not U/perl subdir
[metaconfig.git] / U / perl / d_procselfexe.U
1 ?MAKE:d_procselfexe procselfexe: \
2         Oldconfig Setvar rm ls contains issymlink d_readlink test
3 ?MAKE:  -pick add $@ %<
4 ?S:d_procselfexe:
5 ?S:     Defined if $procselfexe is symlink to the absolute
6 ?S:     pathname of the executing program.
7 ?S:.
8 ?S:procselfexe:
9 ?S:     If d_procselfexe is defined, $procselfexe is the filename
10 ?S:     of the symbolic link pointing to the absolute pathname of
11 ?S:     the executing program.
12 ?S:.
13 ?C:HAS_PROCSELFEXE:
14 ?C:     This symbol is defined if PROCSELFEXE_PATH is a symlink
15 ?C:     to the absolute pathname of the executing program.
16 ?C:.
17 ?C:PROCSELFEXE_PATH:
18 ?C:     If HAS_PROCSELFEXE is defined this symbol is the filename
19 ?C:     of the symbolic link pointing to the absolute pathname of
20 ?C:     the executing program.
21 ?C:.
22 ?H:#$d_procselfexe HAS_PROCSELFEXE      /**/
23 ?H:?%<:#if defined(HAS_PROCSELFEXE) && !defined(PROCSELFEXE_PATH)
24 ?H:?%<:#define PROCSELFEXE_PATH $procselfexe    /**/
25 ?H:?%<:#endif
26 ?H:.
27 ?T:try type
28 ?LINT: set d_procselfexe
29 : Check if there is a /proc symlink to the abs path of
30 : the executing program.  We will honor hints of d_procselfexe=$undef
31 : or procselfexe being non-empty, otherwise will try to determine both
32 : if we have readlink.
33 : AmigaOS will attempt to mount proc: aka /proc, if /proc/... is
34 : referenced, and AmigaOS does not have a proc filesystem anyway.
35 echo " "
36 val="$undef"
37 if $test "X$d_procselfexe" = Xundef; then
38         procselfexe=''
39 elif $test "X$procselfexe" != X -a "X$procselfexe" != 'X '; then
40         val="$define"
41 elif $test "X$d_readlink" = Xdefine; then
42         : NetBSD first as /proc/self is a symlink to /proc/curproc,
43         : and it feels more tidy to avoid an extra level of symlink
44         set NetBSD /proc/curproc/exe Linux /proc/self/exe FreeBSD /proc/curproc/file Solaris /proc/self/path/a.out
45         while test $# -gt 0; do
46             type=$1; try=$2
47             shift; shift
48             if $issymlink $try; then
49                 $ls -l $try > reflect
50                 if $contains /`basename $ls` reflect >/dev/null 2>&1; then
51                     echo "You have $type-like $try."
52                     procselfexe='"'$try'"'
53                     val="$define"
54                     : This will break out of the loop
55                     set X; shift
56                 fi
57             fi
58         done
59 fi
60 $rm -f reflect
61 set d_procselfexe
62 eval $setvar
63