Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (37 loc) · 1.45 KB
/
Copy pathMakefile
File metadata and controls
49 lines (37 loc) · 1.45 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
.PHONY: build clean release all
# Binary name
BINARY_NAME=ihex
ifeq ($(OS),Windows_NT)
BINARY_NAME=ihex.exe
endif
# Build flags for maximum optimization and size reduction
LDFLAGS=-ldflags="-s -w -extldflags '-static'"
GOFLAGS=-trimpath
CGO_ENABLED=0
all: build
build:
@echo "Building $(BINARY_NAME) (optimized)..."
@CGO_ENABLED=$(CGO_ENABLED) go build $(LDFLAGS) $(GOFLAGS) -o $(BINARY_NAME) .
@echo "Build complete: $(BINARY_NAME)"
@ls -lh $(BINARY_NAME) 2>/dev/null || dir $(BINARY_NAME) 2>nul
release:
@echo "Building release binaries..."
@mkdir -p release
@echo "Building Linux amd64..."
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) $(GOFLAGS) -o release/ihex-linux-amd64 .
@echo "Building Linux arm64..."
@GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(LDFLAGS) $(GOFLAGS) -o release/ihex-linux-arm64 .
@echo "Building Windows amd64..."
@GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) $(GOFLAGS) -o release/ihex-windows-amd64.exe .
@echo "Building macOS amd64..."
@GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) $(GOFLAGS) -o release/ihex-darwin-amd64 .
@echo "Building macOS arm64..."
@GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build $(LDFLAGS) $(GOFLAGS) -o release/ihex-darwin-arm64 .
@echo "Release builds complete in ./release/"
@ls -lh release/ 2>/dev/null || dir release 2>nul
clean:
@echo "Cleaning..."
@go clean
@rm -f $(BINARY_NAME) ihex ihex.exe
@rm -rf release/
@echo "Clean complete"