+#include <msp/path/utils.h>
+#include "archive.h"
+#include "builder.h"
+#include "component.h"
+#include "objectfile.h"
+#include "package.h"
+#include "staticlibrary.h"
+
+using namespace std;
+using namespace Msp;
+
+Archive::Archive(Builder &b, const StaticLibrary &lib):
+ ExternalAction(b)
+{
+ const Component &comp=lib.get_component();
+
+ argv.push_back("ar");
+ argv.push_back("rc");
+
+ argv.push_back(lib.get_name());
+ const list<Target *> &deps=lib.get_depends();
+ for(list<Target *>::const_iterator i=deps.begin(); i!=deps.end(); ++i)
+ if(dynamic_cast<ObjectFile *>(*i))
+ argv.push_back((*i)->get_name());
+
+ Path::Path lpath=lib.get_name();
+ if(!builder.get_dry_run())
+ Path::mkpath(lpath.subpath(0, lpath.size()-1), 0755);
+
+ announce(comp.get_package().get_name(), "AR ", relative(lpath, comp.get_package().get_source()).str());
+
+ launch();
+}