Skip to content

Commit 252c19d

Browse files
Ask brew for valgrind include path
Valgrind is typically installed using brew on macOS. This commit makes ./configure detect this case set the appropriate include directory (in the same way as we already do for openssl and gmp).
1 parent 8c727b9 commit 252c19d

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

build-aux/m4/bitcoin_secp.m4

+8
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,11 @@ if test x"$has_gmp" != x"yes"; then
8787
LIBS="$LIBS_TEMP"
8888
fi
8989
])
90+
91+
AC_DEFUN([SECP_VALGRIND_CHECK],[
92+
if test x"$has_valgrind" != x"yes"; then
93+
CPPFLAGS_TEMP="$CPPFLAGS"
94+
CPPFLAGS="$VALGRIND_CPPFLAGS $CPPFLAGS"
95+
AC_CHECK_HEADER([valgrind/memcheck.h], [has_valgrind=yes; AC_DEFINE(HAVE_VALGRIND,1,[Define this symbol if valgrind is installed])])
96+
fi
97+
])

configure.ac

+13-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ case $host_os in
4040
dnl These Homebrew packages may be keg-only, meaning that they won't be found
4141
dnl in expected paths because they may conflict with system files. Ask
4242
dnl Homebrew where each one is located, then adjust paths accordingly.
43-
4443
openssl_prefix=`$BREW --prefix openssl 2>/dev/null`
4544
gmp_prefix=`$BREW --prefix gmp 2>/dev/null`
45+
valgrind_prefix=`$BREW --prefix valgrind 2>/dev/null`
4646
if test x$openssl_prefix != x; then
4747
PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
4848
export PKG_CONFIG_PATH
@@ -52,6 +52,9 @@ case $host_os in
5252
GMP_CPPFLAGS="-I$gmp_prefix/include"
5353
GMP_LIBS="-L$gmp_prefix/lib"
5454
fi
55+
if test x$valgrind_prefix != x; then
56+
VALGRIND_CPPFLAGS="-I$valgrind_prefix/include"
57+
fi
5558
else
5659
AC_PATH_PROG([PORT],port,)
5760
dnl if homebrew isn't installed and macports is, add the macports default paths
@@ -180,12 +183,15 @@ AC_ARG_WITH([valgrind], [AS_HELP_STRING([--with-valgrind=yes|no|auto],
180183
if test x"$req_valgrind" = x"no"; then
181184
enable_valgrind=no
182185
else
183-
AC_CHECK_HEADER([valgrind/memcheck.h], [enable_valgrind=yes], [
186+
SECP_VALGRIND_CHECK
187+
if test x"$has_valgrind" != x"yes"; then
184188
if test x"$req_valgrind" = x"yes"; then
185189
AC_MSG_ERROR([Valgrind support explicitly requested but valgrind/memcheck.h header not available])
186190
fi
187191
enable_valgrind=no
188-
], [])
192+
else
193+
enable_valgrind=yes
194+
fi
189195
fi
190196
AM_CONDITIONAL([VALGRIND_ENABLED],[test "$enable_valgrind" = "yes"])
191197

@@ -424,6 +430,10 @@ if test x"$set_bignum" = x"gmp"; then
424430
SECP_INCLUDES="$SECP_INCLUDES $GMP_CPPFLAGS"
425431
fi
426432

433+
if test x"$enable_valgrind" = x"yes"; then
434+
SECP_INCLUDES="$SECP_INCLUDES $VALGRIND_CPPFLAGS"
435+
fi
436+
427437
if test x"$set_precomp" = x"yes"; then
428438
AC_DEFINE(USE_ECMULT_STATIC_PRECOMPUTATION, 1, [Define this symbol to use a statically generated ecmult table])
429439
fi

0 commit comments

Comments
 (0)