common_deps := src/deck.rb data/cards.csv ._graphics_copy_touch ._graphics_extract_touch config.yml ._layouts/poker.yml

pnp := _output/pnp_A4.pdf
debug := _output/debug.pdf
showcase := _output/hand.png
full := _output/full/front/card_00.png


.PHONY: all
all: $(pnp) $(debug) $(showcase) $(full)

.PHONY: pnp
pnp: $(pnp)

.PHONY: debug
debug: $(debug)

.PHONY: showcase
showcase: $(showcase)

.PHONY: full
full: $(full)

.PHONY: clean
clean:
	@ rm -rf _output/* 2>/dev/null || true
	@ rm -rf ._layouts || true
	@ rm -rf ._graphics || true
	@ rm  -f ._graphics_copy_touch ._graphics_extract_touch || true


$(pnp): $(common_deps)
	bundle exec rake pnp

$(debug): $(common_deps)
	bundle exec rake debug

$(showcase): $(common_deps)
	bundle exec rake showcase

$(full): $(common_deps)
	bundle exec rake full

._graphics_extract_touch: $(wildcard graphics/bundled/*)
	@ mkdir -p ._graphics
	python scripts/extract_graphics.py $^
	@ touch ._graphics_extract_touch

._graphics_copy_touch: $(wildcard graphics/stand-alone/*)
	@ mkdir -p ._graphics
	cp $^ ./._graphics/
	@ touch ._graphics_copy_touch

._layouts/poker.yml: scripts/generate_layouts.py
	python scripts/generate_layouts.py
