diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-09 09:43:38 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-09 09:43:38 +0200 |
commit | 5f29fc16fb85a934280e00e54bc6307685c4e05d (patch) | |
tree | 4092c97dbeb8277ea8126209cb6bd936fdff442f /build | |
parent | 7c6333c365e8f36fff0f4d3957a56a50a11febc2 (diff) |
Add support for specifying additional rpath's
For example:
b config.bin.rpath=/usr/local/lib
Diffstat (limited to 'build')
-rw-r--r-- | build/bin/module.cxx | 44 | ||||
-rw-r--r-- | build/cxx/link.cxx | 13 |
2 files changed, 40 insertions, 17 deletions
diff --git a/build/bin/module.cxx b/build/bin/module.cxx index 0813433..e17463c 100644 --- a/build/bin/module.cxx +++ b/build/bin/module.cxx @@ -40,6 +40,25 @@ namespace build tracer trace ("bin::init"); level5 ([&]{trace << "for " << b.out_path ();}); + // Enter module variables. + // + if (first) + { + auto& v (var_pool); + + v.find ("config.bin.lib", string_type); + v.find ("config.bin.exe.lib", strings_type); + v.find ("config.bin.liba.lib", strings_type); + v.find ("config.bin.libso.lib", strings_type); + v.find ("config.bin.rpath", strings_type); //@@ VAR paths_type + + v.find ("bin.lib", string_type); + v.find ("bin.exe.lib", strings_type); + v.find ("bin.liba.lib", strings_type); + v.find ("bin.libso.lib", strings_type); + v.find ("bin.rpath", strings_type); //@@ VAR paths_type + } + // Register target types. // { @@ -79,23 +98,6 @@ namespace build r.insert<lib> (perform_install_id, "bin.lib", lib_); } - // Enter module variables. - // - if (first) - { - auto& v (var_pool); - - v.find ("config.bin.lib", string_type); - v.find ("config.bin.exe.lib", strings_type); - v.find ("config.bin.liba.lib", strings_type); - v.find ("config.bin.libso.lib", strings_type); - - v.find ("bin.lib", string_type); - v.find ("bin.exe.lib", strings_type); - v.find ("bin.liba.lib", strings_type); - v.find ("bin.libso.lib", strings_type); - } - // Configure. // using config::required; @@ -142,6 +144,14 @@ namespace build v = required (r, "config.bin.libso.lib", libso_lib).first; } + // config.bin.rpath + // + // This one is optional and we merge it into bin.rpath, if any. + // See the cxx module for details on merging. + // + if (const value& v = config::optional (r, "config.bin.rpath")) + b.assign ("bin.rpath") += as<strings> (v); + // Configure "installability" of our target types. // install::path<exe> (b, dir_path ("bin")); // Install into install.bin. diff --git a/build/cxx/link.cxx b/build/cxx/link.cxx index f489a0d..7d6b15e 100644 --- a/build/cxx/link.cxx +++ b/build/cxx/link.cxx @@ -746,6 +746,7 @@ namespace build scope& rs (t.root_scope ()); cstrings args; string storage1; + strings rpaths; if (lt == type::a) { @@ -767,6 +768,18 @@ namespace build args.push_back ("-o"); args.push_back (relt.string ().c_str ()); + if (auto l = t["bin.rpath"]) + { + const auto& ps (as<strings> (*l)); + rpaths.reserve (ps.size ()); // Make sure no reallocations. + + for (const string& p: ps) + { + rpaths.push_back ("-Wl,-rpath," + p); + args.push_back (rpaths.back ().c_str ()); + } + } + append_options (args, t, "cxx.loptions"); } |