From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 3C90F3858403; Fri, 26 Aug 2022 14:31:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C90F3858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1661524304; bh=45mIiGQDwzGlreSsBcFbrVjt/TmbubPXTY4q7THrMtI=; h=From:To:Subject:Date:From; b=l6wOpdJ6Qq/rYvnMTJvDm6UFbiEA5b+5cBY6nDa8oFhHFnlSAC8qO4zH5wtqO76Zk 9Qvl0+SKpbG99NzB4E5KgRr7YxonWVlKI5aDtix9kdaGyGT5y2aLgvdc6X5hZ8EkTB 2nlAth8qUia2OwX35JLMQfd+7Avc7LRjkxkcBlRI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb, gdbsupport: configure: factor out yes/no/auto value checking X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 3055522ab17ac7c6781a3507ebac0fab1c3aa5a4 X-Git-Newrev: 4fd404c298db4e19dbf87331d3b02f451af4c5cd Message-Id: <20220826143144.3C90F3858403@sourceware.org> Date: Fri, 26 Aug 2022 14:31:44 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4fd404c298db= 4e19dbf87331d3b02f451af4c5cd commit 4fd404c298db4e19dbf87331d3b02f451af4c5cd Author: Simon Marchi Date: Thu Jul 28 16:09:45 2022 -0400 gdb, gdbsupport: configure: factor out yes/no/auto value checking =20 Factor out the code that checks that a value is yes/no or yes/no/auto. Add two macros to gdbsupport/common.m4 and use them in gdb/configure.ac =20 I inspected the changes to configure. Other than whitespace changes, we have some benign changes to the error messages (one of them had an error actually). There are changes to the --enable-source-highlight and --enable-libbacktrace handling, but setting enable_source_highlight / enable_libbacktrace was not really useful anyway, they already had the right value. =20 Change-Id: I92587aec36874309e1605e2d60244649f09a757a Diff: --- gdb/configure | 96 +++++++++++++++++++++++++++++++-----------------= ---- gdb/configure.ac | 84 ++++++++++++++++----------------------------- gdbsupport/common.m4 | 28 +++++++++++++++ 3 files changed, 115 insertions(+), 93 deletions(-) diff --git a/gdb/configure b/gdb/configure index 4b5e031bff9..4dbd0c3b13c 100755 --- a/gdb/configure +++ b/gdb/configure @@ -6817,12 +6817,15 @@ fi # Enable MI. # Check whether --enable-gdbmi was given. if test "${enable_gdbmi+set}" =3D set; then : - enableval=3D$enable_gdbmi; case $enableval in - yes | no) - ;; - *) - as_fn_error $? "bad value $enableval for --enable-gdbmi" "$LINENO" 5= ;; - esac + enableval=3D$enable_gdbmi; + case $enableval in + yes | no) + ;; + *) + as_fn_error $? "bad value $enableval for --enable-gdbmi" "$LINENO"= 5 + ;; + esac + else enable_gdbmi=3Dyes fi @@ -6839,12 +6842,15 @@ fi # Enable TUI. # Check whether --enable-tui was given. if test "${enable_tui+set}" =3D set; then : - enableval=3D$enable_tui; case $enableval in - yes | no | auto) - ;; - *) - as_fn_error $? "bad value $enableval for --enable-tui" "$LINENO" 5 ;; - esac + enableval=3D$enable_tui; + case $enableval in + yes | no | auto) + ;; + *) + as_fn_error $? "bad value $enableval for --enable-tui" "$LINENO" 5 + ;; + esac + else enable_tui=3Dauto fi @@ -6853,18 +6859,21 @@ fi # Enable gdbtk. # Check whether --enable-gdbtk was given. if test "${enable_gdbtk+set}" =3D set; then : - enableval=3D$enable_gdbtk; case $enableval in - yes | no) - ;; - *) - as_fn_error $? "bad value $enableval for --enable-gdbtk" "$LINENO" 5= ;; - esac + enableval=3D$enable_gdbtk; + case $enableval in + yes | no) + ;; + *) + as_fn_error $? "bad value $enableval for --enable-gdbtk" "$LINENO"= 5 + ;; + esac + else if test -d "$srcdir/gdbtk"; then - enable_gdbtk=3Dyes - else - enable_gdbtk=3Dno - fi + enable_gdbtk=3Dyes + else + enable_gdbtk=3Dno + fi fi =20 # We unconditionally disable gdbtk tests on selected platforms. @@ -7205,12 +7214,15 @@ fi # Profiling support. # Check whether --enable-profiling was given. if test "${enable_profiling+set}" =3D set; then : - enableval=3D$enable_profiling; case $enableval in - yes | no) - ;; - *) - as_fn_error $? "bad value $enableval for --enable-profile" "$LINENO"= 5 ;; - esac + enableval=3D$enable_profiling; + case $enableval in + yes | no) + ;; + *) + as_fn_error $? "bad value $enableval for --enable-profiling" "$LIN= ENO" 5 + ;; + esac + else enable_profiling=3Dno fi @@ -12039,11 +12051,15 @@ SRCHIGH_CFLAGS=3D =20 # Check whether --enable-source-highlight was given. if test "${enable_source_highlight+set}" =3D set; then : - enableval=3D$enable_source_highlight; case "${enableval}" in - yes) enable_source_highlight=3Dyes ;; - no) enable_source_highlight=3Dno ;; - *) as_fn_error $? "bad value ${enableval} for source-highlight option= " "$LINENO" 5 ;; -esac + enableval=3D$enable_source_highlight; + case $enableval in + yes | no | auto) + ;; + *) + as_fn_error $? "bad value $enableval for --enable-source-highlight= " "$LINENO" 5 + ;; + esac + else enable_source_highlight=3Dauto fi @@ -18756,11 +18772,15 @@ fi # Setup possible use of libbacktrace. # Check whether --enable-libbacktrace was given. if test "${enable_libbacktrace+set}" =3D set; then : - enableval=3D$enable_libbacktrace; case "${enableval}" in - yes) enable_libbacktrace=3Dyes ;; - no) enable_libbacktrace=3Dno ;; - *) as_fn_error $? "bad value ${enableval} for --enable-libbacktrace o= ption" "$LINENO" 5 ;; -esac + enableval=3D$enable_libbacktrace; + case $enableval in + yes | no) + ;; + *) + as_fn_error $? "bad value $enableval for --enable-libbacktrace" "$= LINENO" 5 + ;; + esac + else enable_libbacktrace=3Dyes fi diff --git a/gdb/configure.ac b/gdb/configure.ac index b681988d7a4..215a91c5b27 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -259,15 +259,10 @@ if test "x$targ_defvec" !=3D x; then fi =20 # Enable MI. -AC_ARG_ENABLE(gdbmi, -AS_HELP_STRING([--disable-gdbmi], [disable machine-interface (MI)]), - [case $enableval in - yes | no) - ;; - *) - AC_MSG_ERROR([bad value $enableval for --enable-gdbmi]) ;; - esac], - [enable_gdbmi=3Dyes]) +AC_ARG_ENABLE([gdbmi], + [AS_HELP_STRING([--disable-gdbmi], [disable machine-interface (MI)]= )], + [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-gdbmi])], + [enable_gdbmi=3Dyes]) if test x"$enable_gdbmi" =3D xyes; then if test -d "$srcdir/mi"; then CONFIG_OBS=3D"$CONFIG_OBS \$(SUBDIR_MI_OBS)" @@ -279,28 +274,20 @@ fi =20 # Enable TUI. AC_ARG_ENABLE(tui, -AS_HELP_STRING([--enable-tui], [enable full-screen terminal user interface= (TUI)]), - [case $enableval in - yes | no | auto) - ;; - *) - AC_MSG_ERROR([bad value $enableval for --enable-tui]) ;; - esac],enable_tui=3Dauto) +AS_HELP_STRING([--enable-tui], + [enable full-screen terminal user interface (TUI)]), + [GDB_CHECK_YES_NO_AUTO_VAL([$enableval], [--enable-tui])], + [enable_tui=3Dauto]) =20 # Enable gdbtk. -AC_ARG_ENABLE(gdbtk, -AS_HELP_STRING([--enable-gdbtk], [enable gdbtk graphical user interface (G= UI)]), - [case $enableval in - yes | no) - ;; - *) - AC_MSG_ERROR([bad value $enableval for --enable-gdbtk]) ;; - esac], - [if test -d "$srcdir/gdbtk"; then - enable_gdbtk=3Dyes - else - enable_gdbtk=3Dno - fi]) +AC_ARG_ENABLE([gdbtk], + [AS_HELP_STRING([--enable-gdbtk], [enable gdbtk graphical user inte= rface (GUI)])], + [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-gdbtk])], + [if test -d "$srcdir/gdbtk"; then + enable_gdbtk=3Dyes + else + enable_gdbtk=3Dno + fi]) # We unconditionally disable gdbtk tests on selected platforms. case $host_os in go32* | windows*) @@ -359,15 +346,10 @@ if test "$opt_curses" =3D "yes"; then fi =20 # Profiling support. -AC_ARG_ENABLE(profiling, -AS_HELP_STRING([--enable-profiling], [enable profiling of GDB]), - [case $enableval in - yes | no) - ;; - *) - AC_MSG_ERROR([bad value $enableval for --enable-profile]) ;; - esac], - [enable_profiling=3Dno]) +AC_ARG_ENABLE([profiling], + [AS_HELP_STRING([--enable-profiling], [enable profiling of GDB])], + [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-profiling])], + [enable_profiling=3Dno]) =20 AC_CHECK_FUNCS(monstartup _mcleanup) AC_CACHE_CHECK( @@ -1197,15 +1179,11 @@ AM_CONDITIONAL(HAVE_GUILE, test "${have_libguile}" = !=3D no) SRCHIGH_LIBS=3D SRCHIGH_CFLAGS=3D =20 -AC_ARG_ENABLE(source-highlight, - AS_HELP_STRING([--enable-source-highlight], - [enable source-highlight for source listings]), - [case "${enableval}" in - yes) enable_source_highlight=3Dyes ;; - no) enable_source_highlight=3Dno ;; - *) AC_MSG_ERROR(bad value ${enableval} for source-highlight option) ;; -esac], -[enable_source_highlight=3Dauto]) +AC_ARG_ENABLE([source-highlight], + [AS_HELP_STRING([--enable-source-highlight], + [enable source-highlight for source listings])], + [GDB_CHECK_YES_NO_AUTO_VAL([$enableval], [--enable-source-highlight= ])], + [enable_source_highlight=3Dauto]) =20 if test "${enable_source_highlight}" !=3D "no"; then AC_MSG_CHECKING([for the source-highlight library]) @@ -2105,14 +2083,10 @@ fi =20 # Setup possible use of libbacktrace. AC_ARG_ENABLE([libbacktrace], -[AS_HELP_STRING([--enable-libbacktrace], - [use libbacktrace to write a backtrace after a fatal signa= l.])], -[case "${enableval}" in - yes) enable_libbacktrace=3Dyes ;; - no) enable_libbacktrace=3Dno ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-libbacktrace opti= on) ;; -esac], -enable_libbacktrace=3Dyes) + [AS_HELP_STRING([--enable-libbacktrace], + [use libbacktrace to write a backtrace after a fatal signal.])], + [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-libbacktrace])], + [enable_libbacktrace=3Dyes]) =20 if test "${enable_libbacktrace}" =3D "yes"; then LIBBACKTRACE_INC=3D"-I$srcdir/../libbacktrace/ -I../libbacktrace/" diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4 index d3e9ecbe823..0fed186ae1d 100644 --- a/gdbsupport/common.m4 +++ b/gdbsupport/common.m4 @@ -216,3 +216,31 @@ AC_DEFUN([GDB_AC_COMMON], [ BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t) fi ]) + +dnl Check that the provided value ($1) is either "yes" or "no". If not, +dnl emit an error message mentionning the configure option $2, and abort +dnl the script. +AC_DEFUN([GDB_CHECK_YES_NO_VAL], + [ + case $1 in + yes | no) + ;; + *) + AC_MSG_ERROR([bad value $1 for $2]) + ;; + esac + ]) + +dnl Check that the provided value ($1) is either "yes", "no" or "auto". I= f not, +dnl emit an error message mentionning the configure option $2, and abort +dnl the script. +AC_DEFUN([GDB_CHECK_YES_NO_AUTO_VAL], + [ + case $1 in + yes | no | auto) + ;; + *) + AC_MSG_ERROR([bad value $1 for $2]) + ;; + esac + ])