gnu: python-babel: Update to 2.7.0.
[guix.git] / gnu / packages / patches / guile-relocatable.patch
blob95bddcce8812181f9c7b052752f25d42aee37d75
1 This patch changes Guile to use a default search path relative to the
2 location of the `guile' binary, allowing it to be relocated.
4 --- a/libguile/load.c
5 +++ b/libguile/load.c
6 @@ -26,6 +26,7 @@
8 #include <string.h>
9 #include <stdio.h>
10 +#include <libgen.h>
12 #include "libguile/_scm.h"
13 #include "libguile/alist.h"
14 @@ -325,6 +326,32 @@
15 SCM cpath = SCM_EOL;
17 #ifdef SCM_LIBRARY_DIR
18 + char *program, *bin_dir, *prefix, *module_dir, *ccache_dir;
20 + /* Determine the source and compiled module directories at run-time,
21 + relative to the executable's location.
23 + Note: Use /proc/self/exe instead of argv[0] because the latter is
24 + not necessarily an absolute, nor a valid file name. */
26 + program = scm_gc_malloc_pointerless (256, "string");
27 + readlink ("/proc/self/exe", program, 256);
29 + bin_dir = dirname (strdupa (program));
31 + prefix = scm_gc_malloc_pointerless (strlen (bin_dir) + 4, "string");
32 + strcpy (prefix, bin_dir);
33 + strcat (prefix, "/..");
34 + prefix = canonicalize_file_name (prefix);
36 + module_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string");
37 + strcpy (module_dir, prefix);
38 + strcat (module_dir, "/share/guile/" SCM_EFFECTIVE_VERSION);
40 + ccache_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string");
41 + strcpy (ccache_dir, prefix);
42 + strcat (ccache_dir, "/lib/guile/" SCM_EFFECTIVE_VERSION "/ccache");
44 env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_PATH"));
45 if (env && strcmp (env, "") == 0)
46 /* special-case interpret system-path=="" as meaning no system path instead
47 @@ -333,10 +360,7 @@
48 else if (env)
49 path = scm_parse_path (scm_from_locale_string (env), path);
50 else
51 - path = scm_list_4 (scm_from_locale_string (SCM_LIBRARY_DIR),
52 - scm_from_locale_string (SCM_SITE_DIR),
53 - scm_from_locale_string (SCM_GLOBAL_SITE_DIR),
54 - scm_from_locale_string (SCM_PKGDATA_DIR));
55 + path = scm_list_1 (scm_from_locale_string (module_dir));
57 env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_COMPILED_PATH"));
58 if (env && strcmp (env, "") == 0)
59 @@ -346,8 +370,7 @@
60 cpath = scm_parse_path (scm_from_locale_string (env), cpath);
61 else
63 - cpath = scm_list_2 (scm_from_locale_string (SCM_CCACHE_DIR),
64 - scm_from_locale_string (SCM_SITE_CCACHE_DIR));
65 + cpath = scm_list_1 (scm_from_locale_string (ccache_dir));
68 #endif /* SCM_LIBRARY_DIR */