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"
26 #include "ps-lookup.hh"
27 #include "tex-lookup.hh"
34 bool version_ignore_global_b = false;
35 bool no_paper_global_b = false;
36 bool no_timestamps_global_b = false;
37 bool find_quarts_global_b = false;
38 String default_outname_base_global = "lelie";
39 int default_count_global;
40 File_path global_path;
43 Tex_lookup tex_lookup;
44 Lookup* global_lookup_l = &tex_lookup;
48 Paper_def* global_paper_l = &tex_def;
50 bool experimental_features_global_b = false;
51 bool dependency_global_b = false;
55 String distill_inname_str (String name_str, String& ext_r);
57 Long_option_init theopts[] = {
67 {0, "dependencies", 'd'},
68 {0, "no-timestamps", 'T'},
69 {0, "find-fourths", 'Q'},
70 {0, "ignore-version", 'V'},
77 cout << _f ("Usage: %s [OPTION]... [FILE]...", "lilypond") << '\n';
78 cout << _ ("Typeset music and or play MIDI from FILE or <stdin>");
81 cout << _ ("Options:");
84 " -a, --about about LilyPond\n"
87 " -D, --debug enable debugging output\n"
90 " -d, --dependencies write Makefile dependencies for every input file\n"
93 " -I, --include=DIR add DIR to search path\n"
96 " -i, --init=FILE use FILE as init file\n"
99 " -h, --help this help\n"
102 " -M, --no-paper produce midi output only\n"
105 " -o, --output=FILE set FILE as default output base\n"
108 " -Q, --find-fourths show all intervals greater than a fourth\n"
111 " -t, --test switch on experimental features\n"
114 " -T, --no-timestamps don't timestamp the output\n"
117 " -V, --ignore-version ignore mudela version\n"
120 " -w, --warranty show warranty and copyright\n"
123 cout << _ ("GNU LilyPond was compiled with the following settings:");
132 #ifdef STRING_UTILS_INLINED
133 "STRING_UTILS_INLINED "
135 "datadir=" DIR_DATADIR
137 "localedir=" DIR_LOCALEDIR
151 cout << _ ("GNU LilyPond is Free software, see --warranty");
154 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
156 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
157 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
165 cout << _ ("GNU LilyPond -- The GNU Project music typesetter");
167 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
169 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
170 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
173 " This program is free software; you can redistribute it and/or\n"
174 "modify it under the terms of the GNU General Public License version 2\n"
175 "as published by the Free Software Foundation.\n"
177 " This program is distributed in the hope that it will be useful,\n"
178 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
179 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
180 "General Public License for more details.\n"
182 " You should have received a copy (refer to the file COPYING) of the\n"
183 "GNU General Public License along with this program; if not, write to\n"
184 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
191 *mlog << get_version_str () << endl;
195 main (int argc, char **argv)
197 // facilitate binary distributions
198 char const *env_lily = getenv ("LILYPONDPREFIX");
199 String prefix_directory;
201 prefix_directory = env_lily;
204 setlocale (LC_ALL, ""); /* enable locales */
205 setlocale (LC_NUMERIC, "C"); /* musn't have comma's in TeX output... */
206 String lily_locale_dir;
207 String name (PACKAGE);
209 if (!prefix_directory.empty_b())
211 lily_locale_dir = prefix_directory + "/share/locale";
212 bindtextdomain (name.ch_C (), lily_locale_dir.ch_C());
215 bindtextdomain (name.ch_C (), DIR_LOCALEDIR);
216 textdomain (name.ch_C ());
220 call_constructors ();
221 debug_init (); // should be first
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) + "/init/");
237 global_path.push (DIR_DATADIR);
239 Getopt_long oparser (argc, argv,theopts);
243 while (Long_option_init const * opt = oparser ())
245 switch (opt->shortname)
248 experimental_features_global_b = true;
249 global_lookup_l = &ps_lookup;
250 global_paper_l = &ps_def;
253 outname_str = oparser.optional_argument_ch_C_;
260 find_quarts_global_b = true;
263 global_path.push (oparser.optional_argument_ch_C_);
266 init_str = oparser.optional_argument_ch_C_;
276 version_ignore_global_b = true;
279 dependency_global_b = true;
285 no_paper_global_b = true;
288 no_timestamps_global_b = true;
296 default_outname_base_global = "lelie";
302 while ((arg= oparser.get_next_arg ()))
306 f = distill_inname_str (f, i);
308 default_outname_base_global = "-";
312 split_path (f, a, b, c, d);
313 default_outname_base_global = c;
315 if (outname_str.length_i ())
316 default_outname_base_global = outname_str;
317 if (init_str.length_i ())
327 if (init_str.length_i ())
331 default_outname_base_global = "-";
332 if (outname_str.length_i ())
333 default_outname_base_global = outname_str;
334 do_one_file (i, default_outname_base_global);
337 return exit_status_i_;
341 urg: make input file name:
345 output: file name with added default extension. "" is stdin.
346 in reference argument: the extension. ".ly" if none
349 distill_inname_str (String name_str, String& ext_r)
351 String str = name_str;
357 split_path (str,a,b,c,ext_r);
359 // add extension if not present.
360 if (ext_r.empty_b ())
363 if (global_path.find (a+b+c+ext_r).empty_b ())