]> git.tdb.fi Git - builder.git/commitdiff
Use ${prefix} in .pc files
authorMikko Rasa <tdb@tdb.fi>
Thu, 11 Feb 2010 07:55:17 +0000 (07:55 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 11 Feb 2010 07:55:17 +0000 (07:55 +0000)
source/pkgconfigaction.cpp
source/pkgconfigaction.h

index d0209fa1e33d452d0817323b644c704c4c4fa0e7..6e2ae1facf222c68393b89e2bc03b90779ef92fd 100644 (file)
@@ -8,6 +8,7 @@ Distributed under the LGPL
 #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"
@@ -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;
+}
index 7c725bc665ad808bc179fdd8b3d208160af4d3cd..a19f78662a6b5107a2e98691b97cbc22a51032e1 100644 (file)
@@ -21,6 +21,8 @@ class PkgConfigAction: public Action
 public:
        PkgConfigAction(Builder &, const PkgConfig &);
        virtual int check();
+private:
+       std::string prefixify(const std::string &);
 };
 
 #endif