2015-12-01 10:29:35 +00:00
|
|
|
SHELL = /bin/sh
|
|
|
|
|
2015-12-01 10:28:02 +00:00
|
|
|
# a list of all used commands
|
2015-11-30 17:26:30 +00:00
|
|
|
LILYPOND = lilypond
|
|
|
|
LUALATEX = lualatex
|
|
|
|
MAKEINDEX = makeindex
|
|
|
|
TIMIDITY = timidity
|
|
|
|
OPUSENC = opusenc
|
|
|
|
PDF2PS = pdf2ps
|
|
|
|
PSBOOK = psbook
|
|
|
|
PSTOPS = pstops
|
|
|
|
PSNUP = psnup
|
|
|
|
PS2PDF = ps2pdf
|
2015-12-01 09:02:25 +00:00
|
|
|
SED = sed # do not use in-place editing for compatibility between different sed utilities
|
2015-11-30 17:26:30 +00:00
|
|
|
RM = rm
|
|
|
|
MKDIR = mkdir
|
|
|
|
CD = cd
|
|
|
|
CP = cp
|
|
|
|
|
2015-12-01 10:28:02 +00:00
|
|
|
MIDITEMPO = 120
|
|
|
|
|
2015-11-30 17:26:30 +00:00
|
|
|
SRCDIR = src
|
|
|
|
OUTDIR = out
|
|
|
|
PDFDIR = pdf
|
|
|
|
MIDIDIR = midi
|
|
|
|
OPUSDIR = music
|
|
|
|
SCORESDIR = $(SRCDIR)/scores
|
|
|
|
LYRICSDIR = $(SRCDIR)/lyrics
|
|
|
|
|
|
|
|
OUTPUTFILE = $(OUTDIR)/singalongs.tex
|
|
|
|
|
|
|
|
SCORES = $(wildcard $(SCORESDIR)/*.ly)
|
|
|
|
PDFS = $(patsubst %.ly,$(PDFDIR)/%.pdf,$(notdir $(SCORES)))
|
|
|
|
MIDIS = $(patsubst %.ly,$(MIDIDIR)/%.midi,$(notdir $(SCORES)))
|
|
|
|
OPUSFILES = $(patsubst %.ly,$(OPUSDIR)/%.opus,$(notdir $(SCORES)))
|
|
|
|
|
|
|
|
LILYPONDSUBST = $(foreach score,$(SCORES), \\\\chapter {$(shell grep title "$(score)" | awk -F '"|"' '{print $$2}')} \\\\includely[staffsize=18]{$(abspath $(score))} ~\\\\\\\\ ~\\\\\\\\ \\\\input{$(abspath $(LYRICSDIR)/$(notdir $(basename $(score)))).tex})
|
|
|
|
|
|
|
|
BOOKPDF = $(PDFDIR)/book.pdf
|
|
|
|
BOOKLETPDF = $(PDFDIR)/booklet.pdf
|
|
|
|
|
|
|
|
all: pdfs midis opus book booklet
|
|
|
|
|
|
|
|
pdfs: $(PDFS)
|
|
|
|
|
|
|
|
midis: pdfs $(MIDIS)
|
|
|
|
|
|
|
|
opus: midis $(OPUSFILES)
|
|
|
|
|
|
|
|
book: $(BOOKPDF)
|
|
|
|
|
|
|
|
booklet: $(BOOKLETPDF)
|
|
|
|
|
|
|
|
$(BOOKPDF): | $(PDFDIR) $(OUTDIR)
|
|
|
|
@$(CP) $(SRCDIR)/*.tex $(OUTDIR)/
|
|
|
|
@$(CP) -r lib/* $(OUTDIR)/
|
|
|
|
@$(CP) -r $(SRCDIR)/images $(OUTDIR)/images
|
|
|
|
|
2015-12-01 09:02:25 +00:00
|
|
|
@$(SED) "s;\musicbooklet;$(LILYPONDSUBST);g" $(SRCDIR)/singalongs.tex > $(OUTPUTFILE).00
|
2015-12-01 09:49:31 +00:00
|
|
|
@$(SED) 's/REVISION/$(shell git log -1 --format="%h")/g' $(OUTPUTFILE).00 > $(OUTPUTFILE)
|
2015-11-30 17:26:30 +00:00
|
|
|
|
|
|
|
@$(CD) $(OUTDIR); \
|
|
|
|
$(LUALATEX) -shell-escape singalongs.tex; \
|
|
|
|
$(MAKEINDEX) singalongs.tex; \
|
|
|
|
$(LUALATEX) -shell-escape singalongs.tex
|
|
|
|
|
|
|
|
@$(CP) $(OUTDIR)/singalongs.pdf $(PDFDIR)/$(@F)
|
|
|
|
|
|
|
|
$(BOOKLETPDF): $(BOOKPDF)
|
|
|
|
$(PDF2PS) $(BOOKPDF) - | $(PSBOOK) | $(PSTOPS) -pa4 '1:0@1.0(-1.25cm,0cm)' | $(PSNUP) -2 | $(PS2PDF) - $(PDFDIR)/$(@F)
|
|
|
|
|
|
|
|
$(PDFDIR)/%.pdf: $(SCORESDIR)/%.ly | $(PDFDIR) $(OUTDIR)
|
2015-12-01 09:02:25 +00:00
|
|
|
@$(SED) 's/%title/title/g' $< > $(OUTDIR)/$(notdir $<).00
|
|
|
|
@$(SED) 's/\header {/\paper{indent=0\\mm} \\header { tagline=""/g' $(OUTDIR)/$(notdir $<).00 > $(OUTDIR)/$(notdir $<)
|
2015-11-30 17:26:30 +00:00
|
|
|
@$(LILYPOND) --output=$(PDFDIR)/$(basename $(@F)) $(OUTDIR)/$(notdir $<)
|
|
|
|
|
|
|
|
$(MIDIDIR)/%.midi: $(SCORESDIR)/%.ly | $(MIDIDIR) $(OUTDIR)
|
2015-12-01 09:02:25 +00:00
|
|
|
@$(SED) 's/\layout { }/\midi{ \\tempo 4 = $(MIDITEMPO) }/g' $< > $(OUTDIR)/$(notdir $<).00
|
|
|
|
@$(SED) 's/\header/\include "articulate.ly" \\header/g' $(OUTDIR)/$(notdir $<).00 > $(OUTDIR)/$(notdir $<).01
|
|
|
|
@$(SED) 's/<</\\articulate \\unfoldRepeats <</g' $(OUTDIR)/$(notdir $<).01 > $(OUTDIR)/$(notdir $<)
|
2015-11-30 17:26:30 +00:00
|
|
|
@$(LILYPOND) --output=$(MIDIDIR)/$(basename $(@F)) $(OUTDIR)/$(notdir $<)
|
|
|
|
|
|
|
|
$(OPUSDIR)/%.opus: $(MIDIDIR)/%.midi | $(OPUSDIR)
|
|
|
|
@$(TIMIDITY) $< -Ow -o - | $(OPUSENC) - $(OPUSDIR)/$(@F)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@$(RM) -rf $(PDFDIR) $(MIDIDIR) $(OPUSDIR) $(OUTDIR)
|
|
|
|
|
|
|
|
$(PDFDIR):
|
|
|
|
@$(MKDIR) -p $(PDFDIR)
|
|
|
|
|
|
|
|
$(MIDIDIR):
|
|
|
|
@$(MKDIR) -p $(MIDIDIR)
|
|
|
|
|
|
|
|
$(OPUSDIR):
|
|
|
|
@$(MKDIR) -p $(OPUSDIR)
|
|
|
|
|
|
|
|
$(OUTDIR):
|
|
|
|
@$(MKDIR) -p $(OUTDIR)
|