53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			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_EXTENSION := .cho
 | 
						|
CURRENT_DIR := content/current
 | 
						|
ARCHIVE_DIR := content/archive
 | 
						|
 | 
						|
# Find all .cho files in both current and archive
 | 
						|
SONG_CHO := $(shell find $(CURRENT_DIR) $(ARCHIVE_DIR) -type f -name "*$(SRC_EXTENSION)")
 | 
						|
SONG_PDF := $(SONG_CHO:$(SRC_EXTENSION)=.pdf)
 | 
						|
SONG_HTML := $(SONG_CHO:$(SRC_EXTENSION)=.html)
 | 
						|
 | 
						|
# Songbook only includes current songs (sorted alphabetically)
 | 
						|
CURRENT_CHO := $(shell find $(CURRENT_DIR) -type f -name "*$(SRC_EXTENSION)" | sort)
 | 
						|
CURRENT_PDF := $(CURRENT_CHO:$(SRC_EXTENSION)=.pdf)
 | 
						|
SONGBOOK := content/songbook.pdf
 | 
						|
 | 
						|
.DEFAULT_GOAL := pdf
 | 
						|
 | 
						|
# Pattern rules that work for nested directories
 | 
						|
content/%.pdf: content/%$(SRC_EXTENSION)
 | 
						|
	@echo "Building PDF: $@"
 | 
						|
	$(CHORDPRO_CMD) -o $@ $<
 | 
						|
 | 
						|
content/%.html: content/%$(SRC_EXTENSION)
 | 
						|
	@echo "Building HTML: $@"
 | 
						|
	$(CHORDPRO_CMD) -o $@ $<
 | 
						|
 | 
						|
# Aggregate targets
 | 
						|
all: pdf html songbook
 | 
						|
 | 
						|
pdf: $(SONG_PDF)
 | 
						|
 | 
						|
html: $(SONG_HTML)
 | 
						|
 | 
						|
songbook: $(SONGBOOK)
 | 
						|
 | 
						|
# Songbook combines alphabetically sorted PDFs
 | 
						|
$(SONGBOOK): $(CURRENT_PDF)
 | 
						|
	@echo "Creating songbook (alphabetically sorted)..."
 | 
						|
	gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$@ $(CURRENT_PDF)
 | 
						|
 | 
						|
clean:
 | 
						|
	rm -f $(SONG_PDF) $(SONG_HTML) $(SONGBOOK)
 | 
						|
 |