From nobody Tue Feb 10 05:10:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508160239943695.2798643531555; Mon, 16 Oct 2017 06:23:59 -0700 (PDT) Received: from localhost ([::1]:32978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e45My-0002uN-3A for importer@patchew.org; Mon, 16 Oct 2017 09:23:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e45GD-00067R-Va for qemu-devel@nongnu.org; Mon, 16 Oct 2017 09:16:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e45GB-0004r8-2m for qemu-devel@nongnu.org; Mon, 16 Oct 2017 09:16:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58210) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e45GA-0004qZ-QL for qemu-devel@nongnu.org; Mon, 16 Oct 2017 09:16:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0D4B4E909 for ; Mon, 16 Oct 2017 13:16:45 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-239.ams2.redhat.com [10.36.116.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id E340F6292A; Mon, 16 Oct 2017 13:16:44 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2DA3D4FD5D; Mon, 16 Oct 2017 15:16:44 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E0D4B4E909 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 15:16:34 +0200 Message-Id: <20171016131644.9565-2-kraxel@redhat.com> In-Reply-To: <20171016131644.9565-1-kraxel@redhat.com> References: <20171016131644.9565-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 16 Oct 2017 13:16:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 01/11] build: automatically handle GIT submodule checkout for dtc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" 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 Message-id: 20170929101201.21039-2-berrange@redhat.com [ kraxel: use /bin/sh not bash for scripts/git-submodule.sh ] [ kraxel: fix Makefile dependencies ] Signed-off-by: Gerd Hoffmann [fixup] Makefile dep --- configure | 46 ++++++++++++++++++++++++++------------------= -- Makefile | 24 +++++++++++++++++++++++- .gitignore | 1 + MAINTAINERS | 6 ++++++ scripts/git-submodule.sh | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 21 deletions(-) create mode 100755 scripts/git-submodule.sh diff --git a/configure b/configure index 6587e8014b..38f1710c80 100755 --- a/configure +++ b/configure @@ -264,6 +264,7 @@ cc_i386=3Di386-pc-linux-gnu-gcc libs_qga=3D"" debug_info=3D"yes" stack_protector=3D"" +git_submodules=3D"" =20 # Don't accept a target_list environment variable. unset target_list @@ -3584,27 +3585,30 @@ EOF if compile_prog "" "$fdt_libs" ; then # system DTC is good - use it fdt=3Dyes - elif test -d ${source_path}/dtc/libfdt ; then - # have submodule DTC - use it - fdt=3Dyes - dtc_internal=3D"yes" - mkdir -p dtc - if [ "$pwd_is_source_path" !=3D "y" ] ; then - symlink "$source_path/dtc/Makefile" "dtc/Makefile" - symlink "$source_path/dtc/scripts" "dtc/scripts" - fi - fdt_cflags=3D"-I\$(SRC_PATH)/dtc/libfdt" - fdt_libs=3D"-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs" - elif test "$fdt" =3D "yes" ; then - # have neither and want - prompt for system/submodule install - error_exit "DTC (libfdt) version >=3D 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=3D - fdt=3Dno + # have GIT checkout, so activate dtc submodule + if test -e "${source_path}/.git" ; then + git_submodules=3D"${git_submodules} dtc" + fi + if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.g= it" ; then + fdt=3Dyes + dtc_internal=3D"yes" + mkdir -p dtc + if [ "$pwd_is_source_path" !=3D "y" ] ; then + symlink "$source_path/dtc/Makefile" "dtc/Makefile" + symlink "$source_path/dtc/scripts" "dtc/scripts" + fi + fdt_cflags=3D"-I\$(SRC_PATH)/dtc/libfdt" + fdt_libs=3D"-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs" + elif test "$fdt" =3D "yes" ; then + # Not a git build & no libfdt found, prompt for system install + error_exit "DTC (libfdt) version >=3D 1.4.2 not present." \ + "Please install the DTC (libfdt) devel package" + else + # don't have and don't want + fdt_libs=3D + fdt=3Dno + fi fi fi =20 @@ -5295,6 +5299,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" @@ -5483,6 +5488,7 @@ echo "extra_cxxflags=3D$EXTRA_CXXFLAGS" >> $config_ho= st_mak echo "extra_ldflags=3D$EXTRA_LDFLAGS" >> $config_host_mak echo "qemu_localedir=3D$qemu_localedir" >> $config_host_mak echo "libs_softmmu=3D$libs_softmmu" >> $config_host_mak +echo "GIT_SUBMODULES=3D$git_submodules" >> $config_host_mak =20 echo "ARCH=3D$ARCH" >> $config_host_mak =20 diff --git a/Makefile b/Makefile index 97b4508d7d..9866909e08 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,27 @@ ifneq ($(wildcard config-host.mak),) all: include config-host.mak =20 +git-submodule-update: + +.PHONY: git-submodule-update + +ifeq (0,$(MAKELEVEL)) + git_module_status :=3D $(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_SUBMO= DULES)), \ + "GIT","$(GIT_SUBMODULES)") +endif +endif + +.git-submodule-status: git-submodule-update + # 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 .)) @@ -84,6 +105,7 @@ endif GENERATED_FILES +=3D $(TRACE_HEADERS) GENERATED_FILES +=3D $(TRACE_SOURCES) GENERATED_FILES +=3D $(BUILD_DIR)/trace-events-all +GENERATED_FILES +=3D .git-submodule-status =20 trace-group-name =3D $(shell dirname $1 | sed -e 's/[^a-zA-Z0-9]/_/g') =20 @@ -330,7 +352,7 @@ DTC_MAKE_ARGS=3D-I$(SRC_PATH)/dtc VPATH=3D$(SRC_PATH)/d= tc -C dtc V=3D"$(V)" LIBFDT_src DTC_CFLAGS=3D$(CFLAGS) $(QEMU_CFLAGS) DTC_CPPFLAGS=3D-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libf= dt =20 -subdir-dtc:dtc/libfdt dtc/tests +subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests $(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS=3D"$(DTC_CPPFLAGS)= " CFLAGS=3D"$(DTC_CFLAGS)" LDFLAGS=3D"$(LDFLAGS)" ARFLAGS=3D"$(ARFLAGS)" CC= =3D"$(CC)" AR=3D"$(AR)" LD=3D"$(LD)" $(SUBDIR_MAKEFLAGS) libfdt/libfdt.a,) =20 dtc/%: diff --git a/.gitignore b/.gitignore index 3a7e01dc6a..b5e115d96b 100644 --- a/.gitignore +++ b/.gitignore @@ -113,6 +113,7 @@ /docs/version.texi *.tps .stgit-* +.git-submodule-status cscope.* tags TAGS diff --git a/MAINTAINERS b/MAINTAINERS index 772ac209e1..bb585bbd8f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1949,3 +1949,9 @@ M: Daniel P. Berrange S: Odd Fixes F: docs/devel/build-system.txt =20 +Build System +------------ +GIT submodules +M: Daniel P. Berrange +S: Odd Fixes +F: scripts/git-submodule.sh diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh new file mode 100755 index 0000000000..d8fbc7e47e --- /dev/null +++ b/scripts/git-submodule.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# +# This code is licensed under the GPL version 2 or later. See +# the COPYING file in the top-level directory. + +set -e + +substat=3D".git-submodule-status" + +command=3D$1 +shift +modules=3D"$@" + +if test -z "$modules" +then + test -e $substat || touch $substat + exit 0 +fi + +if ! test -e ".git" +then + echo "$0: unexpectedly called with submodules but no git checkout exis= ts" + exit 1 +fi + +case "$command" in +status) + test -f "$substat" || exit 1 + trap "rm -f ${substat}.tmp" EXIT + git submodule status $modules > "${substat}.tmp" + diff "${substat}" "${substat}.tmp" >/dev/null + exit $? + ;; +update) + git submodule update --init $modules 1>/dev/null 2>&1 + git submodule status $modules > "${substat}" + ;; +esac --=20 2.9.3