# Go parameters GOCMD=go GOBUILD=$(GOCMD) build GOCLEAN=$(GOCMD) clean GOTEST=$(GOCMD) test GOGET=$(GOCMD) get GOMOD=$(GOCMD) mod GOFMT=gofmt GOLINT=golangci-lint # Binary names BINARY_NAME=ccoin BINARY_LINUX=$(BINARY_NAME)-linux-x64 BINARY_MAC=$(BINARY_NAME)-macos-arm64 BINARY_WINDOWS=$(BINARY_NAME)-windows-x64.exe # Build directory BUILD_DIR=build # Version info (can be overridden) VERSION?=1.0.0 BUILD_TIME?=$(shell date -u '+%Y-%m-%d_%H:%M:%S') COMMIT?=$(shell git rev-parse HEAD) # Linker flags to embed version info LDFLAGS=-ldflags "-X ccoin/config/server.version=$(VERSION) -X ccoin/config/server.buildTime=$(BUILD_TIME) -X ccoin/config/server.commit=$(COMMIT) -s -w" -trimpath .PHONY: all build clean test coverage deps fmt lint vet help .PHONY: build-linux build-windows build-darwin run dev .PHONY: docker-build install uninstall # Default target all: clean deps fmt vet test build # Build the binary build: $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) -v # Build for Linux build-linux: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_LINUX) -v # Build for MacOS build-macos: CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_MAC) -v # Build for windows build-windows: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_WINDOWS) -v