[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DOCS: include a sample "Makefile"?
From: |
John Mandereau |
Subject: |
Re: DOCS: include a sample "Makefile"? |
Date: |
Fri, 15 May 2009 12:55:08 +0200 |
User-agent: |
Thunderbird 2.0.0.21 (X11/20090320) |
Jonathan Kulp a écrit :
Thanks for looking at this, John. I've gone through the two makefiles
and updated according to your advice, and have also made changes based
on recommendations in the GNU Make Manual, such as specifying the
shell and defining unusual utilities in variables (viewer as
"acroread" in this case). I found that the only situation where && did
not work in place of ; was in the "for" loop I use in creating the
parts of the stamitz symphony.
I had not read the makefile for Stamitz symphony. Peter made sensible
remarks and proposal,
here are also some detailed comments you could play with. Note that I
might be mistaken
with which subdirectory contain which input or output file.
SHELL=/bin/sh
FILE=stamitz
MASTER_FILE might be clearer
OUTDIR=PDF
VIEWER=acroread
LILY_CMD=lilypond -ddelete-intermediate-files -dno-point-and-click
MAKE_SCORE=cd Scores && $(LILY_CMD) $(FILE).ly
MAKE_PARTS=cd Parts && for LILYFILE in *.ly ; do $(LILY_CMD)
"$$LILYFILE" ; done
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.
.PHONY: parts midi
It misses score and possibly other target names.
score:
$(MAKE_SCORE)
$(DELIVER_SCORE)
$(PREVIEW)
This should the generic PDF rule below (so you no longer need MAKE_SCORE),
and DELIVER_SCORE and PREVIEW are used only once, so you can avoid
defining them too (DELIVER_SCORE is even no longer necessary with the
pattern rule):
###
score: $(OUTDIR)/$(FILE).pdf
$(PREVIEW)$(VIEWER) $< &
###
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.
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))
###
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 ...".
Finally, the makefile misses mention of some input file prerequisites,
e.g. Notes/*.ly.
Here's a starting point:
###
INCLUDED_LYS = $(wildcard Notes/*.ly)
$(OUTDIR)/$(FILE).pdf
###
Happy makefile hacking,
John
- Re: DOCS: include a sample "Makefile"?, (continued)
- Re: DOCS: include a sample "Makefile"?, Cameron Horsburgh, 2009/05/13
- Re: include a sample "Makefile"?, Trevor Daniels, 2009/05/13
- Re: DOCS: include a sample "Makefile"?, Graham Percival, 2009/05/13
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/13
- Re: DOCS: include a sample "Makefile"?, Graham Percival, 2009/05/14
- Re: DOCS: include a sample "Makefile"?, Valentin Villenave, 2009/05/14
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/14
- Re: DOCS: include a sample "Makefile"?, John Mandereau, 2009/05/14
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/14
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/15
- Re: DOCS: include a sample "Makefile"?,
John Mandereau <=
- Re: DOCS: include a sample "Makefile"?, Reinhold Kainhofer, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, John Mandereau, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, Anthony W. Youngman, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/15