ARCHS := linux-amd64 linux-arm64 darwin-amd64
VERSION ?= $(shell git describe --tags --always)
all: clean $(ARCHS)

$(ARCHS):
	@echo "Building for $(@)"
	@GOOS=$(word 1,$(subst -, ,$(@))) GOARCH=$(word 2,$(subst -, ,$(@))) CGO_ENABLED=0 \
	go build -ldflags "-X main.Version=$(VERSION)" -o target/$(@)/gohttpd
	cp config.json target/$(@)/
	cp -r adminui target/$(@)/
	cp gohttpd.service target/$(@)/
	cp install.sh target/$(@)/

clean:
	go clean
	rm -rf target
