@@ -4,21 +4,79 @@ GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
44VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
55
66# Build flags to inject version information
7- LDFLAGS := -X main.Version=$(VERSION ) -X main.GitCommit=$(GIT_COMMIT ) -X main.BuildTime=$(BUILD_DATE )
7+ LDFLAGS := -X main.Version=$(VERSION ) -X main.GitCommit=$(GIT_COMMIT ) -X main.BuildTime=$(BUILD_DATE ) -w -s
88
9+ # Default build for current platform
910.PHONY : build
1011build :
12+ @echo " Building for current platform..."
1113 @go build -ldflags " $( LDFLAGS) " -o aks-flex-node .
1214
15+ # Cross-platform builds for supported architectures
16+ .PHONY : build-linux-amd64
17+ build-linux-amd64 :
18+ @echo " Building for Linux AMD64..."
19+ @GOOS=linux GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o aks-flex-node-linux-amd64 .
20+
21+ .PHONY : build-linux-arm64
22+ build-linux-arm64 :
23+ @echo " Building for Linux ARM64..."
24+ @GOOS=linux GOARCH=arm64 go build -ldflags " $( LDFLAGS) " -o aks-flex-node-linux-arm64 .
25+
26+ # Build all supported platforms
27+ .PHONY : build-all
28+ build-all : build-linux-amd64 build-linux-arm64
29+ @echo " Built binaries for all supported platforms"
30+
31+ # Create release archives
32+ .PHONY : package-linux-amd64
33+ package-linux-amd64 : build-linux-amd64
34+ @echo " Packaging Linux AMD64 binary..."
35+ @tar -czf aks-flex-node-linux-amd64.tar.gz aks-flex-node-linux-amd64
36+
37+ .PHONY : package-linux-arm64
38+ package-linux-arm64 : build-linux-arm64
39+ @echo " Packaging Linux ARM64 binary..."
40+ @tar -czf aks-flex-node-linux-arm64.tar.gz aks-flex-node-linux-arm64
41+
42+ # Package all supported platforms
43+ .PHONY : package-all
44+ package-all : package-linux-amd64 package-linux-arm64
45+ @echo " Packaged all supported platforms"
46+ @ls -la * .tar.gz
47+
1348.PHONY : test
1449test :
1550 @go test ./...
1651
1752.PHONY : clean
1853clean :
54+ @echo " Cleaning build artifacts..."
1955 @go clean
56+ @rm -f aks-flex-node-*
57+ @rm -f * .tar.gz
2058
2159.PHONY : update-build-metadata
2260update-build-metadata :
2361 @echo " 📅 Build Date: $( BUILD_DATE) "
24- @echo " 🎯 Git Commit: $( GIT_COMMIT) "
62+ @echo " 🎯 Git Commit: $( GIT_COMMIT) "
63+ @echo " 🏷️ Version: $( VERSION) "
64+
65+ # Help target
66+ .PHONY : help
67+ help :
68+ @echo " AKS Flex Node Makefile"
69+ @echo " ======================"
70+ @echo " "
71+ @echo " Targets:"
72+ @echo " build Build for current platform"
73+ @echo " build-linux-amd64 Build for Linux AMD64"
74+ @echo " build-linux-arm64 Build for Linux ARM64"
75+ @echo " build-all Build for all supported platforms"
76+ @echo " package-linux-amd64 Package Linux AMD64 binary"
77+ @echo " package-linux-arm64 Package Linux ARM64 binary"
78+ @echo " package-all Package all supported platforms"
79+ @echo " test Run tests"
80+ @echo " clean Clean build artifacts"
81+ @echo " update-build-metadata Show build metadata"
82+ @echo " help Show this help message"
0 commit comments