summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Büsch <mb@bu3sch.de>2010-10-29 14:53:16 +0000
committerMichael Büsch <mb@bu3sch.de>2010-10-29 14:53:16 +0000
commite396e33ad2ea10633c42ec4c580770cb92148dbc (patch)
tree43ff01a513bf88aad7fff3dfd7f4b3e1edd7029f
parent731877c5d95f0caefdd1484fe983083131f8eff2 (diff)
downloadmtk-20170518-e396e33ad2ea10633c42ec4c580770cb92148dbc.zip
mtk-20170518-e396e33ad2ea10633c42ec4c580770cb92148dbc.tar.gz
mtk-20170518-e396e33ad2ea10633c42ec4c580770cb92148dbc.tar.bz2
Add macro for locking of recipe commands.
SVN-Revision: 23708
-rw-r--r--rules.mk10
1 files changed, 10 insertions, 0 deletions
diff --git a/rules.mk b/rules.mk
index 23445bf..007e5bc 100644
--- a/rules.mk
+++ b/rules.mk
@@ -249,6 +249,16 @@ define include_mk
$(eval -include $(if $(DUMP),,$(STAGING_DIR)/mk/$(strip $(1))))
endef
+# Execute commands under flock
+# $(1) => The shell expression.
+# $(2) => The lock name. If not given, the global lock will be used.
+# $(3) => The filedescriptor used for the lock. Defaults to 1023.
+define locked
+ ( $(STAGING_DIR_HOST)/bin/flock -x $(if $(3),$(3),1023) && \
+ $(1) \
+ ) $(if $(3),$(strip $(3)),1023)>$(TMP_DIR)/.$(if $(2),$(strip $(2)),global).flock
+endef
+
# file extension
ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))