Revision 0dba6195

b/configure
27 27
  $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null
28 28
}
29 29

  
30
# check whether a command is available to this shell (may be either an
31
# executable or a builtin)
32
has() {
33
    type "$1" >/dev/null 2>&1
34
}
35

  
36
# search for an executable in PATH
37
path_of() {
38
    local_command="$1"
39
    local_ifs="$IFS"
40
    local_dir=""
41

  
42
    # pathname has a dir component?
43
    if [ "${local_command#*/}" != "$local_command" ]; then
44
        if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then
45
            echo "$local_command"
46
            return 0
47
        fi
48
    fi
49
    if [ -z "$local_command" ]; then
50
        return 1
51
    fi
52

  
53
    IFS=:
54
    for local_dir in $PATH; do
55
        if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then
56
            echo "$local_dir/$local_command"
57
            IFS="${local_ifs:-$(printf ' \t\n')}"
58
            return 0
59
        fi
60
    done
61
    # not found
62
    IFS="${local_ifs:-$(printf ' \t\n')}"
63
    return 1
64
}
65

  
30 66
# default parameters
31 67
cpu=""
32 68
prefix=""
......
767 803
# Solaris specific configure tool chain decisions
768 804
#
769 805
if test "$solaris" = "yes" ; then
770
  solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"`
806
  solinst=`path_of $install`
771 807
  if test -z "$solinst" ; then
772 808
    echo "Solaris install program not found. Use --install=/usr/ucb/install or"
773 809
    echo "install fileutils from www.blastwave.org using pkg-get -i fileutils"
......
780 816
    echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install"
781 817
    exit 1
782 818
  fi
783
  sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"`
819
  sol_ar=`path_of ar`
784 820
  if test -z "$sol_ar" ; then
785 821
    echo "Error: No path includes ar"
786 822
    if test -f /usr/ccs/bin/ar ; then
......
973 1009
# pkgconfig probe
974 1010

  
975 1011
pkgconfig="${cross_prefix}pkg-config"
976
if ! test -x "$(which $pkgconfig 2>/dev/null)"; then
1012
if ! has $pkgconfig; then
977 1013
  # likely not cross compiling, or hope for the best
978 1014
  pkgconfig=pkg-config
979 1015
fi
......
981 1017
##########################################
982 1018
# Sparse probe
983 1019
if test "$sparse" != "no" ; then
984
  if test -x "$(which cgcc 2>/dev/null)"; then
1020
  if has cgcc; then
985 1021
    sparse=yes
986 1022
  else
987 1023
    if test "$sparse" = "yes" ; then
......
997 1033
if $pkgconfig sdl --modversion >/dev/null 2>&1; then
998 1034
  sdlconfig="$pkgconfig sdl"
999 1035
  _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'`
1000
elif which sdl-config >/dev/null 2>&1; then
1036
elif has sdl-config; then
1001 1037
  sdlconfig='sdl-config'
1002 1038
  _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'`
1003 1039
else
......
1428 1464
    fi
1429 1465
  else
1430 1466
    if test "$kvm" = "yes" ; then
1431
      if [ -x "`which awk 2>/dev/null`" ] && \
1432
         [ -x "`which grep 2>/dev/null`" ]; then
1467
      if has awk && has grep; then
1433 1468
        kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \
1434 1469
	| grep "error: " \
1435 1470
	| awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'`
......
1698 1733

  
1699 1734
# Check if tools are available to build documentation.
1700 1735
if test "$docs" != "no" ; then
1701
  if test -x "`which texi2html 2>/dev/null`" -a \
1702
          -x "`which pod2man 2>/dev/null`" ; then
1736
  if has texi2html && has pod2man; then
1703 1737
    docs=yes
1704 1738
  else
1705 1739
    if test "$docs" = "yes" ; then

Also available in: Unified diff