bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make feature rq: Non-pattern rules with multi-target commands


From: Henning Makholm
Subject: Make feature rq: Non-pattern rules with multi-target commands
Date: Sun, 20 Oct 2002 00:06:45 +0200
User-agent: Mutt/1.4i

I think it would be cool if there was some way to write a non-pattern
rule that tells Make that this particular command creates more than
one file simultaneously. I.e., a multi-target rule that works like
multi-target pattern rules.

Here is why I need it: I use a compiler, `mosmlc', that reads a
`*.sml' source file and write a `*.uo' file with object code and a
`*.ui' file with a machine-readable interface summary. The `*.ui' file
is read by later `mosmlc' processes. I have instrumented the compiler
such that it will leave the timestamp on the `*.ui' files unchanged if
its contents does not change; that way I can avoid recompilation of
the dependent compilation units if only the implementation detail
change. (You may or may not remember the exchange on this list about a
year ago where I was helped grasp this aspect of make's operation).

What I would like to do is something like

  foobar.ui foobar.uo: foobar.sml
          mosmlc foobar.sml
  bazquux.ui bazquux.uo: foobar.ui bazquux.sml
          mosmlc foobar.ui bazquux.sml
  binary: foobar.uo bazquux.uo
          <command to link the binary goes here>

but that will make make think that the mosmlc command has to be run
*twice* to remake foobar.uo as well as foobar.ui. When it is run the
second time to make foobar.ui, it will be unchanged even if it changed
in the first compilation, so I'll miss the recompilation of bazquux.

I have tried to think of alternatives like letting foobar.ui be the
sole target of the mosmlc command and then having foobar.uo depend on
foobar.ui with empty commands, or vice versa, but neither seems to get
the timing right.

My current solution is to force the rule to be a pattern rule:

  foobar%ui foobar%uo: foobar%sml
          mosmlc foobar.sml

(intending a stem of `.') but that has a clear smell of being the
Wrong Thing to do. It seems wasteful to bloat the pattern rule
database with one rule for each source file in a large database,
and I need to work around the risk of having the pattern also match
foobar2.ui (which needs different options to mosmlc).

[It also seems that for a pattern rule Make's ideas about whether
foobar.sml "exists or ought to exist" are somehow stricter than for
explicit rules. At least I have had reports that my Makefile confuse
the Win32/Cygwin build of make 3.79.1 - it refuses to apply the
pattern rule, but builds happily (with two compliations) when the
percent sign is replaced by full stops. I suspect that some foul play
with capitalization of the directory parts of the file names is
involved.]

Have I overlooked some syntax that would allow me to do what I want,
or is there an easy workaround? If not, would a patch that adds an
explicit syntax for non-pattern many-targets-at-once rules have a
chance of being considered?

-- 
Henning Makholm          "Jeg har tydeligt gjort opmærksom på, at man ved at
                   følge den vej kun bliver gennemsnitligt ca. 48 år gammel,
               og at man sætter sin sociale situation ganske overstyr og, så
           vidt jeg kan overskue, dør i dybeste ulykkelighed og elendighed."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]