2 main.cc -- implement main: entrypoints
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
14 #include "dimensions.hh"
16 #include "getopt-long.hh"
20 #include "file-path.hh"
22 #include "file-results.hh"
24 #include "ps-lookup.hh"
25 #include "tex-lookup.hh"
26 #include "lily-guile.hh"
33 bool version_ignore_global_b = false;
34 bool no_paper_global_b = false;
35 bool no_timestamps_global_b = false;
36 bool find_quarts_global_b = false;
37 String default_outname_base_global = "lelie";
38 int default_count_global;
39 File_path global_path;
42 Tex_lookup tex_lookup;
43 Lookup* global_lookup_l = &tex_lookup;
45 bool experimental_features_global_b = false;
46 bool dependency_global_b = false;
50 String distill_inname_str (String name_str, String& ext_r);
52 Long_option_init theopts[] = {
62 {0, "dependencies", 'd'},
63 {0, "no-timestamps", 'T'},
64 {0, "find-fourths", 'Q'},
65 {0, "ignore-version", 'V'},
72 cout << _f ("Usage: %s [OPTION]... [FILE]...", "lilypond") << '\n';
73 cout << _ ("Typeset music and or play MIDI from FILE or <stdin>");
76 cout << _ ("Options:");
79 " -a, --about about LilyPond\n"
82 " -D, --debug enable debugging output\n"
85 " -d, --dependencies write Makefile dependencies for every input file\n"
88 " -I, --include=DIR add DIR to search path\n"
91 " -i, --init=FILE use FILE as init file\n"
94 " -h, --help this help\n"
97 " -M, --no-paper produce midi output only\n"
100 " -o, --output=FILE set FILE as default output base\n"
103 " -Q, --find-fourths show all intervals greater than a fourth\n"
106 " -t, --test switch on experimental features\n"
109 " -T, --no-timestamps don't timestamp the output\n"
112 " -V, --ignore-version ignore mudela version\n"
115 " -w, --warranty show warranty and copyright\n"
118 cout << _ ("GNU LilyPond was compiled with the following settings:");
127 #ifdef STRING_UTILS_INLINED
128 "STRING_UTILS_INLINED "
130 "datadir=" DIR_DATADIR
132 "localedir=" DIR_LOCALEDIR
146 cout << _ ("GNU LilyPond is Free software, see --warranty");
149 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
151 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
152 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
160 cout << _ ("GNU LilyPond -- The GNU Project music typesetter");
162 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
164 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
165 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
168 " This program is free software; you can redistribute it and/or\n"
169 "modify it under the terms of the GNU General Public License version 2\n"
170 "as published by the Free Software Foundation.\n"
172 " This program is distributed in the hope that it will be useful,\n"
173 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
174 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
175 "General Public License for more details.\n"
177 " You should have received a copy (refer to the file COPYING) of the\n"
178 "GNU General Public License along with this program; if not, write to\n"
179 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
186 *mlog << get_version_str () << endl;
193 gh_eval_str ("(define (add-column p) (display \"adding column (in guile): \") (display p) (newline))");
201 // facilitate binary distributions
202 char const *env_lily = getenv ("LILYPONDPREFIX");
203 String prefix_directory;
205 prefix_directory = env_lily;
208 setlocale (LC_ALL, ""); /* enable locales */
209 setlocale (LC_NUMERIC, "C"); /* musn't have comma's in TeX output... */
210 String lily_locale_dir;
211 String name (PACKAGE);
213 if (!prefix_directory.empty_b())
215 lily_locale_dir = prefix_directory + "/share/locale";
216 bindtextdomain (name.ch_C (), lily_locale_dir.ch_C());
219 bindtextdomain (name.ch_C (), DIR_LOCALEDIR);
220 textdomain (name.ch_C ());
223 global_path.add ("");
224 // must override (come before) "/usr/local/share/lilypond"!
225 char const *env_sz = getenv ("LILYINCLUDE");
227 global_path.parse_path (env_sz);
229 if (!prefix_directory.empty_b())
231 global_path.add (prefix_directory + "/share/lilypond/init/");
232 global_path.add (prefix_directory + "/share/lilypond");
235 global_path.add (String (DIR_DATADIR) + "/ly/");
236 global_path.add (String (DIR_DATADIR) + "/afm/");
242 main_prog (int argc, char **argv)
246 call_constructors ();
247 debug_init (); // should be first
254 Getopt_long oparser (argc, argv,theopts);
255 while (Long_option_init const * opt = oparser ())
257 switch (opt->shortname)
260 experimental_features_global_b = true;
261 global_lookup_l = &ps_lookup;
264 outname_str = oparser.optional_argument_ch_C_;
271 find_quarts_global_b = true;
274 global_path.push (oparser.optional_argument_ch_C_);
277 init_str = oparser.optional_argument_ch_C_;
287 version_ignore_global_b = true;
290 dependency_global_b = true;
296 no_paper_global_b = true;
299 no_timestamps_global_b = true;
307 default_outname_base_global = "lelie";
313 while ((arg= oparser.get_next_arg ()))
317 f = distill_inname_str (f, i);
319 default_outname_base_global = "-";
323 split_path (f, a, b, c, d);
324 default_outname_base_global = c;
326 if (outname_str.length_i ())
327 default_outname_base_global = outname_str;
328 if (init_str.length_i ())
338 if (init_str.length_i ())
342 default_outname_base_global = "-";
343 if (outname_str.length_i ())
344 default_outname_base_global = outname_str;
345 do_one_file (i, default_outname_base_global);
348 return exit_status_i_;
352 urg: make input file name:
356 output: file name with added default extension. "" is stdin.
357 in reference argument: the extension. ".ly" if none
360 distill_inname_str (String name_str, String& ext_r)
362 String str = name_str;
368 split_path (str,a,b,c,ext_r);
370 // add extension if not present.
371 if (ext_r.empty_b ())
374 if (global_path.find (a+b+c+ext_r).empty_b ())
391 main (int argc, char **argv)
393 gh_enter (argc, argv, (void(*)())main_prog);
394 return exit_status_i_;
398 int main (int argc, char **argv)
400 return main_prog (argc, argv);