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>
15 #include "getopt-long.hh"
19 #include "file-path.hh"
21 #include "file-results.hh"
29 bool version_ignore_global_b = false;
30 bool no_paper_global_b = false;
31 bool no_timestamps_global_b = false;
32 bool find_quarts_global_b = false;
33 bool ps_output_global_b = false;
34 String default_outname_base_global = "lelie";
35 int default_count_global;
36 File_path global_path;
39 bool experimental_features_global_b = false;
40 bool dependency_global_b = false;
44 String distill_inname_str (String name_str, String& ext_r);
46 Long_option_init theopts[] = {
56 {0, "dependencies", 'd'},
57 {0, "no-timestamps", 'T'},
58 {0, "find-fourths", 'Q'},
59 {0, "ignore-version", 'V'},
66 cout << _f ("Usage: %s [OPTION]... [FILE]...", "lilypond") << '\n';
67 cout << _ ("Typeset music and or play MIDI from FILE or <stdin>");
70 cout << _ ("Options:");
73 " -a, --about about LilyPond\n"
76 " -D, --debug enable debugging output\n"
79 " -d, --dependencies write Makefile dependencies for every input file\n"
82 " -I, --include=DIR add DIR to search path\n"
85 " -i, --init=FILE use FILE as init file\n"
88 " -h, --help this help\n"
91 " -M, --no-paper produce midi output only\n"
94 " -o, --output=FILE set FILE as default output base\n"
97 " -Q, --find-fourths show all intervals greater than a fourth\n"
100 " -t, --test switch on experimental features\n"
103 " -T, --no-timestamps don't timestamp the output\n"
106 " -V, --ignore-version ignore mudela version\n"
109 " -w, --warranty show warranty and copyright\n"
112 cout << _ ("GNU LilyPond was compiled with the following settings:");
121 #ifdef STRING_UTILS_INLINED
122 "STRING_UTILS_INLINED "
124 "datadir=" DIR_DATADIR
126 "localedir=" DIR_LOCALEDIR
140 cout << _ ("GNU LilyPond is Free software, see --warranty");
143 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
145 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
146 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
154 cout << _ ("GNU LilyPond -- The GNU Project music typesetter");
156 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
158 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
159 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
162 " This program is free software; you can redistribute it and/or\n"
163 "modify it under the terms of the GNU General Public License version 2\n"
164 "as published by the Free Software Foundation.\n"
166 " This program is distributed in the hope that it will be useful,\n"
167 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
168 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
169 "General Public License for more details.\n"
171 " You should have received a copy (refer to the file COPYING) of the\n"
172 "GNU General Public License along with this program; if not, write to\n"
173 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
180 *mlog << get_version_str () << endl;
184 main (int argc, char **argv)
186 // facilitate binary distributions
187 char const *env_lily = getenv ("LILYPONDPREFIX");
188 String prefix_directory;
190 prefix_directory = env_lily;
193 setlocale (LC_ALL, ""); /* enable locales */
194 setlocale (LC_NUMERIC, "C"); /* musn't have comma's in TeX output... */
195 String lily_locale_dir;
196 String name (PACKAGE);
198 if (!prefix_directory.empty_b())
200 lily_locale_dir = prefix_directory + "/share/locale";
201 bindtextdomain (name.ch_C (), lily_locale_dir.ch_C());
204 bindtextdomain (name.ch_C (), DIR_LOCALEDIR);
205 textdomain (name.ch_C ());
209 call_constructors ();
210 debug_init (); // should be first
212 global_path.add ("");
213 // must override (come before) "/usr/local/share/lilypond"!
214 char const *env_sz = getenv ("LILYINCLUDE");
216 global_path.parse_path (env_sz);
218 if (!prefix_directory.empty_b())
220 global_path.add (prefix_directory + "/share/lilypond/init/");
221 global_path.add (prefix_directory + "/share/lilypond");
224 global_path.add (String (DIR_DATADIR) + "/init/");
226 global_path.push (DIR_DATADIR);
228 Getopt_long oparser (argc, argv,theopts);
232 while (Long_option_init const * opt = oparser ())
234 switch (opt->shortname)
237 experimental_features_global_b = true;
238 ps_output_global_b = true;
241 outname_str = oparser.optional_argument_ch_C_;
248 find_quarts_global_b = true;
251 global_path.push (oparser.optional_argument_ch_C_);
254 init_str = oparser.optional_argument_ch_C_;
264 version_ignore_global_b = true;
267 dependency_global_b = true;
273 no_paper_global_b = true;
276 no_timestamps_global_b = true;
284 default_outname_base_global = "lelie";
290 while ((arg= oparser.get_next_arg ()))
294 f = distill_inname_str (f, i);
296 default_outname_base_global = "-";
300 split_path (f, a, b, c, d);
301 default_outname_base_global = c;
303 if (outname_str.length_i ())
304 default_outname_base_global = outname_str;
305 if (init_str.length_i ())
315 if (init_str.length_i ())
319 default_outname_base_global = "-";
320 if (outname_str.length_i ())
321 default_outname_base_global = outname_str;
322 do_one_file (i, default_outname_base_global);
325 return exit_status_i_;
329 urg: make input file name:
333 output: file name with added default extension. "" is stdin.
334 in reference argument: the extension. ".ly" if none
337 distill_inname_str (String name_str, String& ext_r)
339 String str = name_str;
345 split_path (str,a,b,c,ext_r);
347 // add extension if not present.
348 if (ext_r.empty_b ())
351 if (global_path.find (a+b+c+ext_r).empty_b ())