VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev") COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown") BUILD_TIME := $(shell date "+%Y-%m-%d %H:%M:%S") LDFLAGS := -X 'gosvc.setVersionNumber=$(VERSION)' \ -X 'gosvc.setVersionRelease=$(BRANCH)' \ -X 'gosvc.setVersionBuildTime=$(BUILD_TIME)' \ -X 'gosvc.setVersionDescription=RobotFS Service (commit: $(COMMIT))' UNAME_S := $(shell uname -s) BINARY_NAME := robotfs .PHONY: all all: proto build .PHONY: proto proto: @echo "Generating protobuf files..." protoc --go_out=. --go_opt=paths=source_relative pb/*.proto .PHONY: build build: ifeq ($(UNAME_S),Darwin) @echo "Building for MacOS..." GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) ./ else @echo "Building for Linux..." GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) ./ endif .PHONY: build-linux build-linux: @echo "Building for Linux..." GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) ./ .PHONY: clean clean: rm -f $(BINARY_NAME) rm -f pb/*.pb.go .PHONY: help help: @echo "Available targets:" @echo " all - Generate protobuf files and build for current platform (default)" @echo " proto - Generate protobuf files" @echo " build - Build for current platform" @echo " build-linux - Build for linux platform" @echo " clean - Remove built binaries and generated protobuf files"