configure: error out as early as possible on build = source directory

Message ID
State New
Series configure: error out as early as possible on build = source directory |


Context Check Description
dj/TryBot-apply_patch fail Patch failed to apply to master at the time it was sent
dj/TryBot-32bit fail Patch series failed to apply
redhat-pt-bot/TryBot-still_applies warning Patch no longer applies to master

Commit Message

Zack Weinberg March 22, 2023, 4:17 p.m. UTC
  Related to the discussion at 
<>, if 
someone makes the mistake of running configure in the source directory 
(i.e. attempting to set up to build within the source tree, which we 
don't support) configure should error out as quickly as possible, rather 
than making this hypothetical someone sit through a bunch of compiler 
checks first.

(Ideally we would validate _everything_ about the way configure has been 
invoked before doing any other work, but the other places where we have 
an AC_MSG_ERROR as a response to something about the invocation look 
significantly harder to change.)

Completely untested as I don't have convenient access to a machine with 
autoconf 2.69 at the moment.


@@ -80,10 +88,6 @@ LDFLAGS="$old_LDFLAGS"
  AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])

-if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
-  AC_MSG_ERROR([you must configure in a separate build directory])
  # This will get text that should go into config.make.



diff --git a/ b/
index 011844a3d4..afaedfb056 100644
--- a/
+++ b/
@@ -43,6 +43,14 @@  AC_DEFUN([_AC_PROG_CC_C89], [[$1]])
  dnl This is here so we can set $subdirs directly based on configure 

+# Validate the build directory as early as possible, so that someone
+# who's made the mistake of casually typing "./configure" in the source
+# directory doesn't have to wait for autoconf to probe a bunch of stuff
+# before it gets around to telling them they made a mistake.
+AS_IF(["`cd $srcdir && pwd -P`" = "`pwd -P`"],
+  [AC_MSG_ERROR([you must configure in a separate build directory])