]> git.donarmstrong.com Git - lilypond.git/commitdiff
Finish rename of LILYPONDPREFIX to LILYPOND_DATADIR. Remove confusion
authorJan Nieuwenhuizen <janneke@gnu.org>
Fri, 2 Feb 2007 12:06:30 +0000 (13:06 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Fri, 2 Feb 2007 12:06:30 +0000 (13:06 +0100)
between prefix (/usr) and lilypond_datadir (/usr/share/lilypond/x.y.x),
fixes running from compile prefix and build tree with `current' link.

15 files changed:
Documentation/topdocs/NEWS.tely
Documentation/user/GNUmakefile
Documentation/user/running.itely
SConstruct
flower/GNUmakefile
lily/font-config.cc
lily/general-scheme.cc
lily/include/main.hh
lily/include/relocate.hh
lily/main.cc
lily/relocate.cc
make/ly.make
python/lilylib.py
scm/standalone.scm
scripts/lilypond-invoke-editor.scm

index b79a19a998ec3b8510a38836f82499974d6c5db7..3ec4ab59595018b8780c3d05d6a7d598f591358a 100644 (file)
@@ -85,6 +85,10 @@ and other text spanners.
 This feature was sponsored by Trevor Bača.
 
  
+@item
+The environment variable LILYPONDPREFIX has been renamed to
+LILYPOND_DATADIR.
+
 @item
 Notes or rests, such as a typical end note, that fill an entire
 measure are preceded by some more space.
index 11653d575f96adcbc169a42da0b8120baacd7bee..9186bf5bb0b78d55ba445562522fe5d50197250f 100644 (file)
@@ -40,7 +40,7 @@ info: $(INFO_FILES)
 
 pathsettings:
        @echo export PATH=$(PATH)
-       @echo export LILYPONDPREFIX=$(LILYPONDPREFIX)
+       @echo export LILYPOND_DATADIR=$(LILYPOND_DATADIR)
        @echo export PYTHONPATH=$(PYTHONPATH)
 
 xml: $(outdir)/lilypond/lilypond.xml $(outdir)/lilypond-internals/lilypond-internals.xml
index 5670f9e28b15e641a053f98fbbb5188ef6077ba9..e6ed8fa9044a8f6d328a2b0055b3a73a3126b27f 100644 (file)
@@ -330,11 +330,11 @@ Show the warranty with which GNU LilyPond comes. (It comes with
 
 
 @cindex LANG
-@cindex LILYPONDPREFIX
+@cindex LILYPOND_DATADIR
 
 @code{Lilypond} recognizes the following environment variables:
 @table @code
-@item LILYPONDPREFIX
+@item LILYPOND_DATADIR
 This specifies a directory where locale messages and
 data files will be looked up by default.  The directory should contain
 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
index 5a07e1b33aec49b71850c3d4c66e19032abea440..5df9fd05989864d6084c706bb0b4b1e44cffea90 100644 (file)
@@ -22,7 +22,7 @@ Run from build tree
     PATH=$run/bin:$PATH
 
     #optionally, if you do not use custom.py below
-    #export LILYPONDPREFIX=$run/share/lilypond/<VERSION>
+    #export LILYPOND_DATADIR=$run/share/lilypond/<VERSION>
 
     lilypond input/simple
 
@@ -245,7 +245,7 @@ if not os.path.exists (cachedir):
 
 CacheDir (cachedir)
 
-# No need to set $LILYPONDPREFIX to run lily, but cannot install...
+# No need to set $LILYPOND_DATADIR to run lily, but cannot install...
 if env['debugging'] and not 'install' in COMMAND_LINE_TARGETS:
     env['prefix'] = run_prefix
 
@@ -658,17 +658,17 @@ SConscript ('buildscripts/builder.py')
 env.PrependENVPath ('PATH',
             os.path.join (env['absbuild'], env['out'], 'usr/bin'))
 
-LILYPONDPREFIX = os.path.join (run_prefix, 'share/lilypond/', version)
+LILYPOND_DATADIR = os.path.join (run_prefix, 'share/lilypond/', version)
 
-if not os.path.exists (LILYPONDPREFIX):
-    os.makedirs (LILYPONDPREFIX)
+if not os.path.exists (LILYPOND_DATADIR):
+    os.makedirs (LILYPOND_DATADIR)
 
-env.Command (LILYPONDPREFIX, ['#/SConstruct', '#/VERSION'], symlink_tree)
-env.Depends ('lily', LILYPONDPREFIX)
+env.Command (LILYPOND_DATADIR, ['#/SConstruct', '#/VERSION'], symlink_tree)
+env.Depends ('lily', LILYPOND_DATADIR)
 
 env.Append (ENV = {
-    'LILYPONDPREFIX' : LILYPONDPREFIX,
-    'TEXMF' : '{$LILYPONDPREFIX,'
+    'LILYPOND_DATADIR' : LILYPOND_DATADIR,
+    'TEXMF' : '{$LILYPOND_DATADIR,'
     + os.popen ('kpsexpand \$TEXMF').read ()[:-1] + '}',
     })
 
@@ -781,7 +781,7 @@ env.Command (version_hh, '#/VERSION',
 # post-config environment update
 env.Append (
     run_prefix = run_prefix,
-    LILYPONDPREFIX = LILYPONDPREFIX,
+    LILYPOND_DATADIR = LILYPOND_DATADIR,
 
     # FIXME: move to lily/SConscript?
     LIBPATH = [os.path.join (absbuild, 'flower', env['out'])],
index 670aece45c790970d06f82ce48953360b542e96e..83fc5576fa694fb2763461ead4dc6e25f707f950 100644 (file)
@@ -9,7 +9,7 @@ README_FILES = NEWS-1.0 NEWS-1.1.46 README TODO
 EXTRA_DIST_FILES= VERSION $(README_FILES) $(SCRIPTS)
 STEPMAKE_TEMPLATES=library c++ po test
 
-# test uses LILYPONDPREFIX
+# test uses LILYPOND_DATADIR
 LOCALSTEPMAKE_TEMPLATES=lilypond
 TEST_MODULE_LIBS = ../flower
 export top-src-dir
index ab530eabfdea9221866841d9c0902176055ecc8a..742887f6846efdb84ec21a2f3d6aa1abc133350f 100644 (file)
@@ -45,8 +45,8 @@ init_fontconfig ()
                        
   vector<string> dirs;
 
-  dirs.push_back (prefix_directory + "/fonts/otf/");
-  dirs.push_back (prefix_directory + "/fonts/type1/");
+  dirs.push_back (lilypond_datadir + "/fonts/otf/");
+  dirs.push_back (lilypond_datadir + "/fonts/type1/");
   
   for (vsize i = 0; i < dirs.size (); i++)
     {
index 816dfeee0abad2220c5e30bf1e6597b2bb23f9bc..1d97d4bf8e001f34cec98e560e1cce938819203f 100644 (file)
@@ -289,7 +289,7 @@ LY_DEFINE (ly_effective_prefix, "ly:effective-prefix",
           0, 0, 0, (),
           "Return effective prefix.")
 {
-  return ly_string2scm (prefix_directory);
+  return ly_string2scm (lilypond_datadir);
 }
 
 LY_DEFINE (ly_chain_assoc_get, "ly:chain-assoc-get",
index 69aa8899c7858d60a47bbeb01dd6a7f7977fbb1a..bf02837d93762aac6f8da4fadb59dc19e95ba625 100644 (file)
@@ -35,7 +35,7 @@ extern bool do_internal_type_checking_global;
 extern bool is_pango_format_global;
 extern bool is_TeX_format_global;
 extern bool point_and_click_global;
-extern string prefix_directory;
+extern string lilypond_datadir;
 extern bool use_object_keys;
 extern bool strict_infinity_checking;
 extern string init_scheme_code_global;
index d50614d78715c48d68fca43cc758ca4bd3dcbb5d..80dc22e89023c33b604c874f5e680aa51e7bf89b 100644 (file)
@@ -14,7 +14,6 @@
 
 void read_relocation_dir (string dirname);
 void read_relocation_file (string filename);
-string read_line (FILE *f);
 string expand_environment_variables (string orig);
 
 int sane_putenv (char const *key, string value, bool overwrite);
index 4a539e0eea359ff68e26239ff51d7d04e253eddc..4232f17e2e2fc9ee0e212a28f03cffc49a18f4d5 100644 (file)
@@ -136,7 +136,7 @@ static char const *WARRANTY
 /* Where the init files live.  Typically:
    LILYPOND_DATADIR = /usr/share/lilypond
 */
-string prefix_directory;
+string lilypond_datadir;
 
 /* The jail specification: USER, GROUP, JAIL, DIR. */
 string jail_spec;
@@ -199,9 +199,10 @@ dir_info (FILE *out)
   fputs ("\n", out);
   fprintf (out, "LILYPOND_DATADIR=\"%s\"\n", LILYPOND_DATADIR);
   env_var_info (out, "LILYPONDPREFIX");
+  env_var_info (out, "LILYPOND_DATADIR");
   fprintf (out, "LOCALEDIR=\"%s\"\n", LOCALEDIR);
 
-  fprintf (out, "\nEffective prefix: \"%s\"\n", prefix_directory.c_str ());
+  fprintf (out, "\nEffective prefix: \"%s\"\n", lilypond_datadir.c_str ());
 
   if (relocate_binary)
     {
@@ -377,8 +378,8 @@ main_with_guile (void *, int, char **)
   /* Engravers use lily.scm contents, need to make Guile find it.
      Prepend onto GUILE %load-path, very ugh. */
 
-  prepend_load_path (prefix_directory);
-  prepend_load_path (prefix_directory + "/scm");
+  prepend_load_path (lilypond_datadir);
+  prepend_load_path (lilypond_datadir + "/scm");
 
   if (be_verbose_global)
     dir_info (stderr);
@@ -593,9 +594,6 @@ setup_guile_env ()
               "104857600", overwrite);
 }
 
-void
-read_relocation_dir (string);
-
 int
 main (int argc, char **argv)
 {
index 635b4165c9b2039bdda7fe8654795665ff81beaa..2ff9fc44d37e7721780bf791d07d4398ac588f1e 100644 (file)
@@ -48,7 +48,7 @@ sane_putenv (char const *key, string value, bool overwrite)
       /*
        unfortunately, we can't portably free S here,
        due to various bugs in glibc prior to 2.1.1
-       */ 
+      */ 
       return retval;
     }
   
@@ -97,37 +97,41 @@ prepend_env_path (char const *key, string value)
 #include <winbase.h>
 #endif
 
-void
+static void
 prefix_relocation (string prefix)
 {
-  if (be_verbose_global)
-    warning (_f ("Relocation: compile prefix=%s, new prefix=%s",
-                prefix_directory,
-                prefix.c_str ()));
-  
   string bindir = prefix + "/bin";
   string datadir = prefix + "/share";
   string localedir = datadir + "/locale";
-  string lilypond_datadir = datadir + "/lilypond/";
-
-  if (is_dir (lilypond_datadir + "/" + TOPLEVEL_VERSION))
-    prefix_directory = lilypond_datadir + "/" + TOPLEVEL_VERSION;
-  else if (is_dir (lilypond_datadir + "/current"))
-    prefix_directory = lilypond_datadir + "/current";
-
+  string package_datadir = datadir + "/lilypond/";
+  string old_lilypond_datadir = lilypond_datadir;
+
+  if (is_dir (package_datadir + "/" + TOPLEVEL_VERSION))
+    lilypond_datadir = package_datadir + "/" + TOPLEVEL_VERSION;
+  else if (is_dir (package_datadir + "/current"))
+    lilypond_datadir = package_datadir + "/current";
+  else
+    warning (_f ("not relocating, no %s/ or current/ found under %s",
+                TOPLEVEL_VERSION, package_datadir.c_str ()));
+  
 #if HAVE_GETTEXT
   if (is_dir (localedir))
     bindtextdomain ("lilypond", localedir.c_str ());
 #endif
 
   prepend_env_path ("PATH", bindir);
+
+  if (be_verbose_global)
+    warning (_f ("Relocation: compile datadir=%s, new datadir=%s",
+                old_lilypond_datadir.c_str (),
+                lilypond_datadir.c_str ()));
 }
 
 /*
   UGH : this is a complete mess.
- */
+*/
 
-void
+static void
 framework_relocation (string prefix)
 {
   if (be_verbose_global)
@@ -144,106 +148,106 @@ framework_relocation (string prefix)
 
 /*
   UGH : this is a complete mess.
- */
+*/
 void
 setup_paths (char const *argv0_ptr)
 {
   File_name argv0_filename (argv0_ptr);
   
-  prefix_directory = LILYPOND_DATADIR;
-  if (relocate_binary
-      && getenv ("LILYPOND_RELOCATE_PREFIX"))
+  if (relocate_binary)
     {
-      prefix_directory = getenv ("LILYPOND_RELOCATE_PREFIX");
+      string prefix_directory;
+      if (getenv ("LILYPOND_RELOCATE_PREFIX"))
+       {
+         prefix_directory = getenv ("LILYPOND_RELOCATE_PREFIX");
 #ifdef __MINGW32__
-      /* Normalize file name.  */
-      prefix_directory = File_name (prefix_directory).to_string ();
+         /* Normalize file name.  */
+         prefix_directory = File_name (prefix_directory).to_string ();
 #endif /* __MINGW32__ */
       
-      prefix_relocation (prefix_directory);
-      string bindir = prefix_directory + "/bin";
-      framework_relocation (bindir);
-    }
-  else if (relocate_binary)
-    {
-      string argv0_abs;
-      if (argv0_filename.is_absolute ())
-       {
-         argv0_abs = argv0_filename.to_string ();
-         if (be_verbose_global)
-           warning (_f ("Relocation: is absolute: argv0=%s", argv0_ptr));
+         prefix_relocation (prefix_directory);
+         string bindir = prefix_directory + "/bin";
+         framework_relocation (bindir);
        }
-      else if (argv0_filename.dir_.length ())
+      else if (relocate_binary)
        {
-         argv0_abs = get_working_directory ()
-           + "/" + string (argv0_filename.to_string ());
-         if (be_verbose_global)
-           warning (_f ("Relocation: from cwd: argv0=%s", argv0_ptr));
-       }
-      else
-       {
-         /* Find absolute ARGV0 name, using PATH.  */
-         File_path path;
-         path.parse_path (getenv ("PATH"));
+         string argv0_abs;
+         if (argv0_filename.is_absolute ())
+           {
+             argv0_abs = argv0_filename.to_string ();
+             if (be_verbose_global)
+               warning (_f ("Relocation: is absolute: argv0=%s", argv0_ptr));
+           }
+         else if (argv0_filename.dir_.length ())
+           {
+             argv0_abs = get_working_directory ()
+               + "/" + string (argv0_filename.to_string ());
+             if (be_verbose_global)
+               warning (_f ("Relocation: from cwd: argv0=%s", argv0_ptr));
+           }
+         else
+           {
+             /* Find absolute ARGV0 name, using PATH.  */
+             File_path path;
+             path.parse_path (getenv ("PATH"));
 
-         if (be_verbose_global)
-           warning (_f ("Relocation: from PATH=%s\nargv0=%s",
-                        path.to_string ().c_str (), argv0_ptr));
+             if (be_verbose_global)
+               warning (_f ("Relocation: from PATH=%s\nargv0=%s",
+                            path.to_string ().c_str (), argv0_ptr));
 
 #ifndef __MINGW32__
-         argv0_abs = path.find (argv0_filename.to_string ());
+             argv0_abs = path.find (argv0_filename.to_string ());
 #else /* __MINGW32__ */
-         char const *ext[] = {"exe", "", 0 };
-         argv0_abs = path.find (argv0_filename.to_string (), ext);
+             char const *ext[] = {"exe", "", 0 };
+             argv0_abs = path.find (argv0_filename.to_string (), ext);
 #endif /* __MINGW32__ */
 
-         if (argv0_abs.empty ())
-           programming_error ("cannot find absolute argv0");
-       }
+             if (argv0_abs.empty ())
+               programming_error ("cannot find absolute argv0");
+           }
 
-      string bindir = dir_name (argv0_abs);
-      string argv0_prefix = dir_name (bindir);
-      string compile_prefix = dir_name (dir_name (dir_name (prefix_directory)));
-      if (argv0_prefix != compile_prefix)
-       {
-         prefix_relocation (argv0_prefix);
-         prefix_directory = argv0_prefix;
-       }
-      if (argv0_prefix != compile_prefix || string (FRAMEWORKDIR) != "..")
-       {
-         framework_relocation (bindir + "/" + FRAMEWORKDIR);
-         prefix_directory = bindir + "/" + FRAMEWORKDIR;
+         string bindir = dir_name (argv0_abs);
+         string argv0_prefix = dir_name (bindir);
+         string compile_prefix = dir_name (dir_name (dir_name (lilypond_datadir)));
+         if (argv0_prefix != compile_prefix)
+           {
+             prefix_relocation (argv0_prefix);
+             prefix_directory = argv0_prefix;
+           }
+         if (argv0_prefix != compile_prefix || string (FRAMEWORKDIR) != "..")
+           {
+             framework_relocation (bindir + "/" + FRAMEWORKDIR);
+             prefix_directory = bindir + "/" + FRAMEWORKDIR;
+           }
        }
+
+      lilypond_datadir = prefix_directory
+       + "/share/lilypond/" TOPLEVEL_VERSION;
     }
 
-  /* FIXME: use LILYPOND_DATADIR.  */
-  if (char const *env = getenv ("LILYPONDPREFIX"))
+  if (getenv ("LILYPONDPREFIX"))
+    error (_ ("LILYPONDPREFIX is obsolete, use LILYPOND_DATADIR"));
+
+  if (char const *env = getenv ("LILYPOND_DATADIR"))
     {
 #ifdef __MINGW32__
       /* Normalize file name.  */
-      prefix_directory = File_name (env).to_string ();
+      lilypond_datadir = File_name (env).to_string ();
 #else
-      prefix_directory = env;
+      lilypond_datadir = env;
 #endif
     }
 
+  /* When running from build dir, a full LILYPOND_DATADIR is set-up at
+     $(OUTBASE)/{share, lib}/lilypond/current.  Configure lily using
+     ./configure --prefix=$(pwd)/out */
+  string build_datadir_current = dir_name (lilypond_datadir) + "/current";
+  if (!is_dir (lilypond_datadir.c_str ())
+      && is_dir (build_datadir_current.c_str ()))
+    lilypond_datadir = build_datadir_current;
+  
   global_path.append ("");
 
-
-  /*
-    When running from build dir, a full LILYPOND_PREFIX is set-up at
-
-        $(OUTBASE)/{share, lib}/lilypond/current
-
-  */
-  
-  string build_prefix_current = prefix_directory + "/share/lilypond/" "current";
-  string build_prefix_version = prefix_directory + "/share/lilypond/" TOPLEVEL_VERSION;
-  if (is_dir (build_prefix_version.c_str ()))
-    prefix_directory = build_prefix_version;
-  else if (is_dir (build_prefix_current.c_str ()))
-    prefix_directory = build_prefix_current;
-  
   /* Adding mf/out make lilypond unchanged source directory, when setting
      LILYPONDPREFIX to lilypond-x.y.z */
   char const *suffixes[] = {"ly", "ps", "scm", 0 };
@@ -251,20 +255,18 @@ setup_paths (char const *argv0_ptr)
   vector<string> dirs;
   for (char const **s = suffixes; *s; s++)
     {
-      string path = prefix_directory + to_string ('/') + string (*s);
+      string path = lilypond_datadir + to_string ('/') + string (*s);
       dirs.push_back (path);
     }
   
-  dirs.push_back (prefix_directory + "/fonts/otf/");
-  dirs.push_back (prefix_directory + "/fonts/type1/");
-  dirs.push_back (prefix_directory + "/fonts/svg/");
+  dirs.push_back (lilypond_datadir + "/fonts/otf/");
+  dirs.push_back (lilypond_datadir + "/fonts/type1/");
+  dirs.push_back (lilypond_datadir + "/fonts/svg/");
   
   for (vsize i = 0; i < dirs.size (); i++)
     global_path.prepend (dirs[i]);
 }
 
-
-
 string
 expand_environment_variables (string orig)
 {
@@ -306,7 +308,7 @@ expand_environment_variables (string orig)
            {
              /*
                Hmm. what to do for $1 , $~ etc.?
-              */
+             */
              do
                {
                  end_var ++;
@@ -336,7 +338,7 @@ expand_environment_variables (string orig)
 }
 
 
-string
+static string
 read_line (FILE *f)
 {
   string out;
@@ -402,6 +404,6 @@ read_relocation_dir (string dirname)
       {
        File_name name (ent->d_name);
        if (name.ext_ == "reloc")
-           read_relocation_file (dirname + "/" + name.to_string ());
+         read_relocation_file (dirname + "/" + name.to_string ());
       }
 }
index caee2d22452b6bfee80c04e20047d3e4af64e46f..f9a3f212d447e64408b41f804065d934bd209750 100644 (file)
 # Magic: find and include LilyPond's StepMake rules
 #
 # 0: try local tree
-# 1: follow LILYPONDPREFIX
+# 1: follow LILYPOND_DATADIR
 # 2: try source tree in home
 # 3: try installed tree in $HOME
 # 4: try system installed tree
 # 5: try system installed tree
 #
 make-root=$(wildcard $(depth)/make)
-make-root?=$(wildcard $(LILYPONDPREFIX)/make)
+make-root?=$(wildcard $(LILYPOND_DATADIR)/make)
 make-root?=$(wildcard $(HOME)/usr/src/lilypond/make)
 make-root?=$(wildcard $(HOME)/usr/share/lilypond/make)
 make-root?=$(wildcard /usr/share/lilypond/make)
index 686993e5d87165b69c131aa33e7b1ca141eb22b8..156c9b7c8da95e21516f0775685ccff32f0fa242 100644 (file)
@@ -24,14 +24,14 @@ import optparse
 # it as we do with teTeX on Red Hat Linux: set some environment var
 # (PYTHONPATH) in profile)
 
-# If set, LILYPONDPREFIX must take prevalence
-# if datadir is not set, we're doing a build and LILYPONDPREFIX
+# If set, LILYPOND_DATADIR must take prevalence
+# if datadir is not set, we're doing a build and LILYPOND_DATADIR
 
 datadir = '@local_lilypond_datadir@'
 if not os.path.isdir (datadir):
     datadir = '@lilypond_datadir@'
-if os.environ.has_key ('LILYPONDPREFIX') :
-    datadir = os.environ['LILYPONDPREFIX']
+if os.environ.has_key ('LILYPOND_DATADIR') :
+    datadir = os.environ['LILYPOND_DATADIR']
     while datadir[-1] == os.sep:
        datadir= datadir[:-1]
 
index 5a644d2b3d1b8c9e1312f90b5b39ea306e469ab2..8fbf6b1f65e7319e28e210b57fea2b0e43df238c 100644 (file)
@@ -19,8 +19,8 @@
 
 (define (scm-gulp-file name)
   (set! %load-path 
-       (cons (string-append (getenv "LILYPONDPREFIX") "/ly")
-             (cons (string-append (getenv "LILYPONDPREFIX") "/ps")
+       (cons (string-append (getenv "LILYPOND_DATADIR") "/ly")
+             (cons (string-append (getenv "LILYPOND_DATADIR") "/ps")
                    %load-path)))
   (let ((path (%search-load-path name)))
        (if path
index 275aa901d88304e05d08f1cd1cbaffddbdf1c8f9..0d8ca9ef52cc9714b6daf51b15994127bf6bf8e6 100755 (executable)
@@ -24,9 +24,9 @@
 
 ;; argv0 relocation -- do in wrapper?
 
-(define LILYPONDPREFIX
+(define LILYPOND_DATADIR
   (let* ((prefix
-         (or (getenv "LILYPONDPREFIX")
+         (or (getenv "LILYPOND_DATADIR")
              (dirname  (dirname (car (command-line)))))))
     
 
@@ -150,7 +150,7 @@ Options:
        (begin
          (show-help (current-error-port))
          (exit 2)))
-    (set! %load-path (cons LILYPONDPREFIX %load-path))
+    (set! %load-path (cons LILYPOND_DATADIR %load-path))
 
     (primitive-eval '(use-modules (scm editor)))