]> git.tdb.fi Git - builder.git/blobdiff - source/gnulinker.cpp
Add target and tools for compiling Objective-C sources
[builder.git] / source / gnulinker.cpp
index b2df14cbc9c90e7bff446411654ebf1ce445c7de..b2516d6394eab3ddec5733d10347e0d43923e721 100644 (file)
@@ -212,6 +212,7 @@ Task *GnuLinker::Linker::run(const Target &target) const
        argv.push_back(relative(bin.get_path(), work_dir).str());
 
        bool static_link_ok = (binfo.libmode<=BuildInfo::STATIC);
+       bool need_l_objc = false;
 
        const Target::Dependencies &depends = target.get_dependencies();
        for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i)
@@ -220,7 +221,13 @@ Task *GnuLinker::Linker::run(const Target &target) const
                Target *tgt = (*i)->get_real_target();
 
                if(ObjectFile *obj = dynamic_cast<ObjectFile *>(tgt))
+               {
                        argv.push_back(relative(obj->get_path(), work_dir).str());
+                       /* XXX This is a hack.  A more generic way is needed for tools to pass
+                       information down the chain. */
+                       if(obj->get_tool()->get_tag()=="OBJC")
+                               need_l_objc = true;
+               }
                else if(StaticLibrary *stlib = dynamic_cast<StaticLibrary *>(tgt))
                        argv.push_back((file?file:stlib)->get_path().str());
                else if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(tgt))
@@ -239,6 +246,8 @@ Task *GnuLinker::Linker::run(const Target &target) const
                }
        }
 
+       if(need_l_objc)
+               argv.push_back("-lobjc");
        if(static_link_ok)
                argv.push_back("-static");
        else if(architecture->get_system()=="windows")