#include <msp/fs/utils.h>
#include <msp/io/file.h>
#include <msp/io/print.h>
+#include "builder.h"
#include "package.h"
#include "pkgconfig.h"
#include "pkgconfigaction.h"
announce(spkg.get_name(), "PC", basename(p.get_path()));
IO::BufferedFile out(p.get_path().str(), IO::M_WRITE);
- // Prefix is already included in the various paths
- //IO::print(out, "prefix=%s\n", pkg.get_prefix());
+ IO::print(out, "prefix=%s\n", builder.get_prefix().str());
IO::print(out, "source=%s\n\n", spkg.get_source());
IO::print(out, "Name: %s\n", spkg.get_name());
const BuildInfo &binfo = spkg.get_exported_binfo();
IO::print(out, "Libs:");
for(StringList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i)
- IO::print(out, " -L%s", *i);
+ IO::print(out, " -L%s", prefixify(*i));
for(StringList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i)
IO::print(out, " -l%s", *i);
for(StringList::const_iterator i=binfo.ldflags.begin(); i!=binfo.ldflags.end(); ++i)
IO::print(out, "Cflags:");
for(StringList::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i)
- IO::print(out, " -I%s", *i);
+ IO::print(out, " -I%s", prefixify(*i));
for(StringList::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
IO::print(out, " -D%s", *i);
for(StringList::const_iterator i=binfo.cflags.begin(); i!=binfo.cflags.end(); ++i)
signal_done.emit();
return 0;
}
+
+string PkgConfigAction::prefixify(const std::string &path)
+{
+ const string &prefix = builder.get_prefix().str();
+ if(!path.compare(0, prefix.size(), prefix))
+ return "${prefix}"+path.substr(prefix.size());
+ return path;
+}