[m-dev.] for review: don't delete Mercury-generated C files unnecessarily

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed May 5 16:21:17 AEST 1999


For review by anyone.

Estimated hours taken: 1

configure.in:
	Do not blindly remove the Mercury generated C files in the compiler,
	library, browser and profiler directories if the results of the
	autoconfiguration do not match the standard source distribution's
	assumptions with respect to the number of tag bits and the use of
	unboxed floats. Instead, delete these C files only if the result
	of the autoconfiguration differ from the parameter settings that
	were used in creating those C files.

Zoltan.

Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.164
diff -u -b -u -r1.164 configure.in
--- configure.in	1999/05/02 01:22:32	1.164
+++ configure.in	1999/05/05 08:18:11
@@ -838,20 +838,12 @@
 	if test "$BOOTSTRAP_MC" = ""; then
 		AC_MSG_ERROR("cannot bootstrap: low tag bits less than 2")
 		exit 1
-	else
-		MERCURY_MSG("rebuilding with fewer tag bits")
-		MERCURY_MSG("installation may take longer than usual")
-		rm -f library/*.c compiler/*.c browser/*.c profiler/*.c
 	fi
 fi
 if test "$mercury_cv_low_tag_bits" -gt 2; then
 	if test "$BOOTSTRAP_MC" = ""; then
 		AC_MSG_WARN("bootstrapping using only 2 low tag bits")
 		mercury_cv_low_tag_bits=2
-	else
-		MERCURY_MSG("rebuilding with extra tag bits")
-		MERCURY_MSG("installation may take longer than usual")
-		rm -f library/*.c compiler/*.c browser/*.c profiler/*.c
 	fi
 fi
 AC_DEFINE_UNQUOTED(LOW_TAG_BITS, $mercury_cv_low_tag_bits)
@@ -962,10 +954,6 @@
 		AC_MSG_WARN(*** so you can use unboxed floats," \
 				"which are more efficient.)
 		mercury_cv_unboxed_floats=no
-	else
-		MERCURY_MSG("rebuilding with unboxed floats")
-		MERCURY_MSG("installation may take longer than usual")
-		rm -f library/*.c compiler/*.c browser/*.c profiler/*.c
 	fi
 fi
 if test "$mercury_cv_unboxed_floats" = yes; then
@@ -2098,6 +2086,51 @@
 LIBS="$save_LIBS"
 #-----------------------------------------------------------------------------#
 MERCURY_CHECK_READLINE
+#-----------------------------------------------------------------------------#
+to_keep=""
+to_delete=""
+if test "$BOOTSTRAP_MC" != "" ; then
+	MERCURY_MSG("checking whether any C files need to be rebuilt...")
+	for c_file in library/*.c compiler/*.c browser/*.c profiler/*.c
+	do
+		case $c_file in
+		*/'*.c')
+			;;
+		*)
+			sed -e '/END_OF_C_GRADE_INFO/,$d' < $c_file > confscratch
+			if grep "TAG_BITS=$mercury_cv_low_tag_bits" confscratch > /dev/null 2>&1
+			then
+				if grep "UNBOXED_FLOAT=$mercury_cv_unboxed_floats" confscratch > /dev/null 2>&1
+				then
+					to_keep="$to_keep $c_file"
+				else
+					to_delete="$to_delete $c_file"
+				fi
+			else
+				to_delete="$to_delete $c_file"
+			fi
+			;;
+		esac
+	done
+	if test "$to_delete" = "" ; then
+		if test "$to_keep" != "" ; then
+			MERCURY_MSG("no - they are compatible with autoconfigured settings")
+		else
+			MERCURY_MSG("there are no existing Mercury-generated C files")
+		fi
+	else
+		if test "$to_keep" != "" ; then
+			MERCURY_MSG("the following C files must be rebuilt in a grade")
+			MERCURY_MSG("that is consistent with autoconfigured settings")
+			MERCURY_MSG("$to_delete")
+		else
+			MERCURY_MSG("all Mercury generated C files must be rebuilt in a grade")
+			MERCURY_MSG("that is consistent with autoconfigured settings")
+		fi
+		MERCURY_MSG("installation may take longer than usual")
+	fi
+	rm -f confscratch $to_delete
+fi
 #-----------------------------------------------------------------------------#
 AC_OUTPUT(Mmake.common scripts/Mmake.vars scripts/mmc scripts/mprof
 scripts/mercury_update_interface scripts/mgnuc scripts/ml
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list