public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] configure: error out as early as possible on build = source directory
@ 2023-03-22 16:17 Zack Weinberg
  0 siblings, 0 replies; only message in thread
From: Zack Weinberg @ 2023-03-22 16:17 UTC (permalink / raw)
  To: libc-alpha

Related to the discussion at 
<https://sourceware.org/pipermail/libc-alpha/2023-March/146542.html>, 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.

zw

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

+# 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])
+])
+
  AC_CANONICAL_HOST

  AC_PROG_CC
@@ -80,10 +88,6 @@ LDFLAGS="$old_LDFLAGS"
  AC_LANG_POP([C++])])
  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])
-fi
-
  # This will get text that should go into config.make.
  config_vars=

--
2.34.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-22 16:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22 16:17 [PATCH] configure: error out as early as possible on build = source directory Zack Weinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).