qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v5 00/12] Convert over to use keycodemapdb


From: Gerd Hoffmann
Subject: Re: [Qemu-devel] [PATCH v5 00/12] Convert over to use keycodemapdb
Date: Tue, 19 Sep 2017 16:26:22 +0200

  Hi,

> > The Makefile checks the output of this script, and if it indicates
> > that an submodule update is required, it uses an ifeq() to add a
> > dependancy between "Makefile" and a phony target that re-runs
> > configure (which in turns updates the submodules). If no update was
> > required, then no dependancy from Makefile gets added, so build
> > runs
> > normally.

Neat trick.  I think re-running configure should not be needed though. 
Touching the Makefile should be enough to make make re-evaluating
things after updating submodules ...

cheers,
  Gerd

diff --git a/Makefile b/Makefile
index b53fc69a60..a9a0cea6d9 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,27 @@ CONFIG_ALL=y
 -include config-all-devices.mak
 -include config-all-disas.mak
 
+ifeq (0,$(MAKELEVEL))
+  git_module_status := $(shell \
+    cd '$(SRC_PATH)'; \
+    test -d .git || { echo 0; exit; }; \
+    ./scripts/git-submodule.sh status; \
+    echo $$?; \
+  )
+
+ifeq (1,$(git_module_status))
+Makefile: git-submodule-update
+
+.PHONY: git-submodule-update
+
+git-submodule-update:
+       @echo "GIT submodules out of date, updating."
+       (cd $(SRC_PATH); ./scripts/git-submodule.sh update)
+       @touch Makefile
+endif
+endif
+
+
 config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios
        @echo $@ is out-of-date, running configure
        @# TODO: The next lines include code which supports a smooth
diff --git a/.gitignore b/.gitignore
index cf65316863..0c5fda2fdb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -111,6 +111,7 @@
 /docs/version.texi
 *.tps
 .stgit-*
+.git-submodule-status
 cscope.*
 tags
 TAGS
diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh
new file mode 100755
index 0000000000..07d36c2b82
--- /dev/null
+++ b/scripts/git-submodule.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# config
+modules="dtc"
+substat=".git-submodule-status"
+
+# drop modules not checked out
+modules="$(git submodule status $modules | awk '/^[^-]/ { print $2
}')"
+
+case "$1" 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 $modules
+       git submodule status $modules > "${substat}"
+       ;;
+esac



reply via email to

[Prev in Thread] Current Thread [Next in Thread]