[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DOCS: include a sample "Makefile"?
From: |
Werner LEMBERG |
Subject: |
Re: DOCS: include a sample "Makefile"? |
Date: |
Sun, 17 May 2009 19:10:47 +0200 (CEST) |
> INPUTS= $(wildcard *.ly)
IMHO, exactly THIS statement should be replaced with an explicit list
of all input files so that you can disable or enable files at your
wish. Using the `\' character to suppress the end of line, you can
structure this very nicely:
INPUTS = \
foo-a.ly \
foo-b.ly \
\
bar-x.ly \
bar-y.ly \
...
If you are using GNU make, this can be also stated as
INPUTS += foo-a.ly
INPUTS += foo-b.ly
...
which makes it very easy to comment out the unused lines.
> if I run "make score" again (while there's a current pdf output of
> the file in the PDF dir), instead of saying it's up-to-date, it
> compiles the file again. Can you tell me which part of the makefile
> keeps track of the pdf output?
>
> [...]
>
> .ly.pdf:
> ${LILY_CMD} $<
>
> %.pdf %.midi: %.ly
Hmm. You give the same (well, almost the same) rule twice. This
old-fashioned (but fully portable) suffix rule
.x.y:
foo
is the same as this GNU make pattern rule:
%.x: %.y
foo
However, this pattern rule
%.pdf %.midi: %.ly
foo
says that both %.pdf and %.midi depend on %.ly, and `foo' generates
them both with a single invocation. (You can't express this with an
old-fashioned suffix rule). Having only
%.pdf %.midi: %.ly
$(LILY_CMD) $<
is thus sufficient.
One thing is still missing: The makefile must find the botu the input
and output files to check whether something needs to be remade. This
explicit rule:
score: PDF/${piece}.pdf
$(LILY_CMD) Scores/${piece}.ly
mv ${piece}.pdf PDF/
directly mentions that the output file is created in the `PDF'
subdirectory. The above pattern rule doesn't know that. This is the
reason why your files are made again and again if you use the `score'
target.
The solution to this problem is to use the special VPATH variable of
`make' which lists the directories for both targets and prerequisites.
A limitation is that the directories in `VPATH' are not expanded and
must be given directly (this seems to be undocumented; I'll contact
the GNU make people):
VPATH = /your/dir/Scores /your/dir/PDF
%.pdf %.midi: %.ly
cd PDF; $(LILY_CMD) $<
Note that you can't say
%.pdf %.midi: %.ly
cd PDF
$(LILY_CMD) $<
since `make' invokes the shell for each line separately, so the second
command doesn't see the `cd PDF' at all.
Finally, the `score' target can be simplified to
score: $(piece).pdf
The pattern rule does the rest.
> Also, what is the significance of the curly braces instead of
> parentheses in ${piece}?
Both do exactly the same.
See below for something which works fine for me.
Werner
======================================================================
piece = stamitz
LILY_CMD = lilypond -ddelete-intermediate-files \
-dno-point-and-click
.SUFFIXES: .ly .pdf .midi
VPATH = /your/dir/Scores /your/dir/PDF
%.pdf %.midi: %.ly
cd PDF; $(LILY_CMD) $<
.PHONY: score
score: ${piece}.pdf
- Re: DOCS: include a sample "Makefile"?, (continued)
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/15
- Re: DOCS: include a sample "Makefile"?, Anthony W. Youngman, 2009/05/16
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/16
- Re: DOCS: include a sample "Makefile"?, John Mandereau, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Peter Chubb, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/17
- Re: DOCS: include a sample "Makefile"?,
Werner LEMBERG <=
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Peter Chubb, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/17
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/18
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/18
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/18
- Re: DOCS: include a sample "Makefile"?, Werner LEMBERG, 2009/05/18
- Re: DOCS: include a sample "Makefile"?, Jonathan Kulp, 2009/05/18