* move-if-changed: New script.
authorKen Raeburn <raeburn@mit.edu>
Tue, 26 Mar 2002 21:27:05 +0000 (21:27 +0000)
committerKen Raeburn <raeburn@mit.edu>
Tue, 26 Mar 2002 21:27:05 +0000 (21:27 +0000)
* post.in (depend-postrecurse): Use it.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14289 dc483132-0cff-0310-8789-dd5450dbe970

src/config/ChangeLog
src/config/move-if-changed [new file with mode: 0644]
src/config/post.in

index 1cd7396d9f5e4f26b35bcbbf71f78c34873ca508..c65d72bc17d887ddb35789073b0aa1be7444c323 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-26  Ken Raeburn  <raeburn@mit.edu>
+
+       * move-if-changed: New script.
+       * post.in (depend-postrecurse): Use it.
+
 2002-01-08  Ken Raeburn  <raeburn@mit.edu>
 
        * shlib.conf: For Linux, always add "-lc" at the end of the link
diff --git a/src/config/move-if-changed b/src/config/move-if-changed
new file mode 100644 (file)
index 0000000..21403e1
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Move file 1 to file 2 if they don't already match.
+# Good for "make depend" for example, where it'd be nice to keep the
+# old datestamp.
+if [ $# != 2 ]; then
+  echo 2>&1 usage: $0 newfile oldfilename
+  exit 1
+fi
+#
+if [ ! -r "$2" ]; then
+  exec mv -f "$1" "$2"
+fi
+if cmp "$1" "$2" >/dev/null; then
+  echo "$2 is unchanged"
+  exec rm -f "$1"
+fi
+exec mv -f "$1" "$2"
index 35ae07c34574fbfb4398628b39e4219f1f2e2774..3ca6f0c11c233a2c224cdd10da2af5b17bb209bb 100644 (file)
@@ -41,8 +41,7 @@ depend-postrecurse:: .depend
                sed -e '/^# +++ Dependency line eater +++/,$$d' \
                        < $(srcdir)/Makefile.in | cat - .depend \
                        > $(srcdir)/Makefile.in.new; \
-       $(MV) $(srcdir)/Makefile.in $(srcdir)/Makefile.in.old; \
-       $(MV) $(srcdir)/Makefile.in.new $(srcdir)/Makefile.in; \
+       $(SRCTOP)/config/move-if-changed $(srcdir)/Makefile.in.new $(srcdir)/Makefile.in ; \
        else :; fi
 
 depend:: depend-prerecurse depend-recurse depend-postrecurse