GnuLinker::Linker::Linker(GnuLinker &p, const string &ct):
SubTool(p),
compiler_tag(ct)
-{ }
+{
+ if(compiler_tag=="CC")
+ set_command("gcc", true);
+ else if(compiler_tag=="CXX")
+ set_command("g++", true);
+ else
+ throw invalid_argument("GnuLinker::Linker::Linker");
+}
Target *GnuLinker::Linker::create_target(const list<Target *> &sources, const string &arg)
{
compiler.prepare();
executable = compiler.get_executable();
}
- else
- {
- string command;
- if(compiler_tag=="CC")
- command = "gcc";
- else if(compiler_tag=="CXX")
- command = "g++";
- else
- throw invalid_argument("GnuLinker::Linker::Linker");
-
- set_executable(command, true);
- }
}
Task *GnuLinker::Linker::run(const Target &target) const
argv.push_back("-shared");
argv.push_back("-fPIC");
if(architecture->get_system()!="windows" && !shlib->get_soname().empty())
- argv.push_back("-Wl,-soname,"+shlib->get_soname());
+ {
+ if(architecture->get_system()=="darwin")
+ {
+ argv.push_back("-install_name");
+ argv.push_back(shlib->get_soname());
+
+ const string &ver = shlib->get_package()->get_version();
+ const string &if_ver = shlib->get_package()->get_interface_version();
+ if(!ver.empty() && !if_ver.empty())
+ {
+ argv.push_back("-current_version");
+ argv.push_back(ver);
+ argv.push_back("-compatibility_version");
+ argv.push_back(if_ver);
+ }
+ }
+ else
+ argv.push_back("-Wl,-soname,"+shlib->get_soname());
+ }
}
const BuildInfo &binfo = comp.get_build_info();
argv.push_back("-L"+i->str());
if(binfo.strip)
argv.push_back("-s");
- if(binfo.threads)
+ if(binfo.threads && architecture->get_system()!="windows" && architecture->get_system()!="darwin")
argv.push_back("-pthread");
const Architecture &native_arch = builder.get_native_arch();