1 #include <msp/path/utils.h>
4 #include "executable.h"
6 #include "objectfile.h"
12 Link::Link(Builder &b, const Executable &exe):
15 const Component &comp=exe.get_component();
17 argv.push_back("g++");
19 if(comp.get_type()==Component::LIBRARY)
20 argv.push_back("-shared");
22 const BuildInfo &binfo=comp.get_build_info();
23 for(list<string>::const_iterator i=binfo.ldflags.begin(); i!=binfo.ldflags.end(); ++i)
25 for(list<string>::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i)
26 argv.push_back("-L"+*i);
27 for(list<string>::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i)
28 argv.push_back("-l"+*i);
31 argv.push_back(exe.get_name());
32 const list<Target *> &deps=exe.get_depends();
33 for(list<Target *>::const_iterator i=deps.begin(); i!=deps.end(); ++i)
34 if(dynamic_cast<ObjectFile *>(*i))
35 argv.push_back((*i)->get_name());
37 Path::Path epath=exe.get_name();
38 if(!builder.get_dry_run())
39 Path::mkpath(epath.subpath(0, epath.size()-1), 0755);
41 announce(comp.get_package().get_name(), "LINK", relative(epath, comp.get_package().get_source()).str());