PYTHON=python3
ALLFILES=templates/S2_perm_sw.html templates/S4_server.py venv static/i-ico.png static/i-banner.png
.PHONY: run
run: $(ALLFILES)
($(VENVACT) && python templates/S4_server.py $(PORT) )
.PHONY: files
files: $(ALLFILES)
VENVACT=. ./venv/bin/activate
venv:
$(PYTHON) -m venv venv && ( $(VENVACT) && pip install flask ecdsa pywebpush) || rm -rf venv
# python S1_vapid.py
templates/S2_perm_sw.html: src/S2_perm_sw.html keys/public_key.txt
mkdir -p templates
sed -e 's/YOUR-PUBLIC-KEY/'"$$(cat keys/public_key.txt)"'/' < src/S2_perm_sw.html > templates/S2_perm_sw.html
templates/S4_server.py: src/S4_server.py keys/private_key.txt
if [ -z "$(EMAIL)" ]; then echo Must specify EMAIL.; exit 1; fi
mkdir -p templates
sed -e 's/your@email.com/$(EMAIL)/' -e 's/YOUR-PRIVATE-KEY/'"$$(cat keys/private_key.txt)"'/' < src/S4_server.py > templates/S4_server.py
# XXX - HOST_* and VAPID_SUBJECT
keys/public_key.txt keys/private_key.txt keys/private_key.pem: venv S1_vapid.py
( $(VENVACT) && python S1_vapid.py )
static/i-ico.png:
echo P6 1 1 255 255 0 0 | pnmtopng > $@
static/i-banner.png:
echo P6 1 1 255 0 0 255 | pnmtopng > $@