bug-make
[Top][All Lists]
Advanced

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

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


From: Philip Guenther
Subject: Re: Make feature rq: Non-pattern rules with multi-target commands
Date: Sun, 20 Oct 2002 00:50:38 -0700

address@hidden (Henning Makholm) writes:
>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.

Yeah, this can be useful in some cases.  I remember doing this with
SunOS 4's make using the syntax

target1 + target2: dependencies
        command

but GNU make does not (currently) support that.


>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.

If it's always true that a .sml file generates a .uo and a .ui file,
then a multiple-target pattern rule would seem to be the core of a
solution.  Following the lead of the built-in pattern rules and the
commands you show, that would seem to be something like:

%.uo %.ui: %.sml
        $(COMPILE.sml) $<

SMLC = mosmlc
COMPILE.sml = $(SMLC) $(SMLCFLAGS)


Now, let's look at why you're not doing that:

...
>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).

If foobar2.ui (and presumably foobar2.uo) need different options to
mosmlc, why not just use target-specific assignments?


foobar2.ui foobar2.uo: SMLCFLAGS += --some-option

(I'm not sure whether you need to give it for both in order to guarantee
that make will incorporate it when building the files.  It may be that
make will only check the target that first comes up for building, so
specifying both is probably safer...unless that makes it appears twice
in the command line...)


>Have I overlooked some syntax that would allow me to do what I want,
>or is there an easy workaround?

Given only what you've described, using one or more variables in the
command of a multiple-target pattern rule, combined with target-specific
values for those variables would seem to do provide what you need.


Philip Guenther
address@hidden




reply via email to

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