help-make
[Top][All Lists]
Advanced

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

Re: some question about automatic variables


From: Paul Smith
Subject: Re: some question about automatic variables
Date: Mon, 25 Apr 2011 10:44:23 -0400

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?

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





reply via email to

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