Fix circular dependency in Makefile

Remove circular dependency where VERSION variable was calling 'make version',
which caused resource exhaustion. Also remove LDFLAGS that were unused in
the build commands.
This commit is contained in:
Nick Bozhenko
2025-07-10 12:21:07 -04:00
parent 641d16178f
commit 308fb80a6e
+8 -10
View File
@@ -5,10 +5,8 @@ SHELL := /bin/bash
.PHONY: help .PHONY: help
# Version and build info # Version and build info
VERSION := $(shell make -s version)
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
LDFLAGS := -X main.Version=$(VERSION) -X main.BuildDate=$(BUILD_DATE) -X main.GitCommit=$(GIT_COMMIT)
# Go parameters # Go parameters
GOCMD := go GOCMD := go
@@ -93,22 +91,22 @@ dev-tools: ## Install development tools
##@ Build ##@ Build
build: prepare swagger ## Build aptly binary build: prepare swagger ## Build aptly binary
@echo -e "$(COLOR_YELLOW)$(COLOR_BOLD)Building aptly $(VERSION)...$(COLOR_RESET)" @echo -e "$(COLOR_YELLOW)$(COLOR_BOLD)Building aptly...$(COLOR_RESET)"
@mkdir -p $(BUILD_DIR) @mkdir -p $(BUILD_DIR)
$(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME) . $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) .
@echo -e "$(COLOR_GREEN)$(COLOR_BOLD)✓ Build complete: $(BUILD_DIR)/$(BINARY_NAME)$(COLOR_RESET)" @echo -e "$(COLOR_GREEN)$(COLOR_BOLD)✓ Build complete: $(BUILD_DIR)/$(BINARY_NAME)$(COLOR_RESET)"
build-all: prepare swagger ## Build for all platforms build-all: prepare swagger ## Build for all platforms
@echo -e "$(COLOR_YELLOW)$(COLOR_BOLD)Building for all platforms...$(COLOR_RESET)" @echo -e "$(COLOR_YELLOW)$(COLOR_BOLD)Building for all platforms...$(COLOR_RESET)"
@mkdir -p $(BUILD_DIR) @mkdir -p $(BUILD_DIR)
# Linux # Linux
GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64
GOOS=linux GOARCH=arm64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 GOOS=linux GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64
# macOS # macOS
GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64
GOOS=darwin GOARCH=arm64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 GOOS=darwin GOARCH=arm64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64
# Windows # Windows
GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe
@echo -e "$(COLOR_GREEN)$(COLOR_BOLD)✓ Multi-platform build complete$(COLOR_RESET)" @echo -e "$(COLOR_GREEN)$(COLOR_BOLD)✓ Multi-platform build complete$(COLOR_RESET)"
install: build ## Install aptly to GOPATH/bin install: build ## Install aptly to GOPATH/bin
@@ -253,7 +251,7 @@ ci: prepare lint test security ## Run CI pipeline
@echo -e "$(COLOR_GREEN)$(COLOR_BOLD)✓ CI pipeline complete$(COLOR_RESET)" @echo -e "$(COLOR_GREEN)$(COLOR_BOLD)✓ CI pipeline complete$(COLOR_RESET)"
release: clean build-all ## Prepare release artifacts release: clean build-all ## Prepare release artifacts
@echo -e "$(COLOR_YELLOW)$(COLOR_BOLD)Preparing release $(VERSION)...$(COLOR_RESET)" @echo -e "$(COLOR_YELLOW)$(COLOR_BOLD)Preparing release...$(COLOR_RESET)"
@mkdir -p $(BUILD_DIR)/release @mkdir -p $(BUILD_DIR)/release
@for file in $(BUILD_DIR)/$(BINARY_NAME)-*; do \ @for file in $(BUILD_DIR)/$(BINARY_NAME)-*; do \
base=$$(basename $$file); \ base=$$(basename $$file); \