- printf (_ (WARRANTY).to_str0 ());
-}
-
-static int
-sane_putenv (char const *key, String value, bool overwrite = true)
-{
- if (overwrite || !getenv (key))
- {
- String combine = String (key) + "=" + value;
- char *s = strdup (combine.to_str0 ());
- return putenv (s);
- }
- return -1;
-}
-
-#if ARGV0_RELOCATION
-static int
-set_env_file (char const *key, String value)
-{
- if (is_file (value))
- return sane_putenv (key, value, false);
- else if (be_verbose_global)
- warning (_f ("no such file: %s", value));
- return -1;
-}
-
-static int
-prepend_env_path (char const *key, String value)
-{
- if (is_dir (value))
- {
- if (char const *cur = getenv (key))
- value += to_string (PATHSEP) + cur;
- return sane_putenv (key, value.to_str0 ());
- }
- else if (be_verbose_global)
- warning (_f ("no such directory: %s", value));
- return -1;
-}
-
-String
-dir_name (String const file_name)
-{
- String s = file_name;
- s.substitute ('\\', '/');
- s = s.left_string (s.index_last ('/'));
- return s;
-}
-#endif
-
-#ifdef __MINGW32__
-#include <winbase.h>
-#endif
-
-static void
-setup_paths (char const *argv0)
-{
- prefix_directory = LILYPOND_DATADIR;
-
-#if ARGV0_RELOCATION
-
- if (getenv ("LILYPOND_VERBOSE"))
- be_verbose_global = true;
-
-#if 1 /* Huh, argv0 is not absolute on windows? ndef __MINGW32__ */
- File_path p;
- p.parse_path (getenv ("PATH"));
- String bindir = dir_name (p.find (argv0));
-#else /* __MINGW32__ */
- String bindir = dir_name (argv0);
-#endif
- String argv0_prefix = dir_name (bindir);
- if (argv0_prefix != dir_name (dir_name (dir_name (prefix_directory))))
- {
- if (be_verbose_global)
- warning (_f ("argv0 relocation: prefix=%s, argv0=%s, argv0_prefix=%s",
- prefix_directory,
- argv0,
- argv0_prefix.to_str0 ()));
- String datadir = argv0_prefix + "/share";
- String libdir = argv0_prefix + "/lib";
- String localedir = datadir + "/locale";
- String sysconfdir = argv0_prefix + "/etc";
- String argv0_lilypond_datadir = datadir + "/lilypond/" TOPLEVEL_VERSION;
-
- if (is_dir (argv0_lilypond_datadir))
- prefix_directory = argv0_lilypond_datadir;
-
-#if HAVE_GETTEXT
- if (is_dir (localedir))
- bindtextdomain ("lilypond", localedir.to_str0 ());
-#endif
-
- set_env_file ("FONTCONFIG_FILE", sysconfdir + "/fonts/fonts.conf");
-#ifdef __MINGW32__
- char font_dir[PATH_MAX];
- ExpandEnvironmentStrings ("%windir%/fonts", font_dir, sizeof (font_dir));
- prepend_env_path ("GS_FONTPATH", font_dir);
-#endif
-
- /* FIXME: *cough* 8.15 *cough* */
- prepend_env_path ("GS_FONTPATH", datadir + "/ghostscript/8.15/fonts");
- prepend_env_path ("GS_LIB", datadir + "/ghostscript/8.15/Resource");
- prepend_env_path ("GS_LIB", datadir + "/ghostscript/8.15/lib");
-
- prepend_env_path ("GS_FONTPATH", datadir + "/gs/fonts");
- prepend_env_path ("GS_LIB", datadir + "/gs/Resource");
- prepend_env_path ("GS_LIB", datadir + "/gs/lib");
-
- prepend_env_path ("GUILE_LOAD_PATH", datadir
- + to_string ("/guile/%d.%d",
- SCM_MAJOR_VERSION, SCM_MINOR_VERSION));
- set_env_file ("PANGO_RC_FILE", sysconfdir + "/pango/pangorc");
- prepend_env_path ("PATH", bindir);
- }
-#else
- (void) argv0;
-#endif /* ARGV0_RELOCATION */
-
- /* FIXME: use LILYPOND_DATADIR. */
- if (char const *env = getenv ("LILYPONDPREFIX"))
- {
-#ifdef __MINGW32__
- /* Normalize file name. */
- env = File_name (env).to_string ().get_copy_str0 ();
-#endif
- prefix_directory = env;
- }
-
- global_path.append ("");
-
-
- /*
- When running from build dir, a full LILYPOND_PREFIX is set-up at
-
- $(OUTBASE)/share/lilypond/TOPLEVEL_VERSION
-
- This historical hack will allow the shorthand
-
- LILYPONDPREFIX=out lily/out/lilypond ...
-
- */
-
- struct stat statbuf;
- String build_prefix = prefix_directory + "/share/lilypond/" TOPLEVEL_VERSION;
- if (stat (build_prefix.to_str0 (), &statbuf) == 0)
- prefix_directory = build_prefix;
-
-
- /* Adding mf/out make lilypond unchanged source directory, when setting
- LILYPONDPREFIX to lilypond-x.y.z */
- char *suffixes[] = {"ly", "ps", "scm", 0 };
-
-
- Array<String> dirs;
- for (char **s = suffixes; *s; s++)
- {
- String path = prefix_directory + to_string ('/') + String (*s);
- dirs.push (path);
- }
-
-
- dirs.push (prefix_directory + "/fonts/otf/");
- dirs.push (prefix_directory + "/fonts/type1/");
- dirs.push (prefix_directory + "/fonts/svg/");
-
- for (int i = 0; i < dirs.size (); i++)
- global_path.prepend (dirs[i]);