aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-02-15 10:12:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-02-15 10:12:03 +0200
commitafae6bdd843687b8fa6fe7e619532696389cfc0d (patch)
tree8f5e84293ecd3e76eac8715915e2727f26805a5a
parent9c74a58db7cdb86d6d5a4600accd8ba9df3e1bbe (diff)
Check for /usr/local/include in addition to /usr/include
Specifically, Apple Clang does not have /usr/include (it has its equivalent in /Applications/.../XcodeDefault.xctoolchain/usr/include/) but does have /usr/local/include.
-rw-r--r--build2/cc/module.cxx15
1 files changed, 9 insertions, 6 deletions
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx
index 92b17b7..78e2e0f 100644
--- a/build2/cc/module.cxx
+++ b/build2/cc/module.cxx
@@ -321,7 +321,7 @@ namespace build2
// it's possible the compiler uses some carefully crafted sysroot and by
// adding /usr/local/* we will just mess things up. So the heuristics
// that we will use is this: if the compiler's system include directories
- // contain /usr/include then we add /usr/local/*.
+ // contain /usr[/local]/include then we add /usr/local/*.
//
// Note that similar to GCC we also check for the directory existence.
// Failed that, we can end up with some bizarre yo-yo'ing cases where
@@ -332,21 +332,24 @@ namespace build2
auto& is (inc_dirs);
auto& ls (lib_dirs);
- if (find (is.begin (), is.end (), usr_inc) != is.end ())
+ bool ui (find (is.begin (), is.end (), usr_inc) != is.end ());
+ bool uli (find (is.begin (), is.end (), usr_loc_inc) != is.end ());
+
+ if (ui || uli)
{
+ bool ull (find (ls.begin (), ls.end (), usr_loc_lib) != ls.end ());
+
// Many platforms don't search in /usr/local/lib by default (but do
// for headers in /usr/local/include). So add it as the last option.
//
- if (find (ls.begin (), ls.end (), usr_loc_lib) == ls.end () &&
- exists (usr_loc_lib, true /* ignore_error */))
+ if (!ull && exists (usr_loc_lib, true /* ignore_error */))
ls.push_back (usr_loc_lib);
// FreeBSD is at least consistent: it searches in neither. Quoting
// its wiki: "FreeBSD can't even find libraries that it installed."
// So let's help it a bit.
//
- if (find (is.begin (), is.end (), usr_loc_inc) == is.end () &&
- exists (usr_loc_inc, true /* ignore_error */))
+ if (!uli && exists (usr_loc_inc, true /* ignore_error */))
is.push_back (usr_loc_inc);
}
}