Commit | Line | Data |
---|---|---|
8d8abcf7 | 1 | ?MAKE:d_procselfexe procselfexe: \ |
74123c30 | 2 | Oldconfig Setvar rm ls contains issymlink d_readlink test |
b8117f61 NIS |
3 | ?MAKE: -pick add $@ %< |
4 | ?S:d_procselfexe: | |
8d8abcf7 JH |
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. | |
b8117f61 NIS |
12 | ?S:. |
13 | ?C:HAS_PROCSELFEXE: | |
8d8abcf7 JH |
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. | |
b8117f61 NIS |
21 | ?C:. |
22 | ?H:#$d_procselfexe HAS_PROCSELFEXE /**/ | |
8d8abcf7 JH |
23 | ?H:?%<:#if defined(HAS_PROCSELFEXE) && !defined(PROCSELFEXE_PATH) |
24 | ?H:?%<:#define PROCSELFEXE_PATH $procselfexe /**/ | |
25 | ?H:?%<:#endif | |
b8117f61 | 26 | ?H:. |
c0f9c291 | 27 | ?T:try type |
b8117f61 | 28 | ?LINT: set d_procselfexe |
74123c30 MBT |
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. | |
b8117f61 | 35 | echo " " |
b8117f61 | 36 | val="$undef" |
74123c30 MBT |
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 | |
c0f9c291 MB |
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 | |
2fe09f7d | 50 | if $contains /`basename $ls` reflect >/dev/null 2>&1; then |
c0f9c291 MB |
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 | |
8d8abcf7 | 56 | fi |
c0f9c291 MB |
57 | fi |
58 | done | |
74123c30 MBT |
59 | fi |
60 | $rm -f reflect | |
61 | set d_procselfexe | |
62 | eval $setvar | |
b8117f61 | 63 |