@@ -4,33 +4,56 @@ VERSION ?= dev
44
55GO := go
66GOFLAGS := -trimpath
7- LDFLAGS := -s -w
7+ CGO_ENABLED := 0
8+ DEV_LDFLAGS :=
9+ PROD_LDFLAGS := -s -w
810
9- .PHONY : all build build-linux build-macos build-windows build-wasm build-all clean
11+ .PHONY : all build build-linux build-macos build-windows build-all \
12+ build-prod build-linux-prod build-macos-prod build-windows-prod build-all-prod clean
1013
1114all : build-all
1215
1316build : # # Build for the current platform
14- $(GO ) build $(GOFLAGS ) -ldflags " $( LDFLAGS) " -o $(BINARY_NAME ) .
17+ CGO_ENABLED=$(CGO_ENABLED ) $(GO ) build $(GOFLAGS ) -ldflags " $( DEV_LDFLAGS) " -o $(BINARY_NAME ) .
18+
19+ build-prod : # # Build stripped production binary for the current platform
20+ CGO_ENABLED=$(CGO_ENABLED ) $(GO ) build $(GOFLAGS ) -ldflags " $( PROD_LDFLAGS) " -o $(BINARY_NAME ) .
1521
1622build-linux : # # Build static Linux binary (amd64)
1723 mkdir -p $(DIST_DIR )
18- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO ) build $(GOFLAGS ) -ldflags " $( LDFLAGS) " -o $(DIST_DIR ) /$(BINARY_NAME ) -linux-amd64 .
24+ CGO_ENABLED=$(CGO_ENABLED ) GOOS=linux GOARCH=amd64 $(GO ) build $(GOFLAGS ) -ldflags " $( DEV_LDFLAGS) " -o $(DIST_DIR ) /$(BINARY_NAME ) -linux-amd64 .
25+
26+ build-linux-prod : # # Build stripped static Linux binary (amd64)
27+ mkdir -p $(DIST_DIR )
28+ CGO_ENABLED=$(CGO_ENABLED ) GOOS=linux GOARCH=amd64 $(GO ) build $(GOFLAGS ) -ldflags " $( PROD_LDFLAGS) " -o $(DIST_DIR ) /$(BINARY_NAME ) -linux-amd64 .
1929
20- build-macos : # # Build macOS binary (amd64 + arm64)
30+ build-macos : # # Build static macOS binary (amd64 + arm64)
2131 mkdir -p $(DIST_DIR )
22- CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO ) build $(GOFLAGS ) -ldflags " $( LDFLAGS ) " -o $(DIST_DIR ) /$(BINARY_NAME ) -darwin-amd64 .
23- CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GO ) build $(GOFLAGS ) -ldflags " $( LDFLAGS ) " -o $(DIST_DIR ) /$(BINARY_NAME ) -darwin-arm64 .
32+ CGO_ENABLED=$( CGO_ENABLED ) GOOS=darwin GOARCH=amd64 $(GO ) build $(GOFLAGS ) -ldflags " $( DEV_LDFLAGS ) " -o $(DIST_DIR ) /$(BINARY_NAME ) -darwin-amd64 .
33+ CGO_ENABLED=$( CGO_ENABLED ) GOOS=darwin GOARCH=arm64 $(GO ) build $(GOFLAGS ) -ldflags " $( DEV_LDFLAGS ) " -o $(DIST_DIR ) /$(BINARY_NAME ) -darwin-arm64 .
2434
25- build-windows : # # Build Windows binary (amd64)
35+ build-macos-prod : # # Build stripped static macOS binaries (amd64 + arm64 )
2636 mkdir -p $(DIST_DIR )
27- CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GO ) build $(GOFLAGS ) -ldflags " $( LDFLAGS) " -o $(DIST_DIR ) /$(BINARY_NAME ) -windows-amd64.exe .
37+ CGO_ENABLED=$(CGO_ENABLED ) GOOS=darwin GOARCH=amd64 $(GO ) build $(GOFLAGS ) -ldflags " $( PROD_LDFLAGS) " -o $(DIST_DIR ) /$(BINARY_NAME ) -darwin-amd64 .
38+ CGO_ENABLED=$(CGO_ENABLED ) GOOS=darwin GOARCH=arm64 $(GO ) build $(GOFLAGS ) -ldflags " $( PROD_LDFLAGS) " -o $(DIST_DIR ) /$(BINARY_NAME ) -darwin-arm64 .
2839
29- build-wasm : # # Build WebAssembly binary (js/wasm )
40+ build-windows : # # Build static Windows binary (amd64 )
3041 mkdir -p $(DIST_DIR )
31- GOOS=js GOARCH=wasm $(GO ) build $(GOFLAGS ) -ldflags " $( LDFLAGS) " -o $(DIST_DIR ) /$(BINARY_NAME ) -js-wasm.wasm .
42+ CGO_ENABLED=$(CGO_ENABLED ) GOOS=windows GOARCH=amd64 $(GO ) build $(GOFLAGS ) -ldflags " $( DEV_LDFLAGS) " -o $(DIST_DIR ) /$(BINARY_NAME ) -windows-amd64.exe .
43+
44+ build-windows-prod : # # Build stripped static Windows binary (amd64)
45+ mkdir -p $(DIST_DIR )
46+ CGO_ENABLED=$(CGO_ENABLED ) GOOS=windows GOARCH=amd64 $(GO ) build $(GOFLAGS ) -ldflags " $( PROD_LDFLAGS) " -o $(DIST_DIR ) /$(BINARY_NAME ) -windows-amd64.exe .
47+
48+ build-all : # # Build all target platforms (fully static binaries)
49+ $(MAKE ) build-linux
50+ $(MAKE ) build-macos
51+ $(MAKE ) build-windows
3252
33- build-all : build-linux build-macos build-windows build-wasm # # Build all target platforms
53+ build-all-prod : # # Build all stripped target platforms (fully static binaries)
54+ $(MAKE ) build-linux-prod
55+ $(MAKE ) build-macos-prod
56+ $(MAKE ) build-windows-prod
3457
3558clean : # # Remove build artifacts
3659 rm -rf $(DIST_DIR )
0 commit comments