X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsharedlibrary.cpp;h=9b2fdbb1bd99b02bc3a99f877ec67779b4790c31;hb=0dea0d850f6690de07933794592916d11c9d3f49;hp=5c2d26fea27f799521c6697fc3803db959ea23f4;hpb=66d1078c04849ec17a7343d0494d6ed087e04318;p=builder.git diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index 5c2d26f..9b2fdbb 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -1,18 +1,48 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - +#include +#include +#include "builder.h" #include "component.h" #include "sharedlibrary.h" #include "sourcepackage.h" using namespace std; +using namespace Msp; + +SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p): + Binary(b, p) +{ + libname = FS::basepart(FS::basename(path)); + if(!libname.compare(0, 3, "lib")) + libname = libname.substr(3); +} SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list &objs): - FileTarget(b, &c.get_package(), generate_target_path(c)), - Binary(b, c, objs), - Library(b, &c.get_package(), path, c.get_name()) -{ } + Binary(b, c, generate_filename(c), objs), + libname(c.get_name()) +{ + install_location = "lib"; + if(component->get_type()==Component::MODULE) + install_location /= package->get_name(); + + const string &version = component->get_package().get_version(); + if(!version.empty()) + { + string::size_type i = 0; + for(unsigned dots=0; i=2) + break; + + soname = format("%s.%s", FS::basename(path), version.substr(0, i)); + } +} + +string SharedLibrary::generate_filename(const Component &comp) +{ + if(comp.get_type()==Component::MODULE) + return comp.get_name()+".m"; + else + { + const Architecture &arch = comp.get_package().get_builder().get_current_arch(); + return arch.get_shared_library_patterns().front().apply(comp.get_name()); + } +}