- (let* ((write-file (lambda (str-port ext)
- (let* ((name (format "~a-systems.~a" basename ext))
- (port (open-output-file name)))
- (ly:message (_ "Writing ~a...") name)
- (display (get-output-string str-port) port)
- (close-output-port port))))
- (tex-system-port (open-output-string))
- (texi-system-port (open-output-string))
- (count-system-port (open-output-string))
- (widened-stencils (widen-left-stencil-edges stencils))
- (counted-systems (count-list widened-stencils))
- (eps-files (map dump-counted-stencil counted-systems)))
- (if do-pdf
- ;; par-for-each: a bit faster ...
- (for-each (lambda (y)
- (postscript->pdf 0 0 y))
- eps-files))
- (for-each (lambda (c)
- (if (< 0 c)
- (display (format
- "\\ifx\\betweenLilyPondSystem \\undefined
+ ;; First, create the output, then if necessary, individual staves and
+ ;; finally write some auxiliary files if desired
+ (dump-infinite-stack-EPS stencils)
+ (postprocess-output book framework-eps-module (ly:output-formats)
+ basename
+ (format #f "~a.eps" basename)
+ #t)
+
+ ;; individual staves (*-1.eps etc.); only print if more than one stencil
+ ;; Otherwise the .eps and the -1.eps file will be identical and waste space
+ ;; Also always create if aux-files=##t
+ (if (or create-aux-files (< 1 (length stencils)))
+ (let* ((widened-stencils (widen-left-stencil-edges stencils))
+ (counted-systems (count-list widened-stencils))
+ (eps-files (map dump-counted-stencil counted-systems)))
+ (if do-pdf
+ ;; par-for-each: a bit faster ...
+ (for-each (lambda (y) (postscript->pdf 0 0
+ (dir-basename y ".eps")
+ y #t))
+ eps-files))))
+
+ ;; Now, write some aux files if requested: .texi, .tex and .count
+ ;; for direct inclusion into latex and texinfo
+ (if create-aux-files
+ (let* ((write-file (lambda (str-port ext)
+ (if create-aux-files
+ (let* ((name (format #f "~a-systems.~a" basename ext))
+ (port (open-output-file name)))
+ (ly:message (_ "Writing ~a...") name)
+ (display (get-output-string str-port) port)
+ (close-output-port port)))))
+ (tex-system-port (open-output-string))
+ (texi-system-port (open-output-string))
+ (count-system-port (open-output-string)))
+ (for-each (lambda (c)
+ (if (< 0 c)
+ (format tex-system-port
+ "\\ifx\\betweenLilyPondSystem \\undefined