aboutsummaryrefslogtreecommitdiffstats
path: root/rules.mk
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
commit8db77876decb83915157d510edab03d57c75b70f (patch)
treedde30bd45d216d5e2050550799ba9e6f6997aa1d /rules.mk
parentd582572b08406e6db759a661b1be079a688c985b (diff)
downloadmaster-187ad058-8db77876decb83915157d510edab03d57c75b70f.tar.gz
master-187ad058-8db77876decb83915157d510edab03d57c75b70f.tar.bz2
master-187ad058-8db77876decb83915157d510edab03d57c75b70f.zip
Add macro for locking of recipe commands.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@23708 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'rules.mk')
-rw-r--r--rules.mk10
1 files changed, 10 insertions, 0 deletions
diff --git a/rules.mk b/rules.mk
index 23445bfaee..007e5bc9b2 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)))