]> granicus.if.org Git - esp-idf/blobdiff - make/common.mk
Merge branch 'master' into bugfix/build_dir_base
[esp-idf] / make / common.mk
index b2917d5c96c62d08507fb2b48a1ac0cad6004db9..2b7376a4db46573c27e31f68553d9e725aeef489 100644 (file)
@@ -23,19 +23,27 @@ summary := @echo
 details := @true
 endif
 
-# Pseudo-target to handle the case where submodules need to be
-# re-initialised.
+# Pseudo-target to check a git submodule has been properly initialised
 #
-# $(eval $(call SubmoduleRequiredForFiles,FILENAMES)) to create a target that
-# automatically runs 'git submodule update --init' if those files
-# are missing, and fails if this is not possible.
-define SubmoduleRequiredForFiles
+# $(eval $(call SubmoduleCheck,FILENAMES,SUBMODULE_PATH)) to create a target that
+# automatically runs 'git submodule update --init SUBMODULE_PATH' if any of
+# the files in FILENAMES are missing, and fails if this is not possible.
+#
+# Will also print a WARNING if the submodule at SUBMODULE_PATH appears
+# to require an update.
+define SubmoduleCheck
 $(1):
-       @echo "WARNING: Missing submodule for $$@..."
+       @echo "WARNING: Missing submodule $(2) for $$@..."
        $(Q) [ -d ${IDF_PATH}/.git ] || ( echo "ERROR: esp-idf must be cloned from git to work."; exit 1)
        $(Q) [ -x $(which git) ] || ( echo "ERROR: Need to run 'git submodule --init' in esp-idf root directory."; exit 1)
        @echo "Attempting 'git submodule update --init' in esp-idf root directory..."
-       cd ${IDF_PATH} && git submodule update --init
+       cd ${IDF_PATH} && git submodule update --init $(2)
+
+# Parse 'git submodule status' output for out-of-date submodule.
+# Status output prefixes status line with '+' if the submodule commit doesn't match
+ifneq ("$(shell cd ${IDF_PATH} && git submodule status $(2) | grep '^+')","")
+$$(info WARNING: git submodule $2 may be out of date. Run 'git submodule update' to update.)
+endif
 endef