-
Notifications
You must be signed in to change notification settings - Fork 11
/
makefile
34 lines (26 loc) · 866 Bytes
/
makefile
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
# Makefile for building Go tool for different platforms and compressing binaries
# Binary name
BINARY_NAME=gitcs
# Output directory
OUTPUT_DIR=bin
# Cross-compilation targets
PLATFORMS=linux/amd64 linux/386 windows/amd64 windows/386 darwin/amd64
# Build command for each platform
build:
@for platform in $(PLATFORMS); do \
export GOOS=$${platform%/*}; \
export GOARCH=$${platform#*/}; \
output_name=$(OUTPUT_DIR)/$(BINARY_NAME)_$${GOOS}_$${GOARCH}; \
if [ $$GOOS = "windows" ]; then output_name=$$output_name.exe; fi; \
echo "Building $$output_name"; \
go build -o $$output_name; \
done
# Compress binaries into a zip file
compress:
zip -j $(OUTPUT_DIR)/$(BINARY_NAME)_binaries.zip $(OUTPUT_DIR)/*
# Clean the binaries and zip file
clean:
rm -rf $(OUTPUT_DIR)/*
# Build and compress
all: clean build compress
.PHONY: build compress clean all