]> granicus.if.org Git - zfs/commitdiff
Make --enable-debug fail when given bogus args
authorRichard Yao <richard.yao@clusterhq.com>
Tue, 23 Sep 2014 17:31:33 +0000 (13:31 -0400)
committerTony Hutter <hutter2@llnl.gov>
Wed, 14 Mar 2018 23:10:35 +0000 (16:10 -0700)
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 <tuxoko@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@clusterhq.com>
Closes #2734

config/zfs-build.m4

index 7651dc2c12e4ae80518999ba2a3c9a580e302f51..78a87aef7253d533949ad4d52bda9f4773d775f5 100644 (file)
@@ -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)