1 #include <msp/fs/utils.h>
2 #include <msp/strings/format.h>
5 #include "sharedlibrary.h"
6 #include "sourcepackage.h"
11 SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p):
14 libname = FS::basepart(FS::basename(path));
15 if(!libname.compare(0, 3, "lib"))
16 libname = libname.substr(3);
19 SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
20 Binary(b, c, generate_filename(c), objs),
23 install_location = "lib";
24 if(component->get_type()==Component::MODULE)
26 install_location += '/';
27 install_location += package->get_name();
30 const string &version = component->get_package().get_version();
33 string::size_type i = 0;
34 for(unsigned dots=0; i<version.size(); ++i)
35 if(version[i]=='.' && ++dots>=2)
38 soname = format("%s.%s", FS::basename(path), version.substr(0, i));
42 string SharedLibrary::generate_filename(const Component &comp)
44 if(comp.get_type()==Component::MODULE)
45 return comp.get_name()+".m";
48 const Architecture &arch = comp.get_package().get_builder().get_current_arch();
49 return arch.get_shared_library_patterns().front().apply(comp.get_name());