-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
98 lines (80 loc) · 2.55 KB
/
Copy pathMakefile
File metadata and controls
98 lines (80 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Makefile for Docker Stack Manager
# Go parameters
BINARY_NAME=pulse
GO=go
GOBUILD=$(GO) build
GOCLEAN=$(GO) clean
GOMOD=$(GO) mod
BINARY_UNIX=$(BINARY_NAME)_unix
# Build directory
BUILD_DIR=./build
# Go version check
GO_VERSION=$(shell go version | cut -d ' ' -f 3)
# Compiler flags
LDFLAGS=-ldflags "-s -w"
# Default target
all: setup test build
# Setup dependencies and environment
setup:
@echo "Setting up development environment..."
$(GOMOD) tidy
$(GOMOD) download
$(GOMOD) verify
# Build for current platform
build:
@echo "Building binary for current platform..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) .
# Build for multiple platforms
build-all: build-linux build-darwin build-windows
# Build for Linux
build-linux:
@echo "Building for Linux..."
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)_linux .
# Build for macOS
build-darwin:
@echo "Building for macOS..."
@mkdir -p $(BUILD_DIR)
GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)_darwin .
# Build for Windows
build-windows:
@echo "Building for Windows..."
@mkdir -p $(BUILD_DIR)
GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)_windows.exe .
# Install the binary
install:
@echo "Installing binary..."
$(GOBUILD) -o $(GOPATH)/bin/$(BINARY_NAME) .
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
$(GOCLEAN)
rm -rf $(BUILD_DIR)
rm -f $(GOPATH)/bin/$(BINARY_NAME)
# Run the application
run:
@echo "Running the application..."
$(GO) run .
# Check code quality and run linters
lint:
@echo "Running code quality checks..."
golangci-lint run
# Create a release tarball
release: clean build-all
@echo "Creating release tarball..."
@mkdir -p $(BUILD_DIR)/release
tar -czvf $(BUILD_DIR)/release/$(BINARY_NAME)_$(GO_VERSION).tar.gz -C $(BUILD_DIR) $(BINARY_NAME)_linux $(BINARY_NAME)_darwin $(BINARY_NAME)_windows.exe
# Help target
help:
@echo "Available targets:"
@echo " all - Setup, and build the application"
@echo " setup - Download and verify dependencies"
@echo " build - Build for current platform"
@echo " build-all - Build for Linux, macOS, and Windows"
@echo " install - Install the binary to GOPATH"
@echo " clean - Remove build artifacts"
@echo " run - Run the application"
@echo " lint - Run code quality checks"
@echo " release - Create a release tarball"
.PHONY: all setup test build build-all build-linux build-darwin build-windows install clean run lint release help