Paul D. Smith writes:
 >   cb> The Makefile looks like (as simple as possible):
 > 
 >   cb> LIST = file.out1 file.out2
 > 
 >   cb> all: $(LIST)
 > 
 >   cb> %.out1 %.out2: %.source
 >   cb>        cat $< > $@
 > 
 > You're building only $@ here.  $@ is set to whatever target caused
 > this rule to be invoked.

I agree $@ matches only one thing at a time.

Let's say I do the following with the same Makefile :

$ make file.out1
cat file.source > file.out1
$ make file.out2
cat file.source > file.out2

It will build two files using the same target. I expect "make all" to
build the files in $(LIST): to do the same thing as:
$ make file.out1 file.out2

If I do it in two step, it works, if I do it in one step, it fails :

$ make file.out1 file.out2
cat file.source > file.out1
make: Nothing to be done for `file.out2'.

But if I do it again (file.out1 is already built).

$ make file.out1 file.out2
make: `file.out1' is up to date.
cat file.source > file.out2

??

I'm doing this to avoid writing two distint rules because they build
files the same manner. Let's imagine the following Makefile :

LIST = file.out1 file.out2

all: $(LIST)

%.out1: %.source
       cat $< > $@

%.out2: %.source
       cat $< > $@

--

Now I do :
$ make all
cat file.source > file.out1
cat file.source > file.out2

It works.

I don't want my script to build several files at a time, I want make
to call my script several times with different arguments.

Do you see what I mean ? (I'm sorry for my poor english).

 > IOW, your rule says that the script will build two targets, but
 > your script only builds one.

My rule only say that make matches it when you build *.out1 or
*.out2. It's nearly as if I was doing :

file.out1 file.out2: file.source
        cat $< > $@

$@ will match file.out1 OR file.out2. So if I do
$ make file.out1 file.out2
it will build both files.

This will work but the filename is hardcoded, it won't allow to
$ make whateveryouwant.out{1,2}

 > If your script doesn't build what your makefile told make it would,
 > then make is not going to work the way you expect.

The script make invokes is doing what make expects : building one file
from one source.

Is there a problem with putting two "%" in one target ?

-- 
Cyril Bouthors mailto:[EMAIL PROTECTED]
                phone:+33 1 55 26 58 85
                  fax:+33 1 55 26 59 00

Reply via email to