Re: Fwd: Re: Target-specific variable in subdirectory problem

2017-08-03 Thread Benjamin Cama
Hi Sven, Le jeudi 03 août 2017 à 16:46 +0100, Sven C. Dack a écrit : > it's a common practise to create a Makefile for each subdirectory and > have it include definitions from a parent Makefile. That's probably why > you don't see that many directory-spanning features in make. It's easier > to

Fwd: Re: Target-specific variable in subdirectory problem

2017-08-03 Thread Sven C. Dack
Hello Benjamin, it's a common practise to create a Makefile for each subdirectory and have it include definitions from a parent Makefile. That's probably why you don't see that many directory-spanning features in make. It's easier to manage Makefiles in a structure similar to the source code

Re: Target-specific variable in subdirectory problem

2017-08-03 Thread Benjamin Cama
Le jeudi 03 août 2017 à 15:06 +, Edward Welbourne a écrit : > Benjamin Cama (3 August 2017 17:00) > > Well, I tried: > > > >SUBDIR = $(dir $@) > >$(SUBDIR)/target-%: > > … > > > > But it doesn't work. But without a slash (which is already present at > > the end of

Re: Target-specific variable in subdirectory problem

2017-08-03 Thread Benjamin Cama
Le jeudi 03 août 2017 à 14:59 +0200, Benjamin Cama a écrit : > To further enhance my understanding of the “right” usage of Makefiles, > would you advise me to explicitly specify the subdirectory in the > target > definition? Because I feel that counting on pattern rules to match in > subdirectory

Re: Target-specific variable in subdirectory problem

2017-08-03 Thread Benjamin Cama
Le jeudi 03 août 2017 à 09:20 -0400, Kyle Rose a écrit : > On Aug 3, 2017 9:00 AM, "Benjamin Cama" wrote: > Anyway, it seems that a global variable would solve my problem, and > indeed it looks a bit more right this way: I can still get the stem in > my

Re: Target-specific variable in subdirectory problem

2017-08-03 Thread Kyle Rose
On Aug 3, 2017 9:00 AM, "Benjamin Cama" wrote: Anyway, it seems that a global variable would solve my problem, and indeed it looks a bit more right this way: I can still get the stem in my recipe (with $*), and everything works as expected. It's just that the global namespace

Re: Target-specific variable in subdirectory problem

2017-08-03 Thread Benjamin Cama
Hi Paul, Le mercredi 02 août 2017 à 15:16 -0400, Paul Smith a écrit : > On Wed, 2017-08-02 at 20:03 +0100, Sven C. Dack wrote: > > On 02/08/17 11:19, Benjamin Cama wrote: > > > Hi, > > > > > > I may be doing something wrong, but the following Makefile gives me > > > strange results: the

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Henrik Carlqvist
> The example in his question makes very clear what he wants: he wants a > pattern-specific variable assignment. Most likely yes. If you look at the subject of this thread it says "Target-specific variable in subdirectory problem" so he probably only wants the variable to be set

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Sven C. Dack
No. You're mistake is to assume to know what he wants from looking at his Makefile when you also know it's not working for him. You cannot know what it is he wants when he apparently fails to express it in a Makefile. So you're still only assuming. You base your assumption on the fact that he

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Paul Smith
On Wed, 2017-08-02 at 21:16 +0100, Sven C. Dack wrote: > I suggest you turn your attention towards him and ask him what he > wants. The example in his question makes very clear what he wants: he wants a pattern-specific variable assignment. The solution you provided was not a pattern-specific

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Sven C. Dack
I suggest you turn your attention towards him and ask him what he wants. My example does exactly what I say it does. It's just not your place to tell me I'm wrong when you don't know what he wants his makefile to do and so far haven't responded to him and only to me. Or am I missing

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Paul Smith
On Wed, 2017-08-02 at 20:40 +0100, Sven C. Dack wrote: > It's my understanding that we don't actually know what Benjamin wants to > do, because nobody has asked. So I don't see how this would make me wrong. > >  From his mail am I assuming he wants his Makefile to print "BAR" for a > target

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Sven C. Dack
It's my understanding that we don't actually know what Benjamin wants to do, because nobody has asked. So I don't see how this would make me wrong. From his mail am I assuming he wants his Makefile to print "BAR" for a target "test-stem" as well as "subdir/test-stem", which is what he will

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Paul Smith
On Wed, 2017-08-02 at 20:03 +0100, Sven C. Dack wrote: > Hello, > > try it with the following rules: > > test-%: $(eval FOO = BAR) > test-%: > echo $(FOO) No, this doesn't do what the OP wants. The eval in the prerequisites of the pattern is expanded immediately so this is identical to

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Kyle Rose
On Wed, Aug 2, 2017 at 3:03 PM, Sven C. Dack wrote: > Hello, > > try it with the following rules: > > test-%: $(eval FOO = BAR) > test-%: > echo $(FOO) FOO is a global variable in this case. Not sure what you're trying to demonstrate here. Kyle

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Sven C. Dack
Hello, try it with the following rules: test-%: $(eval FOO = BAR) test-%: echo $(FOO) $ make test-stem echo BAR BAR $ make subdir/test-stem echo BAR BAR I cannot tell you why it fails in your example. My guess is that it's just not good practise to use a plain assignment for a

Re: Target-specific variable in subdirectory problem

2017-08-02 Thread Edward Welbourne
Benjamin Cama (2 August 2017 12:19) > I may be doing something wrong, but the following Makefile gives me > strange results: the target-specific variable does not apply when used > for a target in a subdirectory. > >test-%: FOO = BAR >test-%: >echo $(FOO) > > E.g.:

Target-specific variable in subdirectory problem

2017-08-02 Thread Benjamin Cama
Hi, I may be doing something wrong, but the following Makefile gives me strange results: the target-specific variable does not apply when used for a target in a subdirectory. test-%: FOO = BAR test-%: echo $(FOO) E.g.: $ make test-stem