[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to make symbolic links?
From: |
Philip Guenther |
Subject: |
Re: how to make symbolic links? |
Date: |
Wed, 7 Sep 2011 22:38:45 -0700 |
On Wed, Sep 7, 2011 at 9:02 PM, Mark Galeck (CW) <address@hidden> wrote:
> I am sorry if I have not explained myself properly, but I intend what I wrote.
>
> I want to have a link: dir/foobar, that links to dir1/foobar1, and I am in
> the directory that contains both dir and dir1
>
>>ln -s dir1/foobar1 dir/foobar
>
> works as expected.
No, it doesn't. You say you intend what you wrote, but what you wrote
indicated that either you don't understand symlinks, or you wrote a
nonsensical email to confuse everyone. I have no reason to believe
you are trying to confuse people, so I'll be charitable and assume you
just don't understand symlinks.
Consider the symlink created by this command:
ln -s dir1/foobar1 dir/foobar
Let's assume you run that from the directory /some/neat/path. That
command then creates a symlink at the path
/some/neat/path/dir/foobar
That symlink has the literal value "dir1/foobar1".
Now, for the important part: a symlink whose value is not an absolute
path is *ALWAYS* considered as relative to the directory *CONTAINING
THE SYMLINK*.
So, that symlink effectively "points to" the full path
/some/neat/path/dir/dir1/foobar1
and *NOT*
/some/neat/path/dir1/foobar1
So, if the intent of this makefile recipe:
> dir/foobar: dir1/foobar1
> ln -s $< $@
is to have the target "point to" its dependency, then the rule is *WRONG*.
There are two correct ways to write that rule. Here's the simple one,
that makes the symlink's value an absolute path:
dir/foobar: dir1/foobar1
ln -s ${CURDIR}/$< $@
Here's the complex one, that uses a relative path that walks "up and
over" instead:
dir/foobar: dir1/foobar1
# Assumes that $< is relative and that $@ contains just one
level of directories
ln -s ../$< $@
If you don't understand the comment in that rule, then you need to go
find a plain old book about UNIX that talks about symlinks and read
it. This has nothing to do with make and everything to do with how
symlinks operate in UNIX.
Philip Guenther
- how to make symbolic links?, Mark Galeck (CW), 2011/09/07
- Re: how to make symbolic links?, Paul Smith, 2011/09/07
- RE: how to make symbolic links?, Mark Galeck (CW), 2011/09/08
- Re: how to make symbolic links?, Philip Guenther, 2011/09/08
- RE: how to make symbolic links?, Mark Galeck (CW), 2011/09/08
- Re: how to make symbolic links?, Paul Smith, 2011/09/08
- Re: how to make symbolic links?, Mike Shal, 2011/09/08
- Re: how to make symbolic links?, Philip Guenther, 2011/09/08