[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: some question about automatic variables
From: |
loody |
Subject: |
Re: some question about automatic variables |
Date: |
Tue, 26 Apr 2011 03:44:13 +0800 |
hi:
2011/4/25 Paul Smith <address@hidden>:
> On Mon, 2011-04-25 at 22:17 +0800, loody wrote:
>> 1. There is a section, 10.5.3 Automatic Variables, which explain the
>> meaning and usage of automatic variables.
>> But I cannot find the usage of $< in the manual.
>> Would anyone tell me where it is?
>
> It's right there, in that section:
>
> `$<'
> The name of the first prerequisite. If the target got its
> commands from an implicit rule, this will be the first
> prerequisite added by the implicit rule (*note Implicit Rules::).
>
> Does your info reader support a search function?
it seems I look for quite older make document that I cannot find the
explanation you mentioned.
Now I found it in the latest one. :)
In my document, the format of make is:
target : prerequisites
command
instead of
target : prerequisites
recipe
BTW, what is the "The name of the first prerequisite"
suppose the rule is as below:
$(obj)/%.o : $(src)/%.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
every *.c file in $(src) will apply the rule one by one, right?
if so, why we should emphasis the "first prerequisite"?
Does that mean if we have such rule:
$(obj)/%.o : $(src)/%.c $(src)/%.cpp
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
the above recipe will only work for *.c files below $(src)?
>
>> 2. in that section, there is an example say "if "$@" is "dir/foo.o",
>> $(@D) will be "dir""
>> does that mean if our makefile as below:
>>
>> dir/foo.o dir/abc.o dir/def.o : header.h
>> commands
>>
>> and $@ in the commands will be dir/foo.o and $(D@) will be dir?
>
> Yes, when make is building dir/foo.o. When make is building dir/abc.o
> then $@ will be dir/abc.o.
>
> Remember that the rule above is interpreted by make to be the same as:
>
> dir/foo.o : header.h
> commands
> dir/abc.o : header.h
> commands
> dir/def.o : header.h
> commands
>
> Make does not think that one invocation of the "commands" recipe will
> build all three targets.
>
>
>
--
Regards,
miloody