From f96395e78eaccffbf128336382c74b1250f04032 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Wed, 6 Nov 2019 15:55:12 +0100 Subject: [PATCH] build: mandate use of a build dir != src dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Historically we've allowed builds in the main src dir, but meson does not support this. Explicitly force separate build dir in autotools to align with meson. We must re-enable dependency tracking which the RPM %configure macro turns off. Without this, the build dir doesn't get the source directory tree mirrored. Signed-off-by: Daniel P. Berrangé Signed-off-by: Pavel Hrdina Reviewed-by: Daniel P. Berrangé --- .travis.yml | 3 ++- README-hacking | 13 +++++++++---- README.md | 11 +++++++---- bootstrap.conf | 6 ++++++ configure.ac | 6 ++++++ docs/compiling.html.in | 10 ++++++---- docs/windows.html.in | 3 ++- libvirt.spec.in | 10 +++++++++- 8 files changed, 47 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 478909d3bb..8b70c1c937 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,7 +53,8 @@ matrix: script: # We can't run 'distcheck' or 'syntax-check' because they fail on # macOS, but doing 'install' and 'dist' gives us some useful coverage - - ./autogen.sh --prefix=$(pwd)/install-root && make -j3 && make -j3 install && make -j3 dist + - mkdir build && cd build + - ../autogen.sh --prefix=$(pwd)/install-root && make -j3 && make -j3 install && make -j3 dist git: submodules: true diff --git a/README-hacking b/README-hacking index ec04271c6a..7da940eb13 100644 --- a/README-hacking +++ b/README-hacking @@ -11,7 +11,7 @@ We've opted to keep only the highest-level sources in the GIT repository. This eases our maintenance burden, (fewer merges etc.), but imposes more requirements on anyone wishing to build from the just-checked-out sources. Note the requirements to build the released archive are much less and -are just the requirements of the standard ./configure && make procedure. +are just the requirements of the standard configure && make procedure. Specific development tools and versions will be checked for and listed by the bootstrap script. @@ -34,10 +34,14 @@ reduce download time and disk space requirements: $ export GNULIB_SRCDIR=/path/to/gnulib -The next step is to get all required pieces from gnulib, -to run autoreconf, and to invoke ./configure: +We require to have the build directory different than the source directory: - $ ./autogen.sh + $ mkdir build && cd build + +The next step is to get all required pieces from gnulib, +to run autoreconf, and to invoke ../autogen.sh: + + $ ../autogen.sh And there you are! Just @@ -47,6 +51,7 @@ And there you are! Just At this point, there should be no difference between your local copy, and the GIT master copy: + $ cd .. $ git diff should output no difference. diff --git a/README.md b/README.md index 4d1e86259d..44b0dd87c5 100644 --- a/README.md +++ b/README.md @@ -38,11 +38,13 @@ Installation ------------ Libvirt uses the GNU Autotools build system, so in general can be built -and installed with the usual commands. For example, to build in a manner -that is suitable for installing as root, use: +and installed with the usual commands, however, we mandate to have the +build directory different than the source directory. For example, to build +in a manner that is suitable for installing as root, use: ``` -$ ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var +$ mkdir build && cd build +$ ../configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var $ make $ sudo make install ``` @@ -50,7 +52,8 @@ $ sudo make install While to build & install as an unprivileged user ``` -$ ./configure --prefix=$HOME/usr +$ mkdir build && cd build +$ ../configure --prefix=$HOME/usr $ make $ make install ``` diff --git a/bootstrap.conf b/bootstrap.conf index 0c7de2d2aa..4c784487e2 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -164,3 +164,9 @@ bootstrap_post_import_hook() sed 's,\.\./\.\./\.\.,../..,g; s/^TESTS /GNULIB_TESTS /' $m > $m-t mv -f $m-t $m } + +bootstrap_epilogue() +{ + echo "$0: done. Now you can run 'mkdir build && cd build && ../configure'." + exit 0 +} diff --git a/configure.ac b/configure.ac index 233fbeaaf3..32b246842e 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,12 @@ dnl License along with this library. If not, see dnl . AC_INIT([libvirt], [5.10.0], [libvir-list@redhat.com], [], [https://libvirt.org]) + +if test $srcdir = "." +then + AC_MSG_ERROR([Build directory must be different from source directory]) +fi + AC_CONFIG_SRCDIR([src/libvirt.c]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS([config.h]) diff --git a/docs/compiling.html.in b/docs/compiling.html.in index 8dcceb3eb9..5869ebb90f 100644 --- a/docs/compiling.html.in +++ b/docs/compiling.html.in @@ -9,13 +9,15 @@

Compiling a release tarball

- libvirt uses the standard configure/make/install steps: + libvirt uses the standard configure/make/install steps and mandates + that the build directory is different that the source directory:

 $ xz -c libvirt-x.x.x.tar.xz | tar xvf -
 $ cd libvirt-x.x.x
-$ ./configure
+$ mkdir build && cd build +$ ../configure

The configure script can be given options to change its default @@ -28,7 +30,7 @@ $ ./configure

-$ ./configure --help
+$ ../configure --help

When you have determined which options you want to use (if any), @@ -49,7 +51,7 @@ $ ./configure --help

-$ ./configure [possible options]
+$ ../configure [possible options]
 $ make
 $ sudo make install
diff --git a/docs/windows.html.in b/docs/windows.html.in index 096d118bf7..a0ff525e1a 100644 --- a/docs/windows.html.in +++ b/docs/windows.html.in @@ -180,7 +180,8 @@

-./configure \
+mkdir build && cd build
+../configure \
   --without-sasl \
   --without-polkit \
   --without-python \
diff --git a/libvirt.spec.in b/libvirt.spec.in
index dcad08cb5f..723ced3535 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1163,7 +1163,13 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec)
 %endif
 
 rm -f po/stamp-po
-%configure --with-runstatedir=%{_rundir} \
+
+%define _configure ../configure
+mkdir %{_vpath_builddir}
+cd %{_vpath_builddir}
+
+%configure --enable-dependency-tracking \
+           --with-runstatedir=%{_rundir} \
            %{?arg_qemu} \
            %{?arg_openvz} \
            %{?arg_lxc} \
@@ -1232,6 +1238,7 @@ rm -fr %{buildroot}
 
 export SOURCE_DATE_EPOCH=$(stat --printf='%Y' %{_specdir}/%{name}.spec)
 
+cd %{_vpath_builddir}
 %make_install %{?_smp_mflags} SYSTEMD_UNIT_DIR=%{_unitdir} V=1
 
 rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
@@ -1313,6 +1320,7 @@ mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_qemu_probes.stp \
 %endif
 
 %check
+cd %{_vpath_builddir}
 if ! make %{?_smp_mflags} check VIR_TEST_DEBUG=1
 then
   cat test-suite.log || true