for review: fix handling of $(MLOBJS) dependencies

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 20 16:21:26 AEDT 1998


Tyson, can you please review this one?

Estimated hours taken: 0.5

Fix the handling of dependencies on $(MLOBJS) and $(MLPICOBJS)
so that we don't reinvoke the linker for every make, even when
the executable(s) are already up-to-date.

scripts/Mmake.rules:
	Delete the MLOBJS and MLPICOBJS targets.
	Add `$(MLOBJS_DEPS) : $(MLOBJS)', and likewise for $(MLPICOBJS).

compiler/modules.m:
	When generating the `.dep' files, instead of using the MLOBJS
	and MLPICOBJS phony targets, record dependencies of files on
	$(MLOBJS) by adding those files to $(MLOBJS_DEPS),
	and likewise for $(MLPICOBJS).


cvs diff  compiler/modules.m scripts/Mmake.rules
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.66
diff -u -r1.66 modules.m
--- modules.m	1998/03/20 04:36:19	1.66
+++ modules.m	1998/03/20 04:44:31
@@ -1947,8 +1947,9 @@
 
 	module_name_to_file_name(ModuleName, "", no, ExeFileName),
 	io__write_strings(DepStream, [
+		"MLOBJS_DEPS += ", ExeFileName, "\n",
 		ExeFileName, " : $(", MakeVarName, ".os) ",
-		InitObjFileName, " MLOBJS-", MakeVarName, "\n",
+			InitObjFileName, "\n",
 		"\t$(ML) $(GRADEFLAGS) $(MLFLAGS) -o ", ExeFileName, " ",
 		InitObjFileName, " \\\n",
 		"\t	$(", MakeVarName, ".os) $(MLOBJS) $(MLLIBS)\n\n"
@@ -1965,8 +1966,8 @@
 	]),
 
 	io__write_strings(DepStream, [
-		SplitLibFileName, " : $(", MakeVarName, ".dir_os) ",
-				"MLOBJS-", MakeVarName, "\n",
+		"MLOBJS_DEPS += ", SplitLibFileName, "\n",
+		SplitLibFileName, " : $(", MakeVarName, ".dir_os)\n",
 		"\trm -f ", SplitLibFileName, "\n",
 		"\t$(AR) $(ARFLAGS) ", SplitLibFileName, " $(MLOBJS)\n",
 		"\tfor dir in $(", MakeVarName, ".dirs); do \\\n",
@@ -1993,16 +1994,16 @@
 	]),
 
 	io__write_strings(DepStream, [
-		SharedLibFileName, " : $(", MakeVarName, ".pic_os) ",
-				"MLPICOBJS-", MakeVarName, "\n",
+		"MLPICOBJS_DEPS += ", SharedLibFileName, "\n",
+		SharedLibFileName, " : $(", MakeVarName, ".pic_os)\n",
 		"\t$(ML) --make-shared-lib $(GRADEFLAGS) $(MLFLAGS) -o ",
 			SharedLibFileName, " \\\n",
 		"\t\t$(", MakeVarName, ".pic_os) $(MLPICOBJS) $(MLLIBS)\n\n"
 	]),
 
 	io__write_strings(DepStream, [
-		LibFileName, " : $(", MakeVarName, ".os) ",
-				"MLOBJS-", MakeVarName, "\n",
+		"MLOBJS_DEPS += ", LibFileName, "\n",
+		LibFileName, " : $(", MakeVarName, ".os)\n",
 		"\trm -f ", LibFileName, "\n",
 		"\t$(AR) $(ARFLAGS) ", LibFileName, " ",
 			"$(", MakeVarName, ".os) $(MLOBJS)\n",
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.55
diff -u -r1.55 Mmake.rules
--- Mmake.rules	1998/03/20 02:58:22	1.55
+++ Mmake.rules	1998/03/20 04:57:41
@@ -246,6 +246,27 @@
 endif # $(cs_subdir) != ""
 
 #-----------------------------------------------------------------------------#
+#
+# Code to handle dependencies on $(MLOBJS) and $(MLPICOBJS).
+#
+
+# The generated `.dep' files include rules for targets which may depend
+# on $(MLOBJS) or $(MLPICOBJS).  However, the definition of $(MLOBJS)
+# or $(MLPICOBJS) is in the user's Mmakefile, and the `.dep' files get
+# included *before* the Mmakefile.  The `.dep' files cannot contain
+# those dependency directly, because $(MLOBJS) and $(MLPICOBJS) variables
+# have not yet been defined.
+#
+# Instead, the generated `.dep' files just add the appropriate targets to
+# the $(MLOBJS_DEPS) or $(MLPICOBJS_DEPS) variables, and then we record the
+# dependency of those files on $(MLOBJS) or $(MLPICOBJS) here in Mmake.rules,
+# which gets included after the user's Mmakefile.
+
+$(MLOBJS_DEPS) : $(MLOBJS)
+$(MLPICOBJS_DEPS) : $(MLPICOBJS)
+
+# The following is obsolete; I've kept it here only for
+# bootstrapping reasons and for compatibility with old `.dep' files.
 
 MLOBJS-%: $(MLOBJS)
 	@

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list