# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get

# Binary name
WINDOWS_BINARY_NAME=./release/windows/kode-starter.exe
LINUX_BINARY_NAME=./release/linux/kode-starter

# test, build, clean, release
all: test build

# build
build-windows:
	cd ./version/ && versionManager.exe go build
	cd ..
	set GOOS=windows
	set GOARCH=amd64
	$(GOBUILD) -o $(WINDOWS_BINARY_NAME) -v

build-linux:
	cd ./version/ && versionManager.exe go build
	cd ..
	set GOOS=linux
	set GOARCH=amd64
	$(GOBUILD) -o $(LINUX_BINARY_NAME) -v

build-all: build-windows build-linux

test:
	$(GOTEST) -v ./...

clean:
	$(GOCLEAN)
	powershell.exe -c "rm .\release\ -Recurse -Force" 

release: clean
	cd ./version/ && versionManager.exe go release
	CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(WINDOWS_BINARY_NAME) -v

.PHONY: all build test clean release