for review: MLOBJS.

Tyson Dowd trd at cs.mu.OZ.AU
Thu Mar 5 16:58:35 AEDT 1998


A blast from the past....

On 20-Feb-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 20-Feb-1998, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > Fix bugs in how MLOBJS works.
> 
> That looks fine.  One thing, though:
> ...
> > +MLOBJS-%: $(MLOBJS)
> >	@:
> 
> Is the "@:" necessary?
> I think you should be able to write just the dependency, with no action.

I think so too.  Unfortunately, gmake doesn't agree.

Here's an updated diff that handles MLPICOBJS properly.  I'll commit
this RSN.

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


Estimated hours taken: 3

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 the variable MLOBJS is not set until later.
This means MLOBJS won't be generated from the .c files, and the linker
will abort, complaining that files are missing.

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.59
diff -u -r1.59 modules.m
--- modules.m	1998/03/04 19:47:40	1.59
+++ modules.m	1998/03/05 03:42:37
@@ -1714,7 +1714,7 @@
 
 	io__write_strings(DepStream, [
 		BaseFileName, " : $(", BaseFileName, ".os) ",
-		BaseFileName, "_init.o $(MLOBJS)\n",
+		BaseFileName, "_init.o MLOBJS-", BaseFileName, "\n",
 		"\t$(ML) $(GRADEFLAGS) $(MLFLAGS) -o ", BaseFileName, " ",
 		BaseFileName, "_init.o \\\n",
 		"\t	$(", BaseFileName, ".os) $(MLOBJS) $(MLLIBS)\n\n"
@@ -1730,7 +1730,7 @@
 
 	io__write_strings(DepStream, [
 		BaseFileName, ".split.a : $(", BaseFileName, ".dir_os) ",
-				"$(MLOBJS)\n",
+				"MLOBJS-", BaseFileName, "\n",
 		"\trm -f ", BaseFileName, ".split.a\n",
 		"\t$(AR) $(ARFLAGS) ", BaseFileName, ".split.a $(MLOBJS)\n",
 		"\tfor dir in $(", BaseFileName, ".dirs); do \\\n",
@@ -1751,7 +1751,7 @@
 
 	io__write_strings(DepStream, [
 		"lib", BaseFileName, ".so : $(", BaseFileName, ".pic_os) ",
-				"$(MLPICOBJS)\n",
+				"MLPICOBJS-", BaseFileName, "\n",
 		"\t$(ML) --make-shared-lib $(GRADEFLAGS) $(MLFLAGS) -o ",
 			"lib", BaseFileName, ".so \\\n",
 		"\t\t$(", BaseFileName, ".pic_os) $(MLPICOBJS) $(MLLIBS)\n\n"
@@ -1759,7 +1759,7 @@
 
 	io__write_strings(DepStream, [
 		"lib", BaseFileName, ".a : $(", BaseFileName,
-				".os) $(MLOBJS)\n",
+				".os) MLOBJS-", BaseFileName, "\n",
 		"\trm -f ", BaseFileName, ".a\n",
 		"\t$(AR) $(ARFLAGS) lib", BaseFileName, ".a ",
 			"$(", BaseFileName, ".os) $(MLOBJS)\n",
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/Mmake.rules,v
retrieving revision 1.50
diff -u -r1.50 Mmake.rules
--- Mmake.rules	1998/03/03 17:47:00	1.50
+++ Mmake.rules	1998/03/05 05:52:34
@@ -152,6 +152,12 @@
 	rm -f $@
 	$(MCS) $(GRADEFLAGS) $(MCSFLAGS) $<
 
+MLOBJS-%: $(MLOBJS)
+	@:
+
+MLPICOBJS-%: $(MLPICOBJS)
+	@:
+
 #-----------------------------------------------------------------------------#
 
 # 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