blob: 64cb4243c7a7cf5f0898ccb8dc659495ea18f737 [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
Reid Spencer6697a742005-12-22 02:08:30 +00008dnl $4 - set to 1 to make errors only a warning
Reid Spencera5e26072005-07-17 00:50:40 +00009AC_DEFUN([CHECK_PROGRAM_SANITY],
10[
11AC_MSG_CHECKING([sanity for program ]$1)
12sanity_path=`which $1 2>/dev/null`
13if test "$?" -eq 0 -a -x "$sanity_path" ; then
14 sanity=`$1 $2 2>&1 | grep "$3"`
15 if test -z "$sanity" ; then
16 AC_MSG_RESULT([no])
Reid Spencer36917d92006-12-04 20:28:07 +000017 sanity="0"
Reid Spencer6697a742005-12-22 02:08:30 +000018 if test "$4" -eq 1 ; then
19 AC_MSG_WARN([Program ]$1[ failed to pass sanity check.])
20 else
21 AC_MSG_ERROR([Program ]$1[ failed to pass sanity check.])
22 fi
23 else
24 AC_MSG_RESULT([yes])
Reid Spencer36917d92006-12-04 20:28:07 +000025 sanity="1"
Reid Spencera5e26072005-07-17 00:50:40 +000026 fi
Reid Spencera5e26072005-07-17 00:50:40 +000027else
28 AC_MSG_RESULT([not found])
29fi
30])