[Top][All Lists]

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

Re: unable to use $ORIGIN in rpath

From: Paul Smith
Subject: Re: unable to use $ORIGIN in rpath
Date: Wed, 15 Aug 2007 00:36:06 -0400

On Wed, 2007-08-15 at 09:39 +0530, m c wrote:
> tried using $$$ but that too didnt work.
> TARGETNAME="" MAKETARGET="g++   -o ././
> -shared   -Wl,-Bsymbolic  -Wl,-rpath,'$RIGIN:
> $RIGIN/../lib:.:../lib'  ./obj/debug/sample.o    -ldl -lpthread -lgcc"
> \

Your setup is extremely complicated, but it boils down to a simple
escaping problem.  Escaping in make has an added twist because both make
and the shell (that make invokes to run commands) use "$" to introduce
variables, so you have to quote for both the shell and for make.

Here is what you have:


The := causes this to be evaluated immediately and (assuming RPATHFLAG
is not set) you get RPATHFLAG set to "$ORIGIN:$ORIGIN/../lib:"

Next you have this:

        dynamicdebug : MAKETARGET = ${OSCPP} ... 

Since this using "=", it's not evaluated here and the variable holds the
string as written.

Finally, you have this:

        dynamicdebug ... :
                ...  MAKETARGET="${MAKETARGET}" ... $(MAKE) -f 
                @echo "$@ version built."

Now make will evaluate this command script, which means expanding
${MAKETARGET} and hence $(RPATHFLAG).  However, since RPATHFLAG was
already expanded once (because of the :=) it's not expanded again, which
means that the command line make passes to the shell (assuming all the
other variables besides RPATHFLAG are empty and MAKE = make) is:

        MAKETARGET="$ORIGIN:$ORIGIN/../lib:" make -f

Now, the shell will take over and it will see that $ORIGIN is a valid
shell variable and the *shell* will expand it, to the empty string...
and there's your problem right there.

It's not clear what you WANT to happen, so I can't say how you should
fix it.  If you want the MAKETARGET variable to contain the "$ORIGIN"
reference as a literal string, you should use something like:

        dynamicdebug ... :
                        ...  MAKETARGET='${MAKETARGET}' ... $(MAKE) -f 
                        @echo "$@ version built."

Using single quotes around the variable means the shell won't expand it;
the command the shell sees is:

        MAKETARGET='$ORIGIN:$ORIGIN/../lib:' make -f

 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]