83b88b5c8f00499ba02c9d709cc1b367f4ee51d5
[debian/amanda] / config / amanda / ps.m4
1 #
2 #   Find ps argument for Amanda::Process
3 #
4 AC_DEFUN([AMANDA_PS_ARGUMENT],
5 [
6     AC_PATH_PROG(PS, ps)
7     AC_MSG_CHECKING([ps argument to use])
8     PS_ARGUMENT=
9
10     # ps is *very* non-portable, and across many systems, the same option
11     # (e.g., -e) can mean different things.  So this macro tries to
12     # special-case most known systems, and makes an effort to detect unknown
13     # systems
14     case "$target" in
15         *-*-solaris*)
16             PS_ARGUMENT="-eo pid,ppid,comm"
17             ;;
18
19         *-*-linux-*)
20             PS_ARGUMENT="-eo pid,ppid,command"
21             ;;
22
23         *-*-*bsd*)
24             PS_ARGUMENT="-axo pid,ppid,command"
25             ;;
26
27         *-apple-darwin*)
28             PS_ARGUMENT="-aAco pid,ppid,command"
29             ;;
30
31         *-pc-cygwin)
32             # Cygwin is special-cased in Amanda::Process
33             PS_ARGUMENT=CYGWIN
34             ;;
35
36         *-*-hpux*)
37             # HPUX's 'PS' needs the env var UNIX95 to run in "xpg4" mode
38             PS="UNIX95=1 $PS"
39             PS_ARGUMENT="-eo pid,ppid,comm"
40             ;;
41
42         *)
43             for try in \
44                 "-axo pid,ppid,command" \
45                 "-aAco pid,ppid,command" \
46                 "-eo pid,ppid,comm"
47             do
48                 ps $try >/dev/null 2>/dev/null
49                 if test $? -eq 0; then
50                     PS_ARGUMENT="$try"
51                     break
52                 fi
53             done
54             if test -z "$PS_ARGUMENT"; then
55                 AC_MSG_ERROR([Can't find ps argument to use.])
56             fi
57             ;;
58     esac
59
60     AC_MSG_RESULT($PS_ARGUMENT)
61     AC_SUBST(PS_ARGUMENT)
62 ])