forked from rurreac/slider
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
144 lines (124 loc) · 4.56 KB
/
Makefile
File metadata and controls
144 lines (124 loc) · 4.56 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
################
# Build Slider #
################
# Set variables
BUILD_DIR := build
# UPX better compression by default
UPX_BRUTE ?= no
# Check if UPX is installed
UPX_CHECK := $(shell which upx 2>/dev/null)
ifdef UPX_CHECK
UPX_AVAILABLE := yes
# Strong compression if set
ifeq ($(UPX_BRUTE), yes)
$(warning WARNING: Selected strong compression. This may take a while.)
UPX_CMD := upx --best --lzma --brute
else
UPX_CMD := upx -9
endif
else
UPX_AVAILABLE := no
$(warning WARNING: UPX not found. Binaries will not be compressed. Install UPX for smaller binaries.)
endif
# Get OS information for platform-specific settings
UNAME_S := $(shell uname -s)
# Ensure build directory exists
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Default target
.PHONY: all
all: clean $(BUILD_DIR) macos-arm64 macos-amd64 windows-x86 windows-amd64 windows-arm64 linux-x86 linux-amd64 linux-arm64
# Build for common platforms for quick testing
.PHONY: basic
basic: $(BUILD_DIR) macos-amd64 linux-amd64 windows-x86
# Build for arm64 platforms for quick testing
.PHONY: basic-arm64
basic-arm64: $(BUILD_DIR) macos-arm64 linux-arm64 windows-arm64
# Clean build directory
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)/*
# List all builds with their sizes
.PHONY: list
list:
@echo "Available builds:"
@ls -lh $(BUILD_DIR) | grep -v total
# macOS (arm64)
.PHONY: macos-arm64
macos-arm64:
@echo "Building for macOS (arm64)..."
GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o $(BUILD_DIR)/slider-darwin-arm64 main.go
$(warning WARNING: UPX compression is not supported for macOS binaries.)
# macOS (amd64)
.PHONY: macos-amd64
macos-amd64:
@echo "Building for macOS (amd64)..."
GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o $(BUILD_DIR)/slider-darwin-amd64 main.go
$(warning WARNING: UPX compression is not supported for macOS binaries.)
# Windows (x86)
.PHONY: windows-x86
windows-x86:
@echo "Building for Windows (x86)..."
GOOS=windows GOARCH=386 go build -trimpath -ldflags="-s -w" -o $(BUILD_DIR)/slider-windows-x86.exe main.go
ifeq ($(UPX_AVAILABLE),yes)
@echo "Compressing with UPX..."
$(UPX_CMD) $(BUILD_DIR)/slider-windows-x86.exe || echo "UPX compression failed, using uncompressed binary"
endif
# Windows (amd64)
.PHONY: windows-amd64
windows-amd64:
@echo "Building for Windows (amd64)..."
GOOS=windows GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o $(BUILD_DIR)/slider-windows-amd64.exe main.go
ifeq ($(UPX_AVAILABLE),yes)
@echo "Compressing with UPX..."
$(UPX_CMD) $(BUILD_DIR)/slider-windows-amd64.exe || echo "UPX compression failed, using uncompressed binary"
endif
# Windows (arm64)
.PHONY: windows-arm64
windows-arm64:
@echo "Building for Windows (arm64)..."
GOOS=windows GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o $(BUILD_DIR)/slider-windows-arm64.exe main.go
@echo "Note: UPX doesn't fully support Windows ARM64 binaries yet"
# Linux (x86)
.PHONY: linux-x86
linux-x86:
@echo "Building for Linux (x86)..."
GOOS=linux GOARCH=386 go build -trimpath -ldflags="-s -w" -o $(BUILD_DIR)/slider-linux-x86 main.go
ifeq ($(UPX_AVAILABLE),yes)
@echo "Compressing with UPX..."
$(UPX_CMD) $(BUILD_DIR)/slider-linux-x86 || echo "UPX compression failed, using uncompressed binary"
endif
# Linux (amd64)
.PHONY: linux-amd64
linux-amd64:
@echo "Building for Linux (amd64)..."
GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o $(BUILD_DIR)/slider-linux-amd64 main.go
ifeq ($(UPX_AVAILABLE),yes)
@echo "Compressing with UPX..."
$(UPX_CMD) $(BUILD_DIR)/slider-linux-amd64 || echo "UPX compression failed, using uncompressed binary"
endif
# Linux (arm64)
.PHONY: linux-arm64
linux-arm64:
@echo "Building for Linux (arm64)..."
GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o $(BUILD_DIR)/slider-linux-arm64 main.go
ifeq ($(UPX_AVAILABLE),yes)
@echo "Compressing with UPX..."
$(UPX_CMD) $(BUILD_DIR)/slider-linux-arm64 || echo "UPX compression failed, using uncompressed binary"
endif
# GitHub Release
.PHONY: github-release
github-release:
@if [ -z "$(GITHUB_TOKEN)" ]; then \
echo "Error: GITHUB_TOKEN environment variable is not set."; \
echo "Please export your GitHub Personal Access Token:"; \
echo "export GITHUB_TOKEN=\"your_token_here\""; \
exit 1; \
fi
@echo "Running GoReleaser..."
export GOVERSION=$(shell go version | awk '{print $$3}') && goreleaser release --clean --config .github/goreleaser.yml
# Dry Run Release (Snapshot)
.PHONY: dry-release
dry-release:
@echo "Running Dry Run Release (Snapshot)..."
export GOVERSION=$(shell go version | awk '{print $$3}') && goreleaser release --clean --config .github/goreleaser.yml --skip=publish --snapshot