]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/main.cc
release: 1.1.1
[lilypond.git] / lily / main.cc
index 5467b79e21080151d91b05299eb290a48604e5c1..9adf5a59419f5e97679217da4bc9ad58829ffd0f 100644 (file)
 #include <iostream.h>
 #include <assert.h>
 #include <locale.h>
+#include "lily-guile.hh"
+
 #include "proto.hh"
+#include "dimensions.hh"
 #include "plist.hh"
 #include "getopt-long.hh"
 #include "misc.hh"
@@ -20,6 +23,7 @@
 #include "config.hh"
 #include "file-results.hh"
 #include "debug.hh"
+#include "lily-guile.hh"
 
 #if HAVE_GETTEXT
 #include <libintl.h>
@@ -30,11 +34,15 @@ bool version_ignore_global_b = false;
 bool no_paper_global_b = false;
 bool no_timestamps_global_b = false;
 bool find_quarts_global_b = false;
+
+char const* output_global_ch = "tex";
+// temporarily default to ps, because tex is even more broken
+//char const* output_global_ch = "ps";
+
 String default_outname_base_global =  "lelie";
 int default_count_global;
 File_path global_path;
 
-
 bool experimental_features_global_b = false;
 bool dependency_global_b = false;
 
@@ -56,6 +64,7 @@ Long_option_init theopts[] = {
   {0, "no-timestamps", 'T'},
   {0, "find-fourths", 'Q'},
   {0, "ignore-version", 'V'},
+  {1, "output-format", 'f'},
   {0,0,0}
 };
 
@@ -78,13 +87,16 @@ usage ()
     "  -d, --dependencies     write Makefile dependencies for every input file\n"
     );
   cout  << _ (
-    "  -I, --include=DIR      add DIR to search path\n"
+    "  -h, --help             this help\n"
     );
   cout  << _ (
-    "  -i, --init=FILE        use FILE as init file\n"
+    "  -f, --output-format=X  use output format X\n"
     );
   cout  << _ (
-    "  -h, --help             this help\n"
+    "  -I, --include=DIR      add DIR to search path\n"
+    );
+  cout  << _ (
+    "  -i, --init=FILE        use FILE as init file\n"
     );
   cout  << _ (
     "  -M, --no-paper         produce midi output only\n"
@@ -179,8 +191,8 @@ identify ()
   *mlog << get_version_str () << endl;
 }
 
-int
-main (int argc, char **argv)
+void
+setup_paths ()
 {
   // facilitate binary distributions
   char const *env_lily = getenv ("LILYPONDPREFIX");
@@ -204,10 +216,6 @@ main (int argc, char **argv)
   textdomain (name.ch_C ());
 #endif
 
-  identify ();
-  call_constructors ();
-  debug_init ();               // should be first
-
   global_path.add ("");
   // must override (come before) "/usr/local/share/lilypond"!
   char const *env_sz = getenv ("LILYINCLUDE");
@@ -216,24 +224,38 @@ main (int argc, char **argv)
 
   if (!prefix_directory.empty_b())
     {
-      global_path.add (prefix_directory + "/share/lilypond/init/");
-      global_path.add (prefix_directory + "/share/lilypond");
+      global_path.add (prefix_directory + "/share/lilypond/ly/");
+      global_path.add (prefix_directory + "/share/lilypond/afm/");
+    }
+  else
+    {
+      global_path.add (String (DIR_DATADIR) + "/ly/");
+      global_path.add (String (DIR_DATADIR) + "/afm/");  
     }
+}
 
-  global_path.add (String (DIR_DATADIR) + "/init/");
 
-  global_path.push (DIR_DATADIR);
 
-  Getopt_long oparser (argc, argv,theopts);
-  String init_str;
+void
+main_prog (int argc, char **argv)
+{
+  identify ();
+  call_constructors ();
+  debug_init ();               // should be first
 
+  setup_paths ();
+
+  String init_str;
   String outname_str;
+
+  Getopt_long oparser (argc, argv,theopts);
   while (Long_option_init const * opt = oparser ())
     {
       switch (opt->shortname)
        {
        case 't':
          experimental_features_global_b = true;
+         *mlog << "*** enabling experimental features, you're on your own now ***\n";
          break;
        case 'o':
          outname_str = oparser.optional_argument_ch_C_;
@@ -242,6 +264,9 @@ main (int argc, char **argv)
          notice ();
          exit (0);
          break;
+       case 'f':
+         output_global_ch = oparser.optional_argument_ch_C_;
+         break;
        case 'Q':
          find_quarts_global_b = true;
          break;
@@ -319,16 +344,27 @@ main (int argc, char **argv)
        default_outname_base_global = outname_str;
       do_one_file (i, default_outname_base_global);
     }
+  exit( exit_status_i_);
+}
 
+int
+main (int argc, char **argv)
+{
+#ifdef HAVE_LIBGUILE
+  gh_enter (argc, argv, (void(*)())main_prog);
+  return exit_status_i_;
+#else
+  main_prog (argc, argv);
   return exit_status_i_;
+#endif
 }
 
-/*
-  urg: make input file name: 
+/**
+  make input file name from command arg.
 
-  input: file name
+  @input file name
 
-  output: file name with added default extension. "" is stdin.
+  @output file name with added default extension. "" is stdin.
           in reference argument: the extension. ".ly" if none
  */
 String
@@ -343,6 +379,7 @@ distill_inname_str (String name_str, String& ext_r)
          split_path (str,a,b,c,ext_r);
 
          // add extension if not present.
+         // UGH. Should parametrise in list of default extensions.
          if (ext_r.empty_b ())
            {
              ext_r = ".fly";