add g-wrap patch and discussion of it in INSTALL instructions.
[gwave-svn.git] / acinclude.m4
blob1d4f4666abdfeb373ab7112236ec8b3324965f49
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.
7 dnl
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.
15 else
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.
20   ac_dummy="$PATH"
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
25            ac_cv_prog_$1="$4"
26         else
27           ac_bogus=$ac_dir/$ac_word
28           ac_prog_rejected=yes
29           continue
30       fi
31       break
32     fi
33   done
34   IFS="$ac_save_ifs"
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
38   shift
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.
43     shift
44     set dummy "$ac_dir/$ac_word" "[$]@"
45     shift
46     ac_cv_prog_$1="[$]@"
47 ifelse([$2], [$5], dnl
48 [  else
49     # Default is a loser.
50     AC_MSG_ERROR([$1=$ac_bogus unacceptable, but no other $5 found in [\$]PATH])
51 ])dnl
52   fi
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"
57 ])dnl
58 fi])dnl
59 $1="$ac_cv_prog_$1"
60 if test -n "[$]$1"; then
61   AC_MSG_RESULT([$]$1)
62 else
63   AC_MSG_RESULT(no)
65 AC_SUBST($1)dnl