From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Fam Zheng <famz@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH v6 1/6] build: automatically handle GIT submodule checkout for dtc
Date: Thu, 28 Sep 2017 09:44:25 +0100 [thread overview]
Message-ID: <20170928084430.17059-2-berrange@redhat.com> (raw)
In-Reply-To: <20170928084430.17059-1-berrange@redhat.com>
Currently if DTC is required by configure and not available in the host
OS install, we exit with an error message telling the user to checkout a
git submodule or install the library.
This introduces automatic handling of the git submodule checkout process
and enables it for dtc. This only runs if building from GIT, so users of
release tarballs still need the system library install. The current state
of the git checkout is stashed in .git-submodule-status, and a helper
program is used to determine if this state matches the desired submodule
state. A dependency against 'Makefile' ensures that the submodule state
is refreshed at the start of the build process
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
.gitignore | 1 +
Makefile | 21 +++++++++++++++++++++
configure | 46 ++++++++++++++++++++++++++--------------------
scripts/git-submodule.sh | 31 +++++++++++++++++++++++++++++++
4 files changed, 79 insertions(+), 20 deletions(-)
create mode 100755 scripts/git-submodule.sh
diff --git a/.gitignore b/.gitignore
index 40acfcb9e2..06bf972fc3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -112,6 +112,7 @@
/docs/version.texi
*.tps
.stgit-*
+.git-submodule-status
cscope.*
tags
TAGS
diff --git a/Makefile b/Makefile
index 2be61fcf1c..a0d33b7d80 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,27 @@ ifneq ($(wildcard config-host.mak),)
all:
include config-host.mak
+git-submodule-update:
+
+Makefile: git-submodule-update
+
+.PHONY: git-submodule-update
+
+ifeq (0,$(MAKELEVEL))
+ git_module_status := $(shell \
+ cd '$(SRC_PATH)'; \
+ ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
+ echo $$?; \
+ )
+
+ifeq (1,$(git_module_status))
+git-submodule-update:
+ $(call quiet-command, \
+ (cd $(SRC_PATH); ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
+ "GIT","$(GIT_SUBMODULES)")
+endif
+endif
+
# Check that we're not trying to do an out-of-tree build from
# a tree that's been used for an in-tree build.
ifneq ($(realpath $(SRC_PATH)),$(realpath .))
diff --git a/configure b/configure
index 7727f6ba5b..ed4048f8b2 100755
--- a/configure
+++ b/configure
@@ -264,6 +264,7 @@ cc_i386=i386-pc-linux-gnu-gcc
libs_qga=""
debug_info="yes"
stack_protector=""
+git_submodules=""
# Don't accept a target_list environment variable.
unset target_list
@@ -3580,27 +3581,30 @@ EOF
if compile_prog "" "$fdt_libs" ; then
# system DTC is good - use it
fdt=yes
- elif test -d ${source_path}/dtc/libfdt ; then
- # have submodule DTC - use it
- fdt=yes
- dtc_internal="yes"
- mkdir -p dtc
- if [ "$pwd_is_source_path" != "y" ] ; then
- symlink "$source_path/dtc/Makefile" "dtc/Makefile"
- symlink "$source_path/dtc/scripts" "dtc/scripts"
- fi
- fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
- fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
- elif test "$fdt" = "yes" ; then
- # have neither and want - prompt for system/submodule install
- error_exit "DTC (libfdt) version >= 1.4.2 not present. Your options:" \
- " (1) Preferred: Install the DTC (libfdt) devel package" \
- " (2) Fetch the DTC submodule, using:" \
- " git submodule update --init dtc"
else
- # don't have and don't want
- fdt_libs=
- fdt=no
+ # have GIT checkout, so activate dtc submodule
+ if test -d ${source_path}/.git ; then
+ git_submodules="${git_submodules} dtc"
+ fi
+ if test -d ${source_path}/dtc/libfdt || test -d ${source_path}/.git ; then
+ fdt=yes
+ dtc_internal="yes"
+ mkdir -p dtc
+ if [ "$pwd_is_source_path" != "y" ] ; then
+ symlink "$source_path/dtc/Makefile" "dtc/Makefile"
+ symlink "$source_path/dtc/scripts" "dtc/scripts"
+ fi
+ fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"
+ fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
+ elif test "$fdt" = "yes" ; then
+ # have neither and want - prompt for system/submodule install
+ error_exit "DTC (libfdt) version >= 1.4.2 not present." \
+ "Please install the DTC (libfdt) devel package"
+ else
+ # don't have and don't want
+ fdt_libs=
+ fdt=no
+ fi
fi
fi
@@ -5290,6 +5294,7 @@ echo "local state directory queried at runtime"
echo "Windows SDK $win_sdk"
fi
echo "Source path $source_path"
+echo "GIT submodules $git_submodules"
echo "C compiler $cc"
echo "Host C compiler $host_cc"
echo "C++ compiler $cxx"
@@ -5477,6 +5482,7 @@ echo "extra_cxxflags=$EXTRA_CXXFLAGS" >> $config_host_mak
echo "extra_ldflags=$EXTRA_LDFLAGS" >> $config_host_mak
echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
+echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
echo "ARCH=$ARCH" >> $config_host_mak
diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh
new file mode 100755
index 0000000000..f8e7d44ce6
--- /dev/null
+++ b/scripts/git-submodule.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+set -e
+
+command=$1
+shift
+modules="$@"
+
+test -z "$modules" && exit 0
+
+if ! test -d ".git"
+then
+ echo "$0: unexpectedly called with submodules but no git checkout exists"
+ exit 1
+fi
+
+substat=".git-submodule-status"
+
+case "$command" in
+status)
+ test -f "$substat" || exit 1
+ git submodule status $modules > "${substat}.tmp"
+ trap "rm -f ${substat}.tmp" EXIT
+ diff "${substat}" "${substat}.tmp" >/dev/null
+ exit $?
+ ;;
+update)
+ git submodule update --init $modules 1>/dev/null 2>&1
+ git submodule status $modules > "${substat}"
+ ;;
+esac
--
2.13.5
next prev parent reply other threads:[~2017-09-28 8:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-28 8:44 [Qemu-devel] [PATCH v6 0/6] Initial support for keycodemapdb GIT submodule Daniel P. Berrange
2017-09-28 8:44 ` Daniel P. Berrange [this message]
2017-09-28 8:44 ` [Qemu-devel] [PATCH v6 2/6] docker: don't rely on submodules existing in the main checkout Daniel P. Berrange
2017-09-28 9:44 ` Fam Zheng
2017-09-28 9:52 ` Daniel P. Berrange
2017-09-29 2:35 ` Fam Zheng
2017-09-28 22:59 ` Alistair Francis
2017-09-28 8:44 ` [Qemu-devel] [PATCH v6 3/6] ui: add keycodemapdb repository as a GIT submodule Daniel P. Berrange
2017-09-28 8:44 ` [Qemu-devel] [PATCH v6 4/6] ui: convert common input code to keycodemapdb Daniel P. Berrange
2017-09-28 8:44 ` [Qemu-devel] [PATCH v6 5/6] ui: convert key events to QKeyCodes immediately Daniel P. Berrange
2017-09-28 8:44 ` [Qemu-devel] [PATCH v6 6/6] ui: don't export qemu_input_event_new_key Daniel P. Berrange
2017-09-28 8:53 ` [Qemu-devel] [PATCH v6 0/6] Initial support for keycodemapdb GIT submodule no-reply
2017-09-28 9:27 ` Daniel P. Berrange
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=20170928084430.17059-2-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=famz@redhat.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).