Skip to content

Commit 9caad37

Browse files
authored
Autotools: Refactor Valgrind support (#14736)
When Valgrind is enabled and not found on the system, default error can be thrown by PKG_CHECK_MODULES instead of writing a manual error step. - This uses less redundant variables and has synced CS. - AS_VAR_IF used instead of raw shell ifs - Added some basic help descriptions for macro definitions
1 parent 445c1c9 commit 9caad37

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

configure.ac

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -766,26 +766,19 @@ if test "$ac_cv__asm_goto" = yes; then
766766
AC_DEFINE([HAVE_ASM_GOTO], [1], [Define if asm goto support is available.])
767767
fi
768768

769-
dnl Check valgrind support.
769+
dnl Check Valgrind support.
770770
PHP_ARG_WITH([valgrind],
771-
[whether to enable valgrind support],
771+
[whether to enable Valgrind support],
772772
[AS_HELP_STRING([--with-valgrind],
773-
[Enable valgrind support])],
773+
[Enable Valgrind support])],
774774
[no],
775775
[no])
776776

777-
if test "$PHP_VALGRIND" != "no"; then
778-
PKG_CHECK_MODULES([VALGRIND], [valgrind], [have_valgrind="yes"], [have_valgrind="no"])
779-
780-
if test "$have_valgrind" = "yes"; then
781-
PHP_EVAL_INCLINE($VALGRIND_CFLAGS)
782-
AC_DEFINE(HAVE_VALGRIND, 1, [ ])
783-
else
784-
if test "$with_valgrind" = "yes"; then
785-
AC_MSG_ERROR([Valgrind not found. Please install Valgrind.])
786-
fi
787-
fi
788-
fi
777+
AS_VAR_IF([PHP_VALGRIND], [no],,
778+
[PKG_CHECK_MODULES([VALGRIND], [valgrind],
779+
[PHP_EVAL_INCLINE([$VALGRIND_CFLAGS])
780+
AC_DEFINE([HAVE_VALGRIND], [1],
781+
[Define to 1 if Valgrind is enabled and supported.])])])
789782

790783
dnl Check for openpty. It may require linking against libutil or libbsd.
791784
AC_CHECK_FUNCS([openpty],,

ext/pcre/config0.m4

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,13 @@ else
9595
AC_MSG_RESULT([no])
9696
fi
9797

98+
dnl Enable pcre Valgrind support only in DEBUG build (it affects performance).
99+
AS_VAR_IF([PHP_VALGRIND], [no],,
100+
[AS_VAR_IF([ZEND_DEBUG], [yes],
101+
[AC_DEFINE([HAVE_PCRE_VALGRIND_SUPPORT], [1],
102+
[Define to 1 if pcre has Valgrind support enabled.])])])
103+
98104
PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS)
99105
PHP_ADD_BUILD_DIR($ext_builddir/pcre2lib)
100106
PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcre2lib/])
101-
102-
if test "$PHP_VALGRIND" != "no" && test "$have_valgrind" = "yes"; then
103-
dnl Enable pcre valgrind support only in DEBUG build (it affects performance)
104-
if test "$ZEND_DEBUG" = "yes"; then
105-
AC_DEFINE(HAVE_PCRE_VALGRIND_SUPPORT, 1, [ ])
106-
fi
107-
fi
108107
fi

0 commit comments

Comments
 (0)