From d53a619ef343bc5a5e19699d011b873bc0cf86d8 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 22 Feb 2001 23:28:37 +0100 Subject: [PATCH] patch::: 1.3.130.jcn2 1.3.130.jcn2 ============ ////* Changed default output extension to ".lytex". * Ignore outname = ; settings in output blocks. * Revised input and output naming, now it's possible to include a directory in the output name. This should fix some input/init name related bugs. * Fixed dependencies for outdir in lilypond-book and ly2dvi. * Uniformised tags to read: Generated automatically by: . * Install make/* and stepmake/stepmake/* to enable making use of stepmake templates. * Added example mutopia makefile: make/ly.make. * Lilypond-book now writes lily-.ly files. --- CHANGES | 22 ++++ GNUmakefile.in | 4 +- VERSION | 2 +- aclocal.m4 | 5 + config.make.in | 1 + flower/file-path.cc | 67 +++++++----- flower/include/file-path.hh | 13 ++- lily/include/main.hh | 5 +- lily/include/music-output-def.hh | 3 +- lily/main.cc | 155 +++++++++++++--------------- lily/music-output-def.cc | 33 ++---- lily/paper-def.cc | 9 +- lily/paper-outputter.cc | 4 +- lily/paper-stream.cc | 14 ++- lily/performance.cc | 31 +++--- lily/scores.cc | 9 +- make/GNUmakefile | 7 +- make/ly-rules.make | 4 +- make/ly.make | 126 ++++++++++++++++++++++ make/mutopia-rules.make | 8 +- scm/tex.scm | 2 +- scripts/lilypond-book.py | 44 ++++++-- scripts/ly2dvi.py | 37 +++++-- stepmake/GNUmakefile.in | 7 +- stepmake/aclocal.m4 | 3 + stepmake/stepmake/GNUmakefile | 4 + stepmake/stepmake/generic-vars.make | 2 +- stepmake/stepmake/tex-rules.make | 4 +- 28 files changed, 431 insertions(+), 194 deletions(-) create mode 100644 make/ly.make diff --git a/CHANGES b/CHANGES index 45130da126..d58fe10b43 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,25 @@ +1.3.130.jcn2 +============ + +////* Changed default output extension to ".lytex". + +* Ignore outname = ; settings in output blocks. + +* Revised input and output naming, now it's possible to include a +directory in the output name. This should fix some input/init name +related bugs. + +* Fixed dependencies for outdir in lilypond-book and ly2dvi. + +* Uniformised tags to read: Generated automatically by: . + +* Install make/* and stepmake/stepmake/* to enable making use of +stepmake templates. + +* Added example mutopia makefile: make/ly.make. + +* Lilypond-book now writes lily-.ly files. + 1.3.130.jcn1 ============ diff --git a/GNUmakefile.in b/GNUmakefile.in index 37ac56142a..dc4b58369b 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -19,10 +19,12 @@ README_TXT_FILES = AUTHORS.txt README.txt INSTALL.txt FAQ.txt IN_FILES := $(wildcard *.in) EXTRA_DIST_FILES = lilypond-font-lock.el lilypond-mode.el vimrc VERSION $(README_FILES) $(SCRIPTS) $(IN_FILES) NON_ESSENTIAL_DIST_FILES = $(README_TXT_FILES) +INSTALLATION_DIR=$(datadir) +INSTALLATION_FILES=config.make VERSION # bootstrap stepmake: # -STEPMAKE_TEMPLATES=toplevel yolily-toplevel po +STEPMAKE_TEMPLATES=toplevel yolily-toplevel po install include $(depth)/make/stepmake.make # diff --git a/VERSION b/VERSION index dd6bf67440..a6392e0bc9 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=130 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=jcn2 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/aclocal.m4 b/aclocal.m4 index 1a095357e6..377a145e20 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,3 +1,5 @@ +dnl WARNING WARNING WARNING WARNING +dnl do not edit! this is aclocal.m4, generated from stepmake/aclocal.m4 dnl aclocal.m4 -*-shell-script-*- dnl StepMake subroutines for configure.in @@ -373,6 +375,7 @@ dnl fi ZIP="zip -r -9" # program_suffix=.exe # urg + # ROOTSEP=':' # DIRSEP='\\' # PATHSEP=';' # @@ -395,10 +398,12 @@ dnl fi # this way, you may have buildscripts/out/lilypond-profile # 'automatically' sourced from /usr/etc/profile.d/ too. # + ROOTSEP=':' DIRSEP='/' PATHSEP=':' INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c" else + ROOTSEP='/' DIRSEP='/' PATHSEP=':' LN=ln diff --git a/config.make.in b/config.make.in index 3f2ec353a2..fe73a6aa4a 100644 --- a/config.make.in +++ b/config.make.in @@ -63,6 +63,7 @@ MFMODE = @MFMODE@ METAPOST = @METAPOST@ MFPLAIN_MP = @MFPLAIN_MP@ MSGFMT = @MSGFMT@ +ROOTSEP = @ROOTSEP@ PATHSEP = @PATHSEP@ PERL = @PERL@ PYTHON = @PYTHON@ diff --git a/flower/file-path.cc b/flower/file-path.cc index 80c34db4c1..a17f47c43a 100644 --- a/flower/file-path.cc +++ b/flower/file-path.cc @@ -12,52 +12,67 @@ #include "file-path.hh" #include "flower-debug.hh" +#ifndef PATHSEP +#define PATHSEP ':' +#endif + +#ifndef ROOTSEP +#define ROOTSEP '/' +#endif + #ifndef DIRSEP #define DIRSEP '/' #endif -#ifndef PATHSEP -#define PATHSEP ':' +#ifndef EXTSEP +#define EXTSEP '.' #endif +String +Path::path () const +{ + String s; + if (!root.empty_b ()) + s = root + to_str (ROOTSEP); + if (!dir.empty_b ()) + s += dir + to_str (DIRSEP); + s += base; + if (!ext.empty_b ()) + s += to_str (EXTSEP) + ext; + return s; +} + /** @param path the original full filename @return 4 components of the path. They can be empty */ -void -split_path (String path, - String &drive, String &dirs, String &filebase, String &extension) +Path +split_path (String path) { - // peel off components, one by one. - int di = path.index_i (':'); - if (di >= 0) + Path p; + int i = path.index_i (ROOTSEP); + if (i >= 0) { - drive = path.left_str (di + 1); - path = path.right_str (path.length_i () - di -1); + p.root = path.left_str (i); + path = path.right_str (path.length_i () - i - 1); } - else - drive = ""; - di = path.index_last_i (DIRSEP); - if (di >=0) + i = path.index_last_i (DIRSEP); + if (i >= 0) { - dirs = path.left_str (di + 1); - path = path.right_str (path.length_i ()-di -1); + p.dir = path.left_str (i); + path = path.right_str (path.length_i () - i - 1); } - else - dirs = ""; - di = path.index_last_i ('.'); - if (di >= 0) + i = path.index_last_i ('.'); + if (i >= 0) { - filebase = path.left_str (di); - extension =path.right_str (path.length_i ()-di); + p.base = path.left_str (i); + p.ext = path.right_str (path.length_i () - i - 1); } else - { - extension = ""; - filebase = path; - } + p.base = path; + return p; } void diff --git a/flower/include/file-path.hh b/flower/include/file-path.hh index fdaf3e254a..898bb3939f 100644 --- a/flower/include/file-path.hh +++ b/flower/include/file-path.hh @@ -23,6 +23,17 @@ */ +class Path +{ +public: + String root; + String dir; + String base; + String ext; + + String path () const; +}; + class File_path : private Array { public: @@ -42,6 +53,6 @@ public: @return String &drive, String &dirs, String &filebase, String &extension */ -void split_path (String path, String &drive, String &dirs, String &filebase, String &extension); +Path split_path (String path); #endif diff --git a/lily/include/main.hh b/lily/include/main.hh index 401a896ad5..3d543bb01a 100644 --- a/lily/include/main.hh +++ b/lily/include/main.hh @@ -27,7 +27,6 @@ extern bool find_old_relative_b; extern int exit_status_i_; extern bool experimental_features_global_b; -extern char const* output_global_ch; extern bool dependency_global_b; extern bool verbose_global_b; @@ -42,8 +41,8 @@ extern File_path global_path; */ extern Array global_dumped_header_fieldnames; -extern String default_outname_base_global; -extern String default_outname_suffix_global; +extern String outname_global; +extern String outext_global; extern int default_count_global; extern All_font_metrics *all_fonts_global_p; diff --git a/lily/include/music-output-def.hh b/lily/include/music-output-def.hh index 503a1c8105..7d5872de6d 100644 --- a/lily/include/music-output-def.hh +++ b/lily/include/music-output-def.hh @@ -39,10 +39,9 @@ public: Global_translator *get_global_translator_p (); Translator_group *get_group_translator_p (String type) const; - String get_default_output () const; void assign_translator (SCM transdef); SCM find_translator_l (SCM name) const; - String base_output_str () ; + String outname_str () ; DECLARE_SMOBS(Music_output_def,); }; diff --git a/lily/main.cc b/lily/main.cc index 82f0e60a15..9db178b17d 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -41,13 +41,17 @@ bool no_paper_global_b = false; bool no_timestamps_global_b = false; bool find_old_relative_b = false; -char const* output_global_ch = "tex"; All_font_metrics *all_fonts_global_p; -String default_outname_base_global = "lelie"; -String outname_str_global; -String init_str_global; +String outname_global; +// Hmm: +// (lytex-scm (quote all-definitions)) +// String outext_global = "lytex"; +String outext_global = "tex"; +String init_name_global; + +// default? count int default_count_global; File_path global_path; @@ -61,7 +65,7 @@ int exit_status_i_; Getopt_long * oparser_global_p = 0; -String distill_inname_str (String name_str, String& ext_r); +Path distill_inname (String name_str); /* Internationalisation kludge in two steps: @@ -79,7 +83,7 @@ Long_option_init theopts[] = { {_i ("FILE"), "init", 'i', _i ("use FILE as init file")}, {0, "dependencies", 'M', _i ("write Makefile dependencies for every input file")}, {0, "no-paper", 'm', _i ("produce MIDI output only")}, - {_i ("BASENAME"), "output", 'o', _i ("write output to BASENAME[-x].extension")}, + {_i ("NAME"), "output", 'o', _i ("write output to NAME")}, {0, "find-old-relative", 'Q', _i ("show all changes in relative syntax")}, {0, "safe", 's', _i ("inhibit file output naming and exporting")}, {0, "no-timestamps", 'T', _i ("don't timestamp the output")}, @@ -258,53 +262,49 @@ main_prog (int, char**) cout << endl; call_constructors (); - default_outname_base_global = "lelie"; all_fonts_global_p = new All_font_metrics (global_path.str ()); - + int p=0; const char *arg ; - while ((arg= oparser_global_p->get_next_arg ())) + while ((arg = oparser_global_p->get_next_arg ()) || p == 0) { + String infile; - if (outname_str_global == "") - { - Midi_def::reset_default_count (); - Paper_def::reset_default_count (); - } - String f (arg); - String i; - f = distill_inname_str (f, i); - if (f == "-") - default_outname_base_global = "-"; + if (arg) + infile = arg; else - { - String a,b,c,d; - split_path (f, a, b, c, d); - default_outname_base_global = c; - } - if (outname_str_global.length_i ()) - default_outname_base_global = outname_str_global; - if (init_str_global.length_i ()) - i = init_str_global; + infile = "-"; + + // What/when was this supposed to do? + // It looks like it reset the outname_str_global for every new + // file, but only if user didn't specify a outname? Huh? + // if (outname_str_global == "") + { + Midi_def::reset_default_count (); + Paper_def::reset_default_count (); + } + + Path inpath = distill_inname (infile); + Path outpath = inpath; + outpath.ext = outext_global; + if (!outname_global.empty_b ()) + outpath = split_path (outname_global); + + String init; + if (!init_name_global.empty_b ()) + init = init_name_global; else - i = "init" + i; - do_one_file (i, f); + init = "init." + inpath.ext; + + /* Burp: output name communication goes through _global */ + String save_outname_global = outname_global; + outname_global = outpath.path (); + do_one_file (init, inpath.path ()); + outname_global = save_outname_global; p++; } - if (!p) - { - String i; - if (init_str_global.length_i ()) - i = init_str_global; - else - i = "init.ly"; - default_outname_base_global = "-"; - if (outname_str_global.length_i ()) - default_outname_base_global = outname_str_global; - do_one_file (i, default_outname_base_global); - } delete oparser_global_p; - exit( exit_status_i_); + exit (exit_status_i_); } @@ -330,7 +330,7 @@ main (int argc, char **argv) switch (opt->shortname_ch_) { case 'v': - version(); + version (); exit (0); // we print a version anyway. break; case 't': @@ -338,14 +338,20 @@ main (int argc, char **argv) progress_indication ("*** enabling experimental features, you're on your own now ***\n"); break; case 'o': - outname_str_global = oparser_global_p->optional_argument_ch_C_; + { + String s = oparser_global_p->optional_argument_ch_C_; + Path p = split_path (s); + if (p.ext.empty_b ()) + p.ext = outext_global; + outname_global = p.path (); + } break; case 'w': notice (); exit (0); break; case 'f': - output_global_ch = oparser_global_p->optional_argument_ch_C_; + outext_global = oparser_global_p->optional_argument_ch_C_; break; case 'Q': find_old_relative_b= true; @@ -357,7 +363,7 @@ main (int argc, char **argv) global_path.push (oparser_global_p->optional_argument_ch_C_); break; case 'i': - init_str_global = oparser_global_p->optional_argument_ch_C_; + init_name_global = oparser_global_p->optional_argument_ch_C_; break; case 'h': usage (); @@ -395,46 +401,33 @@ main (int argc, char **argv) } /** - make input file name from command arg. + Make input file name from command argument. - @input file name - - @output file name with added default extension. "" is stdin. - in reference argument: the extension. ".ly" if none + Path describes file name with added default extension, + ".ly" if none. "-" is stdin. */ -String -distill_inname_str (String name_str, String& ext_r) +Path +distill_inname (String str) { - String str = name_str; - if (str.length_i ()) + Path p = split_path (str); + if (str.empty_b () || str == "-") + p.base = "-"; + else { - if (str != "-") + String orig_ext = p.ext; + char const *extensions[] = {"ly", "fly", "sly", "", 0}; + for (int i = 0; extensions[i]; i++) { - String a,b,c; - split_path (str,a,b,c,ext_r); - - // add extension if not present. - char const* extensions[] = {"", ".ly", ".fly", ".sly", "", 0}; - extensions[0] = ext_r.ch_C (); - for (int i = 0; extensions[i]; i++) - { - if (!global_path.find (a+b+c+extensions[i]).empty_b ()) - { - ext_r = extensions[i]; - break; - } - } - str = a+b+c+ext_r; - // in any case, assume (init).ly - if (!ext_r.length_i ()) - ext_r = ".ly"; + p.ext = orig_ext; + if (*extensions[i] && !p.ext.empty_b ()) + p.ext += "."; + p.ext += extensions[i]; + if (!global_path.find (p.path ()).empty_b ()) + break; } + /* Reshuffle extension */ + p = split_path (p.path ()); } - else - { - str = "-"; - ext_r = ".ly"; - } - return str; + return p; } diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index fbb2e12ba8..bf46b4645c 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -15,6 +15,7 @@ #include "global-translator.hh" #include "translator-def.hh" #include "main.hh" +#include "file-path.hh" #include "lily-guile.hh" #include "ly-smobs.icc" @@ -120,20 +121,6 @@ Music_output_def::get_global_translator_p () return dynamic_cast (tg); } - - -String -Music_output_def::get_default_output () const -{ - if (safe_global_b || !scope_p_->elem_b ("output")) - return ""; - SCM s = scope_p_->scm_elem ("output"); - - return gh_string_p (s) ? ly_scm2string (s) : String (""); -} - - - int Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) { @@ -145,17 +132,15 @@ Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) ugh: should move into Music_output_def (complication: .midi and .tex need separate counts.) */ String -Music_output_def::base_output_str () +Music_output_def::outname_str () { - String str = get_default_output (); - - if (str.empty_b ()) + String out = outname_global; + int def = get_next_default_count (); + if (def) { - str = default_outname_base_global; - int def = get_next_default_count (); - if (def) - str += "-" + to_str (def); + Path p = split_path (out); + p.base += "-" + to_str (def); + out = p.path (); } - - return str; + return out; } diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 12f787a633..063051f595 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -105,16 +105,15 @@ Paper_def::reset_default_count() Paper_outputter* Paper_def::paper_outputter_p () { - String basename = base_output_str (); - String outname = basename; - if (outname != "-") - outname += String (".") + output_global_ch; + String outname = outname_str (); progress_indication (_f ("paper output to %s...", outname == "-" ? String ("") : outname)); target_str_global_array.push (outname); Paper_outputter * po = new Paper_outputter (outname); - po->basename_ = basename; + Path p = split_path (outname); + p.ext = ""; + po->basename_ = p.path (); return po; } diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 1c55022e84..7afa06e812 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -41,7 +41,7 @@ Paper_outputter::Paper_outputter (String name) lilypond -f scm x.ly guile -s x.scm */ - verbatim_scheme_b_ = output_global_ch == String ("scm"); + verbatim_scheme_b_ = outext_global == "scm"; if (verbatim_scheme_b_) { @@ -74,7 +74,7 @@ Paper_outputter::output_header () gh_define ("security-paranoia", SCM_BOOL_T); } - SCM exp = gh_list (ly_symbol2scm ((String (output_global_ch) + "-scm").ch_C()), + SCM exp = gh_list (ly_symbol2scm ((outext_global + "-scm").ch_C()), ly_quote_scm (ly_symbol2scm ("all-definitions")), SCM_UNDEFINED); exp = scm_eval2 (exp, SCM_EOL); diff --git a/lily/paper-stream.cc b/lily/paper-stream.cc index 86f2ee5de8..b15e262892 100644 --- a/lily/paper-stream.cc +++ b/lily/paper-stream.cc @@ -6,10 +6,14 @@ (c) 1997--2000 Han-Wen Nienhuys */ +#include +#include +#include #include #include "main.hh" #include "paper-stream.hh" +#include "file-path.hh" #include "debug.hh" const int MAXLINELEN = 200; @@ -18,8 +22,14 @@ ostream * open_file_stream (String filename) { ostream *os; - if (filename.length_i () && (filename != "-")) - os = new ofstream (filename.ch_C ()); + if (!filename.empty_b () && (filename != "-")) + { + Path p = split_path (filename); + if (!p.dir.empty_b ()) + if (mkdir (p.dir.ch_C (), 0777) == -1 && errno != EEXIST) + error (_f ("can't create directory: `%s'", p.dir)); + os = new ofstream (filename.ch_C ()); + } else os = new ostream (cout._strbuf); if (!*os) diff --git a/lily/performance.cc b/lily/performance.cc index 9da4c7dc38..53d223c7d2 100644 --- a/lily/performance.cc +++ b/lily/performance.cc @@ -20,6 +20,7 @@ #include "performance.hh" #include "score.hh" #include "file-results.hh" +#include "file-path.hh" #include "lily-version.hh" #include "killing-cons.tcc" @@ -74,11 +75,13 @@ Performance::output_header_track (Midi_stream& midi_stream) Midi_track midi_track; // perhaps multiple text events? + String id_str; String str = String (_("Creator: ")); if (no_timestamps_global_b) - str += gnu_lilypond_str (); + id_str = gnu_lilypond_str (); else - str += gnu_lilypond_version_str(); + id_str = gnu_lilypond_version_str(); + str += id_str; str += "\n"; /* @@ -89,7 +92,8 @@ Performance::output_header_track (Midi_stream& midi_stream) Midi_text creator (&creator_a); midi_track.add (Moment (0), &creator); - str = _("Automatically generated"); + str = _("Generated automatically by: "); + str += id_str; if (no_timestamps_global_b) str += ".\n"; else @@ -141,20 +145,15 @@ Performance::add_element (Audio_element *p) void Performance::process() { - String out = midi_l_->get_default_output (); - if (out.empty_b ()) + String out = outname_global; + if (out == "-") + out = "lelie.midi"; + int def = midi_l_->get_next_default_count (); + if (def) { - - out = default_outname_base_global; - if (out == "-") - out = "lelie"; - int def = midi_l_->get_next_default_count (); - if (def) - { - out += "-" + to_str (def); - } - - out += ".midi"; + Path p = split_path (out); + p.base += "-" + to_str (def); + out = p.path (); } Midi_stream midi_stream (out); diff --git a/lily/scores.cc b/lily/scores.cc index 84e9891994..894a6a46c3 100644 --- a/lily/scores.cc +++ b/lily/scores.cc @@ -32,13 +32,13 @@ void write_dependency_file (String fn, Array targets, { const int WRAPWIDTH = 65; - progress_indication (_f ("Writing dependency file: `%s'...", fn.ch_C ())); + progress_indication (_f ("dependencies output to %s...", fn.ch_C ())); progress_indication ("\n"); ofstream f (fn.ch_C ()); if (!f) warning (_f ("can't open file: `%s'", fn)); - f << "# Automatically generated by " << gnu_lilypond_version_str () << '\n'; + f << "# Generated automatically by: " << gnu_lilypond_version_str () << '\n'; String out; for (int i=0; i < targets.size (); i ++) out += targets[i] + " "; @@ -60,7 +60,10 @@ do_deps() { if (dependency_global_b) { - write_dependency_file (default_outname_base_global + ".dep", target_str_global_array, + Path p = split_path (outname_global); + p.ext = "dep"; + write_dependency_file (p.path (), + target_str_global_array, inclusion_global_array); } } diff --git a/make/GNUmakefile b/make/GNUmakefile index b4e188d328..e62590a7c8 100644 --- a/make/GNUmakefile +++ b/make/GNUmakefile @@ -1,8 +1,11 @@ # file make/Makefile depth = .. -STEPMAKE_TEMPLATES=makedir -BLURBS=BLURB # COPERTINA FLAPTEKST +STEPMAKE_TEMPLATES=makedir install +##BLURBS=BLURB # COPERTINA FLAPTEKST + +INSTALLATION_DIR=$(datadir)/make +INSTALLATION_FILES=$(DIST_FILES) include $(depth)/make/stepmake.make diff --git a/make/ly-rules.make b/make/ly-rules.make index 49a0f6dd12..ea199bca79 100644 --- a/make/ly-rules.make +++ b/make/ly-rules.make @@ -5,7 +5,7 @@ $(outdir)/%.latex: %.doc rm -f $@ - LILYPONDPREFIX=$(LILYPONDPREFIX)/.. $(PYTHON) $(script-dir)/lilypond-book.py --outdir=$(outdir) -I $(pwd) -I $(input-dir)/tricks/ -I $(input-dir)/regression/ -I $(input-dir)/test/ --dependencies --dep-prefix=$(outdir)/ $< + LILYPONDPREFIX=$(LILYPONDPREFIX)/.. $(PYTHON) $(script-dir)/lilypond-book.py --outdir=$(outdir) -I $(pwd) -I $(input-dir)/tricks/ -I $(input-dir)/regression/ -I $(input-dir)/test/ --dependencies $< chmod -w $@ # don't do ``cd $(outdir)'', and assume that $(outdir)/.. is the src dir. @@ -19,7 +19,7 @@ $(outdir)/%.texi: %.tely # for plain info doco: don't run lily $(outdir)/%.nexi: %.tely rm -f $@ - LILYPONDPREFIX=$(LILYPONDPREFIX)/.. $(PYTHON) $(script-dir)/lilypond-book.py --outdir=$(outdir) --no-lily -I $(pwd) -I $(input-dir)/tricks/ -I $(input-dir)/regression/ -I $(input-dir)/test/ --dependencies --dep-prefix=$(outdir)/ --format=texi $< + LILYPONDPREFIX=$(LILYPONDPREFIX)/.. $(PYTHON) $(script-dir)/lilypond-book.py --outdir=$(outdir) --no-lily -I $(pwd) -I $(input-dir)/tricks/ -I $(input-dir)/regression/ -I $(input-dir)/test/ --dependencies --format=texi $< mv $(@D)/$(*F).texi $@ chmod -w $@ diff --git a/make/ly.make b/make/ly.make new file mode 100644 index 0000000000..0a0d8a6f2a --- /dev/null +++ b/make/ly.make @@ -0,0 +1,126 @@ +#!/usr/bin/make +# Mutopia Makefile Project +# + +# +# For testing installed lily +# +make-root=$(wildcard $(HOME)/tmp/test/usr/share/lilypond/make) +#make-root=$(wildcard $(HOME)/usr/src/lilypond/make) +make-root?=$(wildcard /usr/share/lilypond/make) + +ifneq ($(make-root),) + +depth=$(make-root)/.. +LOCALSTEPMAKE_TEMPLATES=mutopia +include $(make-root)/stepmake.make + +else + burp +# +# Minimalistic standalone part. I'd very much like to install make/* +# and stepmake/stepmake/* in /usr/share/lilypond, and junk this. +# + +outdir=out +PAPERSIZE= +LY_FILES=$(wildcard *.ly) + +default: + echo $(DEP_FILES) + $(examples) +clean: + rm -f $(outdir)/* $(outdir)-letter/* + + +# +# stepmake/stepmake/files.ly +# +DEP_FILES:=$(wildcard $(outdir)/*.dep) + +# +# stepmake/stepmake/generic-targets.make +# +include $(outdir)/dummy.dep $(DEP_FILES) + +$(outdir)/dummy.dep: + -mkdir -p $(outdir) + touch $(outdir)/dummy.dep + +# +# make/mutopia-rules.make +# + +# don't junk intermediate .dvi files. They're easier to view than +# .ps or .png +.PRECIOUS: $(outdir)/%.dvi + +# +# should we dist ps-to-pngs? +# +$(outdir)/%.png: $(outdir)/%.ps + ps-to-pngs $< + -mv $(name-stem)-page*.png $(outdir)/ + touch $@ + +$(outdir)/%.dvi: %.ly + ly2dvi --outdir=$(outdir) --dependencies $< + -mv $(basename $<)*.midi $(outdir) + +$(outdir)-$(PAPERSIZE)/%.dvi: %.ly + ly2dvi.py --outdir=$(outdir)-$(PAPERSIZE) --dependencies --papersize=$(PAPERSIZE) $< + -mv $(basename $<)*.midi $(outdir)-$(PAPERSIZE) + + +# +# stepmake/stepmake/tex-rules.make +# +$(outdir)/%.tex: %.tex + cp $< $@ + +$(outdir)/%.dvi: $(outdir)/%.tex + (cd $(outdir); tex \\nonstopmode \\input $( sys.exit (0) -def write_deps (fn, target): +def write_deps (fn, target, chunks): + global read_files sys.stdout.write('writing `%s\'\n' % os.path.join(g_outdir, fn)) f = open (os.path.join(g_outdir, fn), 'w') f.write ('%s%s: ' % (g_dep_prefix, target)) - for d in __main__.read_files: + for d in read_files: f.write ('%s ' % d) + basenames=[] + for c in chunks: + if c[0] == 'lilypond': + (type, body, opts, todo, basename) = c; + basenames.append (basename) + for d in basenames: + if g_outdir: + d=g_outdir + '/' + d + f.write ('%s.tex ' % d) + f.write ('\n') + #if len (basenames): + # for d in basenames: + # f.write ('%s.ly ' % d) + # f.write (' : %s' % target) f.write ('\n') f.close () - __main__.read_files = [] + read_files = [] def identify(): sys.stdout.write ('lilypond-book (GNU LilyPond) %s\n' % program_version) @@ -1077,6 +1108,7 @@ def fix_epswidth (chunks): def do_file(input_filename): + global foutn file_settings = {} if outname: my_outname = outname @@ -1116,7 +1148,7 @@ def do_file(input_filename): # should chmod -w if do_deps: - write_deps (my_depname, foutn) + write_deps (my_depname, foutn, chunks) outname = '' diff --git a/scripts/ly2dvi.py b/scripts/ly2dvi.py index 165e63b142..3075a506fb 100644 --- a/scripts/ly2dvi.py +++ b/scripts/ly2dvi.py @@ -251,7 +251,7 @@ class TeXOutput: top= r""" %% Creator: %s -%% Automatically generated from %s, %s +%% Generated automatically by: %s, from %s, at %s \documentclass[%s]{article} @@ -276,7 +276,7 @@ class TeXOutput: \renewcommand{\@oddfoot}{\parbox{\textwidth}{\mbox{}\thefooter}}%% %s \begin{document} -""" % ( program_id(), Props.get('filename'), now, Props.get('papersize'), +""" % ( program_id(), program_id(), Props.get('filename'), now, Props.get('papersize'), Props.get('language'), Props.get('linewidth'), textheightsetting, Props.get('orientation'), Props.get('header'), Props.get('pagenumber')) @@ -926,7 +926,7 @@ def getLilyopts(): else: if Props.get('dependencies'): - dep=' -M' + dep=' --dependencies' else: dep='' return inc + dep @@ -959,6 +959,14 @@ def getTeXFile(contents): else: return texfiles +def getDepFiles (log): + files=[] + for line in string.split (log,'\n'): + m = re.search ("dependencies output to (.+)\.\.\.", line) + if m: + files.append (m.group (1)) + return files + def unc2dos(path): """ Convert a path of format ///this/that/the/other to @@ -1008,7 +1016,8 @@ Options: -h,--help this help text -k,--keeply2dvi keep ly2dvi output files -l,--language= give LaTeX language (babel) - -o,--output= set output directory + -o,--outdir= set output directory + --output= set output directory -p,--papersize= give LaTeX papersize (eg. a4) -s,--separate run all files separately through LaTeX @@ -1035,8 +1044,8 @@ def main(): 'include=', 'keeplilypond', 'landscape', 'nonumber', 'Width=', 'dependencies', 'help', 'keeply2dvi', 'language=', - 'output=', 'version', 'papersize=', 'separate', - 'postscript']) + 'outdir=', 'output=', 'version', + 'papersize=', 'separate', 'postscript']) for opt in options: o = opt[0] @@ -1066,7 +1075,7 @@ def main(): Props.setKeeply2dvi(1,'commandline') elif o == '--language' or o == '-l': Props.setLanguage(a,'commandline') - elif o == '--output' or o == '-o': + elif o == '--outdir' or o == '-o' or o == '--output': Props.setOutput(a,'commandline') elif o == '--papersize' or o == '-p': Props.setPaperZize(a,'commandline') @@ -1117,6 +1126,7 @@ def main(): if stat: sys.exit('ExitBadLily', cmd ) texFiles=getTeXFile(log) + depFiles=getDepFiles (log) writeLilylog(file,log) Props.addLilyOutputFiles(texFiles,'program') texInputFiles = texInputFiles + texFiles @@ -1143,6 +1153,19 @@ def main(): firstfile=0 if not Props.get('separate'): outfile.end() + + # --outdir mess + if Props.get ('output'): + outdir=Props.get ('output') + for i in depFiles: + text=open (i).read () + # brr + # text=re.sub ('\n([^:]*:)', '\n' + outdir + '/\\1', text) + text=re.sub ('\n([^:]*).tex', '\n' + outdir + '/\\1.dvi', text) + text=re.sub (' ([^:]*).tex', ' ' + outdir + '/\\1.dvi', text) + open (os.path.join (outdir, i), 'w').write (text) + os.remove (i) + else: help() sys.exit('ExitBadArgs','No files specified') diff --git a/stepmake/GNUmakefile.in b/stepmake/GNUmakefile.in index 349ff922af..a50edb862e 100644 --- a/stepmake/GNUmakefile.in +++ b/stepmake/GNUmakefile.in @@ -11,7 +11,7 @@ depth = . ifeq ($(PACKAGE),STEPMAKE) SUBDIRS = bin make stepmake else -SUBDIRS = +SUBDIRS = stepmake endif # @@ -30,12 +30,15 @@ STEPMAKE_TEMPLATES=toplevel texinfo include $(depth)/make/stepmake.make # +# 2nd: THIS IS NO MISTAKE +# this makes lilypond's make dist descent into stepmake +# should check if we can remove the above # descent order into subdirectories: # ifeq ($(PACKAGE),STEPMAKE) SUBDIRS = bin make stepmake else -SUBDIRS = +SUBDIRS = stepmake endif # diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4 index 1a095357e6..f5ba556edd 100644 --- a/stepmake/aclocal.m4 +++ b/stepmake/aclocal.m4 @@ -373,6 +373,7 @@ dnl fi ZIP="zip -r -9" # program_suffix=.exe # urg + # ROOTSEP=':' # DIRSEP='\\' # PATHSEP=';' # @@ -395,10 +396,12 @@ dnl fi # this way, you may have buildscripts/out/lilypond-profile # 'automatically' sourced from /usr/etc/profile.d/ too. # + ROOTSEP=':' DIRSEP='/' PATHSEP=':' INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c" else + ROOTSEP='/' DIRSEP='/' PATHSEP=':' LN=ln diff --git a/stepmake/stepmake/GNUmakefile b/stepmake/stepmake/GNUmakefile index 7bdbd3c278..bb2a1c72c4 100644 --- a/stepmake/stepmake/GNUmakefile +++ b/stepmake/stepmake/GNUmakefile @@ -16,6 +16,10 @@ STEPMAKE_TEMPLATES=makedir install # -include $(depth)/make/stepmake.make +ifeq ($(PACKAGE),STEPMAKE) INSTALLATION_DIR=$(datadir)/stepmake +else +INSTALLATION_DIR=$(dir $(datadir))/$(package)/stepmake/stepmake +endif INSTALLATION_FILES=GNUmakefile $(MAKE_FILES) diff --git a/stepmake/stepmake/generic-vars.make b/stepmake/stepmake/generic-vars.make index e8e6cc6162..37f75620bf 100644 --- a/stepmake/stepmake/generic-vars.make +++ b/stepmake/stepmake/generic-vars.make @@ -137,7 +137,7 @@ endif # substitute $(STRIP) in Site.make if you want stripping DO_STRIP=true -LOOP=$(foreach i, $(SUBDIRS), $(MAKE) PACKAGE=$(PACKAGE) -C $(i) $@ &&) true +LOOP=$(foreach i, $(SUBDIRS), $(MAKE) PACKAGE=$(PACKAGE) package=$(package) -C $(i) $@ &&) true # different redhat releases need different flags for etags. Just use defaults. ETAGS_FLAGS= # -CT diff --git a/stepmake/stepmake/tex-rules.make b/stepmake/stepmake/tex-rules.make index ffbaf5ba24..c5da9738cd 100644 --- a/stepmake/stepmake/tex-rules.make +++ b/stepmake/stepmake/tex-rules.make @@ -14,8 +14,8 @@ $(outdir)/%.dvi: $(outdir)/%.latex latex \\nonstopmode \\input $(