During the last years I tought myself to write scores using LilyPond and furthermore to make file handling easier by using Bash scripts. Recently I started a project a little bigger than only one or two pages and once again I came across the article about Makefiles in the LilyPond Documentary.
Even though reading this article it was kinda hard for me to grasp the actual technique behind the template Makefile
also because the article does not supply the file repository it is working with.
So I though to take the time to make up an example project to ask, how a Makefile
in this scenario could look like. How I would build it step by step and how I actually run the Makefile. (Edit: referring to a make man page I got my understanding as far as being able to say that one uses make
as interpreter like bash
on a shell-script.sh
. The command then simply looks like make -f Makefile
run in the root directory of the project.)
The Project has a file-structure like this:
├── Book.ly
├── Book.pdf
├── global-files
│ ├── copyright.ily
│ ├── Frontpage.ily
│ ├── header.ily
│ └── paper.ily
├── input-files-voiceI
│ ├── Nr_01-voiceI.ily
│ ├── Nr_02-voiceI.ily
│ └── Nr_03-voiceI.ily
├── input-files-voiceII
│ ├── Nr_01-voiceII.ily
│ ├── Nr_02-voiceII.ily
│ └── Nr_03-voiceII.ily
├── README.md
├── single-pages-voiceI
│ ├── MIDI
│ │ ├── Score-Nr_01-voiceI.midi
│ │ ├── Score-Nr_02-voiceI.midi
│ │ └── Score-Nr_03-voiceI.midi
│ ├── PDF
│ │ ├── Score-Nr_01-voiceI.pdf
│ │ ├── Score-Nr_02-voiceI.pdf
│ │ └── Score-Nr_03-voiceI.pdf
│ ├── Score-Nr_01-voiceI.ly
│ ├── Score-Nr_02-voiceI.ly
│ └── Score-Nr_03-voiceI.ly
├── single-pages-voiceI_a_II
│ ├── MIDI
│ │ ├── Score-I_u_II_Nr_01.midi
│ │ ├── Score-I_u_II_Nr_02.midi
│ │ └── Score-I_u_II_Nr_03.midi
│ ├── PDF
│ │ ├── Score-I_u_II_Nr_01.pdf
│ │ ├── Score-I_u_II_Nr_02.pdf
│ │ └── Score-I_u_II_Nr_03.pdf
│ ├── Score-I_u_II_Nr_01.ly
│ ├── Score-I_u_II_Nr_02.ly
│ └── Score-I_u_II_Nr_03.ly
└── single-pages-voiceII
├── MIDI
│ ├── Score-Nr_01-voiceII.midi
│ ├── Score-Nr_02-voiceII.midi
│ └── Score-Nr_03-voiceII.midi
├── PDF
│ ├── Score-Nr_01-voiceII.pdf
│ ├── Score-Nr_02-voiceII.pdf
│ └── Score-Nr_03-voiceII.pdf
├── Score-Nr_01-voiceII.ly
├── Score-Nr_02-voiceII.ly
└── Score-Nr_03-voiceII.ly
The input-files of both voices have a format like this:
\relative c {
\clef bass
\time 3/4
\key c major
c4( d e f | %01
g1) \bar "|." | %02
}
The Score files have the purpose to be compiled for output of PDF and MIDI. and simply look like this (despite the fact that the Scores
for two systems contain another Staff
):
\version "2.18.2"
#(set-default-paper-size "a4")
#(set-global-staff-size 22)
\include "../global-files/header.ily"
\score {
\new StaffGroup = "" \with {
instrumentName = \markup { \bold \huge { \larger "1." }}
}
<<
\new Staff = "celloI" \with { midiInstrument = #"cello" }
\include "../input-files-voiceI/Nr_01-voiceI.ily"
>>
\layout {}
\midi {}
}
The Book part is the part I'm still pretty unhappy with. I would prefer this pretty simple with just using the Score*.ly
files as \includes
, but I get problems with the \includes
that are already in the Score.ly
files, since they do not only contain the \score
block to be compileable by them selfs.
Well I could use a \book
with setting a book output name like \bookOutputSuffix "OutputName"
, but then my Book.ly
would become a massive file, taking quite a long time to be compiled, even for a small change on a single piece.
So right now my Book.ly
file has the following format and the only purpose to compile the whole book with two voices in two staffs, but with all pieces, here 01-03:
\version "2.18.2"
#(set-default-paper-size "a4")
#(set-global-staff-size 22)
\include "./global-files/paper.ily"
\book {
\include "./global-files/Frontpage.ily"
%%%% Score Number: 1 ==================================%%%%
\score {
\new StaffGroup = "" \with {
instrumentName = \markup { \bold \huge { \larger "1." }}}
<<
\new Staff = "voiceI" \with { midiInstrument = #"voice" }
\include "./input-files-voiceI//Nr_01-voiceI.ily"
\new Staff = "voiceII" \with { midiInstrument = #"voice" }
\include "./input-files-voiceII//Nr_01-voiceII.ily"
>>
\layout {
\printTupletBow
}
}
%%%% Score Number: 2 ==================================%%%%
\score {
\new StaffGroup = "" \with {
instrumentName = \markup { \bold \huge { \larger "2." }}}
<<
\new Staff = "voiceI" \with { midiInstrument = #"voice" }
\include "./input-files-voiceI//Nr_02-voiceI.ily"
\new Staff = "voiceII" \with { midiInstrument = #"voice" }
\include "./input-files-voiceII//Nr_02-voiceII.ily"
>>
\layout {}
}
%%%% Score Number: 3 ==================================%%%%
\score {
\new StaffGroup = "" \with {
instrumentName = \markup { \bold \huge { \larger "3." }}}
<<
\new Staff = "voiceI" \with { midiInstrument = #"voice" }
\include "./input-files-voiceI//Nr_03-voiceI.ily"
\new Staff = "voiceII" \with { midiInstrument = #"voice" }
\include "./input-files-voiceII//Nr_03-voiceII.ily"
>>
\layout {}
}
}
My workflow is the following:
- I write the input files:
input-file.ily
- I run a
bash-script.sh
that creates the compileableScore.ly
files from theinput-files/*.ily
- I run a
bash-script.sh
that creates the compileableBook.ly
file from theinput-files/*.ily
- I compile the
Score.ly
files one by one or run a simplefor file in *.ly; do lilypond "$file"; done
loop, but in each of the three Score directories. I use a script to move the PDF and MIDI files into their corresponding folders. - I simply run
lilypond
to compile theBook.ly
file.
DONE
The actual project this question is asked for can be found here on GitHub
Update 1:
My system:
Operating System: Debian GNU/Linux bullseye/sid
Kernel: Linux 5.3.0-2-686-pae
Architecture: x86
GNU LilyPond: 2.18.2
My Editor - GNU Nano: 4.5
Guake Terminal: 3.6.3
GNU Make: 4.2.1
I added my shell-scripts
to a separate Git-Repository
Update 2:
This is a very simplified chart of the dependencies. Assuming there was only one voice
:
./infiles/
infile{01..03}.ily -------------> ./Book.ly ===> Book.pdf
| ^ ^ ^
*---------> Scores{01..03}.ly === | | |=====> Score{01..03}.pdf
^ ^ === | | |=====> Score{01..03}.midi
| | | | |
./global-files/ | | | | |
header.ily ------* | | | |
copyright.ily ---------+-------------* | |
Frontpage.ily -------------------------* |
paper.ily ---------------------------*