mixtape/makefile
Emil Miler af93017204
Some checks failed
Build / build (push) Failing after 2s
Use Docker to invoke ChordPro
This allows us to run Make in a predictable environemnt without having
to install all the perl dependencies. It should work both locally
and during build in the pipeline.
2024-06-01 12:09:55 +02:00

37 lines
906 B
Makefile

ifdef CHORDPRO_PIPELINE
CHORDPRO_CMD = chordpro
else
CHORDPRO_CMD = docker run -ti --rm --env HOME=$(HOME) --env USER=$(USER) --workdir $(shell pwd) --volume $(HOME):$(HOME) chordpro/chordpro:latest chordpro --config=chordpro.json
endif
SRC_DIR := $(wildcard content/*)
SRC_EXTENSION := .cho
SONG_CHO := $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/*$(SRC_EXTENSION)))
SONG_PDF := $(patsubst %$(SRC_EXTENSION),%.pdf,$(SONG_CHO))
SONG_HTML := $(patsubst %$(SRC_EXTENSION),%.html,$(SONG_CHO))
SONGBOOK := songbook.pdf
.DEFAULT_GOAL := all
%.pdf: %$(SRC_EXTENSION)
$(CHORDPRO_CMD) -o $@ $<
%.html: %$(SRC_EXTENSION)
$(CHORDPRO_CMD) -o $@ $<
all: $(SONG_PDF) $(SONG_HTML) $(SONGBOOK)
$(SONGBOOK): $(SONG_PDF)
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$@ $^
.PHONY: html
html: $(SONG_HTML)
.PHONY: pdf
pdf: $(SONG_PDF)
.PHONY: clean
clean:
rm -f $(SONG_PDF) $(SONG_HTML) $(SONGBOOK)