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))");
198 main_prog (int argc, char **argv)
202 // facilitate binary distributions
203 char const *env_lily = getenv ("LILYPONDPREFIX");
204 String prefix_directory;
206 prefix_directory = env_lily;
209 setlocale (LC_ALL, ""); /* enable locales */
210 setlocale (LC_NUMERIC, "C"); /* musn't have comma's in TeX output... */
211 String lily_locale_dir;
212 String name (PACKAGE);
214 if (!prefix_directory.empty_b())
216 lily_locale_dir = prefix_directory + "/share/locale";
217 bindtextdomain (name.ch_C (), lily_locale_dir.ch_C());
220 bindtextdomain (name.ch_C (), DIR_LOCALEDIR);
221 textdomain (name.ch_C ());
225 call_constructors ();
226 debug_init (); // should be first
228 global_path.add ("");
229 // must override (come before) "/usr/local/share/lilypond"!
230 char const *env_sz = getenv ("LILYINCLUDE");
232 global_path.parse_path (env_sz);
234 if (!prefix_directory.empty_b())
236 global_path.add (prefix_directory + "/share/lilypond/init/");
237 global_path.add (prefix_directory + "/share/lilypond");
240 global_path.add (String (DIR_DATADIR) + "/ly/");
241 global_path.add (String (DIR_DATADIR) + "/afm/");
243 Getopt_long oparser (argc, argv,theopts);
247 while (Long_option_init const * opt = oparser ())
249 switch (opt->shortname)
252 experimental_features_global_b = true;
253 global_lookup_l = &ps_lookup;
256 outname_str = oparser.optional_argument_ch_C_;
263 find_quarts_global_b = true;
266 global_path.push (oparser.optional_argument_ch_C_);
269 init_str = oparser.optional_argument_ch_C_;
279 version_ignore_global_b = true;
282 dependency_global_b = true;
288 no_paper_global_b = true;
291 no_timestamps_global_b = true;
299 default_outname_base_global = "lelie";
305 while ((arg= oparser.get_next_arg ()))
309 f = distill_inname_str (f, i);
311 default_outname_base_global = "-";
315 split_path (f, a, b, c, d);
316 default_outname_base_global = c;
318 if (outname_str.length_i ())
319 default_outname_base_global = outname_str;
320 if (init_str.length_i ())
330 if (init_str.length_i ())
334 default_outname_base_global = "-";
335 if (outname_str.length_i ())
336 default_outname_base_global = outname_str;
337 do_one_file (i, default_outname_base_global);
340 return exit_status_i_;
344 urg: make input file name:
348 output: file name with added default extension. "" is stdin.
349 in reference argument: the extension. ".ly" if none
352 distill_inname_str (String name_str, String& ext_r)
354 String str = name_str;
360 split_path (str,a,b,c,ext_r);
362 // add extension if not present.
363 if (ext_r.empty_b ())
366 if (global_path.find (a+b+c+ext_r).empty_b ())
383 main (int argc, char **argv)
385 gh_enter (argc, argv, (void(*)())main_prog);
386 return exit_status_i_;
390 int main (int argc, char **argv)
392 return main_prog (argc, argv);