kommersbuch/Makefile

94 lines
3.1 KiB
Makefile
Raw Normal View History

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
WORKING_DIR := $(patsubst %/,%,$(dir $(mkfile_path)))
2017-11-08 10:07:22 +00:00
BOOKNAME=kommersbuch
SRC_DIR=src
BUILD_DIR=build
TMP_DIR=tmp
SONG_DIR=${SRC_DIR}/songs
BUILD_BOOK_DIR=${BUILD_DIR}/books
TMP_BOOK_DIR=${TMP_DIR}/books
BUILD_SONG_DIR=${BUILD_DIR}/songs
TMP_SONG_DIR=${TMP_DIR}/songs
BUILD_MIDI_DIR=${BUILD_DIR}/midi
TMP_MIDI_DIR=${TMP_DIR}/midi
BUILD_OPUS_DIR=${BUILD_DIR}/opus
LY_FILES=$(wildcard ${SONG_DIR}/*.ly)
LY_PDFS=$(patsubst %.ly,${BUILD_SONG_DIR}/%.pdf,$(notdir ${LY_FILES}))
LY_TMP_PDFS=$(patsubst %.ly,${TMP_SONG_DIR}/%.pdf,$(notdir ${LY_FILES}))
LY_MIDIS=$(patsubst %.ly,${BUILD_MIDI_DIR}/%.midi,$(notdir ${LY_FILES}))
LY_TMP_MIDIS=$(patsubst %.ly,${TMP_MIDI_DIR}/%.midi,$(notdir ${LY_FILES}))
LY_OPUS=$(patsubst %.ly,${BUILD_OPUS_DIR}/%.opus,$(notdir ${LY_FILES}))
.PHONY: book songs midi opus clean directories all
.DEFAULT_GOAL := all
${BUILD_BOOK_DIR}:
mkdir -p ${BUILD_BOOK_DIR}
${BUILD_SONG_DIR}:
mkdir -p ${BUILD_SONG_DIR}
${BUILD_MIDI_DIR}:
mkdir -p ${BUILD_MIDI_DIR}
${TMP_BOOK_DIR}:
mkdir -p ${TMP_BOOK_DIR}
${TMP_SONG_DIR}:
mkdir -p ${TMP_SONG_DIR}
${TMP_MIDI_DIR}:
mkdir -p ${TMP_MIDI_DIR}
${BUILD_OPUS_DIR}:
mkdir -p ${BUILD_OPUS_DIR}
2022-04-18 12:50:22 +00:00
${TMP_SONG_DIR}/%.pdf: ${SONG_DIR}/%.ly ${SONG_DIR}/%.tex | ${TMP_SONG_DIR}
2017-11-08 10:07:22 +00:00
cd ${SRC_DIR} && lualatex --jobname='$(notdir $(basename $@))' --output-directory=${WORKING_DIR}/${TMP_SONG_DIR} --shell-escape ${WORKING_DIR}/${SRC_DIR}/song.tex ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).ly ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).tex
2020-07-16 12:34:05 +00:00
rm -r ${SRC_DIR}/tmp-ly
2017-11-08 10:07:22 +00:00
2022-04-18 12:50:22 +00:00
${BUILD_MIDI_DIR}/%.midi: ${TMP_MIDI_DIR}/%-1.midi | ${BUILD_MIDI_DIR}
2017-11-08 10:07:22 +00:00
cp $< $@
2022-04-18 12:50:22 +00:00
${TMP_MIDI_DIR}/%-1.midi: ${SONG_DIR}/%.ly | ${TMP_MIDI_DIR}
lilypond --output=${TMP_MIDI_DIR} ${WORKING_DIR}/$<
2017-11-08 10:07:22 +00:00
2022-04-18 12:50:22 +00:00
${BUILD_OPUS_DIR}/%.opus: ${BUILD_MIDI_DIR}/%.midi | ${BUILD_OPUS_DIR}
2017-11-08 10:07:22 +00:00
timidity $< -Ow -o - | opusenc - $@
2022-04-18 12:50:22 +00:00
${TMP_BOOK_DIR}/%.pdf: ${SRC_DIR}/%.tex ${SRC_DIR}/images/title.png | ${TMP_BOOK_DIR}
2017-11-08 10:07:22 +00:00
latexmk -cd -lualatex -e '$$lualatex=q/lualatex %O -shell-escape %S/' -output-directory=${WORKING_DIR}/${TMP_BOOK_DIR} $<
2020-07-16 12:34:05 +00:00
rm -r ${SRC_DIR}/tmp-ly
2017-11-08 10:07:22 +00:00
2017-11-09 11:23:44 +00:00
${TMP_BOOK_DIR}/%-folio.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t folio -i $(notdir $<) -o $(notdir $@)
#long edge binding
${TMP_BOOK_DIR}/%-quarto.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t quarto -i $(notdir $<) -o $(notdir $@)
${TMP_BOOK_DIR}/%-sexto.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t sexto -i $(notdir $<) -o $(notdir $@)
2017-11-08 10:07:22 +00:00
#short edge binding
${TMP_BOOK_DIR}/%-octavo.pdf: ${TMP_BOOK_DIR}/%.pdf
cd ${TMP_BOOK_DIR} && \
../../bin/makebook -v -t octavo -i $(notdir $<) -o $(notdir $@)
2022-04-18 12:50:22 +00:00
${BUILD_DIR}/%.pdf: ${TMP_DIR}/%.pdf | ${BUILD_BOOK_DIR} ${BUILD_SONG_DIR}
2017-11-08 10:07:22 +00:00
cp $< $@
2022-04-18 12:50:22 +00:00
book: ${BUILD_BOOK_DIR}/${BOOKNAME}.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-folio.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-quarto.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-sexto.pdf ${BUILD_BOOK_DIR}/${BOOKNAME}-octavo.pdf ${LY_FILES}
songs: ${LY_PDFS}
midi: ${LY_MIDIS}
opus: ${LY_OPUS}
2017-11-08 10:07:22 +00:00
all: book songs midi opus
clean:
rm -rf ${BUILD_DIR}
rm -rf ${TMP_DIR}