.PHONY: all clean windows linux darwin

include scripts/platforms.mk

BINARY_NAME=goonscape
VERSION=1.1.0
BUILD_DIR=build
ASSETS_DIR=resources

all: clean $(PLATFORMS)

$(PLATFORMS):
	@echo "Building for $@..."
	@mkdir -p $(BUILD_DIR)/$@
	@scripts/build.sh $(word 1,$(subst /, ,$@)) $(word 2,$(subst /, ,$@)) \
		$(BUILD_DIR)/$@/$(BINARY_NAME)$(if $(findstring windows,$@),.exe,)
	@cp -r $(ASSETS_DIR) $(BUILD_DIR)/$@/
	@cd $(BUILD_DIR) && zip -r $(BINARY_NAME)-$(word 1,$(subst /, ,$@))-$(word 2,$(subst /, ,$@))-v$(VERSION).zip $@
	@echo "Done building for $@"

clean:
	rm -rf $(BUILD_DIR)

# Development build for current platform
dev:
	go build -o $(BINARY_NAME)

# Run tests
test:
	go test ./... 