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)