WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 01 of 10] build: define "move-if-changed" make macro

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 01 of 10] build: define "move-if-changed" make macro
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 23 Jun 2011 17:20:52 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Thu, 23 Jun 2011 09:24:47 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1308846051@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1308846051@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1308843343 -3600
# Node ID edb8e868a964365a3ffe5c7d17467f9f08bf2803
# Parent  4fa92ff6c6156c2723d716a48c041dcb2c92938b
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>

diff -r 4fa92ff6c615 -r edb8e868a964 Config.mk
--- a/Config.mk Thu Jun 23 16:35:43 2011 +0100
+++ b/Config.mk Thu Jun 23 16:35:43 2011 +0100
@@ -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
@@ -133,7 +143,7 @@ define buildmakevars2file-closure
        echo "XEN_CONFIG_DIR=\"$(XEN_CONFIG_DIR)\"" >> $(1).tmp;           \
        echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >> $(1).tmp;           \
        echo "XEN_LOCK_DIR=\"$(XEN_LOCK_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 4fa92ff6c615 -r edb8e868a964 tools/libxl/Makefile
--- a/tools/libxl/Makefile      Thu Jun 23 16:35:43 2011 +0100
+++ b/tools/libxl/Makefile      Thu Jun 23 16:35:43 2011 +0100
@@ -74,7 +74,8 @@ genpath-target = $(call buildmakevars2fi
 
 _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
 
@@ -84,8 +85,8 @@ libxl.h: _libxl_types.h
 
 _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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel