John Mandereau wrote:
MASTER_FILE might be clearer
Ok I've changed this.
Shell loops can often be replaced with source wildcards and pattern
rules, which takes advantage of several make implementations (including
GNU), especially concurrency: with the increasing number of multi-core
CPUs present in computers (even recent Intel Atoms in netbooks have two
cores), this really matters. I propose to address this with targets
'first' to 'fourth' below. Of course '-j' option should be used to
enable parallel building.
This is great, John! Man, I was trying to do some of the stuff you
mentioned below and my head was swimming, but then I looked this topic
up in the GNU Make Manual and it's perfect for building the parts and
the separate movements. Here's the revised, much more elegant parts target:
parts:
$(LILY_CMD) $(wildcard Parts/*.ly)
mv *.pdf $(OUTDIR)/
.PHONY: parts midi
It misses score and possibly other target names.
Yes, I only put those two because the other targets weren't having the
"already up-to-date" problem on the Mac platform. I've gone ahead and
added all targets to the .PHONY line anyway, for the sake of form.
first:
$(LILY_CMD) Scores/$(FILE)I.ly
mv $(FILE)I.pdf $(OUTDIR)/
$(VIEWER) $(OUTDIR)/$(FILE)I.pdf &
You define this command sequence four times, which is not very
maintainable.
Right, this is something I did for my own use, which I wouldn't do in
the finished product for sharing with others. The idea was to be able
to select which movement to build easily if I were still working on
individual movements. "make first" seemed to me a very nice way to build
the first movement, while not building all the others.
I suggest something like the following — it's untested, I leave
softening rough edges
and checking whether it uses GNU extensions up to you.
###
$(OUTDIR)/%.pdf: Scores/%.ly
$(LILY_CMD) $<
mv $*.pdf $(OUTDIR)
$(VIEWER) $@
# necessary to include newline in the variable value
define movement_pdf_target
mv$(1): $(OUTDIR)/$(FILE)$(1).pdf
endef
MOVEMENTS=I II III IV
# define targets mvI ... mvIV
# maybe need to be surrounded by $(eval ...)
$(foreach m, MOVEMENTS, $(call movement_pdf_target,$(m))
parts: $(foreach m, MOVEMENTS, mv$(m))
Whew, this would take some time to digest. I found it easier to build
all movements at once the same way as the parts:
movements:
$(LILY_CMD) $(wildcard Scores/$(MASTER_FILE)I*.ly)
mv *.pdf $(OUTDIR)/
This works perfectly and is much easier for me to understand. :)
I'm curious about what you were trying to show me, though, and will try
to digest it when I have a bigger chunk of time.
###
Also, some people prefer not to call the viewer by default, but that's
personal taste and depends on your viewer. One possibility is to enclose viewer
commands
within a 'ifneq ($(NOAUTOVIEW),)' block, so that viewer calls can be
disabled
by calling "make NOAUTOVIEW=1 ...".
Yes, I only called the viewer for the full score and for the "first"
"second" and so forth. It would be very annoying to have the windows
popping open after every part was compiled. I'll see if I can create the
no-viewer option, though.
Finally, the makefile misses mention of some input file prerequisites,
e.g. Notes/*.ly.
Here's a starting point:
###
INCLUDED_LYS = $(wildcard Notes/*.ly)
What does this do? I didn't realize I would need to specify that there
were included files. Is this just a courtesy to someone looking at the
makefile to tell them where the included files are? I suppose I could
use a variable like that to make sure the files were included if I were
to run convert-ly on the whole archive, too.
$(OUTDIR)/$(FILE).pdf
###
Happy makefile hacking,
John
Thanks. I'm having fun. :)
Jon
p.s. copying the whole makefile below so you can view changes in context
--
Jonathan Kulp
http://www.jonathankulp.com
###
SHELL=/bin/sh
MASTER_FILE=stamitz
OUTDIR=PDF
VIEWER=acroread
LILY_CMD=lilypond -ddelete-intermediate-files -dno-point-and-click
INCLUDED_LYS = $(wildcard Notes/*.ly)
PREVIEW=$(VIEWER) $(OUTDIR)/$(MASTER_FILE).pdf &
.PHONY: score movements parts midi
all: score movements parts midi
score:
$(LILY_CMD) Scores/$(MASTER_FILE).ly
mv $(MASTER_FILE).pdf $(OUTDIR)/
$(PREVIEW)
movements:
$(LILY_CMD) $(wildcard Scores/$(MASTER_FILE)I*.ly)
mv *.pdf $(OUTDIR)/
parts:
$(LILY_CMD) $(wildcard Parts/*.ly)
mv *.pdf $(OUTDIR)/
midi:
$(LILY_CMD) Scores/$(MASTER_FILE)MIDI.ly
mv *.midi MIDI/
cd MIDI && mv stamitzMIDI.midi stamitz-I.midi && \
mv stamitzMIDI-1.midi stamitz-II.midi && \
mv stamitzMIDI-2.midi stamitz-III.midi && \
mv stamitzMIDI-3.midi stamitz-IV.midi
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel