From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@gmail.com>
Subject: Re: [PATCH v2] configure: add support for pseudo-"in source tree" builds
Date: Thu, 20 Aug 2020 19:51:51 +0200 [thread overview]
Message-ID: <2ed3b98c-62da-72dc-05b8-a8e05a621bad@redhat.com> (raw)
In-Reply-To: <20200820173124.243984-1-berrange@redhat.com>
On 8/20/20 7: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
> "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>
> ---
>
> This is a simple integration of Eric's proposal from
>
> https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg07290.html
>
> with a bit of configure magic. It is enough to enable
>
> ./configure
> make
> make check
>
> I've not tested it beyond that. Note it blows away the "build/"
> dir each time ./configure is run so it is pristine each time.
>
> We could optionally symlink binaries from build/ into $PWD
> if people think that is important, eg by changing GNUmakefile
> to have:
>
> recurse: all
> for bin in `find build -maxdepth 1 -type f -executable | grep -v -E '(ninjatool|config.status)'`; \
> do \
> ln -f -s $$bin . ; \
> done
>
> and some cleanup logic to purge the symlinks for "make clean"
>
> This goes on top of Paolo's most recent meson port v175 posting,
> or whatever number it is upto now :-)
>
> 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)
> +
> +if test "$PWD" == "$source_path"
> +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
Tested normal build in fresh clone, then in my current workdir:
./configure
Using './build' as the directory for build output
ERROR: ./build dir already exists and was not previously created by
configure
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> + fi
> + fi
> +
> + mkdir build
> + touch $MARKER
> +
> + cat > GNUmakefile <<EOF
> +# This file is auto-generated by configure to support in-source tree
> +# 'make' command invokation
> +
> +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
> + 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"
>
next prev parent reply other threads:[~2020-08-20 17:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-20 17:31 [PATCH v2] configure: add support for pseudo-"in source tree" builds Daniel P. Berrangé
2020-08-20 17:51 ` Philippe Mathieu-Daudé [this message]
2020-08-20 17:52 ` Eric Blake
2020-08-20 21:15 ` Eric Blake
2020-08-21 8:31 ` Daniel P. Berrangé
2020-08-21 10:04 ` Kevin Wolf
2020-08-21 10:15 ` Paolo Bonzini
2020-08-21 10:54 ` Kevin Wolf
2020-08-21 12:58 ` Paolo Bonzini
2020-08-21 10:17 ` Daniel P. Berrangé
2020-08-21 10:16 ` Paolo Bonzini
2020-08-21 10:17 ` Kevin Wolf
2020-08-21 10:31 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ed3b98c-62da-72dc-05b8-a8e05a621bad@redhat.com \
--to=philmd@redhat.com \
--cc=berrange@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).