# tour/Makefile
#
# Render every page of the virtual tour, rooms/<room>/<page>.conf, to
# build/<room>/<page>.html, and copy the stylesheet and the rooms' images to
# build/. The originals in a room's images/org/ are sources, and are not
# copied. build/ is published as it is.
# Needs python3-tidylib (apt).
#
#   make                        all pages
#   make ROOMS=example BUILD=build-example
#                               the example rooms instead
#   make clean                  remove build/
#
# License: CC0, no copyright; see LICENSE.
# This file is part of the virtual tour around my student house, made by
# Maarten Tromp <maarten@geekabit.nl>. More info on the project:
# https://www.geekabit.nl/projects/virtual-tour-of-my-student-house/


ROOMS		?= rooms
BUILD		?= build
TEMPLATE	:= template/template.html
CSS			:= template/tour.css

CONFS		:= $(wildcard $(ROOMS)/*/*.conf)
PAGES		:= $(patsubst $(ROOMS)/%.conf,$(BUILD)/%.html,$(CONFS))
IMAGES		:= $(wildcard $(addprefix $(ROOMS)/*/images/,*.jpg *.png) \
				$(addprefix $(ROOMS)/*/images/640/,*.jpg *.png))
IMG_TARGETS	:= $(patsubst $(ROOMS)/%,$(BUILD)/%,$(IMAGES))

PYTHON		:= python3
RENDER		:= $(PYTHON) render.py


.PHONY: all clean

all: $(PAGES) $(IMG_TARGETS) $(BUILD)/tour.css

$(BUILD)/%.html: $(ROOMS)/%.conf $(TEMPLATE) render.py
	$(RENDER) -t $(TEMPLATE) $< $@

$(BUILD)/tour.css: $(CSS)
	@mkdir -p $(@D)
	cp $< $@

$(IMG_TARGETS): $(BUILD)/%: $(ROOMS)/%
	@mkdir -p $(@D)
	cp $< $@

clean:
	- $(RM) -r $(BUILD)
