summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-03-12 00:20:12 +0000
committerDavid Robillard <d@drobilla.net>2010-03-12 00:20:12 +0000
commit4204ee4da991e652f3142b5d90c37849052c9484 (patch)
tree26e94505b421f073da9416096dabd7545c3e1f05
parentceb650a78a837ae950b67066571e53e519d311ee (diff)
downloadlilv-4204ee4da991e652f3142b5d90c37849052c9484.tar.gz
lilv-4204ee4da991e652f3142b5d90c37849052c9484.tar.bz2
lilv-4204ee4da991e652f3142b5d90c37849052c9484.zip
Make default LV2_PATH a configure-time option (supporting ~ and glob expansion).
Use LIBDIRNAME in default LV2_PATH if none is given (e.g. use lib64 instead of lib if --libdir=/usr/lib64). Fix ticket #465. git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2544 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/world.c43
-rw-r--r--wscript15
2 files changed, 42 insertions, 16 deletions
diff --git a/src/world.c b/src/world.c
index 32ebd31..e057fd5 100644
--- a/src/world.c
+++ b/src/world.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <stdlib.h>
#include <dirent.h>
+#include <wordexp.h>
#include <string.h>
#include <librdf.h>
#include "slv2/types.h"
@@ -583,21 +584,33 @@ slv2_world_load_all(SLV2World world)
if (lv2_path) {
slv2_world_load_path(world, lv2_path);
} else {
- const char* const home = getenv("HOME");
- if (home) {
-#ifdef __APPLE__
- const char* const suffix = "/Library/Audio/Plug-Ins/LV2:/Library/Audio/Plug-Ins/LV2"
- ":/usr/local/lib/lv2:/usr/lib/lv2";
-#else
- const char* const suffix = "/.lv2:/usr/local/lib/lv2:/usr/lib/lv2";
-#endif
- lv2_path = slv2_strjoin(home, suffix, NULL);
- } else {
-#ifdef __APPLE__
- lv2_path = strdup("/Library/Audio/Plug-Ins/LV2:/usr/local/lib/lv2:/usr/lib/lv2");
-#else
- lv2_path = strdup("/usr/local/lib/lv2:/usr/lib/lv2");
-#endif
+ char default_path[sizeof(SLV2_DEFAULT_LV2_PATH)];
+ memcpy(default_path, SLV2_DEFAULT_LV2_PATH, sizeof(SLV2_DEFAULT_LV2_PATH));
+ char* dir = default_path;
+ size_t lv2_path_len = 0;
+ while (*dir != '\0') {
+ char* colon = strchr(dir, ':');
+ if (colon)
+ *colon = '\0';
+ wordexp_t p;
+ wordexp(dir, &p, 0);
+ for (unsigned i = 0; i < p.we_wordc; i++) {
+ const size_t word_len = strlen(p.we_wordv[i]);
+ if (!lv2_path) {
+ lv2_path = strdup(p.we_wordv[i]);
+ lv2_path_len = word_len;
+ } else {
+ lv2_path = (char*)realloc(lv2_path, lv2_path_len + word_len + 2);
+ *(lv2_path + lv2_path_len) = ':';
+ strcpy(lv2_path + lv2_path_len + 1, p.we_wordv[i]);
+ lv2_path_len += word_len + 1;
+ }
+ }
+ wordfree(&p);
+ if (colon)
+ dir = colon + 1;
+ else
+ *dir = '\0';
}
slv2_world_load_path(world, lv2_path);
diff --git a/wscript b/wscript
index 2835915..54111e3 100644
--- a/wscript
+++ b/wscript
@@ -49,6 +49,8 @@ def set_options(opt):
help="Build unit tests")
opt.add_option('--bash-completion', action='store_true', default=False, dest='bash_completion',
help="Install bash completion script in /etc/bash_completion.d")
+ opt.add_option('--default-lv2-path', type='string', default='', dest='default_lv2_path',
+ help="Default LV2 path to use if $LV2_PATH is unset (globs and ~ supported)")
def configure(conf):
autowaf.configure(conf)
@@ -61,16 +63,27 @@ def configure(conf):
conf.define('SLV2_VERSION', SLV2_VERSION)
if Options.options.dyn_manifest:
conf.define('SLV2_DYN_MANIFEST', 1)
- conf.write_config_header('slv2-config.h')
+
+ if Options.options.default_lv2_path == '':
+ if Options.platform == 'darwin':
+ Options.options.default_lv2_path = "~/Library/Audio/Plug-Ins/LV2:/Library/Audio/Plug-Ins/LV2:~/.lv2:/usr/local/lib/lv2:/usr/lib/lv2"
+ elif Options.platform == 'haiku':
+ Options.options.default_lv2_path = "~/Library/Audio/Plug-Ins/LV2:/Library/Audio/Plug-Ins/LV2:~/.lv2:/usr/local/lib/lv2:/usr/lib/lv2"
+ else:
+ Options.options.default_lv2_path = "~/.lv2:/usr/local/" + conf.env['LIBDIRNAME'] + '/lv2:' + conf.env['LIBDIR'] + '/lv2'
conf.env['USE_JACK'] = conf.env['HAVE_JACK'] and not Options.options.no_jack
conf.env['BUILD_TESTS'] = Options.options.build_tests
conf.env['BASH_COMPLETION'] = Options.options.bash_completion
+ conf.define('SLV2_DEFAULT_LV2_PATH', Options.options.default_lv2_path)
+
+ conf.write_config_header('slv2-config.h')
autowaf.print_summary(conf)
autowaf.display_msg(conf, "Jack clients", str(conf.env['USE_JACK']))
autowaf.display_msg(conf, "Unit tests", str(conf.env['BUILD_TESTS']))
autowaf.display_msg(conf, "Dynamic Manifest Support", str(conf.env['SLV2_DYN_MANIFEST'] == 1))
+ autowaf.display_msg(conf, "Default LV2_PATH", str(conf.env['SLV2_DEFAULT_LV2_PATH']))
print
tests = '''