[m-rev.] for review: don't touch mercury_conf.h

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Mar 30 14:09:31 AEDT 2006


configure.in:
runtime/Mmakefile:
	Since touching mercury_conf.h's timestamp causes a bunch of files to be
	recompiled, don't touch mercury_conf.h unless its contents have
	actually changed. Ignore changes in comments only, as in the comment
	about whether the recreation of mercury_conf.h was started from the top
	level directory or the runtime directory.

Index: configure.in
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/configure.in,v
retrieving revision 1.448
diff -u -b -r1.448 configure.in
--- configure.in	14 Mar 2006 05:55:24 -0000	1.448
+++ configure.in	30 Mar 2006 03:02:20 -0000
@@ -4304,6 +4304,21 @@
 	fi
 fi
 
+# The references to $conf_h_copy and $had_old_conf_h below are in code that
+# autoconf puts into a subshell, so we must export them.
+conf_h_copy=/tmp/mercury_conf.h.$$
+# trap "rm -f $conf_h_copy" 0 1 2 3 13 15
+export conf_h_copy
+if test -f runtime/mercury_conf.h
+then
+	/bin/rm -f $conf_h_copy
+	cp runtime/mercury_conf.h $conf_h_copy
+	had_old_conf_h=true
+else
+	had_old_conf_h=false
+fi
+export had_old_conf_h
+
 # IMPORTANT NOTE
 # --------------
 # Any new entries here may need to be handled by scripts/mercury_config.in.
@@ -4338,7 +4353,18 @@
 case $reconfiguring in no)
 	for header in $CONFIG_HEADERS ; do
 		if test "$header" = "runtime/mercury_conf.h"; then
+			if $had_old_conf_h && \
+				cmp runtime/mercury_conf.h "$conf_h_copy" \
+					> /dev/null && \
+				test -f runtime/mercury_conf.h.date
+			then
+				# The date file need not be updated, so don't
+				# update it, since that would lead to the
+				# recompilation of a bunch of files.
+				true
+			else
 			touch runtime/mercury_conf.h.date
+			fi
 		fi
 	done
 	# conftest.junk is used to avoid a warning if there
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.131
diff -u -b -r1.131 Mmakefile
--- runtime/Mmakefile	24 Feb 2006 07:11:19 -0000	1.131
+++ runtime/Mmakefile	30 Mar 2006 03:04:03 -0000
@@ -390,10 +390,21 @@
 	cat `vpath_find $(CFILES)` | grep '^INIT ' > $(RT_LIB_NAME).init
 
 mercury_conf.h.date: $(MERCURY_DIR)/config.status mercury_conf.h.in
+	if test -f mercury_conf.h ; then \
+		mv mercury_conf.h mercury_conf.h.was ; fi
 	$(MERCURY_DIR)/config.status --header=mercury_conf.h
+	@mv mercury_conf.h mercury_conf.h.tmp
+	@sed -e '/Generated by configure/s:mercury_conf:runtime/mercury_conf:' \
+		< mercury_conf.h.tmp > mercury_conf.h
 	# check to ensure there were no mispelt autoconf variable names
 	if grep -n '[^$$]@' mercury_conf.h; then false; else true; fi
-	echo datestamp > mercury_conf.h.date
+	# check if we need to update the timestamp
+	if test -f mercury_conf.h.was -a -f mercury_conf.h.date && \
+		cmp mercury_conf.h.was mercury_conf.h > /dev/null ; \
+		then mv mercury_conf.h.was mercury_conf.h ; \
+		else echo datestamp > mercury_conf.h.date ; \
+	fi
+	@-rm -f mercury_conf.h.tmp mercury_conf.h.was
 
 mercury_conf.h: mercury_conf.h.date
 	@true
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list