blob: 5c4d1904fc7d62c4358844209621f457bb50fa49 [file] [log] [blame]
Reid Spencera5e26072005-07-17 00:50:40 +00001dnl Check a program for version sanity. The test runs a program, passes it an
2dnl argument to make it print out some identification string, and filters that
3dnl output with a regular expression. If the output is non-empty, the program
4dnl passes the sanity check.
5dnl $1 - Name or full path of the program to run
6dnl $2 - Argument to pass to print out identification string
7dnl $3 - grep RE to match identification string
8AC_DEFUN([CHECK_PROGRAM_SANITY],
9[
10AC_MSG_CHECKING([sanity for program ]$1)
11sanity_path=`which $1 2>/dev/null`
12if test "$?" -eq 0 -a -x "$sanity_path" ; then
13 sanity=`$1 $2 2>&1 | grep "$3"`
14 if test -z "$sanity" ; then
15 AC_MSG_RESULT([no])
16 AC_MSG_ERROR([Program ]$1[ failed to pass sanity check.])
17 fi
18 AC_MSG_RESULT([yes])
19else
20 AC_MSG_RESULT([not found])
21fi
22])