1##
2##  shtool.m4 -- GNU shtool Autoconf macros
3##  Copyright (c) 1999-2008 Ralf S. Engelschall <rse@engelschall.com>
4##
5##  This file is part of shtool and free software; you can redistribute
6##  it and/or modify it under the terms of the GNU General Public
7##  License as published by the Free Software Foundation; either version
8##  2 of the License, or (at your option) any later version.
9##
10##  This file is distributed in the hope that it will be useful,
11##  but WITHOUT ANY WARRANTY; without even the implied warranty of
12##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13##  General Public License for more details.
14##
15##  You should have received a copy of the GNU General Public License
16##  along with this program; if not, write to the Free Software
17##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
19##
20
21##
22##  the standard macro for finding GNU shtool:
23##  AC_PROG_SHTOOL
24##
25AC_DEFUN([AC_PROG_SHTOOL],[dnl
26AC_PREREQ(2.13)dnl
27AC_MSG_CHECKING([for GNU shtool])
28AC_CACHE_VAL(ac_cv_shtool,[dnl
29#   canonicalize and split path string
30ac_paths="`echo .:$ac_aux_dir:$PATH |\
31           sed -e 's%/*:%:%g' -e 's%/*$%%' \
32               -e 's/^:/.:/' -e 's/::/:.:/g' -e 's/:$/:./' \
33               -e 's/:/ /g'`"
34#   iterate over $PATH but prefer CWD
35ac_cv_shtool=""
36for ac_path in $ac_paths; do
37    if test -f "$ac_path/shtool" && test ! -d "$ac_path/shtool"; then
38        ac_cv_shtool="$ac_path/shtool"
39        break
40    fi
41done
42#   check for existance
43if test ".$ac_cv_shtool" = .; then
44    AC_MSG_ERROR([no shtool found in .:$PATH])
45fi
46#   check deeper
47ac_rc=`($ac_cv_shtool --version) </dev/null 2>/dev/null | grep 'GNU shtool'`
48if test ".$ac_rc" = .; then
49    ac_cv_shtool="${CONFIG_SHELL-/bin/sh} $ac_cv_shtool"
50    ac_rc=`($ac_cv_shtool --version) </dev/null 2>/dev/null | grep 'GNU shtool'`
51    if test ".$ac_rc" = .; then
52        AC_MSG_ERROR([$ac_cv_shtool seems not to be GNU shtool])
53    fi
54fi
55])dnl
56AC_MSG_RESULT([$ac_cv_shtool])
57SHTOOL="$ac_cv_shtool"
58AC_SUBST(SHTOOL)
59])
60
61