Paul D. Smith wrote:
%% "galathaea" writes:
gg> Recursive variable `TEST10' references itself (eventually).
gg> which, of course, was the point. I found that my test code had
gg> been using an experimental make version "3.81rc" which I had
gg> installed on to my test machine from a different project. The
gg> version that fails (and that I need working code for) is 3.79.1.
The ability to use recursive functions with "call" was added in 3.80 I
I could more easily convince the powers that be to upgrade to 3.80 than 3.81, so that is good news. Although not necessary for this problem now, I could easily contrive examples where this never-before-used feature would be essential to the continuing health of my company's business! =)
gg> I can do this in shell scripting really easily:
gg> pwd | sed -e "s/\/TOP.*$//"
gg> but when I try a naive translation to makefilese:
gg> $(shell pwd | sed -e "s/\/TOP.*$//")
gg> I get nothing. I obviously do not understand how to get pipes
gg> working in shell calls in makefiles, but I've tried a couple of
gg> different ways using quotes and \" escaping the sed command
gg> quotes, all without luck.
Your problem doesn't have anything to do with _SHELL_ quoting and
everything to do with _MAKE_ quoting.
As with any other string evaluated by make, any time you want a literal
dollar sign ($) to appear you have to escape it as two dollar signs
($$). So you want:
dir := $(shell pwd | sed -e "s,/TOP.*$$,,")
revised pds> dir := $(shell pwd | sed -e 's,/TOP.*,,')
(note in sed you can use any character as a delimiter, not just "/";
handy if your pattern contains "/" chars).
Thank you! I had convinced myself that it was the piping, when all along it was variable reference expansion... I knew there was stupidity here, but was too stupid to identify where it was occuring.
Just as a side note, I came up with another method that works. It is probably the ugliest hack one could apply to the problem, but it was the first that I could get working on the correct make version.
and performed the calculation in three steps:
1) exchange directory separators for spaces (so now we have a list!)
2) for each item in the list:
2a) add it to a calculation list
2b) if the current element is the name I am looking for, store a final copy of the calculation list
3) substitute the directory separators back in for spaces (and an extra one up front)
Its a very imperative algorithm that I did not like, but at least got me past the hurdle.
I will use the more succinct and maintainable shell call, though, which is what I had wanted in the first place. Thank you Paul for your help!
galathaea: prankster, fablist, magician, liar