help-make
[Top][All Lists]
Advanced

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

Re: help needed understanding multiple target pattern rules


From: Philip Guenther
Subject: Re: help needed understanding multiple target pattern rules
Date: Tue, 13 Jan 2009 10:26:53 -0800

On Tue, Jan 13, 2009 at 3:40 AM, Lilie Weaver <address@hidden> wrote:
> I have a number of files, lets call them foo.txt, bar.bar and baz.z. They
> are all dependant on another set of files, lets say makefoo, barmaker, and
> bazzer (the point is none of the file names follow a pattern), but are all
> made by a single command, lets say the shell script setup.sh
>
> I want to write a rule with multiple targets like this:
>
> foo.txt bar.bar baz.z: makefoo barmaker bazzer
>              ./setup.sh
>
> so that each time any of the pre-requisites are out of date, don't exist, or
> the files don't exist (i.e. setup has not been run before), setup.sh is run.
> However, rules with multiple targets (unless they are pattern rules) run the
> command once for each target. This is obviously not what I want. So I tried
> making a pattern rule with multiple targets, because then (10.5.1) make
> knows that all the targets are made by a single command. The problem is (or
> may not be??) that the filenames don't follow a pattern:
>
> f%o.txt b%r.bar b%z.z: makefoo barmaker bazzer
>              ./setup.sh

That only works if the '%' in each target filename expands to the same
thing.  It's a wildcard, but must expand to the same thing in each
one.

If there really is no pattern to the filenames, nothing in common that
can be used as the %, then you'll need to instead use a sentinel file
setup:

foo.txt bar.bar baz.z: setup.sh-run

setup.sh-run: makefoo barmaker bazzer
        ./setup.sh
        @touch $@

(At least that's my memory of how to express this...)

> (also, I suspect setup.sh should also be a pre-requisite?)

If setup.sh could change such that its previous output would be
incorrect after the change, then making it a prerequisite would
certainly make sense.


Philip Guenther




reply via email to

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