You have to escape the quotes.  Your example above won't work always:
lt_prog_compiler_static may begin with `-n':
  lt_prog_compiler_static=-non-shared
`echo' may interpret `-n'.  Boom.  Prepending `echo's first argument
with a space fixes that.
Aha. Right you are.

Actually, you just need to escape the quotes, there's no need
to actually add a space. This shell script worked on all of
ksh, bourne shell (real one, not bash masquerading as one),
zsh and bash:

compiler_wl='-Wl,'
static='-n ${wl}-foo,bar ${wl}baz'
flags=`wl=$compiler_wl eval echo \"$static\"`
echo "$flags"

Not that the extra spacing matters, but I'm doing that pedantic
thing again :)

So getting back to an actual bit of libtool code, we could have:

sflag=`wl=$lt_prog_compiler_wl eval echo \"$lt_prog_compiler_static\"`
LDFLAGS="$LDFLAGS $sflag"

Again using a short variable for the sake of my mailer. In actual
code I'd use something like 'tmpstaticflag' to its obviously a
temporary variable.

Kean


Reply via email to