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 String default_outname_base_global = "lelie";
34 int default_count_global;
35 File_path global_path;
38 bool experimental_features_global_b = false;
39 bool dependency_global_b = false;
43 String distill_inname_str (String name_str, String& ext_r);
45 Long_option_init theopts[] = {
55 {0, "dependencies", 'd'},
56 {0, "no-timestamps", 'T'},
57 {0, "find-fourths", 'Q'},
58 {0, "ignore-version", 'V'},
65 cout << _f ("Usage: %s [OPTION]... [FILE]...", "lilypond") << '\n';
66 cout << _ ("Typeset music and or play MIDI from FILE or <stdin>");
69 cout << _ ("Options:");
72 " -a, --about about LilyPond\n"
75 " -D, --debug enable debugging output\n"
78 " -d, --dependencies write Makefile dependencies for every input file\n"
81 " -I, --include=DIR add DIR to search path\n"
84 " -i, --init=FILE use FILE as init file\n"
87 " -h, --help this help\n"
90 " -M, --no-paper produce midi output only\n"
93 " -o, --output=FILE set FILE as default output base\n"
96 " -Q, --find-fourths show all intervals greater than a fourth\n"
99 " -t, --test switch on experimental features\n"
102 " -T, --no-timestamps don't timestamp the output\n"
105 " -V, --ignore-version ignore mudela version\n"
108 " -w, --warranty show warranty and copyright\n"
111 cout << _ ("GNU LilyPond was compiled with the following settings:");
120 #ifdef STRING_UTILS_INLINED
121 "STRING_UTILS_INLINED "
123 "datadir=" DIR_DATADIR
125 "localedir=" DIR_LOCALEDIR
139 cout << _ ("GNU LilyPond is Free software, see --warranty");
142 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
144 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
145 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
153 cout << _ ("GNU LilyPond -- The GNU Project music typesetter");
155 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
157 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
158 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
161 " This program is free software; you can redistribute it and/or\n"
162 "modify it under the terms of the GNU General Public License version 2\n"
163 "as published by the Free Software Foundation.\n"
165 " This program is distributed in the hope that it will be useful,\n"
166 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
167 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
168 "General Public License for more details.\n"
170 " You should have received a copy (refer to the file COPYING) of the\n"
171 "GNU General Public License along with this program; if not, write to\n"
172 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
179 *mlog << get_version_str () << endl;
183 main (int argc, char **argv)
187 setlocale (LC_ALL, "");
188 // setlocale (LC_MESSAGES, "");
189 String name (PACKAGE);
191 bindtextdomain (name.ch_C (), DIR_LOCALEDIR);
192 textdomain (name.ch_C ());
196 call_constructors ();
197 debug_init (); // should be first
199 global_path.add ("");
200 // must override (come before) "/usr/local/share/lilypond"!
201 char const *env_sz = getenv ("LILYINCLUDE");
203 global_path.parse_path (env_sz);
205 global_path.add (String (DIR_DATADIR) + "/init/");
207 global_path.push (DIR_DATADIR);
209 Getopt_long oparser (argc, argv,theopts);
213 while (Long_option_init const * opt = oparser ())
215 switch (opt->shortname)
218 experimental_features_global_b = true;
221 outname_str = oparser.optional_argument_ch_C_;
228 find_quarts_global_b = true;
231 global_path.push (oparser.optional_argument_ch_C_);
234 init_str = oparser.optional_argument_ch_C_;
244 version_ignore_global_b = true;
247 dependency_global_b = true;
253 no_paper_global_b = true;
256 no_timestamps_global_b = true;
264 default_outname_base_global = "lelie";
270 while ((arg= oparser.get_next_arg ()))
274 f = distill_inname_str (f, i);
276 default_outname_base_global = "-";
280 split_path (f, a, b, c, d);
281 default_outname_base_global = c;
283 if (outname_str.length_i ())
284 default_outname_base_global = outname_str;
285 if (init_str.length_i ())
295 if (init_str.length_i ())
299 default_outname_base_global = "-";
300 if (outname_str.length_i ())
301 default_outname_base_global = outname_str;
302 do_one_file (i, default_outname_base_global);
305 return exit_status_i_;
309 urg: make input file name:
311 output: file name with added default extension. "" is stdin.
312 in reference argument: the extention. ".ly" if none
316 distill_inname_str (String name_str, String& ext_r)
318 String str = name_str;
324 split_path (str,a,b,c,ext_r);
326 // add extension if not present.
327 if (ext_r.empty_b ())
330 if (global_path.find (a+b+c+ext_r).empty_b ())