const BuildInfo &binfo = spkg.get_exported_build_info();
IO::print(out, "Libs:");
for(BuildInfo::PathList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i)
- IO::print(out, " -L%s", FS::relative(*i, builder.get_prefix()).str());
+ IO::print(out, " -L%s", prefixify(*i, builder.get_prefix()));
for(BuildInfo::WordList::const_iterator i=binfo.libs.begin(); i!=binfo.libs.end(); ++i)
IO::print(out, " -l%s", *i);
if(binfo.threads)
IO::print(out, "Cflags:");
for(BuildInfo::PathList::const_iterator i=binfo.incpath.begin(); i!=binfo.incpath.end(); ++i)
- IO::print(out, " -I%s", FS::relative(*i, builder.get_prefix()).str());
+ IO::print(out, " -I%s", prefixify(*i, builder.get_prefix()));
for(BuildInfo::DefineMap::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i)
if(i->second.empty())
IO::print(out, " -D%s", i->first);
status = Task::SUCCESS;
}
+
+string PkgConfigGenerator::Worker::prefixify(const FS::Path &path, const FS::Path &prefix)
+{
+ if(FS::descendant_depth(path, prefix)>=0)
+ {
+ FS::Path rel_path = FS::relative(path, prefix);
+ return "${prefix}"+rel_path.str().substr(1);
+ }
+ else
+ return path.str();
+}