X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpkgconfigaction.cpp;h=33687ebb5251ea9465d4331d00578d6e7a522223;hb=dad4c41302de525a1456e9d5b738831487c8acac;hp=b21c6b74bde2e79664b19ae0836aa69953d451bf;hpb=66d1078c04849ec17a7343d0494d6ed087e04318;p=builder.git diff --git a/source/pkgconfigaction.cpp b/source/pkgconfigaction.cpp index b21c6b7..33687eb 100644 --- a/source/pkgconfigaction.cpp +++ b/source/pkgconfigaction.cpp @@ -1,14 +1,7 @@ -/* $Id$ - -This file is part of builder -Copyright © 2006-2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include #include #include #include +#include "builder.h" #include "package.h" #include "pkgconfig.h" #include "pkgconfigaction.h" @@ -19,13 +12,12 @@ using namespace Msp; PkgConfigAction::PkgConfigAction(Builder &b, const PkgConfig &p): Action(b) { - const SourcePackage &spkg=*static_cast(p.get_package()); + const SourcePackage &spkg = *static_cast(p.get_package()); - announce(spkg.get_name(), "PC", relative(p.get_path(), spkg.get_source()).str()); + 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()); @@ -33,16 +25,16 @@ PkgConfigAction::PkgConfigAction(Builder &b, const PkgConfig &p): IO::print(out, "Version: %s\n", spkg.get_version()); IO::print(out, "Requires:"); - const PackageList &reqs=spkg.get_requires(); + const PackageList &reqs = spkg.get_requires(); for(PackageList::const_iterator i=reqs.begin(); i!=reqs.end(); ++i) if((*i)->get_use_pkgconfig()) IO::print(out, " %s", (*i)->get_name()); out.put('\n'); - const BuildInfo &binfo=spkg.get_exported_binfo(); + 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) @@ -51,7 +43,7 @@ PkgConfigAction::PkgConfigAction(Builder &b, const PkgConfig &p): 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) @@ -64,3 +56,11 @@ int PkgConfigAction::check() 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; +}