From b6970d44a8b11d1499e0054a98e9359ca3db5d93 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 16 May 2005 23:25:37 +0000 Subject: [PATCH] *** empty log message *** --- ChangeLog | 4 ++ Documentation/pictures/GNUmakefile | 4 +- flower/file-path.cc | 3 +- lily/main.cc | 89 +++++++++++++++++++++++++++--- scm/backend-library.scm | 9 +-- scm/editor.scm | 3 +- scripts/lilypond-invoke-editor.scm | 16 +++++- 7 files changed, 109 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index b1eeae4995..927ed21c39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-05-16 Jan Nieuwenhuizen + + * lily/main.cc (setup_paths)[ARGV0_RELOCATION]: + 2005-05-16 Mats Bengtsson * lily/horizontal-bracket.cc (print): Take care of the direction diff --git a/Documentation/pictures/GNUmakefile b/Documentation/pictures/GNUmakefile index 7490fd6a59..b1e9ee9d1e 100644 --- a/Documentation/pictures/GNUmakefile +++ b/Documentation/pictures/GNUmakefile @@ -7,6 +7,8 @@ OUTPNG_FILES = $(addprefix $(outdir)/,$(XPM_FILES:.xpm=.png)) EXTRA_DIST_FILES= $(XPM_FILES) +include $(depth)/make/stepmake.make + ifeq ($(PLATFORM_WINDOWS),yes) OUT_DIST_FILES = $(icon) # $(package-icon) @@ -35,8 +37,6 @@ $(outdir)/%-8.png: $(outdir)/%.png convert -depth 8 $< $@ endif # PLATFORM_WINDOWS -include $(depth)/make/stepmake.make - default: $(icon) local-dist: $(icon) # $(package-icon) xgifs: $(OUTGIF_FILES) diff --git a/flower/file-path.cc b/flower/file-path.cc index 1c0fb5628d..32f174943a 100644 --- a/flower/file-path.cc +++ b/flower/file-path.cc @@ -112,8 +112,7 @@ File_path::find (String name) const return name; #ifdef __MINGW32__ - if (name[0] == '\\' || (name.length () > 2 && name[2] == '\\') - || name.index ('//')) + if (name.index ('\\') >= 0) programming_error ("file name not normalized: " + name); #endif /* __MINGW32__ */ diff --git a/lily/main.cc b/lily/main.cc index eb2f222d17..32455ce104 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -170,16 +170,32 @@ static Long_option_init options_static[] #define LILYPOND_DATADIR PACKAGE_DATADIR "/" TOPLEVEL_VERSION +static void +env_var_info (FILE *out, char const* key) +{ + if (char const *value = getenv (key)) + fprintf (out, "%s=\"%s\"\n", key, value); +} + static void dir_info (FILE *out) { fputs ("\n", out); fprintf (out, "LILYPOND_DATADIR=\"%s\"\n", LILYPOND_DATADIR); - if (char const *env = getenv ("LILYPONDPREFIX")) - fprintf (out, "LILYPONDPREFIX=\"%s\"\n", env); + env_var_info (out, "LILYPONDPREFIX"); fprintf (out, "LOCALEDIR=\"%s\"\n", LOCALEDIR); fprintf (out, "\nEffective prefix: \"%s\"\n", prefix_directory.to_str0 ()); + +#if ARGV0_RELOCATION + env_var_info (out, "FONTCONFIG_FILE"); + env_var_info (out, "FONTCONFIG_PATH"); + env_var_info (out, "GS_FONTPATH"); + env_var_info (out, "GS_LIB"); + env_var_info (out, "GUILE_LOAD_PATH"); + env_var_info (out, "PANGO_RC_FILE"); + env_var_info (out, "PATH"); +#endif } static void @@ -240,10 +256,71 @@ warranty () printf (_ (WARRANTY).to_str0 ()); } +#if ARGV0_RELOCATION +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; +} + +static int +prepend_env_path (char const *key, String value) +{ + if (char const* cur = getenv (key)) + value += to_string (PATHSEP) + cur; + return sane_putenv (key, value.to_str0 ()); +} + +String +dir_name (String const file_name) +{ + String s = file_name; + s.substitute ('\\', '/'); + s = s.left_string (s.index_last ('/')); + return s; +} +#endif + static void -setup_paths () +setup_paths (char const* argv0) { prefix_directory = LILYPOND_DATADIR; + +#if ARGV0_RELOCATION + String bindir = dir_name (argv0); + String argv0_prefix = dir_name (bindir); + if (argv0_prefix != dir_name (dir_name (dir_name (prefix_directory)))) + { + warning (_f ("argv0 relocation: argv0=%s, prefix=%s", argv0, + prefix_directory)); + String datadir = argv0_prefix + "/share"; + String libdir = argv0_prefix + "/lib"; + String sysconfdir = argv0_prefix + "/etc"; + prefix_directory = datadir + "/lilypond/" TOPLEVEL_VERSION; + + sane_putenv ("FONTCONFIG_FILE", sysconfdir + "/fonts/fonts.conf", false); + prepend_env_path ("GUILE_LOAD_PATH", datadir + + to_string ("/guile/%d.%d", + SCM_MAJOR_VERSION, SCM_MINOR_VERSION)); +#ifdef __MINGW32__ + /* FIXME: this is broken and must go, but updating the environment + takes a relogin/reboot. Can gs be wrapped? */ + prepend_env_path ("GS_FONTPATH", "c:/windows/fonts"); +#endif + prepend_env_path ("GS_FONTPATH", datadir + "/gs/fonts"); + prepend_env_path ("GS_LIB", datadir + "/gs/Resource"); + prepend_env_path ("GS_LIB", datadir + "/gs/lib"); + sane_putenv ("PANGO_RC_FILE", sysconfdir + "/pango/pango.modules", false); + prepend_env_path ("PATH", bindir); + } +#endif /* ARGV0_RELOCATION */ + if (char const *env = getenv ("LILYPONDPREFIX")) prefix_directory = env; @@ -420,9 +497,7 @@ main_with_guile (void *, int, char **) char const *str0 = init_scheme_code_string.to_str0 (); if (be_verbose_global) - { - progress_indication (_f("Evaluating %s", str0)); - } + progress_indication (_f("Evaluating %s", str0)); scm_c_eval_string ((char *) str0); } @@ -600,7 +675,7 @@ int main (int argc, char **argv) { setup_localisation (); - setup_paths (); + setup_paths (argv[0]); parse_argv (argc, argv); if (isatty (STDIN_FILENO)) identify (stderr); diff --git a/scm/backend-library.scm b/scm/backend-library.scm index 756d6c6638..74e5369359 100644 --- a/scm/backend-library.scm +++ b/scm/backend-library.scm @@ -36,8 +36,8 @@ (let* ((pdf-name (string-append (basename name ".ps") ".pdf" )) (cmd (format #f "gs\ + -dSAFER\ -dCompatibilityLevel=1.4 \ - ~S\ -sPAPERSIZE=~a\ -q\ -dNOPAUSE\ @@ -47,12 +47,13 @@ -c .setpdfwrite\ -f ~S\ " - ;; gs on windows with -dSAFER fails on opening a - ;; file that has no group read permissions. - (if (eq? PLATFORM 'windows) "" "-dSAFER") (sanitize-command-option papersizename) pdf-name name))) + ;; The wrapper on windows cannot handle `=' signs, + ;; gs has a workaround with #. + (if (eq? PLATFORM 'windows) + (set! cmd (string-regex-substitute "=" "#" cmd))) (if (access? pdf-name W_OK) (delete-file pdf-name)) diff --git a/scm/editor.scm b/scm/editor.scm index b02d3917f4..047d9af7a2 100644 --- a/scm/editor.scm +++ b/scm/editor.scm @@ -14,7 +14,8 @@ ("gvim" . "gvim --remote +:%(line)s:norm%(column)s %(file)s") ("nedit" . "nc -noask +%(line)s %(file)s") ("gedit" . "gedit +%(line)s %(file)s") - ("jedit" . "jedit %(file)s +line:%(line)s"))) + ("jedit" . "jedit %(file)s +line:%(line)s") + ("lilypad" . "lilypad +%(line)s:%(column)s %(file)s"))) (define (get-editor) (or (getenv "LYEDITOR") diff --git a/scripts/lilypond-invoke-editor.scm b/scripts/lilypond-invoke-editor.scm index 56218fb744..e61d10f779 100755 --- a/scripts/lilypond-invoke-editor.scm +++ b/scripts/lilypond-invoke-editor.scm @@ -17,11 +17,21 @@ (srfi srfi-14)) (define PROGRAM-NAME "lilypond-invoke-editor") -(define TOPLEVEL-VERSION "2.5.25") -(define DATADIR "@DATADIR@") +(define TOPLEVEL-VERSION "@TOPLEVEL_VERSION@") +(define DATADIR "@datadir@") (define COMPILE-TIME-PREFIX (format #f "~a/lilypond/~a" DATADIR TOPLEVEL-VERSION)) -(define LILYPONDPREFIX (or (getenv "LILYPONDPREFIX") COMPILE-TIME-PREFIX)) + +;; argv0 relocation -- do in wrapper? +(define LILYPONDPREFIX + (or (getenv "LILYPONDPREFIX") + (let* ((bindir (dirname (car (command-line)))) + (prefix (dirname bindir)) + (lilypond-prefix + (if (eq? prefix (dirname DATADIR)) COMPILE-TIME-PREFIX + (format #f "~a/share/lilypond/~a" + prefix TOPLEVEL-VERSION)))) + lilypond-prefix))) ;; gettext wrapper for guile < 1.7.2 (if (defined? 'gettext) -- 2.39.2