m4: merge TangentOrg/ddm4
[awesomized/libmemcached] / m4 / ax_prog_valgrind.m4
1 # ===========================================================================
2 # https://github.com/BrianAker/ddm4
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_PROG_VALGRIND([tool],[options],[ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
8 #
9 # DESCRIPTION
10 #
11 # Look for valgrind and make sure it is a recent version of it.
12 #
13 # LICENSE
14 #
15 # Copyright (c) 2012-2013 Brian Aker <brian@tangent.org>
16 #
17 # Copying and distribution of this file, with or without modification, are
18 # permitted in any medium without royalty provided the copyright notice
19 # and this notice are preserved. This file is offered as-is, without any
20 # warranty.
21
22 #serial 1
23
24 AC_DEFUN([AX_PROG_VALGRIND],
25 [AX_WITH_PROG([VALGRIND],[valgrind],[:])
26 AS_IF([test x"VALGRIND" = x":"],
27 [VALGRIND=],
28 [AS_IF([test -x "$VALGRIND"],
29 [AC_MSG_CHECKING([Checking to see if $VALGRIND is recent])
30 junk=`$VALGRIND --version &> version_file`
31 ax_valgrind_version=`head -1 version_file`
32 rm version_file
33 AC_MSG_RESULT([$VALGRIND is version "$ax_valgrind_version"])
34 ])
35 ])
36
37 AS_IF([test -n "${VALGRIND}"],
38 [AC_SUBST([VALGRIND])
39 LIBTOOL_COMMAND="\${LIBTOOL} --mode=execute"
40 AC_SUBST([LIBTOOL_COMMAND])
41 AX_ADD_AM_MACRO([[TESTS_ENVIRONMENT=\"\${LIBTOOL_COMMAND} \${VALGRIND} --tool=$1 $2\"]])
42 ifelse([$3], , :, [$3])],
43 [ifelse([$4], , :, [$4])])
44 ])