## directories

dir_source := source
dir_build := build


## commands

cmd_log := echo "--"
cmd_tsc := tsc --lib es2015,dom
cmd_cp := cp
cmd_lessc := lessc
cmd_mkdir := mkdir -p


## rules

all: structure logic style
.PHONY: all

structure: ${dir_build}/index.html
.PHONY: structure

${dir_build}/index.html: ${dir_source}/index.html
	@ ${cmd_log} "structure …"
	@ ${cmd_mkdir} $(dir $@)
	@ ${cmd_cp} -ru $^ $@

logic: ${dir_build}/logic.js
.PHONY: logic

${dir_build}/logic.js: \
	${dir_source}/logic/types.ts \
	${dir_source}/logic/helpers.ts \
	${dir_source}/logic/model.ts \
	${dir_source}/logic/view.ts \
	${dir_source}/logic/control.ts \
	${dir_source}/logic/main.ts
	@ ${cmd_log} "logic …"
	@ ${cmd_mkdir} $(dir $@)
	@ ${cmd_tsc} $^ --outFile $@

style: ${dir_build}/style.css
.PHONY: style

${dir_build}/style.css: ${dir_source}/style.less
	@ ${cmd_log} "style …"
	@ ${cmd_mkdir} $(dir $@)
	@ ${cmd_lessc} $^ > $@