for review: MLOBJS.

Tyson Dowd trd at cs.mu.OZ.AU
Fri Feb 20 16:58:33 AEDT 1998


Hi,

Fergus, want to check this?

===================================================================


Estimated hours taken: 2

Fix bugs in how MLOBJS works.

Because mmake puts the contents of the .dep file before the Mmakefile
when generating a makefile for gmake, the scheme of using
	MLOBJS=foo.o bar.o
in the Mmakefile won't work. The dependencies in the .dep file such as
	libxyz.a: ..... $(MLOBJS)
are expanded when read, but MLOBJS is not set until later. This means
MLOBJS won't be generated from the .c files.

So the solution is to output
	libxyz.a: ..... MLOBJS
where MLOBJS is a target, and is defined in Mmake.rules (which is seen
by make after the contents of Mmakefile).
	MLOBJS: $(MLOBJS).

(In fact, it gets more complicated: to support different MLOBJS variables
for different programs/libraries, so we use MLOBJS-xyz as the target,
and a pattern matching rule in Mmake.rules). 

This must also be done for MLPICOBJS.

compiler/modules.m:
	Output the targets instead of the variables.

scripts/Mmake.rules:
	Pattern match MLOBJS-% and MLPICOBJS-% dependencies, and make
	them depend on the corresponding variables.


Index: compiler/modules.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/modules.m,v
retrieving revision 1.56
diff -u -r1.56 modules.m
--- modules.m	1998/02/07 09:55:32	1.56
+++ modules.m	1998/02/19 07:54:56
@@ -1159,7 +1159,7 @@
 
 	io__write_strings(DepStream, [
 		ModuleName, " : $(", ModuleName, ".os) ",
-		ModuleName, "_init.o $(MLOBJS)\n",
+		ModuleName, "_init.o MLOBJS-", ModuleName, "\n",
 		"\t$(ML) $(GRADEFLAGS) $(MLFLAGS) -o ", ModuleName, " ",
 		ModuleName, "_init.o \\\n",
 		"\t	$(", ModuleName, ".os) $(MLOBJS) $(MLLIBS)\n\n"
@@ -1175,7 +1175,7 @@
 
 	io__write_strings(DepStream, [
 		ModuleName, ".split.a : $(", ModuleName, ".dir_os) ",
-				"$(MLOBJS)\n",
+				"MLOBJS-", ModuleName, "\n",
 		"\trm -f ", ModuleName, ".split.a\n",
 		"\t$(AR) $(ARFLAGS) ", ModuleName, ".split.a $(MLOBJS)\n",
 		"\tfor dir in $(", ModuleName, ".dirs); do \\\n",
@@ -1202,7 +1202,8 @@
 	]),
 
 	io__write_strings(DepStream, [
-		"lib", ModuleName, ".a : $(", ModuleName, ".os) $(MLOBJS)\n",
+		"lib", ModuleName, ".a : $(", ModuleName, ".os) MLOBJS-", 
+		ModuleName, "\n",
 		"\trm -f ", ModuleName, ".a\n",
 		"\t$(AR) $(ARFLAGS) lib", ModuleName, ".a ",
 			"$(", ModuleName, ".os) $(MLOBJS)\n",
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/Mmake.rules,v
retrieving revision 1.49
diff -u -r1.49 Mmake.rules
--- Mmake.rules	1998/02/12 10:04:33	1.49
+++ Mmake.rules	1998/02/19 07:49:53
@@ -146,6 +146,9 @@
 	rm -f $@
 	$(MCS) $(GRADEFLAGS) $(MCSFLAGS) $<
 
+MLOBJS-%: $(MLOBJS)
+        @:
+
 #-----------------------------------------------------------------------------#
 
 # The actions for `mmake clean' etc. are in the `.d' files.


-- 
       Tyson Dowd           # There isn't any reason why Linux can't be
                            # implemented as an enterprise computing solution.
     trd at cs.mu.oz.au        # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.



More information about the developers mailing list