.PHONY=static all clean

ALL_STATIC := $(patsubst res_gen/static/%,generador_public/%,$(wildcard res_gen/static/*))
ALL_TEMPLATES := $(wildcard res_gen/templates/*.html)
PY_SRC := $(wildcard src/**.py)

all: generador_public generador_public/index.html static generador_public/res/canciones

static: $(ALL_STATIC)

generador_public:
	mkdir generador_public

generador_public/res/canciones:
	rsync -a latex/canciones generador_public/res/.

generador_public/index.html: $(ALL_TEMPLATES) $(PY_SRC)
	python3 src/create_generator.py \
		--latex latex/cancionero.tex \
		--other-latex latex/canciones/ \
		--author NONE --title NONE

generador_public/%: res_gen/static/%
	cp -ra $< $@

clean:
	rm -rf generador_public songs.dat

.PHONY: upload
upload: all
	rsync -a --delete generador_public/* uberspace:html/cancionero-generador/.
