gentoo: use /var/run for new /run compatibility
[util-vserver.git] / m4 / ensc_pathprog.m4
1 dnl $Id$
2
3 dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 dnl  
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; version 2 of the License.
8 dnl  
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl  
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program; if not, write to the Free Software
16 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 dnl Usage: ENSC_SET_SEARCHPATH(<PATH>)
19 AC_DEFUN([ENSC_SET_SEARCHPATH],
20 [
21         ensc_searchpath="$1"
22 ])
23
24 dnl Usage: ENSC_PATHPROG_INIT
25 AC_DEFUN([ENSC_PATHPROG_INIT],
26 [
27         ENSC_PATHPROG_SED=
28         AC_SUBST([ENSC_PATHPROG_SED])
29 ])
30
31
32 dnl Usage: ENSC_PATHPROG(<VAR>, <PROG>[, <DFLT>, <DESCR>, <DEREF>])
33 AC_DEFUN([ENSC_PATHPROG],
34 [
35         AC_REQUIRE([ENSC_SET_SEARCHPATH])
36         AC_REQUIRE([ENSC_PATHPROG_INIT])
37
38         if test -z "$3"; then
39                 rq=true
40         else
41                 rq=false
42         fi
43
44         if $rq; then
45                 ensc_dflt=
46         else
47                 ensc_dflt="$3"
48         fi
49
50         AC_PATH_PROGS($1, [$2], [$ensc_dflt], [$ensc_searchpath])
51
52         if test -z "${$1}" && $rq; then
53                 if test -z "$4"; then
54                         AC_MSG_ERROR([Can not find the '$2' tool within '${ensc_searchpath:-$PATH}'.])
55                 else
56                         AC_MSG_ERROR([
57 Can not find the '$2' tool within '${ensc_searchpath:-$PATH}'.
58 $4])
59                 fi
60         fi
61
62         if test "x$5" = x; then
63                 ensc_pathprog_path="${$1}"
64                 while test -h "$ensc_pathprog_path"; do
65                         case "$ensc_pathprog_path" in
66                                 ../*) $1=`readlink -f "${$1}"`; break ;;
67                         esac
68                         ensc_pathprog_path=`readlink "$ensc_pathprog_path"`
69                 done
70         fi
71
72         test "${$1}" && ENSC_PATHPROG_SED="${ENSC_PATHPROG_SED}s!@'$1'@!${$1}!g;"
73
74         test "${$1}"])
75
76
77
78 dnl Usage: ENSC_PATHPROG_STANDARD_TOOLS)
79 AC_DEFUN([ENSC_PATHPROG_STANDARD_TOOLS],
80 [
81         ENSC_PATHPROG(AWK,       awk)
82         ENSC_PATHPROG(CAT,       cat)
83         ENSC_PATHPROG(CHOWN,     chown)
84         ENSC_PATHPROG(CMP,       cmp)
85         ENSC_PATHPROG(CP,        cp)
86         ENSC_PATHPROG(DIRNAME,   dirname)
87         ENSC_PATHPROG(EGREP,     egrep, [], [], no-deref)
88         ENSC_PATHPROG(ENV,       env)
89         ENSC_PATHPROG(GREP,      grep)
90         ENSC_PATHPROG(LN,        ln)
91         ENSC_PATHPROG(MKDIR,     mkdir)
92         ENSC_PATHPROG(MKFIFO,    mkfifo)
93         ENSC_PATHPROG(MKTEMP,    mktemp)
94         ENSC_PATHPROG(MOUNT,     mount)
95         ENSC_PATHPROG(MV,        mv)
96         ENSC_PATHPROG(NICE,      nice)
97         ENSC_PATHPROG(PS,        ps)
98         ENSC_PATHPROG(RM,        rm)
99         ENSC_PATHPROG(RMDIR,     rmdir)
100         ENSC_PATHPROG(SED,       sed)
101         ENSC_PATHPROG(SH,        sh)
102         ENSC_PATHPROG(TAC,       tac)
103         ENSC_PATHPROG(TAR,       tar)
104         ENSC_PATHPROG(TOUCH,     touch)
105         ENSC_PATHPROG(TTY,       tty)
106         ENSC_PATHPROG(UMOUNT,    umount)
107         ENSC_PATHPROG(WC,        wc)
108 ])
109