[Top][All Lists]

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

Re: (should-be) simple directory parsing

From: Paul D. Smith
Subject: Re: (should-be) simple directory parsing
Date: Mon, 15 May 2006 21:24:03 -0400

%% "galathaea galathaea" <address@hidden> 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

  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.*$$,,")

(note in sed you can use any character as a delimiter, not just "/";
handy if your pattern contains "/" chars).

  gg> I suspect this is the easiest task in the world and every makefile
  gg> in the world that I failed to look at today has it right there in
  gg> plain view.  I suspect there is a one-liner that does this in some
  gg> obvious way, and I am just wasting time with obscure back-routes.

I don't know about that, but if it were me I'd probably use something
like this:

    dir := $(word 1,$(subst /TOP, ,$(CURDIR)))

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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