aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/c/init.cxx6
-rw-r--r--libbuild2/cc/common.hxx3
-rw-r--r--libbuild2/cc/init.cxx7
-rw-r--r--libbuild2/cc/pkgconfig.cxx47
-rw-r--r--libbuild2/cxx/init.cxx6
5 files changed, 58 insertions, 11 deletions
diff --git a/libbuild2/c/init.cxx b/libbuild2/c/init.cxx
index be001a8..6725ca7 100644
--- a/libbuild2/c/init.cxx
+++ b/libbuild2/c/init.cxx
@@ -225,6 +225,9 @@ namespace build2
vp["cc.export.libs"],
vp["cc.export.impl_libs"],
+ vp["cc.pkconfig.include"],
+ vp["cc.pkconfig.lib"],
+
vp.insert_alias (vp["cc.stdlib"], "c.stdlib"), // Same as cc.stdlib.
vp["cc.runtime"],
@@ -276,6 +279,9 @@ namespace build2
vp.insert_alias (d.c_runtime, "c.runtime");
vp.insert_alias (d.c_importable, "c.importable");
+ vp.insert_alias (d.c_pkgconfig_include, "c.pkgconfig.include");
+ vp.insert_alias (d.c_pkgconfig_lib, "c.pkgconfig.lib");
+
auto& m (extra.set_module (new config_module (move (d))));
m.guess (rs, loc, extra.hints);
diff --git a/libbuild2/cc/common.hxx b/libbuild2/cc/common.hxx
index 78442f8..81cebda 100644
--- a/libbuild2/cc/common.hxx
+++ b/libbuild2/cc/common.hxx
@@ -102,6 +102,9 @@ namespace build2
const variable& c_export_libs;
const variable& c_export_impl_libs;
+ const variable& c_pkgconfig_include;
+ const variable& c_pkgconfig_lib;
+
const variable& x_stdlib; // x.stdlib
const variable& c_runtime; // cc.runtime
diff --git a/libbuild2/cc/init.cxx b/libbuild2/cc/init.cxx
index affc4ab..5c15835 100644
--- a/libbuild2/cc/init.cxx
+++ b/libbuild2/cc/init.cxx
@@ -113,6 +113,13 @@ namespace build2
vp.insert<vector<name>> ("cc.export.libs");
vp.insert<vector<name>> ("cc.export.impl_libs");
+ // Header (-I) and library (-L) search paths to use in the generated .pc
+ // files instead of the default install.{include,lib}. Relative paths
+ // are resolved as install paths.
+ //
+ vp.insert<dir_paths> ("cc.pkconfig.include");
+ vp.insert<dir_paths> ("cc.pkconfig.lib");
+
// Hint variables (not overridable).
//
vp.insert<string> ("config.cc.id", false);
diff --git a/libbuild2/cc/pkgconfig.cxx b/libbuild2/cc/pkgconfig.cxx
index 29d9155..d4ceb88 100644
--- a/libbuild2/cc/pkgconfig.cxx
+++ b/libbuild2/cc/pkgconfig.cxx
@@ -1507,20 +1507,46 @@ namespace build2
// install without actual install and remove the file if it exists.
//
// @@ Shouldn't we use target's install value rather than install.lib
- // in case it gets installed into a custom location?
+ // in case it gets installed into a custom location? I suppose one
+ // can now use cc.pkgconfig.lib to customize this.
//
using install::resolve_dir;
- dir_path ldir (resolve_dir (g,
- cast<dir_path> (g["install.lib"]),
- false /* fail_unknown */));
- if (ldir.empty ())
+ small_vector<dir_path, 1> ldirs;
+
+ if (const dir_paths* ds = cast_null<dir_paths> (g[c_pkgconfig_lib]))
+ {
+ for (const dir_path& d: *ds)
+ {
+ bool f (ldirs.empty ());
+
+ ldirs.push_back (resolve_dir (g, d, !f /* fail_unknown */));
+
+ if (f && ldirs.back ().empty ())
+ break;
+ }
+ }
+ else
+ ldirs.push_back (resolve_dir (g,
+ cast<dir_path> (g["install.lib"]),
+ false /* fail_unknown */));
+
+ if (!ldirs.empty () && ldirs.front ().empty ())
{
rmfile (ctx, p, 3 /* verbosity */);
return;
}
- dir_path idir (resolve_dir (g, cast<dir_path> (g["install.include"])));
+ small_vector<dir_path, 1> idirs;
+
+ if (const dir_paths* ds = cast_null<dir_paths> (g[c_pkgconfig_include]))
+ {
+ for (const dir_path& d: *ds)
+ idirs.push_back (resolve_dir (g, d));
+ }
+ else
+ idirs.push_back (resolve_dir (g,
+ cast<dir_path> (g["install.include"])));
// Note that generation can take some time if we have a large number of
// prerequisite libraries.
@@ -1666,13 +1692,11 @@ namespace build2
return n;
};
- // @@ TODO: support whole archive?
- //
-
// Cflags.
//
os << "Cflags:";
- os << " -I" << escape (idir.string ());
+ for (const dir_path& d: idirs)
+ os << " -I" << escape (d.string ());
save_poptions (x_export_poptions);
save_poptions (c_export_poptions);
os << endl;
@@ -1691,7 +1715,8 @@ namespace build2
// While we don't need it for a binless library itselt, it may be
// necessary to resolve its binful dependencies.
//
- os << " -L" << escape (ldir.string ());
+ for (const dir_path& d: ldirs)
+ os << " -L" << escape (d.string ());
// Now process ourselves as if we were being linked to something (so
// pretty similar to link_rule::append_libraries()). We also reuse
diff --git a/libbuild2/cxx/init.cxx b/libbuild2/cxx/init.cxx
index cd5169d..106668a 100644
--- a/libbuild2/cxx/init.cxx
+++ b/libbuild2/cxx/init.cxx
@@ -668,6 +668,9 @@ namespace build2
vp["cc.export.libs"],
vp["cc.export.impl_libs"],
+ vp["cc.pkconfig.include"],
+ vp["cc.pkconfig.lib"],
+
vp.insert<string> ("cxx.stdlib"),
vp["cc.runtime"],
@@ -733,6 +736,9 @@ namespace build2
vp.insert_alias (d.c_module_name, "cxx.module_name");
vp.insert_alias (d.c_importable, "cxx.importable");
+ vp.insert_alias (d.c_pkgconfig_include, "cxx.pkgconfig.include");
+ vp.insert_alias (d.c_pkgconfig_lib, "cxx.pkgconfig.lib");
+
auto& m (extra.set_module (new config_module (move (d))));
m.guess (rs, loc, extra.hints);