.PHONY: all clean dist

HTMLS = $(patsubst notebooks/%.ipynb,html/%.html,$(wildcard notebooks/*.ipynb))

all: $(HTMLS)

clean:
	rm -r html

html/%.html: notebooks/%.ipynb | html
	podman run -it --rm -v .:/home/sage/eulerbooks --userns=keep-id sagemath/sagemath:latest jupyter nbconvert --to html eulerbooks/$< --output $@ --output-dir=eulerbooks/

html:
	mkdir -p html

dist: eulerbooks.tar.gz

eulerbooks.tar.gz: $(HTMLS) Makefile README.md LICENSE
	rm -f $@
	mkdir eulerbooks
	cp -r html eulerbooks
	mkdir eulerbooks/notebooks
	cp notebooks/*.ipynb eulerbooks/notebooks
	cp -r notebooks/txt eulerbooks/notebooks
	cp LICENSE Makefile README.md eulerbooks
	tar -czf $@ eulerbooks
	rm -r eulerbooks
