2005-07-17 00:50:40 +00:00
|
|
|
dnl Check a program for version sanity. The test runs a program, passes it an
|
|
|
|
dnl argument to make it print out some identification string, and filters that
|
|
|
|
dnl output with a regular expression. If the output is non-empty, the program
|
|
|
|
dnl passes the sanity check.
|
|
|
|
dnl $1 - Name or full path of the program to run
|
|
|
|
dnl $2 - Argument to pass to print out identification string
|
|
|
|
dnl $3 - grep RE to match identification string
|
2005-12-22 02:08:30 +00:00
|
|
|
dnl $4 - set to 1 to make errors only a warning
|
2005-07-17 00:50:40 +00:00
|
|
|
AC_DEFUN([CHECK_PROGRAM_SANITY],
|
|
|
|
[
|
|
|
|
AC_MSG_CHECKING([sanity for program ]$1)
|
2007-01-03 20:59:52 +00:00
|
|
|
sanity="0"
|
2005-07-17 00:50:40 +00:00
|
|
|
sanity_path=`which $1 2>/dev/null`
|
|
|
|
if test "$?" -eq 0 -a -x "$sanity_path" ; then
|
|
|
|
sanity=`$1 $2 2>&1 | grep "$3"`
|
|
|
|
if test -z "$sanity" ; then
|
|
|
|
AC_MSG_RESULT([no])
|
2006-12-04 20:28:07 +00:00
|
|
|
sanity="0"
|
2005-12-22 02:08:30 +00:00
|
|
|
if test "$4" -eq 1 ; then
|
|
|
|
AC_MSG_WARN([Program ]$1[ failed to pass sanity check.])
|
|
|
|
else
|
|
|
|
AC_MSG_ERROR([Program ]$1[ failed to pass sanity check.])
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
AC_MSG_RESULT([yes])
|
2006-12-04 20:28:07 +00:00
|
|
|
sanity="1"
|
2005-07-17 00:50:40 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
AC_MSG_RESULT([not found])
|
|
|
|
fi
|
|
|
|
])
|