Check the value of the sanitize argument to determine if sanitize should
be enabled. This fixes that sanitize is enabled when --disable-sanitize
is passed to the configure script.
The third AC_ARG_ENABLE parameter defines an action, if the parameter is
present, but doesn't check its value. Therefore it is also invoked if the
parameter is disabled or --enable-foo=no is set. Therefore don't define
these actions and instead check the value with an AS_IF statement
afterwards, as shown in [1].
[1] https://autotools.info/autoconf/arguments.html
[guillem@hadrons.org:
- Minor coding style fixes.
- Minor wording fixes in commit message. ]
Fixes: 257800a03c6b ("build: Add support for sanitizer compiler flags")
Closes: !31
Signed-off-by: Guillem Jover <guillem@hadrons.org>
CFLAGS="$CFLAGS $LIBBSD_COMPILER_FLAGS"
AC_ARG_ENABLE([sanitize],
- [AS_HELP_STRING([--enable-sanitize], [enable compiler sanitizer support])],
- [
+ [AS_HELP_STRING([--enable-sanitize], [enable compiler sanitizer support])])
+ AS_IF([test "x$enable_sanitize" = "xyes"], [
LIBBSD_COMPILER_FLAGS=''
LIBBSD_CHECK_COMPILER_FLAG([-fsanitize=address])
LIBBSD_CHECK_COMPILER_FLAG([-fsanitize=leak])