Imported Upstream version 3.1.0
[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 "$host" in
15         *-*-solaris*)
16             PS_ARGUMENT="-eo pid,ppid,comm"
17             PS_ARGUMENT_ARGS="-eo pid,ppid,comm"
18             ;;
19
20         *-*-linux-*)
21             PS_ARGUMENT="-eo pid,ppid,command"
22             PS_ARGUMENT_ARGS="-eo pid,ppid,command"
23             ;;
24
25         *-*-*bsd*)
26             PS_ARGUMENT="-axo pid,ppid,command"
27             PS_ARGUMENT_ARGS="-axo pid,ppid,command"
28             ;;
29
30         *-apple-darwin*)
31             PS_ARGUMENT="-aAco pid,ppid,command"
32             PS_ARGUMENT_ARGS="-aAo pid,ppid,command"
33             ;;
34
35         *-pc-cygwin)
36             # Cygwin is special-cased in Amanda::Process
37             PS_ARGUMENT=CYGWIN
38             PS_ARGUMENT_ARGS="-ef"
39             ;;
40
41         *-*-hpux*)
42             # HPUX's 'PS' needs the env var UNIX95 to run in "xpg4" mode
43             PS="UNIX95=1 $PS"
44             PS_ARGUMENT="-eo pid,ppid,comm"
45             PS_ARGUMENT_ARGS="-eo pid,ppid,comm"
46             ;;
47
48         *)
49             for try in \
50                 "-axo pid,ppid,command" \
51                 "-aAco pid,ppid,command" \
52                 "-eo pid,ppid,comm"
53             do
54                 ps $try >/dev/null 2>/dev/null
55                 if test $? -eq 0; then
56                     PS_ARGUMENT="$try"
57                     break
58                 fi
59             done
60             for try in \
61                 "-axo pid,ppid,command" \
62                 "-aAo pid,ppid,command" \
63                 "-eo pid,ppid,comm"
64             do
65                 ps $try >/dev/null 2>/dev/null
66                 if test $? -eq 0; then
67                     PS_ARGUMENT_ARGS="$try"
68                     break
69                 fi
70             done
71             if test -z "$PS_ARGUMENT" -o -z "$PS_ARGUMENT_ARGS"; then
72                 AC_MSG_ERROR([Can't find ps argument to use.])
73             fi
74             ;;
75     esac
76
77     AC_MSG_RESULT($PS_ARGUMENT)
78     AC_SUBST(PS_ARGUMENT)
79     AC_MSG_RESULT($PS_ARGUMENT_ARGS)
80     AC_SUBST(PS_ARGUMENT_ARGS)
81 ])