[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Makefile document improvement

From: foxfanfare
Subject: Makefile document improvement
Date: Sun, 15 Mar 2020 04:31:10 -0700 (MST)

Hi all,

I'm currently learning the use of Makefile and how to automate the creation
of lilypond files. In the process, it's important to keep a clean repertory
structure, as suggested in the documentation

However, I had problems when generating some midi files when you want them
to be placed automatically in the appropriate folder. The documentation
suggests this code:

# The pattern rule to create PDF and MIDI files from a LY input file.
# The .pdf output files are put into the `PDF' subdirectory, and the
# .midi files go into the `MIDI' subdirectory.
%.pdf %.midi:
        $(LILY_CMD) $<; \           # this line begins with a tab
        if test -f "$*.pdf"; then \
            mv "$*.pdf" PDF/; \
        fi; \
        if test -f "$*.midi"; then \
            mv "$*.midi" MIDI/; \

But if you have a bookoutputname set in your .ly file (for instance if you
want multiple midi files within the same file), this code won't work because
the midi file name won't match the original *.ly name and the generated
files will stay at the root folder. After some time thinking about that
problem (I'm not a bash expert at all), I came to this solution:

%.pdf %.midi:
        $(LILY_CMD) $<; \           # this line begins with a tab
          for file in *; do \
            if [[ $$file == *.pdf ]]; then \
              mv $$file PDF/; \
            fi; \
            if [[ $$file == *.midi ]]; then \
              mv $$file MIDI/; \
            fi; \

What do you think, would it be a good idea to update the example in the
documentation or not?

Sent from:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]