]> git.donarmstrong.com Git - lilypond.git/commitdiff
Finish rename of LILYPONDPREFIX to LILYPOND_DATADIR. Remove confusion
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 3 Feb 2007 15:28:30 +0000 (16:28 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 3 Feb 2007 15:28:30 +0000 (16:28 +0100)
between prefix (/usr) and lilypond_datadir (/usr/share/lilypond/x.y.x),
fixes running from compile prefix and build tree with `current' link.

Conflicts:

Documentation/topdocs/NEWS.tely
lily/general-scheme.cc
lily/relocate.cc
scm/standalone.scm

14 files changed:
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 3377634f8f553dd16b45529399a31886bdcea071..abf2c238521d0e647dcfa0e8e12b6d5f9f10118a 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 f4cbfdd3263765a292b297e1fcdeca0fad8bf4bb..dbfbdc9d0c4e037533c3815a724ab31b52f111cd 100644 (file)
@@ -326,11 +326,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 40949dc51106b23e698931ebb09d0a95a78af76b..ab2b1d1e71939106b7b3ae0d77388f6567b03aee 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
 
@@ -242,7 +242,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
 
@@ -661,17 +661,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] + '}',
     })
 
@@ -801,7 +801,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 cbf77c7944d012c9186e50edb1c1dd7143a1f034..2dd25319f99ecbb32c46e2d2672fe5f04e101a7e 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 159de6b96602b5b45a6802e2fec31295143030e1..9a52ecb41e74055d5cd3b7a9db650540974dd8e4 100644 (file)
@@ -287,7 +287,7 @@ LY_DEFINE (ly_effective_prefix, "ly:effective-prefix",
           0, 0, 0, (),
           "Return effective prefix.")
 {
-  return scm_makfrom0str (prefix_directory.c_str ());
+  return scm_makfrom0str (lilypond_datadir.c_str ());
 }
 
 LY_DEFINE (ly_chain_assoc_get, "ly:chain-assoc-get",
index 5369507628be787f6216590bff99c8895df420ff..d966d0266ba421b1da68128792d7ef0377e676b8 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;
 /*
index e3af270a88e2c6d1bc9ab955abfa6c9bfc2cbb7f..2ed0addad1bf741157187cae697c8fb08b172e8f 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 30b9926423323c6d8e0da1879f8f8f3c0f73b131..3c269b1a34d914c7cb6fbf1c2fc80883f9be45d0 100644 (file)
@@ -137,7 +137,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;
@@ -200,9 +200,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)
     {
@@ -378,8 +379,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);
@@ -616,9 +617,6 @@ setup_guile_env ()
               "104857600", overwrite);
 }
 
-void
-read_relocation_dir (string);
-
 int
 main (int argc, char **argv)
 {
index d7aed8133c586dc1c191649c62f0a1120746c804..aabc2088a4e9c9f98924b95b7c9a7f9971236392 100644 (file)
@@ -47,7 +47,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;
     }
   
@@ -96,37 +96,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)
@@ -143,110 +147,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 ("can't 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/lilypond/TOPLEVEL_VERSION
-
-     This historical hack will allow the shorthand
-
-        LILYPONDPREFIX=out lily/out/lilypond ...
-
-  */
-  
-  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 };
@@ -254,20 +254,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)
 {
@@ -309,7 +307,7 @@ expand_environment_variables (string orig)
            {
              /*
                Hmm. what to do for $1 , $~ etc.?
-              */
+             */
              do
                {
                  end_var ++;
@@ -339,7 +337,7 @@ expand_environment_variables (string orig)
 }
 
 
-string
+static string
 read_line (FILE *f)
 {
   string out;
@@ -404,6 +402,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 877b98e360b1a67cd0390627385e524d9c87a9da..2cbeea21cac8b01c3445a18005704c6da1153ba4 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 681a49d04297727f11ff25c2ac8a757e7d755811..7ccef5726e9d1519d204606c00f25625cc2fe754 100644 (file)
@@ -16,8 +16,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)))