diff options
author | Josh Blum <josh@joshknows.com> | 2016-10-09 17:32:04 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2016-11-04 12:38:32 -0500 |
commit | 1c129248e62f00f8e7a3cf2db2a309415441729d (patch) | |
tree | 8c726b47f7bd17e0319b47c9fdbfd1527c9b4889 | |
parent | 3fc55073f28ec97036dfe3f5ff9d9a7491f3ea80 (diff) |
runtime: support dynamically located gnuradio installs
Support a "GR_PREFIX" env var to overload prefix() with.
When this env var is specified, sysconfdir() and prefsdir()
also changes to reflect this using the same directory logic
specified in the top level CMakeLists.txt
-rw-r--r-- | gnuradio-runtime/lib/constants.cc.in | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gnuradio-runtime/lib/constants.cc.in b/gnuradio-runtime/lib/constants.cc.in index 516e2f8798..b368e9dc3f 100644 --- a/gnuradio-runtime/lib/constants.cc.in +++ b/gnuradio-runtime/lib/constants.cc.in @@ -24,6 +24,7 @@ #include <config.h> #endif +#include <stdlib.h> #include <gnuradio/constants.h> namespace gr { @@ -31,18 +32,36 @@ namespace gr { const std::string prefix() { + //Use "GR_PREFIX" environment variable when specified + const char *prefix = getenv("GR_PREFIX"); + if (prefix != NULL) return prefix; + return "@prefix@"; } const std::string sysconfdir() { + //Provide the sysconfdir in terms of prefix() + //when the "GR_PREFIX" environment var is specified. + if (getenv("GR_PREFIX") != NULL) + { + return prefix() + "/@GR_CONF_DIR@"; + } + return "@SYSCONFDIR@"; } const std::string prefsdir() { + //Provide the prefsdir in terms of sysconfdir() + //when the "GR_PREFIX" environment var is specified. + if (getenv("GR_PREFIX") != NULL) + { + return sysconfdir() + "/@CMAKE_PROJECT_NAME@/conf.d"; + } + return "@GR_PREFSDIR@"; } |