Added depv macros in order to make some targets dependent on variables

This commit is contained in:
Vladimir Kozhukalov 2013-01-30 17:48:26 +04:00
parent 2e7ff7cc94
commit d8bc865619
3 changed files with 19 additions and 0 deletions

View File

@ -2,6 +2,7 @@ PWD:=$(shell pwd -P)
SOURCE_DIR:=$(PWD)
BUILD_DIR:=$(PWD)/build
DEPV_DIR:=$(BUILD_DIR)/depv
.PHONY: all clean test help deep_clean

View File

@ -1,7 +1,9 @@
include $(SOURCE_DIR)/mirror/centos/yum_repos.mk
$(BUILD_DIR)/mirror/centos/etc/yum.conf: $(call depv,yum_conf)
$(BUILD_DIR)/mirror/centos/etc/yum.conf: export contents:=$(yum_conf)
$(BUILD_DIR)/mirror/centos/etc/yum.conf: \
$(SOURCE_DIR)/mirror/centos/yum_repos.mk \
$(SOURCE_DIR)/mirror/centos/yum-priorities-plugin.py
mkdir -p $(BUILD_DIR)/mirror/centos/etc/yum/pluginconf.d
echo "[main]\nenabled=1" > $(BUILD_DIR)/mirror/centos/etc/yum/pluginconf.d/priorities.conf
@ -11,6 +13,7 @@ $(BUILD_DIR)/mirror/centos/etc/yum.conf: \
echo "$${contents}" > $@
$(BUILD_DIR)/mirror/centos/etc/yum.repos.d/base.repo: $(call depv,YUM_REPOS)
$(BUILD_DIR)/mirror/centos/etc/yum.repos.d/base.repo: \
export contents:=$(foreach repo,$(YUM_REPOS),\n$(yum_repo_$(repo)))
$(BUILD_DIR)/mirror/centos/etc/yum.repos.d/base.repo: \

View File

@ -8,6 +8,21 @@ define ACTION.TOUCH
touch $@
endef
# This macros is to make targets dependent on variables
# It writes variable value into temporary file varname.tmp,
# then it compares temporary file with the varname.dep file.
# If there is a difference between them, varname.dep will be updated
# and the target which depends on it will be rebuilt.
# Example:
# target: $(call depv,varname)
define depv
$(shell mkdir -p $(DEPV_DIR))
$(shell echo "$($1)" > $(DEPV_DIR)/$1.tmp)
$(shell diff >/dev/null 2>&1 $(DEPV_DIR)/$1.tmp $(DEPV_DIR)/$1.dep \
|| mv $(DEPV_DIR)/$1.tmp $(DEPV_DIR)/$1.dep)
$(DEPV_DIR)/$1.dep
endef
define NEWLINE