]> git.tdb.fi Git - builder.git/blobdiff - source/gnulinker.cpp
Redesign the library mode system
[builder.git] / source / gnulinker.cpp
index 13352870299778b8ba205092e3e742ed008be813..070bdcef745581b333947408248c6dfd184c5610 100644 (file)
@@ -121,8 +121,6 @@ Task *GnuLinker::Linker::run(const Target &target) const
                if(!shlib->get_soname().empty())
                        argv.push_back("-Wl,-soname,"+shlib->get_soname());
        }
-       else if(comp.get_package().get_library_mode()==ALL_STATIC)
-               argv.push_back("-static");
 
        const BuildInfo &binfo = comp.get_build_info();
        for(BuildInfo::PathList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i)
@@ -141,6 +139,8 @@ Task *GnuLinker::Linker::run(const Target &target) const
        argv.push_back("-o");
        argv.push_back(relative(bin.get_path(), work_dir).str());
 
+       bool static_link_ok = (comp.get_package().get_library_mode()<=STATIC);
+
        const Target::Dependencies &depends = target.get_depends();
        for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i)
        {
@@ -151,9 +151,15 @@ Task *GnuLinker::Linker::run(const Target &target) const
                else if(StaticLibrary *stlib = dynamic_cast<StaticLibrary *>(tgt))
                        argv.push_back(stlib->get_path().str());
                else if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(tgt))
+               {
                        argv.push_back("-l"+shlib->get_libname());
+                       static_link_ok = false;
+               }
        }
 
+       if(static_link_ok)
+               argv.push_back("-static");
+
        if(!builder.get_dry_run())
                FS::mkpath(FS::dirname(bin.get_path()), 0755);