List Info

Thread: how to get a directory's "full" name?




how to get a directory's "full" name?
user name
2006-05-12 17:10:17
  as part of my multi-arch build, i need to convert a
(probably)
relative directory name to its full name.  that is, if
someone refers
to "..", i need to get the full directory name
of ".."

  this "function" seems to work:

real-dir = $(shell cd $ ; echo $$)

cd to arg, then echo full dir name.  is there a simpler or
built-in
way that's better?

rday


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
how to get a directory's "full" name?
user name
2006-05-12 17:16:26
> cd to arg, then echo full dir name.  is there a simpler
or built-in
> way that's better?

the unix command dirname gives the directory name
see also basename for getting file name in a similar manner

-aditya


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
how to get a directory's "full" name?
user name
2006-05-12 17:18:31
%% "Aditya Kher" <aditya.khergmail.com> writes:

  >> cd to arg, then echo full dir name.  is there a
simpler or built-in
  >> way that's better?

  ak> the unix command dirname gives the directory name
  ak> see also basename for getting file name in a
similar manner

dirname and basename are simply string munchers: they break
up strings
on "/" etc.  They do NOT evaluate their
arguments to find
fully-qualified pathnames.

In addition, the make functions $(dir ...), $(notdir ...),
$(basename ...),
etc. are much better/faster for this kind of thing, as long
as you don't
need to work on a shell variable.

-- 
------------------------------------------------------------
-------------------
 Paul D. Smith <psmithgnu.org>          Find
some GNU make tips at:
 http://www.gnu.org        
             http://make.paulandlesl
ey.org
 "Please remain calm...I may be mad, but I am a
professional." --Mad Scientist


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
how to get a directory's "full" name?
user name
2006-05-12 17:16:49
%% "Robert P. J. Day" <rpjdaymindspring.com> writes:

  rpjd> as part of my multi-arch build, i need to convert
a (probably)
  rpjd> relative directory name to its full name.  that
is, if someone
  rpjd> refers to "..", i need to get the
full directory name of ".."

  rpjd> this "function" seems to work:

  rpjd> real-dir = $(shell cd $ ; echo $$)

This is not portable; not all shells set or track the PWD
environment
variable.

  rpjd> cd to arg, then echo full dir name.  is there a
simpler or built-in
  rpjd> way that's better?

If you're willing to limit your makefiles to newer versions
of make you
can use the $(abspath ...) or $(abspath ...) functions.

-- 
------------------------------------------------------------
-------------------
 Paul D. Smith <psmithgnu.org>          Find
some GNU make tips at:
 http://www.gnu.org        
             http://make.paulandlesl
ey.org
 "Please remain calm...I may be mad, but I am a
professional." --Mad Scientist


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )