From 3f838e0f8f7fb2ecda613f92de118a4d0b54ef89 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 11 Feb 2010 07:55:17 +0000 Subject: [PATCH] Use ${prefix} in .pc files --- source/pkgconfigaction.cpp | 16 ++++++++++++---- source/pkgconfigaction.h | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/source/pkgconfigaction.cpp b/source/pkgconfigaction.cpp index d0209fa..6e2ae1f 100644 --- a/source/pkgconfigaction.cpp +++ b/source/pkgconfigaction.cpp @@ -8,6 +8,7 @@ Distributed under the LGPL #include #include #include +#include "builder.h" #include "package.h" #include "pkgconfig.h" #include "pkgconfigaction.h" @@ -23,8 +24,7 @@ PkgConfigAction::PkgConfigAction(Builder &b, const PkgConfig &p): 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()); @@ -41,7 +41,7 @@ PkgConfigAction::PkgConfigAction(Builder &b, const PkgConfig &p): 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) @@ -50,7 +50,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) @@ -63,3 +63,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; +} diff --git a/source/pkgconfigaction.h b/source/pkgconfigaction.h index 7c725bc..a19f786 100644 --- a/source/pkgconfigaction.h +++ b/source/pkgconfigaction.h @@ -21,6 +21,8 @@ class PkgConfigAction: public Action public: PkgConfigAction(Builder &, const PkgConfig &); virtual int check(); +private: + std::string prefixify(const std::string &); }; #endif -- 2.45.2