%% Cyril Bouthors <[EMAIL PROTECTED]> writes:
>> You're building only $@ here. $@ is set to whatever target caused
>> this rule to be invoked.
cb> I agree $@ matches only one thing at a time.
I already explained all this last time. Please re-read my previous
message carefully. I'll try again.
The syntax of:
%.x %.y : %.z
means that the rule will be run only once. That's the whole point
behind this syntax. If you want the rule to be run once for each
individual target, you can't use this syntax.
cb> Let's say I do the following with the same Makefile :
cb> $ make file.out1
cb> cat file.source > file.out1
cb> $ make file.out2
cb> cat file.source > file.out2
cb> It will build two files using the same target.
The first time you run "make", it needs to build file.out1, so it runs
the rule you've given to do so. Make thinks that that rule also builds
file.out2, but that's irrelevant here, since you didn't ask for it.
The second time you run "make", it needs to build file.out2, and sees
that (a) that file doesn't exist, and (b) there's a rule to build it, so
it runs the rule.
Remember make is stateless between invocations; it has no idea what it
built _last_ time, only what exists now and what it needs to build. The
second time it sees that file.out2 doesn't exist, so it runs the rule to
build it.
cb> I expect "make all" to
cb> build the files in $(LIST): to do the same thing as:
cb> $ make file.out1 file.out2
cb> If I do it in two step, it works, if I do it in one step, it fails :
cb> $ make file.out1 file.out2
cb> cat file.source > file.out1
cb> make: Nothing to be done for `file.out2'.
This isn't a failure, it's just telling you that nothing needs to be
done.
Your makefile says that one invocation of the rule will build both
files. So, when you ask for both files to be built, make just runs the
rule once, and thinks its done. Re-read that a couple of times.
cb> But if I do it again (file.out1 is already built).
cb> $ make file.out1 file.out2
cb> make: `file.out1' is up to date.
cb> cat file.source > file.out2
See above.
cb> I'm doing this to avoid writing two distint rules because they build
cb> files the same manner. Let's imagine the following Makefile :
cb> LIST = file.out1 file.out2
cb> all: $(LIST)
cb> %.out1: %.source
cb> cat $< > $@
cb> %.out2: %.source
cb> cat $< > $@
If you want this, you have to write this.
cb> I don't want my script to build several files at a time, I want make
cb> to call my script several times with different arguments.
Then you cannot use a pattern rule with multiple targets on the
left-hand side.
That syntax means something completely different, as I've explained. If
what it means isn't what you want, you shouldn't use it.
cb> My rule only say that make matches it when you build *.out1 or
cb> *.out2. It's nearly as if I was doing :
cb> file.out1 file.out2: file.source
cb> cat $< > $@
No. This means something entirely different. The rule:
file.out1 file.out2: file.source
...
is identical to this:
file.out1: file.source
...
file.out2: file.source
...
it's true. But the pattern rule:
%.out1 %.out2: %.source
...
is _NOT_ even close to the same thing as:
%.out1: %.source
...
%.out2: %.source
...
Not even close. If you want the latter, you have to write it that way.
cb> Is there a problem with putting two "%" in one target ?
There's no problem: it does exactly what it is documented to do in the
manual. However, what it does is apparently not what you want it to do.
So you shouldn't use it.
--
-------------------------------------------------------------------------------
Paul D. Smith <[EMAIL PROTECTED]> Find some GNU make tips at:
http://www.gnu.org http://www.ultranet.com/~pauld/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist