Modify Makefile.am and configure.ac only if they actually change.
authorBen Pfaff <blp@nicira.com>
Fri, 17 Oct 2008 17:07:21 +0000 (10:07 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 17 Oct 2008 17:07:21 +0000 (10:07 -0700)
Touching them unnecessarily causes Git to think they changed even if
their contents are the same.

boot.sh

diff --git a/boot.sh b/boot.sh
index d39ba903c7d18a42aeba2f0352ecbaef79c21b2c..7c674c5079f7ae85c332a0db8745e011751773a2 100755 (executable)
--- a/boot.sh
+++ b/boot.sh
@@ -30,15 +30,25 @@ done
 # Find the "include ext/automake.mk" line in Makefile.am and comment
 # it out or in according to whether ext is available, and similarly
 # for "m4_include(ext/configure.m4)" in configure.ac.
+subst() {
+    perl -pe "$1" < "$2" > "$2.tmp"
+    if cmp -s "$2.tmp" "$2"; then
+       rm "$2.tmp"
+    else
+       mv "$2.tmp" "$2"
+    fi
+}
 if test "$have_ext" = yes; then
     echo 'Enabling openflowext...'
-    perl -i.bak -pe 's|^#(include ext/automake\.mk)$|$1|' Makefile.am
-    perl -i.bak -pe 's|^#(m4_include\(ext/configure\.m4\))$|$1|' configure.ac
+    OC='#'
+    NC=
 else
     echo 'Disabling openflowext...'
-    perl -i.bak -pe 's|^(include ext/automake\.mk)$|#$1|' Makefile.am
-    perl -i.bak -pe 's|^(m4_include\(ext/configure\.m4\))$|#$1|' configure.ac
+    OC=
+    NC='#'
 fi
+subst "s|^$OC(include ext/automake\\.mk)\$|$NC\$1|" Makefile.am
+subst "s|^$OC(m4_include\\(ext/configure\.m4\\))\$|$NC\$1|" configure.ac
 
 # Bootstrap configure system from .ac/.am files
 autoreconf --install -I config --force