-include .env
export

COMPOSE = docker compose

.PHONY: help fetch push build up down logs rebuild drawings drawings-all drawings-one shell-latex remotes

help:
	@echo "make push           push the three repos (sv), then this one (main); DRY=1 for a dry run"
	@echo "make fetch          init/update the submodules (scripts/fetch.sh)"
	@echo "make build          generate the site into ./site-build"
	@echo "make up | down      start/stop the local web server (http://127.0.0.1:8080)"
	@echo "make rebuild        build, then (re)start the web server"
	@echo "make drawings       regenerate drawings whose .tex is newer than the .svg (JOBS=4)"
	@echo "make drawings-all   regenerate every drawing"
	@echo "make drawings-one ID=502"
	@echo "make remotes        show git remotes of the three repos"

fetch:
	./scripts/fetch.sh

push:
	./scripts/push.sh $(if $(DRY),--dry-run)

build:
	$(COMPOSE) --profile build run --rm build

up:
	$(COMPOSE) up -d web
	@echo "http://$(BIND_ADDR):$(WEB_PORT)"

down:
	$(COMPOSE) down

logs:
	$(COMPOSE) logs -f web

rebuild: build up

JOBS ?= 4
drawings:
	$(COMPOSE) --profile latex run --rm latex --stale -j $(JOBS)

drawings-all:
	$(COMPOSE) --profile latex run --rm latex --all -j $(JOBS)

drawings-one:
	$(COMPOSE) --profile latex run --rm latex $(ID)

remotes:
	@for r in 50ohm 50ohm-contents-dl 50ohm-ansible; do echo "== $$r ($$(git -C $$r branch --show-current))"; git -C $$r remote -v; done
