[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v8 016/152] configure: add support for pseudo-"in source tree" bui
From: |
Paolo Bonzini |
Subject: |
[PULL v8 016/152] configure: add support for pseudo-"in source tree" builds |
Date: |
Fri, 21 Aug 2020 06:21:13 -0400 |
From: Daniel P. Berrangé <berrange@redhat.com>
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>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
.gitignore | 2 ++
configure | 48 +++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
index f8b3cd6fd5..d1e5e06242 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+/GNUmakefile
+/build/
/.doctrees
/config-devices.*
/config-all-devices.*
diff --git a/configure b/configure
index 35d6492343..cc04a560a0 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
+ 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
@@ -279,9 +324,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"
--
2.26.2
- [PULL v8 008/152] tests/vm: do not pollute configure with --efi-aarch64, (continued)
- [PULL v8 008/152] tests/vm: do not pollute configure with --efi-aarch64, Paolo Bonzini, 2020/08/21
- [PULL v8 002/152] optionrom: simplify Makefile, Paolo Bonzini, 2020/08/21
- [PULL v8 004/152] trace: switch position of headers to what Meson requires, Paolo Bonzini, 2020/08/21
- [PULL v8 010/152] tests/docker: add test script for static linux-user builds, Paolo Bonzini, 2020/08/21
- [PULL v8 005/152] meson: rename included C source files to .c.inc, Paolo Bonzini, 2020/08/21
- [PULL v8 012/152] configure: do not include $(...) variables in config-host.mak, Paolo Bonzini, 2020/08/21
- [PULL v8 011/152] nsis: use "make DESTDIR=" instead of "make prefix=", Paolo Bonzini, 2020/08/21
- [PULL v8 009/152] tests/vm: check for Python YAML parser in the Makefile, Paolo Bonzini, 2020/08/21
- [PULL v8 013/152] configure: expand path variables for meson configure, Paolo Bonzini, 2020/08/21
- [PULL v8 015/152] tests/vm: include setuptools, Paolo Bonzini, 2020/08/21
- [PULL v8 016/152] configure: add support for pseudo-"in source tree" builds,
Paolo Bonzini <=
- [PULL v8 014/152] configure: prepare CFLAGS/CXXFLAGS/LDFLAGS for Meson, Paolo Bonzini, 2020/08/21
- [PULL v8 019/152] build-sys hack: link with whole .fa archives, Paolo Bonzini, 2020/08/21
- [PULL v8 018/152] configure: generate Meson cross file, Paolo Bonzini, 2020/08/21
- [PULL v8 022/152] meson: enable pie, Paolo Bonzini, 2020/08/21
- [PULL v8 021/152] meson: move summary to meson.build, Paolo Bonzini, 2020/08/21
- [PULL v8 020/152] build-sys: add meson submodule, Paolo Bonzini, 2020/08/21
- [PULL v8 025/152] meson: add testsuite Makefile generator, Paolo Bonzini, 2020/08/21
- [PULL v8 024/152] meson: add sparse support, Paolo Bonzini, 2020/08/21
- [PULL v8 023/152] meson: use coverage option, Paolo Bonzini, 2020/08/21
- [PULL v8 028/152] meson: add version.o, Paolo Bonzini, 2020/08/21