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"
32 bool version_ignore_global_b = false;
33 bool no_paper_global_b = false;
34 bool no_timestamps_global_b = false;
35 bool find_quarts_global_b = false;
36 String default_outname_base_global = "lelie";
37 int default_count_global;
38 File_path global_path;
41 Tex_lookup tex_lookup;
42 Lookup* global_lookup_l = &tex_lookup;
44 bool experimental_features_global_b = false;
45 bool dependency_global_b = false;
49 String distill_inname_str (String name_str, String& ext_r);
51 Long_option_init theopts[] = {
61 {0, "dependencies", 'd'},
62 {0, "no-timestamps", 'T'},
63 {0, "find-fourths", 'Q'},
64 {0, "ignore-version", 'V'},
71 cout << _f ("Usage: %s [OPTION]... [FILE]...", "lilypond") << '\n';
72 cout << _ ("Typeset music and or play MIDI from FILE or <stdin>");
75 cout << _ ("Options:");
78 " -a, --about about LilyPond\n"
81 " -D, --debug enable debugging output\n"
84 " -d, --dependencies write Makefile dependencies for every input file\n"
87 " -I, --include=DIR add DIR to search path\n"
90 " -i, --init=FILE use FILE as init file\n"
93 " -h, --help this help\n"
96 " -M, --no-paper produce midi output only\n"
99 " -o, --output=FILE set FILE as default output base\n"
102 " -Q, --find-fourths show all intervals greater than a fourth\n"
105 " -t, --test switch on experimental features\n"
108 " -T, --no-timestamps don't timestamp the output\n"
111 " -V, --ignore-version ignore mudela version\n"
114 " -w, --warranty show warranty and copyright\n"
117 cout << _ ("GNU LilyPond was compiled with the following settings:");
126 #ifdef STRING_UTILS_INLINED
127 "STRING_UTILS_INLINED "
129 "datadir=" DIR_DATADIR
131 "localedir=" DIR_LOCALEDIR
145 cout << _ ("GNU LilyPond is Free software, see --warranty");
148 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
150 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
151 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
159 cout << _ ("GNU LilyPond -- The GNU Project music typesetter");
161 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
163 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
164 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
167 " This program is free software; you can redistribute it and/or\n"
168 "modify it under the terms of the GNU General Public License version 2\n"
169 "as published by the Free Software Foundation.\n"
171 " This program is distributed in the hope that it will be useful,\n"
172 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
173 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
174 "General Public License for more details.\n"
176 " You should have received a copy (refer to the file COPYING) of the\n"
177 "GNU General Public License along with this program; if not, write to\n"
178 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
185 *mlog << get_version_str () << endl;
189 main (int argc, char **argv)
191 // facilitate binary distributions
192 char const *env_lily = getenv ("LILYPONDPREFIX");
193 String prefix_directory;
195 prefix_directory = env_lily;
198 setlocale (LC_ALL, ""); /* enable locales */
199 setlocale (LC_NUMERIC, "C"); /* musn't have comma's in TeX output... */
200 String lily_locale_dir;
201 String name (PACKAGE);
203 if (!prefix_directory.empty_b())
205 lily_locale_dir = prefix_directory + "/share/locale";
206 bindtextdomain (name.ch_C (), lily_locale_dir.ch_C());
209 bindtextdomain (name.ch_C (), DIR_LOCALEDIR);
210 textdomain (name.ch_C ());
214 call_constructors ();
215 debug_init (); // should be first
217 global_path.add ("");
218 // must override (come before) "/usr/local/share/lilypond"!
219 char const *env_sz = getenv ("LILYINCLUDE");
221 global_path.parse_path (env_sz);
223 if (!prefix_directory.empty_b())
225 global_path.add (prefix_directory + "/share/lilypond/init/");
226 global_path.add (prefix_directory + "/share/lilypond");
229 global_path.add (String (DIR_DATADIR) + "/init/");
231 global_path.push (DIR_DATADIR);
233 Getopt_long oparser (argc, argv,theopts);
237 while (Long_option_init const * opt = oparser ())
239 switch (opt->shortname)
242 experimental_features_global_b = true;
243 global_lookup_l = &ps_lookup;
246 outname_str = oparser.optional_argument_ch_C_;
253 find_quarts_global_b = true;
256 global_path.push (oparser.optional_argument_ch_C_);
259 init_str = oparser.optional_argument_ch_C_;
269 version_ignore_global_b = true;
272 dependency_global_b = true;
278 no_paper_global_b = true;
281 no_timestamps_global_b = true;
289 default_outname_base_global = "lelie";
295 while ((arg= oparser.get_next_arg ()))
299 f = distill_inname_str (f, i);
301 default_outname_base_global = "-";
305 split_path (f, a, b, c, d);
306 default_outname_base_global = c;
308 if (outname_str.length_i ())
309 default_outname_base_global = outname_str;
310 if (init_str.length_i ())
320 if (init_str.length_i ())
324 default_outname_base_global = "-";
325 if (outname_str.length_i ())
326 default_outname_base_global = outname_str;
327 do_one_file (i, default_outname_base_global);
330 return exit_status_i_;
334 urg: make input file name:
338 output: file name with added default extension. "" is stdin.
339 in reference argument: the extension. ".ly" if none
342 distill_inname_str (String name_str, String& ext_r)
344 String str = name_str;
350 split_path (str,a,b,c,ext_r);
352 // add extension if not present.
353 if (ext_r.empty_b ())
356 if (global_path.find (a+b+c+ext_r).empty_b ())