3 dnl AC_PROG_GREPSTDOUT(var-to-set, program-to-find, string to grep for,
4 dnl value-if-found, value-if-unfound)
5 dnl try all programs in $PATH named program-to-find, grepping their
6 dnl stdout for the indicated string. First one to pass wins.
8 AC_DEFUN([AC_PROG_GREPSTDOUT],
9 [# Extract the first word of "$2", so it can be a program name with args.
10 set dummy $2; ac_word=[$]2
11 AC_MSG_CHECKING([for suitable $ac_word])
12 AC_CACHE_VAL(ac_cv_prog_$1,
13 [if test -n "[$]$1"; then
14 ac_cv_prog_$1="[$]$1" # Let the user override the test.
16 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
17 dnl $ac_dummy forces splitting on constant user-supplied paths.
18 dnl POSIX.2 word splitting is done only on the output of word expansions,
19 dnl not every word. This closes a longstanding sh security hole.
21 for ac_dir in $ac_dummy; do
22 test -z "$ac_dir" && ac_dir=.
23 if test -f $ac_dir/$ac_word; then
24 if ($ac_dir/$2 | grep $3 >/dev/null) ; then
27 ac_bogus=$ac_dir/$ac_word
35 if test "$ac_prog_rejected" = yes; then
36 # We found a bogon in the path, so make sure we never use it.
37 set dummy [$]ac_cv_prog_$1
39 if test [$]# -gt 0; then
40 # We chose a different compiler from the bogus one.
41 # However, it has the same basename, so the bogon will be chosen
42 # first if we set $1 to just the basename; use the full file name.
44 set dummy "$ac_dir/$ac_word" "[$]@"
47 ifelse([$2], [$5], dnl
50 AC_MSG_ERROR([$1=$ac_bogus unacceptable, but no other $5 found in [\$]PATH])
54 dnl If no 5th arg is given, leave the cache variable unset,
55 dnl so AC_PROG_GREPSTDOUT will keep looking.
56 ifelse([$5], , , [ test -z "[$]ac_cv_prog_$1" && ac_cv_prog_$1="$5"
60 if test -n "[$]$1"; then