GOROOT := $(shell go env | grep GOROOT | sed -e "s/GOROOT=//g" | sed -e "s/[']//g")

.Phony: build
build: clean build.wasm build.site

.Phony: clean
clean:
	-rm -r target
	mkdir target

.Phony: build.wasm
build.wasm:
	mkdir target/wasm
	GOOS=js GOARCH=wasm go build -o target/wasm/clocks.wasm ./cmds/clocks
	GOOS=js GOARCH=wasm go build -o target/wasm/gotemplate.wasm ./cmds/gotemplate
	GOOS=js GOARCH=wasm go build -o target/wasm/timestamps.wasm ./cmds/timestamps
	GOOS=js GOARCH=wasm go build -o target/wasm/android-icons.wasm ./cmds/android-icons
	GOOS=js GOARCH=wasm go build -o target/wasm/golines.wasm ./cmds/golines
	cp $(GOROOT)/lib/wasm/wasm_exec.js target/wasm/.

.Phony: build.site
build.site:
	cp -r site/* target/.

.Phony: dev
dev: build
	( cd target ; python3 -m http.server )