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é <berra...@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 poeople 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 :-) .gitignore | 2 ++ configure | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 8 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..a5c88ad1ac 100755 --- a/configure +++ b/configure @@ -11,6 +11,38 @@ unset CLICOLOR_FORCE GREP_OPTIONS # Don't allow CCACHE, if present, to use cached results of compile tests! export CCACHE_RECACHE=yes +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" +fi + +if test "$PWD" == "$source_path" +then + echo "Using './build' as the directory for build output" + rm -rf build + mkdir -p build + cat > GNUmakefile <<EOF + +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" ; then rm -rf build ; 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,14 +329,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" -fi - # default parameters cpu="" iasl="iasl" -- 2.26.2