]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.146
authorfred <fred>
Wed, 27 Mar 2002 01:02:26 +0000 (01:02 +0000)
committerfred <fred>
Wed, 27 Mar 2002 01:02:26 +0000 (01:02 +0000)
18 files changed:
Documentation/user/GNUmakefile
Documentation/user/lilypond.tely
Documentation/user/ly2dvi.itexi
Documentation/user/preface.itely
NEWS
input/bugs/lyrics-bar.ly [new file with mode: 0644]
lily/system-start-delimiter.cc
ly/generate-interface-doc.ly [new file with mode: 0644]
make/lilypond-vars.make
make/lilypond.spec.in
make/ly-rules.make
make/ly.make
make/mutopia-rules.make
mf/feta-generic.mf
mf/feta-timesig.mf
scm/documentation-lib.scm
scm/generate-interface-doc.scm [new file with mode: 0644]
scripts/ly2dvi.py

index 08a4b139c5f009ec8efee3a497397a8645097d92..d36ffe5d6db94c569910b46d7665f2f9a995c601 100644 (file)
@@ -46,7 +46,7 @@ $(outdir)/%.info: $(outdir)/%.texi
 default: 
 
 # Info is now built by default via texinfo-rules.
-# We must build them by defaulbt, otherwise they get built during make install
+# We must build them by default, otherwise they get built during make install
 info: $(INFO_FILES)
 
 
@@ -115,14 +115,27 @@ local-clean:
        rm -f fonts.aux fonts.log feta*.tfm feta*.*pk 
        rm -rf $(outdir)/lilypond $(outdir)/lilypond-internals
 
-# when cross-compiling, we don't have lilypond
+$(outdir)/lilypond.nexi: $(outdir)/interfaces.itexi
+$(outdir)/lilypond.texi: $(outdir)/interfaces.itexi
+
+# Rules for the automatically generated documentation
+# When cross-compiling, we don't have lilypond, so we fake
 ifneq ($(CROSS),yes)
-$(outdir)/lilypond-internals.nexi $(outdir)/lilypond-internals.texi:
+dummy:
+$(outdir)/lilypond-internals.nexi $(outdir)/lilypond-internals.texi: dummy
        cd $(outdir) && ../$(depth)/$(builddir)/lily/$(outconfbase)/lilypond ../$(src-depth)/ly/generate-documentation
        -ln $(outdir)/lilypond-internals.texi $(outdir)/lilypond-internals.nexi
+
+$(outdir)/interfaces.itexi: dummy
+       cd $(outdir) && ../$(depth)/$(builddir)/lily/$(outconfbase)/lilypond ../$(src-depth)/ly/generate-interface-doc
+
 else
+
 $(outdir)/lilypond-internals.nexi $(outdir)/lilypond-internals.texi:
        touch $@
        touch $(outdir)/$(*F).nexi
+
+$(outdir)/interfaces.itexi:
+       cp dummy-interfaces.itexi $@
 endif
 
index 96f3ae35b609049d0811a75e0f633eedd6d3fd21..1c88efb3347faf465a491b07c90a336ef7094219 100644 (file)
@@ -79,7 +79,8 @@ this and other documentation.
 * Conversion tools::               Converting to lilypond source format.
 * lilypond-book::                  Interleaving text with music.
 * Internals::                      How it all works.
-* Literature::                     additional reading
+* Literature::                     Additional reading
+* Full Grob interface list::       Generated list of all Grob properties.
 * Index of internals:(lilypond-internals).  Auto generated detailed documentation.
 * Index::                          Unified index.
 * Function Index::                 Function index.
@@ -102,8 +103,9 @@ this and other documentation.
 @mbinclude ly2dvi.itexi
 @mbinclude convert-ly.itexi
 @mbinclude lilypond-book.itely
-@mbinclude convertors.itely
+@mbinclude converters.itely
 @mbinclude literature.itely
+@mbinclude interfaces.itexi
 
 @c FIXME: Index has two alphabetically sorted lists @code vs plain?
 @node Index
index e2351c5eaed81b9365fe1a2b72790db122808959..abb6dc2f2b63e17a1f0770b11a5e1c7d98ca97de 100644 (file)
@@ -15,33 +15,40 @@ one or more DVI files.
 @subsection Invoking ly2dvi
 
 @example
-        ly2dvi [options] inputfile[.ly] [....]
+ly2dvi [OPTION]... [FILE]...
 @end example
 
 @unnumberedsec Options
 
 @table @code
-@item -s,--set=@var{KEY}=@var{VAL}
-    Add @var{key}= @var{val} to the settings, overriding those specified
-in the files. Possible keys: language, latexheaders, latexpackages,
-papersizename, pagenumber, linewidth, orientation, textheight. 
-
 @item -k,--keep
     Keep the temporary directory including LilyPond and ly2dvi output
 files. The temporary directory is created in the current directory as @code{ly2dvi.dir}.
-@item -P,--postscript
-    Generate  PostScript in stead of DVI.
-@item --no-lily
-    Do not run LilyPond; useful for debugging ly2dvi.
+@item -d,--dependencies
+    Write makefile dependencies for every input file.
 @item -h,--help
     Print help.
-@item -I,--include
-    Add to the lilypond include path.
-@item -d,--dependencies
-    Make a dependency file for the output.
-@item --outdir=@var{dir}
-    Generate output (including MIDI files) in @var{dir}
-
+@item -I,--include=@var{DIR}
+    Add @var{DIR} to LilyPond's include path.
+@item -m,--no-paper
+    Produce MIDI output only.
+@item --no-lily
+    Do not run LilyPond; useful for debugging ly2dvi.
+@item -o,--output=@var{FILE}
+    Generate output to @var{FILE}.  The extension of @var{FILE} is ignored.
+@item -P,--postscript
+    Also generate PostScript output.
+@item -s,--set=@var{KEY}=@var{VAL}
+    Add @var{key}= @var{val} to the settings, overriding those specified
+in the files. Possible keys: language, latexheaders, latexpackages,
+papersize, pagenumber, linewidth, orientation, textheight.
+@item -v,--version
+Show version information 
+@item -V,--verbose
+Be verbose
+@item -w,--warranty
+Show the warranty with which GNU LilyPond comes. (It comes with 
+@strong{NO WARRANTY}!)
 @end table
 
 @subsection Titling layout
@@ -102,14 +109,22 @@ read from the @code{\paper} block, if set.
 @item linewidth
    Is read from the @code{\paper} block.  
 
-@item papersizename
-   Specify name of papersize. Is read from the @code{\paper} block.
+@item papersize
+   Specify the papersize. Is read from the @code{\paper} block.
+@end table
+
+@subsection Environment variables
+
+@table @code
+@item LANG
+selects the language for the warning messages of Ly2dvi and LilyPond.
 @end table
 
 @subsection  Bugs
 
-Assumes that settings for LilyPond are correct. Assumes that @code{cp}
-and @code{rm} are in the path.
+Assumes that @code{cp} and @code{rm} are in the path.
+
+Cannot generate @TeX{} or @code{PostScript} only.
 
 If find something that you consider a bug, please send a bugreport (See
 @ref{Bug reports}) to @email{bug-gnu-music@@gnu.org}.
index 9211d00fa3eeb40021f6e032de54ee1fbd52f6cb..20a85a9ce364ab62a9244536a296db7c2b54ed33 100644 (file)
@@ -22,10 +22,11 @@ flexibility and good documentation.  We hope you will have as much fun
 in using LilyPond as we have when hacking it.
 
 This manual was written to help you learn LilyPond, but as you might
-imagine, we don't have much to learn about it.  Therefore, we can't
-really judge whether the manual is clear for a newbie, but maybe you
-can!  So, should you find any part of the manual vague or outdated,
-please tell us your suggestions: if you don't, we'll never know.
+imagine, we ourselves don't have much to learn about it.  Therefore,
+we can't really judge whether the manual is clear for a newbie, but
+maybe you can!  So, should you find any part of the manual vague or
+outdated, please tell us your suggestions: if you don't, we'll never
+know.
 
 Han-Wen and Jan
 
diff --git a/NEWS b/NEWS
index c80c4bc83e156e683a11528ec5859ffed0441dfc..aec5cbde5094e5e6c72ad2c13ebb2dfa171c8f4c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,7 @@
 
 New features in 1.4
 
-* Finale (.etf), PMX (.pmx) and musedata import tools.
+* Finale (.etf), PMX, Musedata and Mup import tools.
 
 * Point and click functionality using emacs and Xdvi.
 
diff --git a/input/bugs/lyrics-bar.ly b/input/bugs/lyrics-bar.ly
new file mode 100644 (file)
index 0000000..26a675c
--- /dev/null
@@ -0,0 +1,45 @@
+
+%
+% Lyrics with barline colliding is fine now, BUT
+% There's an horizontal gap between staff and end bar 
+%
+
+\header{
+texidoc="
+Adding a @code{Bar_engraver} to the LyricsVoice context makes sure that
+lyrics don't collide with barlines.
+";
+}
+
+\score {
+       \context StaffGroup <
+       \notes \context Staff {
+               b1 \bar "|:"; b1 \bar ":|";
+       }
+       \lyrics\context Lyrics <
+               \context LyricsVoiceWithBars {
+%                      thisContextHasBarEngraver1  added
+                       ThisContextCertainlyHasBarEngraverAddedButThereHasBeenSomethingFunnyBefore1.  Here.
+               }
+               \context LyricsVoice {
+                       this4 one has no BarEngraverAddedToContext1
+               }
+       >
+       \notes \context Staff = SB { b1 b1 }
+       >
+       \paper {
+               linewidth = -1.0\cm;
+               \translator {
+                       \LyricsContext
+                       \accepts "LyricsVoiceWithBars";
+               }
+               \translator {
+                       \LyricsVoiceContext
+                       \consists "Bar_engraver";
+                       \name "LyricsVoiceWithBars";
+               }
+               \translator {
+                       \LyricsVoiceContext
+               }
+       }
+}
index 811a4171e35f7635e8a20743e55f4deef5aadb21..5ebe1920230bd258f6ada4118faf2d088fb643ee 100644 (file)
@@ -143,9 +143,13 @@ System_start_delimiter::staff_brace (Grob*me,Real y)
 {
 
   /*
-    FIXME: should look at afm/tfm file for dimensions.
+    FIXME:
+    * should look at afm/tfm file for dimensions.
+     (This breaks ascii-art output: it hasn't got 255 symbols)
     
-    (This breaks ascii-art output: it hasn't got 255 symbols)
+    * more glyphs (or maybe just better sized (fixed # of staff-spaces)),
+      the size mismatches with the staffs are very ugly
+         
    */
 
   // ugrhn
diff --git a/ly/generate-interface-doc.ly b/ly/generate-interface-doc.ly
new file mode 100644 (file)
index 0000000..a50eeaf
--- /dev/null
@@ -0,0 +1,5 @@
+
+%
+% Running LilyPond on this file generates the short interface doc
+%
+#(eval-string (ly-gulp-file "generate-interface-doc.scm"))
index 83f330c9fd583c1c342b851ad334f625b3256a54..2135a39c835212e8cd2a9d6c413d67f225c3d5d0 100644 (file)
@@ -22,7 +22,7 @@ ABC2LY = $(script-dir)/abc2ly.py
 CONVERT_LY = $(script-dir)/convert-ly.py
 LILYPOND = $(depth)/$(builddir)/lily/$(outconfbase)/lilypond
 LILYPOND_BOOK = $(script-dir)/lilypond-book.py
-LILYPOND_BOOK_INCLUDES = -I $(pwd) -I $(input-dir)/tricks/ -I $(input-dir)/regression/ -I $(input-dir)/test/ -I $(input-dir)/tutorial/
+LILYPOND_BOOK_INCLUDES = -I $(pwd) -I $(outdir) -I$(input-dir) -I $(input-dir)/tricks/ -I $(input-dir)/regression/ -I $(input-dir)/test/ -I $(input-dir)/tutorial/
 LY2DVI = $(script-dir)/ly2dvi.py
 PS_TO_GIFS = $(buildscript-dir)/ps-to-gifs.sh
 PS_TO_PNGS = $(buildscript-dir)/ps-to-pngs.sh
index f98142ef72300fa1287292a26ed26cc181020a3a..8916512e46def098feaaae064e975bc238799bfc 100644 (file)
@@ -124,6 +124,7 @@ fi
 %{_prefix}/bin/ly2dvi
 %{_prefix}/bin/midi2ly
 %{_prefix}/bin/lilypond-book
+%{_prefix}/bin/mup2ly
 %{_prefix}/bin/musedata2ly
 %{_prefix}/bin/pmx2ly
 %else
@@ -144,6 +145,7 @@ fi
 %{_prefix}/man/man1/midi2ly.1.gz
 %{_prefix}/man/man1/lilypond-book.1.gz
 %{_prefix}/man/man1/musedata2ly.1.gz
+%{_prefix}/man/man1/mup2ly.1.gz
 %{_prefix}/man/man1/pmx2ly.1.gz
 
 %{_prefix}/share/lilypond/
index 81b623957dbbdf91ecf245fa1c6e45aeca148d87..8c6dc1e97e57273286e854ce6dfb3564f77bfdd3 100644 (file)
@@ -33,3 +33,11 @@ $(outdir)/%.info: $(outdir)/%.nexi
 # nfo: info from non-lily texi
 #$(outdir)/%.nfo: $(outdir)/%.nexi
 #      $(MAKEINFO) --output=$(outdir)/$(*F).info $<
+
+
+#
+# Timothy's booklet
+#
+$(outdir)/%-book.ps: $(outdir)/%.ps
+       psbook $< $<.tmp
+       pstops  '2:0L@.7(21cm,0)+1L@.7(21cm,14.85cm)' $<.tmp $@
index 8355a3dc659c1b5daf74d396d50723a283f65f0e..caee2d22452b6bfee80c04e20047d3e4af64e46f 100644 (file)
@@ -57,12 +57,12 @@ examples=
 #
 mutopia-examples=$(name) $(parts)
 
-#
+# moved to ly-rules.make
 # Timothy's booklet
 #
-$(outdir)/%-book.ps: $(outdir)/%.ps
-       psbook $< $<.tmp
-       pstops '2:0L(11.45in,0.25in)+1L(11.45in,5.6in)' $<.tmp $@
+#$(outdir)/%-book.ps: $(outdir)/%.ps
+#      psbook $< $<.tmp
+#      pstops  '2:0L@.7(21cm,0)+1L@.7(21cm,14.85cm)' $<.tmp $@
 
 #
 # Catch-all target: type `make foo' to make out/foo.ps,
index a901a3be97e2e1ac2d72aa22cbf8035d785fdec4..cf3db5394388d30f203d4962a9df8db2db189fe9 100644 (file)
@@ -21,15 +21,16 @@ $(outdir)/%.ly: %.abc
        $(PYTHON) $(ABC2LY) -o $@ $< 
 
 $(outdir)/%.dvi: $(outdir)/%.ly
-       $(PYTHON) $(LY2DVI) --outdir=$(outdir) --dependencies $< 
+       $(PYTHON) $(LY2DVI) --output=$@ --dependencies $< 
 
 # don't junk intermediate .dvi files.  They're easier to view than
 # .ps or .png
 .PRECIOUS: $(outdir)/%.dvi
 
 $(outdir)/%.dvi: %.ly
-       $(PYTHON) $(LY2DVI) --outdir=$(outdir) --dependencies $< 
+       $(PYTHON) $(LY2DVI) --output=$@ --dependencies $< 
 
 $(outdir)-$(PAPERSIZE)/%.dvi: %.ly
-       $(PYTHON) $(LY2DVI) --outdir=$(outdir)-$(PAPERSIZE) --dependencies --set=papersize=$(PAPERSIZE) $< 
+       $(PYTHON) $(LY2DVI) --output=$@ --dependencies --set=papersize=$(PAPERSIZE) $< 
+
 
index 2e31f1ada84b71cd89fd3b13c2f54ccdf80ee6d2..7be674ce323fbe4c46e906dc6e432ff77b123199 100644 (file)
@@ -39,12 +39,12 @@ if test = 0:
 else:
 %      input feta-bolletjes;   
 %      input feta-banier;
-       input feta-eindelijk;
+%      input feta-eindelijk;
 %      input feta-klef;
 %      input feta-toevallig;
 %      input feta-schrift;
 %      input feta-haak;
-%      input feta-timesig;
+       input feta-timesig;
 %      input feta-pendaal;
 %      input feta-accordion;
 fi
index 488e8ea732f021a7630bd418cc9690c31ac27db5..cc22ca8ab9c2dcac57b70dfa66b93256b07dccca 100644 (file)
@@ -3,15 +3,15 @@
 % 
 % source file of the Feta (not an abbreviation of Font-En-Tja) music font
 % 
-% (c) 1998--1999 Mats Bengtsson <matsb@s3.kth.se>,
-%              Christian Mondrup <scancm@biobase.dk>
+% (c) 1998--2001 Mats Bengtsson <matsb@s3.kth.se>,
+%               Christian Mondrup <scancm@biobase.dk>
 
 fet_begingroup("timesig");
 
 def set_C_width =
        save left_width, right_width;
-       left_width# := 0.9 staff_space#;
-       right_width# := .7 staff_space#;
+       left_width# := 1.0 staff_space#;
+       right_width# := 0.8 staff_space#;
        define_pixels(left_width,right_width);
 enddef;
 
@@ -31,27 +31,28 @@ def draw_C =
        z4 = (0, -staff_space);
        z5r = (right_width - stafflinethickness, -0.4 staff_space);
        
-       penpos1(hair, 0);
+       penpos1(hair, 10);
        penpos2(stafflinethickness, 90);
        penpos3(left_fatness * staff_space, 180);
        penpos4(stafflinethickness, -90);
        penpos5(hair, -5);
+       z6l = z1l;
+       penpos6(hair, 0);
        
-       draw_bulb(-1, z1l,  z1r, bulb_rad, .8);
+       draw_bulb(-1, z6l,  z6r, bulb_rad, .8);
 
-       fill z1l{up} .. z2l{left} .. z3l{down} .. z4l{right} ..
+       fill z1l{dir (100)} .. z2l{left} .. z3l{down} .. z4l{right} ..
        simple_serif(z5l, z5r, -90) .. 
-       z4r{left} .. z3r{up} .. z2r{right} .. z1r -- cycle;
+       z4r{left} .. z3r{up} .. z2r{right} .. {dir (-80)}z1r -- cycle;
        
-%      labels(1,2,3,4,5);
-       penlabels(1,2,3,4,5);
+       penlabels(1,2,3,4,5,6);
 enddef;
 
 fet_beginchar ("4/4 meter", "C4/4", "fourfourmeter")
        set_C_width;
        set_char_box(left_width# + staff_space#, right_width# + staff_space#, 
                staff_space#, staff_space#);
-       
+
        draw_C;
 fet_endchar;
 
index b12860eeb96eb067033c893da30c110861b7bc05..02f5a5606372e443112f1e20ff8fa48027ba412b 100644 (file)
@@ -134,13 +134,23 @@ Add a ref if REF is set
    ;; prepend GNU for dir, must be unique
    "\n* GNU " name ": (" file-name ").          " name "."
    "\n@end direntry"
-   (node "Top") ",(lilypond)Index,(lilypond)Development," top
+   ;; ugh, prev and next should be settable, of course
+   (node "Top") ",(lilypond)Index,(lilypond)Full Grob interface list," top
    "\n@top"
    (texi-section 1 name #f)
    (texi-menu items-alist)
    "\n@contents"
    ))
 
+(define (itexi-file-head name file-name top items-alist)
+  (string-append
+   "@c -*-texinfo-*-"
+   (node name) ",,," top
+   (texi-section 1 name #f)
+   (texi-menu items-alist)
+   "\n@contents"
+   ))
+
 (define (context-name name)
   name)
 
diff --git a/scm/generate-interface-doc.scm b/scm/generate-interface-doc.scm
new file mode 100644 (file)
index 0000000..565f72a
--- /dev/null
@@ -0,0 +1,52 @@
+
+;;; generate-interface-doc.scm -- Generate list of all intefaces, for refman
+;;;
+;;; source file of the GNU LilyPond music typesetter
+;;; 
+;;; (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;; Jan Nieuwenhuizen <janneke@gnu.org>
+
+;;; File entry point for generated documentation
+
+;;; Running LilyPond on this file generates the documentation
+
+
+
+;; We use ly-gulp because these files live in
+;;
+;;     PATH=$LILYPONDPREFIX/scm:<datadir>/scm
+;;
+(eval-string (ly-gulp-file "documentation-lib.scm"))
+(eval-string (ly-gulp-file "engraver-documentation-lib.scm"))
+(eval-string (ly-gulp-file "backend-documentation-lib.scm"))
+
+;;(define no-copies #t)  ; from 490 to 410K, but doesn't look nice yet
+;;
+;; Also, copies of interfaces use up lots more space, but that's
+;; functional because the default property values of the interfaces
+;; are described...
+(define no-copies #f)
+
+(let* ((doc (string-append
+            (document-all-interfaces "Full Grob interface list")
+            )
+       )
+       (name "interfaces")
+       (outname (string-append name ".itexi"))
+       (out (open-output-file outname)))
+
+  (writing-wip outname)
+  (display 
+   (string-append
+    ;;(itexi-file-head
+    ;; 
+    ;; ;; we can't use (dir) and top if we're included by lilypond.tely
+    ;; "Grob interfaces" name ""
+    ;; '(
+    ;;   ("Grob interfaces" . "Grob Interfaces")
+    ;;   ))
+    doc
+    "\n")
+   out))
+
+(newline (current-error-port))
index 56de2cb14a7bf9e0497a1bc91ee1088c2572bd5c..fe178eb96d297fd18ec73098f309d08a2fc6c62d 100644 (file)
@@ -1,5 +1,13 @@
 #!@PYTHON@
-# run lily, setup LaTeX input.
+# Run lilypond, latex, dvips.
+#
+# This is the third incarnation of ly2dvi.
+#
+# Earlier incarnations of ly2dvi were written by
+# Jeffrey B. Reed<daboys@austin.rr.com> (Python version)
+# Jan Arne Fagertun <Jan.A.Fagertun@@energy.sintef.no> (Bourne shell script)
+#
+
 
 # Note: gettext work best if we use ' for docstrings and "
 # for gettextable strings
@@ -7,8 +15,20 @@
 '''
 TODO:
 
-  * check --dependencies
+  * figure out which set of command line options should make ly2dvi:
 
+      na: create tex only?  
+      na: create latex only? 
+      na: create tex and latex
+      default: create dvi only
+      na: create tex, latex and dvi
+      -P: create dvi and ps
+      na: * create ps only
+
+     etc.
+
+     for foo.ly, rename ly2dvi.dir to out-ly2dvi, foo.ly2dvi, foo.dir ?
+     
   * move versatile taglines, 
   
      \header {
@@ -73,17 +93,23 @@ extra_fields = extra_init.keys ()
 
 fields = layout_fields + extra_fields
 program_name = 'ly2dvi'
-help_summary = _("Generate .dvi with LaTeX for LilyPond")
+help_summary = _ ("Generate .dvi with LaTeX for LilyPond")
 
 include_path = ['.']
-no_lily = 0
-outdir = '.'
+lily_p = 1
+paper_p = 1
+
+output = 0
+targets = {
+       'DVI' : 0,
+       'LATEX' : 0,
+       'MIDI' : 0,
+       'TEX' : 0,
+       }
+
 track_dependencies_p = 0
 dependency_files = []
 
-# generate ps ?
-postscript_p = 0
-
 # be verbose?
 verbose_p = 0
 
@@ -221,8 +247,6 @@ def help ():
        sys.stdout.write ('\n\n')
        sys.stdout.write (_ ("Report bugs to %s") % 'bug-gnu-music@gnu.org')
        sys.stdout.write ('\n')
-       sys.exit (0)
-
 
 def setup_temp ():
        global temp_dir
@@ -238,11 +262,12 @@ def setup_temp ():
 def system (cmd, ignore_error = 0):
        if verbose_p:
                progress (_ ("Invoking `%s\'") % cmd)
-       st = os.system (cmd)
+       st = os.system (cmd) >> 8
        if st:
-               msg =  ( _ ("error: ") + _ ("command exited with value %d") % st)
+               name = re.match ('[ \t]*([^ \t]*)', cmd).group (1)
+               msg = name + ': ' + _ ("command exited with value %d") % st
                if ignore_error:
-                       sys.stderr.write (msg + ' ' + _ ("(ignored)") + ' ')
+                       warning (msg + ' ' + _ ("(ignored)") + ' ')
                else:
                        error (msg)
 
@@ -278,36 +303,51 @@ def strip_extension (f, ext):
 # END Library
 
 option_definitions = [
+       ('', 'd', 'dependencies', _ ("write Makefile dependencies for every input file")),
        ('', 'h', 'help', _ ("this help")),
-       ('KEY=VAL', 's', 'set', _ ("change global setting KEY to VAL")),
-       ('DIR', 'I', 'include', _ ("add DIR to LilyPond\'s search path")),
-       ('', 'P', 'postscript', _ ("generate PostScript output")),
-       ('', 'k', 'keep', _ ("keep all output, and name the directory ly2dvi.dir")),
+       (_ ("DIR"), 'I', 'include', _ ("add DIR to LilyPond's search path")),
+       ('', 'k', 'keep', _ ("keep all output, and name the directory %s.dir") % program_name),
        ('', '', 'no-lily', _ ("don't run LilyPond")),
+       ('', 'm', 'no-paper', _ ("produce MIDI output only")),
+       (_ ("FILE"), 'o', 'output', _ ("write ouput to FILE")),
+       # why capital P?
+       ('', 'P', 'postscript', _ ("generate PostScript output")),
+       (_ ("KEY=VAL"), 's', 'set', _ ("change global setting KEY to VAL")),
        ('', 'V', 'verbose', _ ("verbose")),
        ('', 'v', 'version', _ ("print version number")),
        ('', 'w', 'warranty', _ ("show warranty and copyright")),
-       ('DIR', '', 'outdir', _ ("dump all final output into DIR")),
-       ('', 'd', 'dependencies', _ ("write Makefile dependencies for every input file")),
        ]
 
-def run_lilypond (files):
-       opts = ''
+def run_lilypond (files, outbase, dep_prefix):
+       opts = '--output=%s.tex' % outbase
        opts = opts + ' ' + string.join (map (lambda x : '-I ' + x, include_path))
-       opts = opts + ' ' + string.join (map (lambda x : '-H ' + x, fields))
-
+       if paper_p:
+               opts = opts + ' ' + string.join (map (lambda x : '-H ' + x, fields))
+       else:
+               opts = opts + ' --no-paper'
+               
        if track_dependencies_p:
-               opts = opts + " --dependencies "
+               opts = opts + " --dependencies"
+               if dep_prefix:
+                       opts = opts + ' --dep-prefix=%s' % dep_prefix
 
        fs = string.join (files)
+
+       if not verbose_p:
+               progress ( _("Running %s...") % 'LilyPond')
+               # cmd = cmd + ' 1> /dev/null 2> /dev/null'
+       else:
+               opts = opts + ' --verbose'
        
-       system ('lilypond  %s %s ' % (opts, fs))
+       system ('lilypond %s %s ' % (opts, fs))
 
 def analyse_lilypond_output (filename, extra):
+       
+       # urg
        '''Grep FILENAME for interesting stuff, and
        put relevant info into EXTRA.'''
        filename = filename+'.tex'
-       progress (_ ("Analyzing `%s'") % filename)
+       progress (_ ("Analyzing %s...") % filename)
        s = open (filename).read ()
 
        # search only the first 10k
@@ -335,6 +375,7 @@ def find_tex_files_for_base (base, extra):
 
 def find_tex_files (files, extra):
        tfiles = []
+       
        for f in files:
                x = 0
                while 1:
@@ -457,27 +498,22 @@ def global_latex_definition (tfiles, extra):
 
        return s
 
-def do_files (fs, extra):
-
-       '''process the list of filenames in FS, using standard settings in EXTRA.
-       '''
-       if not no_lily:
-               run_lilypond (fs)
-
-       wfs = find_tex_files (fs, extra)
+def run_latex (files, outbase, extra):
+       wfs = find_tex_files ([outbase] + files[1:], extra)
        s = global_latex_definition (wfs, extra)
 
-       latex_file ='ly2dvi.out'
-       f = open (latex_file + '.tex', 'w')
+       f = open (outbase + '.latex', 'w')
        f.write (s)
        f.close ()
 
-       # todo: nonstopmode
-       system ('latex \\\\nonstopmode \\\\input %s' % latex_file)
-       return latex_file + '.dvi'
+       cmd = 'latex \\\\nonstopmode \\\\input %s' % outbase + '.latex'
+       if not verbose_p:
+               progress ( _("Running %s...") % 'LaTeX')
+               cmd = cmd + ' 1> /dev/null 2> /dev/null'
 
-def generate_postscript (dvi_name, extra):
-       '''Run dvips on DVI_NAME, optionally doing -t landscape'''
+       system (cmd)
+
+def run_dvips (outbase, extra):
 
        opts = ''
        if extra['papersize']:
@@ -486,12 +522,13 @@ def generate_postscript (dvi_name, extra):
        if extra['orientation'] and extra['orientation'][0] == 'landscape':
                opts = opts + ' -t landscape'
 
-       ps_name = re.sub (r'\.dvi', r'.ps', dvi_name)
-       system ('dvips %s -o %s %s' % (opts, ps_name, dvi_name))
-
-       return ps_name
+       cmd = 'dvips %s -o %s %s' % (opts, outbase + '.ps', outbase + '.dvi')
+       
+       if not verbose_p:
+               progress ( _("Running %s...") % 'dvips')
+               cmd = cmd + ' 2> /dev/null'
                
-
+       system (cmd)
 
 def generate_dependency_file (depfile, outname):
        df = open (depfile, 'w')
@@ -525,16 +562,21 @@ for opt in options:
                pass
        elif o == '--help' or o == '-h':
                help ()
+               sys.exit (0)
        elif o == '--include' or o == '-I':
                include_path.append (a)
        elif o == '--postscript' or o == '-P':
-               postscript_p = 1
+               targets['PS'] = 0
        elif o == '--keep' or o == '-k':
                keep_temp_dir_p = 1
        elif o == '--no-lily':
-               no_lily = 1
-       elif o == '--outdir':
-               outdir = a
+               lily_p = 0
+       elif o == '--no-paper' or o == '-m':
+               targets = {}
+               targets['MIDI'] = 0
+               paper_p = 0
+       elif o == '--output' or o == '-o':
+               output = a
        elif o == '--set' or o == '-s':
                ss = string.split (a, '=')
                set_setting (extra_init, ss[0], ss[1])
@@ -546,7 +588,10 @@ for opt in options:
                identify ()
                sys.exit (0)
        elif o == '--warranty' or o == '-w':
-               warranty ()
+               try:
+                       system ('lilypond -w')
+               except:
+                       warranty ()
                sys.exit (0)
 
 # On most platforms, this is equivalent to
@@ -555,73 +600,102 @@ def compat_abspath (path):
        return os.path.normpath (os.path.join (os.getcwd (), path))
 
 include_path = map (compat_abspath, include_path)
-files = map (compat_abspath, files) 
-outdir = compat_abspath (outdir)
 
-       
-files = map (lambda x: strip_extension (x, '.ly'), files)
+original_output = output
 
-if files:
-       setup_temp ()
-       setup_environment ()
-       
-       extra = extra_init
-       
-       dvi_name = do_files (files, extra)
+if files and files[0] != '-':
 
-       if postscript_p:
-               ps_name = generate_postscript (dvi_name, extra)
+       files = map (lambda x: strip_extension (x, '.ly'), files)
 
+       if not output:
+               output = os.path.basename (files[0])
 
+       for i in ('.dvi', '.latex', '.ly', '.ps', '.tex'):
+               output = strip_extension (output, i)
 
-       base = os.path.basename (files[0])
-       dest = base
-       type = 'foobar'
-       srcname = 'foobar'
-       
-       if postscript_p:
-               srcname = ps_name
-               dest = dest + '.ps'
-               type = 'PS'
+       files = map (compat_abspath, files) 
+
+       if os.path.dirname (output) != '.':
+               dep_prefix = os.path.dirname (output)
        else:
-               srcname = dvi_name
-               dest= dest + '.dvi'
-               type = 'DVI'
+               dep_prefix = 0
 
-       dest = os.path.join (outdir, dest)
-       midi = base + '.midi'
-       midi = os.path.join (outdir, midi)
+       reldir = os.path.dirname (output)
+       (outdir, outbase) = os.path.split (compat_abspath (output))
+       
+       setup_environment ()
+       setup_temp ()
+       
+       extra = extra_init
        
-       if outdir != '.':
+       if lily_p:
+               try:
+                       run_lilypond (files, outbase, dep_prefix)
+               except:
+                       # TODO: friendly message about LilyPond setup/failing?
+                       #
+                       # TODO: lilypond should fail with different
+                       # error codes for:
+                       #   - guile setup/startup failure
+                       #   - font setup failure
+                       #   - init.ly setup failure
+                       #   - parse error in .ly
+                       #   - unexpected: assert/core dump
+                       targets = {}
+
+       if targets.has_key ('DVI') or targets.has_key ('PS'):
+               try:
+                       run_latex (files, outbase, extra)
+                       # unless: add --tex, or --latex?
+                       del targets['TEX']
+                       del targets['LATEX']
+               except:
+                       # TODO: friendly message about TeX/LaTeX setup,
+                       # trying to run tex/latex by hand
+                       if targets.has_key ('DVI'):
+                               del targets['DVI']
+                       if targets.has_key ('PS'):
+                               del targets['PS']
+
+       # TODO: does dvips ever fail?
+       if targets.has_key ('PS'):
+               run_dvips (outbase, extra)
+
+       if outdir != '.' and (track_dependencies_p or targets.keys ()):
                system ('mkdir -p %s' % outdir)
-               
-       #if re.match ('.*[.]dvi', string.join (os.listdir ('.'))):
-       if os.path.isfile (srcname):
-               # huh, and what bout all other (-1, -2) scores?
-               system ('cp \"%s\" \"%s\"' % (srcname, dest))
-       else:
-               dest = 0
-       if re.match ('.*[.]midi', string.join (os.listdir ('.'))):
-               system ('cp *.midi %s' % outdir)
-       else:
-               midi = 0
-
-       depfile = os.path.join (outdir, base + '.dep')
 
+       # add DEP to targets?
        if track_dependencies_p:
-               generate_dependency_file (depfile, dest)
+               depfile = os.path.join (outdir, outbase + '.dep')
+               generate_dependency_file (depfile, depfile)
+               if os.path.isfile (depfile):
+                       progress (_ ("dependencies output to %s...") % depfile)
+
+       for i in targets.keys ():
+               ext = string.lower (i)
+               if re.match ('.*[.]%s' % ext, string.join (os.listdir ('.'))):
+                       system ('cp *.%s %s' % (ext, outdir))
+               outname = outbase + '.' + string.lower (i)
+               abs = os.path.join (outdir, outname)
+               if reldir != '.':
+                       outname = os.path.join (reldir, outname)
+               if os.path.isfile (abs):
+                       progress (_ ("%s output to %s...") % (i, outname))
+               elif verbose_p:
+                       warning (_ ("can't find file: `%s'") % outname)
 
        os.chdir (original_dir)
        cleanup_temp ()
-
-       # most insteresting info last
-       # don't say silly things
-       if os.path.isfile (depfile):
-               progress (_ ("dependencies output to %s...") % depfile)
-       if dest and os.path.isfile (dest):
-               progress (_ ("%s output to %s...") % (type, dest))
-       if midi and os.path.isfile (midi):
-               progress (_ ("%s output to %s...") % ('MIDI', midi))
+       
+else:
+       # FIXME
+       help ()
+       sys.stderr.write ('\n')
+       try:
+               error (_ ("no FILEs specified, can't invoke as filter"))
+       except:
+               pass
+       sys.exit (2)