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: > > martind@swiftboat:~/tmp/benjamin-cama-2017-08-03$ cat Makefile > SUBDIR = $(@D) > $(SUBDIR)/target-%: > martind@swiftboat:~/tmp/benjamin-cama-2017-08-03$ make -n -p 2>&1 | grep > target- | grep -v FEATURES > /target-%: > martind@swiftboat:~/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 _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make