gdb, gdbsupport: configure: factor out yes/no/auto value checking

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

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.

Change-Id: I92587aec36874309e1605e2d60244649f09a757a
This commit is contained in:
Simon Marchi 2022-07-28 16:09:45 -04:00 committed by Simon Marchi
parent 3055522ab1
commit 4fd404c298
3 changed files with 115 additions and 93 deletions

96
gdb/configure vendored
View file

@ -6817,12 +6817,15 @@ fi
# Enable MI. # Enable MI.
# Check whether --enable-gdbmi was given. # Check whether --enable-gdbmi was given.
if test "${enable_gdbmi+set}" = set; then : if test "${enable_gdbmi+set}" = set; then :
enableval=$enable_gdbmi; case $enableval in enableval=$enable_gdbmi;
yes | no) case $enableval in
;; yes | no)
*) ;;
as_fn_error $? "bad value $enableval for --enable-gdbmi" "$LINENO" 5 ;; *)
esac as_fn_error $? "bad value $enableval for --enable-gdbmi" "$LINENO" 5
;;
esac
else else
enable_gdbmi=yes enable_gdbmi=yes
fi fi
@ -6839,12 +6842,15 @@ fi
# Enable TUI. # Enable TUI.
# Check whether --enable-tui was given. # Check whether --enable-tui was given.
if test "${enable_tui+set}" = set; then : if test "${enable_tui+set}" = set; then :
enableval=$enable_tui; case $enableval in enableval=$enable_tui;
yes | no | auto) case $enableval in
;; yes | no | auto)
*) ;;
as_fn_error $? "bad value $enableval for --enable-tui" "$LINENO" 5 ;; *)
esac as_fn_error $? "bad value $enableval for --enable-tui" "$LINENO" 5
;;
esac
else else
enable_tui=auto enable_tui=auto
fi fi
@ -6853,18 +6859,21 @@ fi
# Enable gdbtk. # Enable gdbtk.
# Check whether --enable-gdbtk was given. # Check whether --enable-gdbtk was given.
if test "${enable_gdbtk+set}" = set; then : if test "${enable_gdbtk+set}" = set; then :
enableval=$enable_gdbtk; case $enableval in enableval=$enable_gdbtk;
yes | no) case $enableval in
;; yes | no)
*) ;;
as_fn_error $? "bad value $enableval for --enable-gdbtk" "$LINENO" 5 ;; *)
esac as_fn_error $? "bad value $enableval for --enable-gdbtk" "$LINENO" 5
;;
esac
else else
if test -d "$srcdir/gdbtk"; then if test -d "$srcdir/gdbtk"; then
enable_gdbtk=yes enable_gdbtk=yes
else else
enable_gdbtk=no enable_gdbtk=no
fi fi
fi fi
# We unconditionally disable gdbtk tests on selected platforms. # We unconditionally disable gdbtk tests on selected platforms.
@ -7205,12 +7214,15 @@ fi
# Profiling support. # Profiling support.
# Check whether --enable-profiling was given. # Check whether --enable-profiling was given.
if test "${enable_profiling+set}" = set; then : if test "${enable_profiling+set}" = set; then :
enableval=$enable_profiling; case $enableval in enableval=$enable_profiling;
yes | no) case $enableval in
;; yes | no)
*) ;;
as_fn_error $? "bad value $enableval for --enable-profile" "$LINENO" 5 ;; *)
esac as_fn_error $? "bad value $enableval for --enable-profiling" "$LINENO" 5
;;
esac
else else
enable_profiling=no enable_profiling=no
fi fi
@ -12039,11 +12051,15 @@ SRCHIGH_CFLAGS=
# Check whether --enable-source-highlight was given. # Check whether --enable-source-highlight was given.
if test "${enable_source_highlight+set}" = set; then : if test "${enable_source_highlight+set}" = set; then :
enableval=$enable_source_highlight; case "${enableval}" in enableval=$enable_source_highlight;
yes) enable_source_highlight=yes ;; case $enableval in
no) enable_source_highlight=no ;; yes | no | auto)
*) as_fn_error $? "bad value ${enableval} for source-highlight option" "$LINENO" 5 ;; ;;
esac *)
as_fn_error $? "bad value $enableval for --enable-source-highlight" "$LINENO" 5
;;
esac
else else
enable_source_highlight=auto enable_source_highlight=auto
fi fi
@ -18756,11 +18772,15 @@ fi
# Setup possible use of libbacktrace. # Setup possible use of libbacktrace.
# Check whether --enable-libbacktrace was given. # Check whether --enable-libbacktrace was given.
if test "${enable_libbacktrace+set}" = set; then : if test "${enable_libbacktrace+set}" = set; then :
enableval=$enable_libbacktrace; case "${enableval}" in enableval=$enable_libbacktrace;
yes) enable_libbacktrace=yes ;; case $enableval in
no) enable_libbacktrace=no ;; yes | no)
*) as_fn_error $? "bad value ${enableval} for --enable-libbacktrace option" "$LINENO" 5 ;; ;;
esac *)
as_fn_error $? "bad value $enableval for --enable-libbacktrace" "$LINENO" 5
;;
esac
else else
enable_libbacktrace=yes enable_libbacktrace=yes
fi fi

View file

@ -259,15 +259,10 @@ if test "x$targ_defvec" != x; then
fi fi
# Enable MI. # Enable MI.
AC_ARG_ENABLE(gdbmi, AC_ARG_ENABLE([gdbmi],
AS_HELP_STRING([--disable-gdbmi], [disable machine-interface (MI)]), [AS_HELP_STRING([--disable-gdbmi], [disable machine-interface (MI)])],
[case $enableval in [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-gdbmi])],
yes | no) [enable_gdbmi=yes])
;;
*)
AC_MSG_ERROR([bad value $enableval for --enable-gdbmi]) ;;
esac],
[enable_gdbmi=yes])
if test x"$enable_gdbmi" = xyes; then if test x"$enable_gdbmi" = xyes; then
if test -d "$srcdir/mi"; then if test -d "$srcdir/mi"; then
CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_MI_OBS)" CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_MI_OBS)"
@ -279,28 +274,20 @@ fi
# Enable TUI. # Enable TUI.
AC_ARG_ENABLE(tui, AC_ARG_ENABLE(tui,
AS_HELP_STRING([--enable-tui], [enable full-screen terminal user interface (TUI)]), AS_HELP_STRING([--enable-tui],
[case $enableval in [enable full-screen terminal user interface (TUI)]),
yes | no | auto) [GDB_CHECK_YES_NO_AUTO_VAL([$enableval], [--enable-tui])],
;; [enable_tui=auto])
*)
AC_MSG_ERROR([bad value $enableval for --enable-tui]) ;;
esac],enable_tui=auto)
# Enable gdbtk. # Enable gdbtk.
AC_ARG_ENABLE(gdbtk, AC_ARG_ENABLE([gdbtk],
AS_HELP_STRING([--enable-gdbtk], [enable gdbtk graphical user interface (GUI)]), [AS_HELP_STRING([--enable-gdbtk], [enable gdbtk graphical user interface (GUI)])],
[case $enableval in [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-gdbtk])],
yes | no) [if test -d "$srcdir/gdbtk"; then
;; enable_gdbtk=yes
*) else
AC_MSG_ERROR([bad value $enableval for --enable-gdbtk]) ;; enable_gdbtk=no
esac], fi])
[if test -d "$srcdir/gdbtk"; then
enable_gdbtk=yes
else
enable_gdbtk=no
fi])
# We unconditionally disable gdbtk tests on selected platforms. # We unconditionally disable gdbtk tests on selected platforms.
case $host_os in case $host_os in
go32* | windows*) go32* | windows*)
@ -359,15 +346,10 @@ if test "$opt_curses" = "yes"; then
fi fi
# Profiling support. # Profiling support.
AC_ARG_ENABLE(profiling, AC_ARG_ENABLE([profiling],
AS_HELP_STRING([--enable-profiling], [enable profiling of GDB]), [AS_HELP_STRING([--enable-profiling], [enable profiling of GDB])],
[case $enableval in [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-profiling])],
yes | no) [enable_profiling=no])
;;
*)
AC_MSG_ERROR([bad value $enableval for --enable-profile]) ;;
esac],
[enable_profiling=no])
AC_CHECK_FUNCS(monstartup _mcleanup) AC_CHECK_FUNCS(monstartup _mcleanup)
AC_CACHE_CHECK( AC_CACHE_CHECK(
@ -1197,15 +1179,11 @@ AM_CONDITIONAL(HAVE_GUILE, test "${have_libguile}" != no)
SRCHIGH_LIBS= SRCHIGH_LIBS=
SRCHIGH_CFLAGS= SRCHIGH_CFLAGS=
AC_ARG_ENABLE(source-highlight, AC_ARG_ENABLE([source-highlight],
AS_HELP_STRING([--enable-source-highlight], [AS_HELP_STRING([--enable-source-highlight],
[enable source-highlight for source listings]), [enable source-highlight for source listings])],
[case "${enableval}" in [GDB_CHECK_YES_NO_AUTO_VAL([$enableval], [--enable-source-highlight])],
yes) enable_source_highlight=yes ;; [enable_source_highlight=auto])
no) enable_source_highlight=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for source-highlight option) ;;
esac],
[enable_source_highlight=auto])
if test "${enable_source_highlight}" != "no"; then if test "${enable_source_highlight}" != "no"; then
AC_MSG_CHECKING([for the source-highlight library]) AC_MSG_CHECKING([for the source-highlight library])
@ -2105,14 +2083,10 @@ fi
# Setup possible use of libbacktrace. # Setup possible use of libbacktrace.
AC_ARG_ENABLE([libbacktrace], AC_ARG_ENABLE([libbacktrace],
[AS_HELP_STRING([--enable-libbacktrace], [AS_HELP_STRING([--enable-libbacktrace],
[use libbacktrace to write a backtrace after a fatal signal.])], [use libbacktrace to write a backtrace after a fatal signal.])],
[case "${enableval}" in [GDB_CHECK_YES_NO_VAL([$enableval], [--enable-libbacktrace])],
yes) enable_libbacktrace=yes ;; [enable_libbacktrace=yes])
no) enable_libbacktrace=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-libbacktrace option) ;;
esac],
enable_libbacktrace=yes)
if test "${enable_libbacktrace}" = "yes"; then if test "${enable_libbacktrace}" = "yes"; then
LIBBACKTRACE_INC="-I$srcdir/../libbacktrace/ -I../libbacktrace/" LIBBACKTRACE_INC="-I$srcdir/../libbacktrace/ -I../libbacktrace/"

View file

@ -216,3 +216,31 @@ AC_DEFUN([GDB_AC_COMMON], [
BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t) BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
fi 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". If 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
])