On 2014年12月22日 23:37, xunxun wrote:
> On 2014/12/22 22:09, Andreas Mattheiss wrote:
>> Hi,
>>
>> Am Mon, 22 Dec 2014 22:00:23 +0800 schrieb xunxun:
>>
>>
>>> You can try
>>>
>>> LDFLAGS += -lrt ../configure ...
>> I'm not quite with you, this appears not to be a shell command, right?
>> Where would the LDFLAGS += -lrt go?
>>
>> Andreas
>>
> No space
> 
> LDFLAGS+=-lrt ../configure
> 
>

This looks a little suspicious.

First of all, does xunxun's environment or Andreas's define LDFLAGS
already? That is, is there an LDFLAGS variable in the environment?

Mine does not. As a matter of fact
env | grep LD
printed out only
LD_LIBRARY_PATH=:/usr/local/lib

So probably without using "+=", a simple assignment to LDFALGS=-rt may be
enough.

But *if* there is already LDFLAGS, which I don't think Ubunto or
slackware defines usually, then there is a subtle behavioral issue.

Unlike what |make| does to its variables when it sees += (see the example at
the end),
shell treats the string addition WITHOUT any whitespace and
So if the existing LDFLAGS is, say, "-lm", then
-lrt is concatenated as "-lm-lrt" which is not desirable.
So you might as well write this carefully and
LDFLAGS="$LDFLAGS -lrt" ...
instead *if and only if* LDFLAGS is already defined.

I thought EXPLICIT exporting is required, but
no, LDFLAGS is exported only to the executed configure command .
LDFLAGS="..." ./configure
Neat.
cf. "If no command name results, variable assignments shall affect the
current execution environment. Otherwise, the variable assignments shall be
exported for the execution environment of the command and shall not affect
the current execution environment (except for special built-ins). If any of
the variable assignments attempt to assign a value to a read-only variable,
a variable assignment error shall occur. See Consequences of Shell Errors
for the consequences of these errors."
from posix shell description:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01
(See the paragraph in 2.9.1 Simple Commands)


[1] make's variable handling when it sees +=
Here is an example. Note how var1 and var2 are added by +=.

--- begin quote Makefile ---
var1=abc
var2=def
var1+=${var2}

all:
        echo ${var1}
--- end quote
--- running make produces the output: note the whitespace.
make -k
echo abc def
abc def


PS: BTW, I was surprised to find that with bash, the following occurred.
$ PARAM=abc echo ${PARAM}

$
It seems substitution is done before "PARAM=abc" is evaluated, and come to
think of it,
it is natural and to be expected. So we can write LDFLAGS="$LDFLAGS -lrt"
./configure
if LDFLAGS is defined already.

_______________________________________________
dev-builds mailing list
dev-builds@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-builds

Reply via email to