X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/23f0f29a8e0198f5b3fb0d41ca8144d84ec80b81..eacbaf7ca0fc16e2cc873393cc5bef72ab8509ef:/rules.mk?ds=sidebyside diff --git a/rules.mk b/rules.mk index 23445bfae..d3521649a 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. +define locked + SHELL= \ + $(STAGING_DIR_HOST)/bin/flock \ + $(TMP_DIR)/.$(if $(2),$(strip $(2)),global).flock \ + -c '$(subst ','\'',$(1))' +endef + # file extension ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))