bug-make
[Top][All Lists]
Advanced

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

Re: Targets directory name concatenation strangeness


From: Benjamin Cama
Subject: Re: Targets directory name concatenation strangeness
Date: Thu, 03 Aug 2017 19:05:10 +0200

Hi Martin,

Le jeudi 03 août 2017 à 16:53 +0000, Martin Dorey a écrit :
> You're trying to use an automatic variable in a scope where it doesn't
> have the value you want.  make -p is how I'd debug such:
> 
> address@hidden:~/tmp/benjamin-cama-2017-08-03$ cat Makefile
> SUBDIR = $(@D)
> $(SUBDIR)/target-%:
> address@hidden:~/tmp/benjamin-cama-2017-08-03$ make -n -p 2>&1 | grep target- 
> | grep -v FEATURES
> /target-%:
> address@hidden:~/tmp/benjamin-cama-2017-08-03$
> 
> The documentation, specifically
> https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html, 
> speaks directly to this case:
> 
> "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."

Thank you very much for this reminder, and the "-p" switch that I did
not know. Examining the example without a slash with it made me realize
that it then works because the target is then the bare pattern filename
($(SUBDIR) is empty and there is no slash added before the file name),
which can match in any subdirectory. So, I was actually back where I
started.

Thanks again for these explanations!
-- 
Benjamin Cama - Tél : 258




reply via email to

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