help-make
[Top][All Lists]
Advanced

[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 02:26:18 -0400

On Wed, 2007-08-15 at 11:16 +0530, m c wrote:
> tried but it didnt work

> MAKETARGET='g++   -o ././libSampleSoD.so -shared   -Wl,-Bsymbolic  
> -Wl,-rpath,$ORIGIN:$ORIGIN/../lib:.:../lib  ./obj/debug/sample.o    -ldl 
> -lpthread -lgcc'

> g++   -o ././libSampleSoD.so -shared    -Wl,-Bsymbolic  
> -Wl,-rpath,RIGIN:RIGIN/../lib:.:../lib  ./obj/debug/sample.o    -ldl 
> -lpthread -lgcc

Well, now MAKETARGET is being set properly.

The next problem is that in Make.mk, that variable is recursive (all
variables taken from the environment are recursive) and so it's expanded
by make before being passed to the shell:


> # allows high level make to set dependencies based on target
> ${BUILDDIR}/${TARGETNAME}:    ${OBJS}
>       ${MAKETARGET}

Here when ${MAKETARGET} is expanded, the $ORIGIN value in it will be
interpreted by make as an expansion of the variable $O (which is empty)
followed by the string 'RIGIN', which is exactly what you see.

In order to fix THIS you'll have to add an extra level of escaping to
$ORIGIN, so it survives the second expansion.  Note though!  This means
you cannot use this variable directly in Makefile; it will only work in
the sub-makes:

        RPATHFLAG := $$$$ORIGIN:$$$$ORIGIN/../lib:$(RPATHFLAG)

Now the first expansion will leave RPATHFLAG set to '$$ORIGIN:
$$ORIGIN/../lib:' which will be preserved by the sub-make invocation,
then will be expanded to '$ORIGIN:$ORIGIN/../lib:' when the sub-make
runs the command.

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