APP_NAME = DDNSUpdater
BIN_DIR = bin
VERSION = 0.1.0

all: build run

# Default build
build:
	@if not exist $(BIN_DIR) mkdir $(BIN_DIR)
	set CGO_ENABLED=0 && \
	set GOOS=windows && set GOARCH=amd64 && \
	go build -ldflags="-s -w -trimpath -X main.version=$(VERSION)" -o $(BIN_DIR)\$(APP_NAME).exe .

run:
	go run .

clean:
	@if exist $(BIN_DIR) rmdir /s /q $(BIN_DIR)

# Windows-specific optimized build
windows:
	@if not exist $(BIN_DIR) mkdir $(BIN_DIR)
	set CGO_ENABLED=0 && \
	set GOOS=windows && set GOARCH=amd64 && \
	go build -ldflags="-s -w -trimpath -X main.version=$(VERSION)" -o $(BIN_DIR)\$(APP_NAME).exe .

tidy:
	go mod tidy

fmt:
	go fmt ./...
