From 08ccaf109b1ccc4f0affb5a563fae839ea312b26 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Sun, 18 Aug 2019 22:48:18 +0200 Subject: [PATCH] scons: facilitate passing linker options with '$ORIGIN' Passing CUSTOM_LDFLAGS='-Wl,-rpath=$ORIGIN' to ./configure is unnecessarily difficult and error-prone. The option needs to be protected from SCons variable substitution by doubling the '$', and also from shell parameter expansion with a backslash. Such fortified value then cannot be used directly in contexts where either expansion does not happen. This commit makes that protection optional by injecting variable named ORIGIN, that resolves to '$ORIGIN', into both the SCons construction Environment and the process environment, so whenever '$ORIGIN' undergoes variable substitution, it is replaced by the original string. --- SConstruct | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SConstruct b/SConstruct index 5ace5f677..f5c1b9028 100644 --- a/SConstruct +++ b/SConstruct @@ -142,6 +142,8 @@ PLUGINS = { # plugins with external dependencies def init_environment(env): env.Decider('MD5-timestamp') env.SourceCode(".", None) + env['ORIGIN'] = Literal('$ORIGIN') + env['ENV']['ORIGIN'] = '$ORIGIN' if os.environ.get('RANLIB'): env['RANLIB'] = os.environ['RANLIB'] if os.environ.get('AR'):