[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] build: define "move-if-changed" make macro.



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1310646155 -3600
# Node ID f2c177561402210a0825e00a8fc897fa56ae4ec1
# Parent  7c39a2c0d870f9a374f181b581bcf82a2a7ff364
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@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---


diff -r 7c39a2c0d870 -r f2c177561402 Config.mk
--- a/Config.mk Thu Jul 14 18:09:58 2011 +0100
+++ b/Config.mk Thu Jul 14 13:22:35 2011 +0100
@@ -118,6 +118,16 @@
     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 @@
        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)
diff -r 7c39a2c0d870 -r f2c177561402 tools/libxl/Makefile
--- a/tools/libxl/Makefile      Thu Jul 14 18:09:58 2011 +0100
+++ b/tools/libxl/Makefile      Thu Jul 14 13:22:35 2011 +0100
@@ -75,7 +75,8 @@
 
 _libxl_paths.h: genpath
        sed -e "s/\([^=]*\)=\(.*\)/#define \1 \2/g" $@.tmp >$@.2.tmp
-       if ! cmp -s $@.2.tmp $@; then mv -f $@.2.tmp $@; fi
+       rm -f $@.tmp
+       $(call move-if-changed,$@.2.tmp,$@)
 
 libxl_paths.c: _libxl_paths.h
 
@@ -85,8 +86,8 @@
 
 _libxl_%.h _libxl_%.c: libxl.idl gen%.py libxl%.py
        $(PYTHON) gen$*.py libxl.idl __libxl_$*.h __libxl_$*.c
-       mv __libxl_$*.h _libxl_$*.h
-       mv __libxl_$*.c _libxl_$*.c
+       $(call move-if-changed,__libxl_$*.h,_libxl_$*.h)
+       $(call move-if-changed,__libxl_$*.c,_libxl_$*.c)
 
 libxenlight.so: libxenlight.so.$(MAJOR)
        ln -sf $< $@

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.