[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug report] Make doesn't know $@ when referenced in the prerequisit
From: |
Paul Smith |
Subject: |
Re: [Bug report] Make doesn't know $@ when referenced in the prerequisites |
Date: |
Sat, 18 Mar 2017 22:18:43 -0400 |
On Sun, 2017-03-19 at 01:51 +0000, Alejandro García Vallejo wrote:
> bar: $(@:%r=foo%z)
> @echo End
>
> foobaz:
> @echo The
>
> """
> GNU Make Output:
> End
>
> Make fails to read $@ (aka, it's empty).
That's not a bug; that's defined behavior. From the GNU make manual:
https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html
> It’s very important that you recognize the limited scope in which
> automatic variable values are available: they only have values within
> the recipe. In particular, you cannot use them anywhere within the
> target list of a rule; they have no value there and will expand to the
> empty string. Also, they cannot be accessed directly within the
> prerequisite list of a rule. A common mistake is attempting to use $@
> within the prerequisites list; this will not work. However, there is a
> special feature of GNU make, secondary expansion (see Secondary
> Expansion), which will allow automatic variable values to be used in
> prerequisite lists.