]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/main.cc
release: 1.3.145
[lilypond.git] / lily / main.cc
index d5ed455e4befe7fa0d871db92db63095dd585272..0c6ee806b081b4229b9f3e0e5eae177d9a28eba9 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include <stdlib.h>
@@ -41,6 +41,9 @@
 /* Write dependencies file? */
 bool dependency_global_b = false;
 
+/* Prepend to dependencies */
+String dependency_prefix_global;
+
 /* Names of header fields to be dumped to a separate file. */
 Array<String> dump_header_fieldnames_global;
 
@@ -50,9 +53,6 @@ String init_name_global;
 /* Do not calculate and write paper output? */
 bool no_paper_global_b = false;
 
-/* Do not write timestamps in output? */
-bool no_timestamps_global_b = false;
-
 /* Selected output format.
    One of tex, ps, scm, as. */
 String output_format_global = "tex";
@@ -66,6 +66,8 @@ bool safe_global_b = false;
 /* Verbose progress indication? */
 bool verbose_global_b = false;
 
+/* Scheme code to execute before parsing, after .scm init */
+String init_scheme_code_string = "(begin #t ";
 
 
 /*
@@ -105,14 +107,15 @@ static Long_option_init options_static[] = {
   {_i ("DIR"), "include", 'I',  _i ("add DIR to search path")},
   {_i ("FILE"), "init", 'i',  _i ("use FILE as init file")},
   {0, "dependencies", 'M',  _i ("write Makefile dependencies for every input file")},
+  {_i ("DIR"), "dep-prefix", 'P',  _i ("prepend DIR to dependencies")},
   {0, "no-paper", 'm',  _i ("produce MIDI output only")},
   {_i ("NAME"), "output", 'o',  _i ("write output to NAME")},
   {0, "safe", 's',  _i ("inhibit file output naming and exporting")},
-  {0, "no-timestamps", 'T',  _i ("don't timestamp the output")},
   {0, "version", 'v',  _i ("print version number")},
-  {0, "verbose", 'V', _i("verbose")},
+  {0, "verbose", 'V', _i ("verbose")},
   {0, "warranty", 'w',  _i ("show warranty and copyright")},
-  {0,0,0, 0}
+  {_i ("EXPR"), "evaluate", 'e',_i ("evalute EXPR as Scheme after .scm init is read")},
+  {0,0,0,0}
 };
 
 void
@@ -133,7 +136,7 @@ usage ()
   cout << _ ("Typeset music and or play MIDI from FILE");
   cout << "\n\n";
   cout << 
-_(
+_ (
 "LilyPond is a music typesetter.  It produces beautiful sheet music\n"
 "using a high level description file as input.  LilyPond is part of \n"
 "the GNU Project.\n"
@@ -178,7 +181,7 @@ version ()
     "lilypond");
   cout << endl;
 
-  cout << _f ("Copyright (c) %s by", "1996--2000");
+  cout << _f ("Copyright (c) %s by", "1996--2001");
   cout << '\n';
   cout << "  Han-Wen Nienhuys <hanwen@cs.uu.nl>\n";
   cout << "  Jan Nieuwenhuizen <janneke@gnu.org>\n";
@@ -190,7 +193,7 @@ notice ()
   cout << '\n';
   cout << _ ("GNU LilyPond -- The music typesetter");
   cout << '\n';
-  cout << _f ("Copyright (c) %s by", "1996--2000");
+  cout << _f ("Copyright (c) %s by", "1996--2001");
   cout << '\n';
   cout << "  Han-Wen Nienhuys <hanwen@cs.uu.nl>\n";
   cout << "  Jan Nieuwenhuizen <janneke@gnu.org>\n";
@@ -231,10 +234,10 @@ setup_paths ()
     urg; what *do* we want with $LILYPONDPREFIX, DIR_DATADIR and $prefix/share
     handy for multiple source-dir runs, though...
    */
-  if (!prefix_directory.empty_b())
+  if (!prefix_directory.empty_b ())
     {
       lily_locale_dir = prefix_directory + "/share/locale";
-      bindtextdomain (name.ch_C (), lily_locale_dir.ch_C());
+      bindtextdomain (name.ch_C (), lily_locale_dir.ch_C ());
     }
   else
     bindtextdomain (name.ch_C (), DIR_LOCALEDIR);
@@ -261,7 +264,7 @@ setup_paths ()
       global_path.add (p);
 
 #if !KPATHSEA
-      /* Urg: GNU make's $(word) index starts at 1 */
+      /* Urg: GNU make's $ (word) index starts at 1 */
       int i  = 1;
       while (global_path.try_add (p + to_str (".") + to_str (i)))
        i++;
@@ -304,7 +307,7 @@ String
 format_to_ext (String format)
 {
   if (format == "tex")
-    /* .lytex change in separate (revertable) patch: 1.3.130.jcn4 */
+    /* .lytex change put off */
     return "tex"; // "lytex";
   return format;
 }
@@ -324,6 +327,9 @@ main_prog (int, char**)
   call_constructors ();
   all_fonts_global_p = new All_font_metrics (global_path.str ());
 
+  init_scheme_code_string += ")";
+  gh_eval_str ((char *)init_scheme_code_string.ch_C());
+  
   int p=0;
   const char *arg ;
   while ((arg = oparser_p_static->get_next_arg ()) || p == 0)
@@ -379,25 +385,40 @@ main_prog (int, char**)
   exit (exit_status_global);
 }
 
+static int
+sane_putenv (char const* key, char const* value)
+{
+  /*
+    putenv is POSIX, setenv is BSD 4.3
+    Urg, but putenv blindly overwrites environment settings.
+  */
+  if (!getenv (key))
+    return putenv ((char*)((String (key) + "=" + value).ch_C ()));
+  return -1;
+}
 
 int
 main (int argc, char **argv)
 {
-  debug_init ();               // should be first (can see that; but Why?)
   setup_paths ();
 
-  /*
-    prepare guile for heavy mem usage.
+  /* Prepare GUILE for heavy memory usage.  If you have plenty memory,
+     this may speed up GUILE a bit.  If you're short on memory, these
+     settings
+    
+        export GUILE_INIT_SEGMENT_SIZE_1=36000
+         export GUILE_MAX_SEGMENT_SIZE=576000
 
-    putenv is POSIX, setenv is BSD 4.3
-   */
-  putenv ("GUILE_INIT_SEGMENT_SIZE_1=4194304");
-  putenv ("GUILE_MAX_SEGMENT_SIZE=8388608");
+     may considerably decrease memory footprint (~*0.85), with a small
+     execution time penalty (~*1.10).  */
+  
+  sane_putenv ("GUILE_INIT_SEGMENT_SIZE_1", "4194304");
+  sane_putenv ("GUILE_MAX_SEGMENT_SIZE", "8388608");
 
   ly_init_kpath (argv[0]);
   
-  oparser_p_static = new Getopt_long(argc, argv, options_static);
-  while (Long_option_init const * opt = (*oparser_p_static)())
+  oparser_p_static = new Getopt_long (argc, argv, options_static);
+  while (Long_option_init const * opt = (*oparser_p_static) ())
     {
       switch (opt->shortname_ch_)
        {
@@ -414,6 +435,10 @@ main (int argc, char **argv)
            output_name_global = p.str ();
          }
          break;
+       case 'e':
+         init_scheme_code_string +=
+           oparser_p_static->optional_argument_ch_C_;
+         break;
        case 'w':
          notice ();
          exit (0);
@@ -421,6 +446,9 @@ main (int argc, char **argv)
        case 'f':
            output_format_global = oparser_p_static->optional_argument_ch_C_;
          break;
+       case 'P':
+           dependency_prefix_global = oparser_p_static->optional_argument_ch_C_;
+         break;
        case 'H':
          dump_header_fieldnames_global.push (oparser_p_static->optional_argument_ch_C_);
          break;
@@ -446,9 +474,6 @@ main (int argc, char **argv)
        case 'm':
          no_paper_global_b = true;
          break;
-       case 'T':
-         no_timestamps_global_b = true;
-         break;
        default:
          assert (false);
          break;
@@ -459,7 +484,7 @@ main (int argc, char **argv)
 #ifdef WINNT
   gh_enter (argc, argv, main_prog);
 #else
-  gh_enter (argc, argv, (void(*)(int, char**))main_prog);
+  gh_enter (argc, argv, (void (*) (int, char**))main_prog);
 #endif
 
   return 0;                    // unreachable