From 0f1ff38476ba255eb1f066f675c8721168ff2295 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Tue, 23 Sep 2014 13:31:33 -0400 Subject: [PATCH] Make --enable-debug fail when given bogus args Currently, bogus options to --enable-debug become --disable-debug. That means that passing --enable-debug=true is analogous to --disable-debug, but the result is counterintuitive. We switch to AS_CASE to allow us to fail when given a bogus option. Also, we modify the text printed to clarify that --enable-debug enables assertions. Reviewed-by: Chunwei Chen Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Closes #2734 --- config/zfs-build.m4 | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index 7651dc2c12..78a87aef72 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -6,30 +6,37 @@ AC_DEFUN([ZFS_AC_LICENSE], [ AC_MSG_RESULT([$ZFS_META_LICENSE]) ]) +AC_DEFUN([ZFS_AC_DEBUG_ENABLE], [ + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" + HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG -Werror" + DEBUG_CFLAGS="-DDEBUG -Werror" + DEBUG_STACKFLAGS="-fstack-check" + DEBUG_ZFS="_with_debug" + AC_DEFINE(ZFS_DEBUG, 1, [zfs debugging enabled]) +]) + +AC_DEFUN([ZFS_AC_DEBUG_DISABLE], [ + KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG " + HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG " + DEBUG_CFLAGS="-DNDEBUG" + DEBUG_STACKFLAGS="" + DEBUG_ZFS="_without_debug" +]) + AC_DEFUN([ZFS_AC_DEBUG], [ - AC_MSG_CHECKING([whether debugging is enabled]) + AC_MSG_CHECKING([whether assertion support will be enabled]) AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], - [Enable generic debug support @<:@default=no@:>@])], + [Enable assertion support @<:@default=no@:>@])], [], [enable_debug=no]) - AS_IF([test "x$enable_debug" = xyes], - [ - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" - HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG -Werror" - DEBUG_CFLAGS="-DDEBUG -Werror" - DEBUG_STACKFLAGS="-fstack-check" - DEBUG_ZFS="_with_debug" - AC_DEFINE(ZFS_DEBUG, 1, [zfs debugging enabled]) - ], - [ - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG " - HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG " - DEBUG_CFLAGS="-DNDEBUG" - DEBUG_STACKFLAGS="" - DEBUG_ZFS="_without_debug" - ]) + AS_CASE(["x$enable_debug"], + ["xyes"], + [ZFS_AC_DEBUG_ENABLE], + ["xno"], + [ZFS_AC_DEBUG_DISABLE], + [AC_MSG_ERROR([Unknown option $enable_debug])]) AC_SUBST(DEBUG_CFLAGS) AC_SUBST(DEBUG_STACKFLAGS)