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>
13 #include "lily-guile.hh"
16 #include "dimensions.hh"
18 #include "getopt-long.hh"
22 #include "file-path.hh"
24 #include "file-results.hh"
26 #include "ps-lookup.hh"
27 #include "tex-lookup.hh"
35 bool version_ignore_global_b = false;
36 bool no_paper_global_b = false;
37 bool no_timestamps_global_b = false;
38 bool find_quarts_global_b = false;
39 String default_outname_base_global = "lelie";
40 int default_count_global;
41 File_path global_path;
44 Tex_lookup tex_lookup;
45 Lookup* global_lookup_l = &tex_lookup;
47 bool experimental_features_global_b = false;
48 bool dependency_global_b = false;
52 String distill_inname_str (String name_str, String& ext_r);
54 Long_option_init theopts[] = {
64 {0, "dependencies", 'd'},
65 {0, "no-timestamps", 'T'},
66 {0, "find-fourths", 'Q'},
67 {0, "ignore-version", 'V'},
74 cout << _f ("Usage: %s [OPTION]... [FILE]...", "lilypond") << '\n';
75 cout << _ ("Typeset music and or play MIDI from FILE or <stdin>");
78 cout << _ ("Options:");
81 " -a, --about about LilyPond\n"
84 " -D, --debug enable debugging output\n"
87 " -d, --dependencies write Makefile dependencies for every input file\n"
90 " -I, --include=DIR add DIR to search path\n"
93 " -i, --init=FILE use FILE as init file\n"
96 " -h, --help this help\n"
99 " -M, --no-paper produce midi output only\n"
102 " -o, --output=FILE set FILE as default output base\n"
105 " -Q, --find-fourths show all intervals greater than a fourth\n"
108 " -t, --test switch on experimental features\n"
111 " -T, --no-timestamps don't timestamp the output\n"
114 " -V, --ignore-version ignore mudela version\n"
117 " -w, --warranty show warranty and copyright\n"
120 cout << _ ("GNU LilyPond was compiled with the following settings:");
129 #ifdef STRING_UTILS_INLINED
130 "STRING_UTILS_INLINED "
132 "datadir=" DIR_DATADIR
134 "localedir=" DIR_LOCALEDIR
148 cout << _ ("GNU LilyPond is Free software, see --warranty");
151 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
153 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
154 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
162 cout << _ ("GNU LilyPond -- The GNU Project music typesetter");
164 cout << _f ("Copyright (c) %s by", "1996, 1997, 1998");
166 cout << " " + _ ("Han-Wen Nienhuys <hanwen@cs.uu.nl>") + "\n";
167 cout << " " + _ ("Jan Nieuwenhuizen <janneke@gnu.org>") + "\n";
170 " This program is free software; you can redistribute it and/or\n"
171 "modify it under the terms of the GNU General Public License version 2\n"
172 "as published by the Free Software Foundation.\n"
174 " This program is distributed in the hope that it will be useful,\n"
175 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
176 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
177 "General Public License for more details.\n"
179 " You should have received a copy (refer to the file COPYING) of the\n"
180 "GNU General Public License along with this program; if not, write to\n"
181 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
188 *mlog << get_version_str () << endl;
195 gh_eval_str ("(define (add-column p) (display \"adding column (in guile): \") (display p) (newline))");
200 main_prog (int argc, char **argv)
204 // facilitate binary distributions
205 char const *env_lily = getenv ("LILYPONDPREFIX");
206 String prefix_directory;
208 prefix_directory = env_lily;
211 setlocale (LC_ALL, ""); /* enable locales */
212 setlocale (LC_NUMERIC, "C"); /* musn't have comma's in TeX output... */
213 String lily_locale_dir;
214 String name (PACKAGE);
216 if (!prefix_directory.empty_b())
218 lily_locale_dir = prefix_directory + "/share/locale";
219 bindtextdomain (name.ch_C (), lily_locale_dir.ch_C());
222 bindtextdomain (name.ch_C (), DIR_LOCALEDIR);
223 textdomain (name.ch_C ());
227 call_constructors ();
228 debug_init (); // should be first
230 global_path.add ("");
231 // must override (come before) "/usr/local/share/lilypond"!
232 char const *env_sz = getenv ("LILYINCLUDE");
234 global_path.parse_path (env_sz);
236 if (!prefix_directory.empty_b())
238 global_path.add (prefix_directory + "/share/lilypond/init/");
239 global_path.add (prefix_directory + "/share/lilypond");
242 global_path.add (String (DIR_DATADIR) + "/init/");
244 global_path.push (DIR_DATADIR);
246 Getopt_long oparser (argc, argv,theopts);
250 while (Long_option_init const * opt = oparser ())
252 switch (opt->shortname)
255 experimental_features_global_b = true;
256 global_lookup_l = &ps_lookup;
259 outname_str = oparser.optional_argument_ch_C_;
266 find_quarts_global_b = true;
269 global_path.push (oparser.optional_argument_ch_C_);
272 init_str = oparser.optional_argument_ch_C_;
282 version_ignore_global_b = true;
285 dependency_global_b = true;
291 no_paper_global_b = true;
294 no_timestamps_global_b = true;
302 default_outname_base_global = "lelie";
308 while ((arg= oparser.get_next_arg ()))
312 f = distill_inname_str (f, i);
314 default_outname_base_global = "-";
318 split_path (f, a, b, c, d);
319 default_outname_base_global = c;
321 if (outname_str.length_i ())
322 default_outname_base_global = outname_str;
323 if (init_str.length_i ())
333 if (init_str.length_i ())
337 default_outname_base_global = "-";
338 if (outname_str.length_i ())
339 default_outname_base_global = outname_str;
340 do_one_file (i, default_outname_base_global);
343 // return exit_status_i_;
347 main (int argc, char **argv)
349 gh_enter (argc, argv, (void(*)())main_prog);
350 return exit_status_i_;
354 urg: make input file name:
358 output: file name with added default extension. "" is stdin.
359 in reference argument: the extension. ".ly" if none
362 distill_inname_str (String name_str, String& ext_r)
364 String str = name_str;
370 split_path (str,a,b,c,ext_r);
372 // add extension if not present.
373 if (ext_r.empty_b ())
376 if (global_path.find (a+b+c+ext_r).empty_b ())