qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] configure: add support for pseudo-"in source tree" builds


From: Eric Blake
Subject: Re: [PATCH v2] configure: add support for pseudo-"in source tree" builds
Date: Thu, 20 Aug 2020 12:52:26 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

On 8/20/20 12:31 PM, Daniel P. Berrangé wrote:
Meson requires the build dir to be separate from the source tree. Many
people are used to just running "./configure && make" though and the
meson conversion breaks that.

This introduces some backcompat support to make it appear as if an
"in source tree" build is being done, but with the the results in the

s/the the/the/

"build/" directory. This allows "./configure && make" to work as it
did historically, albeit with the output binaries staying under build/.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---



In v2:

  - Use a marker file so we don't blow away a build/ dir
    we didn't create
  - Silence the distclean rule
  - Fix broken use of error_exit that's not defined yet
  - Add comment to GNUmakefile

  .gitignore |  2 ++
  configure  | 48 +++++++++++++++++++++++++++++++++++++++++++++---
  2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index 92311284ef..4ccb9ed975 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+/GNUmakefile
+/build/
  /.doctrees
  /config-devices.*
  /config-all-devices.*
diff --git a/configure b/configure
index cc5f58f31a..cdffe221c7 100755
--- a/configure
+++ b/configure
@@ -11,6 +11,51 @@ unset CLICOLOR_FORCE GREP_OPTIONS
  # Don't allow CCACHE, if present, to use cached results of compile tests!
  export CCACHE_RECACHE=yes
+# make source path absolute
+source_path=$(cd "$(dirname -- "$0")"; pwd)

Our mails crossed; my 1 comment about CDPATH impacting this is still valid.

+
+if test "$PWD" == "$source_path"

and s/==/=/ for non-bash

+then
+    echo "Using './build' as the directory for build output"
+
+    MARKER=build/auto-created-by-configure
+
+    if test -e build
+    then
+       if test -f $MARKER
+       then
+          rm -rf build
+       else
+           echo "ERROR: ./build dir already exists and was not previously created 
by configure"
+           exit 1

TAB damage.

+       fi
+    fi
+
+    mkdir build
+    touch $MARKER
+
+    cat > GNUmakefile <<EOF
+# This file is auto-generated by configure to support in-source tree
+# 'make' command invokation

invocation

+
+ifeq (\$(MAKECMDGOALS),)
+recurse: all
+endif
+
+.NOTPARALLEL: %
+%: force
+       @echo 'changing dir to build for \$(MAKE) "\$(MAKECMDGOALS)"...'
+       @\$(MAKE) -C build -f Makefile \$(MAKECMDGOALS)
+       @if test "\$(MAKECMDGOALS)" = "distclean" && test -e 
build/auto-created-by-configure ; then rm -rf build GNUmakefile ; fi
+force: ;
+.PHONY: force
+GNUmakefile: ;
+
+EOF

Quote the first EOF to avoid having to quote all $ in the heredoc

+    cd build
+    exec $source_path/configure "$@"
+fi
+
  # Temporary directory used for files created while
  # configure runs. Since it is in the build directory
  # we can safely blow away any previous version of it
@@ -297,9 +342,6 @@ ld_has() {
      $ld --help 2>/dev/null | grep ".$1" >/dev/null 2>&1
  }
-# make source path absolute
-source_path=$(cd "$(dirname -- "$0")"; pwd)
-
  if printf %s\\n "$source_path" "$PWD" | grep -q "[[:space:]:]";
  then
    error_exit "main directory cannot contain spaces nor colons"


With corrections, this is looking good; I'm okay if v3 includes:
Reviewed-by: Eric Blake <eblake@redhat.com>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]