help-make
[Top][All Lists]
Advanced

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

Re: How to get the current directory name


From: Paul D. Smith
Subject: Re: How to get the current directory name
Date: Thu, 5 Apr 2001 13:49:43 -0400

%% Eric Venditti <address@hidden> writes:

  ev> MYTARGET = $(shell pwd | awk -F'/' '{print $NF}' )

You have to escape the variable intro char here, just like in command
scripts, if you want it to go to the shell.  Make is expanding the
make variable "$N" here.  Use:

  MYTARGET = $(shell pwd | awk -F'/' '{print $$NF}' )
                                             ^^

However, you don't want that.  You at least should use ":=":

  MYTARGET := $(shell pwd | awk -F'/' '{print $$NF}' )

so that the subshell is only run once.

And, you don't even need a subshell, why not just use:

  MYTARGET := $(notdir $(CURDIR))

This requires GNU make 3.77 or better (the current best version is
3.79.1).

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "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]