another Makefile fix

Matthew Fluet Matthew Fluet <fluet@CS.Cornell.EDU>
Thu, 4 Oct 2001 09:34:30 -0400 (EDT)


> What?  How can a call to cmcat fail just because I changed a dependency?

The call to cmcat can fail if src/mlyacc.lex.sml and friends don't exist.
I assume the issue is that we list mlyacc.lex.sml in the src/sources.cm
file (rather than mlyacc.lex), so when CM does it's dependency analysis,
it really wants to read mlyacc.lex.sml.

> My suggesion is that there be a new target: I would suggest cm, which makes
> the mlyacc.cm file, but NO ONE depend on that target.  Thus there is no
> DWIM'ishness and no circularities, and yet if you do a
>       make cm
> it will make mlyacc.cm.  Isn't this better than the ifeq stuff?

I'm o.k. with this; it does remove the MAKECMDGOALS hack.  So, the
proposal would have:

.PHONY:	cm
cm: src/yacc.lex.sml src/yacc.grm.sig src/yacc.grm.sml
	(								\
		echo 'Group is' &&					\
		cmcat sources.cm | grep -v 'mlton-stubs-in-smlnj' &&	\
		echo 'call-main.sml';					\
	) >$(NAME).cm

And I get the following behavior:

(clean sources, mlyacc.cm exists): make
build src/yacc.lex.sml and friends, build mlyacc

(clean sources, mlyacc.cm doesn't exist): make
mlton: mlyacc.cm does not exist
make: *** No rule to make target `mlyacc.cm', needed by `mlyacc'.  Stop.

(clean sources, mlyacc.cm exists): make cm
build src/yacc.lex.sml and friends, build mlyacc.cm

(clean sources, mlyacc.cm doesn't exists): make cm
build src/yacc.lex.sml and friends, build mlyacc.cm

(clean sources, mlyacc.cm exists): make cm all
build src/yacc.lex.sml and friends, build mlyacc.cm, build mlyacc

Henry has a valid point about the DWIM'ishness.  That last example is
something we could reasonably expect to do, but it wouldn't have the right
behaviour under the MAKECMDGOALS hack.

I don;t know what is the intended behaviour in the second case.  I'm o.k.
with make failing when mlyacc.cm doesn't exist and the only way to create
mlyacc.cm is by the explicit make cm.