Stop `configure` and throw an error when `--with-build-sysroot` is
passed without arguments.

If someone by mistake passes `--with-build-sysroot` only, or sepparates
value by space instead of `=` it currently tries to build creating
errors that are unclearly related to it (i.e., trying to use 'yes' as
the sysroot and deriving weird include paths from it, like
'yes/usr/include').

Since this syntax is valid in a lot of programs (i.e. those built with
getopt_long), throwing an error avoid build-time issues.

ChangeLog:

        * configure.ac: Validate the value passed for
        `--with-build-sysroot` to detect 'yes' (no argument)

        * configure: Regenerate `configure` with `autoreconf-2.69`

gcc/ChangeLog:

        * configure.ac: Validate the value passed for
        `--with-build-sysroot` to detect 'yes' (no argument)
        * configure: Regenerate `configure` with `autoreconf-2.69`

Signed-off-by: Agatha Isabelle Moreira <[email protected]>
---
 configure        | 5 ++++-
 configure.ac     | 5 ++++-
 gcc/configure    | 9 ++++++---
 gcc/configure.ac | 5 ++++-
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index e2150f50aac..b81297050f8 100755
--- a/configure
+++ b/configure
@@ -10898,7 +10898,10 @@ copy_dirs=
 
 # Check whether --with-build-sysroot was given.
 if test "${with_build_sysroot+set}" = set; then :
-  withval=$with_build_sysroot; if test x"$withval" != x ; then
+  withval=$with_build_sysroot; if test x"$withval" = "xyes" ; then
+     as_fn_error $? "--with-build-sysroot requires a path argument, 
use--with-build-sysroot=path" "$LINENO" 5
+   fi
+   if test x"$withval" != x ; then
      SYSROOT_CFLAGS_FOR_TARGET="--sysroot=$withval"
    fi
 else
diff --git a/configure.ac b/configure.ac
index edd53b2bb42..46f8cbc89ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2979,7 +2979,10 @@ copy_dirs=
 AC_ARG_WITH([build-sysroot], 
   [AS_HELP_STRING([--with-build-sysroot=SYSROOT],
                  [use sysroot as the system root during the build])],
-  [if test x"$withval" != x ; then
+  [if test x"$withval" = "xyes" ; then
+     AC_MSG_ERROR([--with-build-sysroot requires a path argument, 
use--with-build-sysroot=path])
+   fi
+   if test x"$withval" != x ; then
      SYSROOT_CFLAGS_FOR_TARGET="--sysroot=$withval"
    fi],
   [SYSROOT_CFLAGS_FOR_TARGET=])
diff --git a/gcc/configure b/gcc/configure
index 1ef7ea3d482..65c0642bd62 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -3719,7 +3719,10 @@ fi
 
 # Check whether --with-build-sysroot was given.
 if test "${with_build_sysroot+set}" = set; then :
-  withval=$with_build_sysroot; if test x"$withval" != x ; then
+  withval=$with_build_sysroot; if test x"$withval" = "xyes"; then
+     as_fn_error $? "--with-build-sysroot requires a path argument, 
use--with-build-sysroot=path" "$LINENO" 5
+   fi
+   if test x"$withval" != x ; then
      SYSROOT_CFLAGS_FOR_TARGET="--sysroot=$withval"
    fi
 else
@@ -21975,7 +21978,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21978 "configure"
+#line 21981 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -22081,7 +22084,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 22084 "configure"
+#line 22087 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 4e8269d03b6..afb6a0d7921 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -140,7 +140,10 @@ AC_ARG_WITH([native-system-header-dir],
 AC_ARG_WITH(build-sysroot, 
   [AS_HELP_STRING([--with-build-sysroot=sysroot],
                   [use sysroot as the system root during the build])],
-  [if test x"$withval" != x ; then
+  [if test x"$withval" = "xyes"; then
+     AC_MSG_ERROR([--with-build-sysroot requires a path argument, 
use--with-build-sysroot=path])
+   fi
+   if test x"$withval" != x ; then
      SYSROOT_CFLAGS_FOR_TARGET="--sysroot=$withval"
    fi],
   [SYSROOT_CFLAGS_FOR_TARGET=])
-- 
2.54.0

Reply via email to