diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2011-07-14 13:22:35 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2011-07-14 13:22:35 +0100 |
commit | 2407671d89b44df4aa7d976b6cb2ff99016ce202 (patch) | |
tree | 7c99c488e47310c89279c7ffa49e7f17650066ab /Config.mk | |
parent | 872ecdc9b54f40b6b52318f423cc7073671e8b7c (diff) | |
download | xen-2407671d89b44df4aa7d976b6cb2ff99016ce202.tar.gz xen-2407671d89b44df4aa7d976b6cb2ff99016ce202.tar.bz2 xen-2407671d89b44df4aa7d976b6cb2ff99016ce202.zip |
build: define "move-if-changed" make macro.
Use it to replace various places which (should) use the
if ! cmp -s ...; then mv ....; fi
pattern.
Also add an else clause to cleanup the unchanged temporary file.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'Config.mk')
-rw-r--r-- | Config.mk | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -118,6 +118,16 @@ define buildmakevars2shellvars export XEN_ROOT="$(XEN_ROOT)" endef +# +# Compare $(1) and $(2) and replace $(2) with $(1) if they differ +# +# Typically $(1) is a newly generated file and $(2) is the target file +# being regenerated. This prevents changing the timestamp of $(2) only +# due to being auto regenereated with the same contents. +define move-if-changed + if ! cmp -s $(1) $(2); then mv -f $(1) $(2); else rm -f $(1); fi +endef + buildmakevars2file = $(eval $(call buildmakevars2file-closure,$(1))) define buildmakevars2file-closure .PHONY: genpath @@ -134,7 +144,7 @@ define buildmakevars2file-closure echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >> $(1).tmp; \ echo "XEN_LOCK_DIR=\"$(XEN_LOCK_DIR)\"" >> $(1).tmp; \ echo "XEN_RUN_DIR=\"$(XEN_RUN_DIR)\"" >> $(1).tmp; \ - if ! cmp $(1).tmp $(1); then mv -f $(1).tmp $(1); fi + $(call move-if-changed,$(1).tmp,$(1)) endef ifeq ($(debug),y) |