The attached patch adds the system dir (based on the executable's
path) to Option::SystemDirs if SystemDirs wasn't set explicitly
via --system.
e.g.
executable location: /usr/local/bin/bitcc
system dir: /usr/local
It should work on all glibc based systems and POSIX.1-2008 compliant
ones. On other *nix based systems and Windows/Vista the patch should
compile but doesn't change SystemDirs.
Thomas
--- bitc/src/compiler/bitcc.cxx 2008-11-16 06:55:03.000000000 +0100
+++ bitc-thomas/src/compiler/bitcc.cxx 2008-12-02 14:38:58.000000000 +0100
@@ -271,6 +271,29 @@
}
}
+/// @brief Add executable dependent Options::SystemDirs to support
+/// tar-ball installations.
+void
+AddInstallSystemDir()
+{
+#if defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE)
+ if (Options::SystemDirs.empty()) {
+ char * self = ::realpath("/proc/self/exe", NULL);
+ if (self) {
+ filesystem::path p = self;
+ p = p.branch_path();
+ if (exists(p)) {
+ p = p.branch_path();
+ if (exists(p)) {
+ Options::SystemDirs.push_back(p);
+ }
+ }
+ ::free(self);
+ }
+ }
+#endif
+}
+
/// @brief Add an argument to be passed to the compiler before or
/// after the generated BitC C file.
void
@@ -714,6 +737,9 @@
if (Options::backEnd == 0)
Options::backEnd = &BackEnd::backends[0];
+ // support tar-ball installations
+ AddInstallSystemDir();
+
for (size_t i = 0; i < Options::SystemDirs.size(); i++) {
filesystem::path incPath = Options::SystemDirs[i] / "include";
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev