44 lines
1.1 KiB
Makefile
44 lines
1.1 KiB
Makefile
# Project name
|
|
PROJECT_NAME=adhoc-server
|
|
|
|
# Get version from the program
|
|
VERSION=$(shell go run . -v | awk '{print $$2}')
|
|
|
|
# Build directories pattern
|
|
BUILD_DIR=./build
|
|
BUILD_PATTERN=$(BUILD_DIR)/$(PROJECT_NAME)-$(VERSION)-linux
|
|
|
|
# Binary name
|
|
BINARY_NAME=$(PROJECT_NAME)
|
|
|
|
# Build flags
|
|
BUILD_FLAGS=-ldflags "-s -w"
|
|
CGO=CGO_ENABLED=0
|
|
|
|
# Build targets
|
|
.PHONY: all linux_amd64 linux_arm7 linux_arm64 clean version
|
|
|
|
all: linux_amd64 linux_arm7 linux_arm64
|
|
|
|
version:
|
|
@echo Version: $(VERSION)
|
|
|
|
linux_amd64:
|
|
$(CGO) GOOS=linux GOARCH=amd64 go build $(BUILD_FLAGS) -o $(BUILD_PATTERN)-amd64/$(BINARY_NAME)
|
|
|
|
linux_arm7:
|
|
$(CGO) GOOS=linux GOARCH=arm GOARM=7 go build $(BUILD_FLAGS) -o $(BUILD_PATTERN)-arm7/$(BINARY_NAME)
|
|
|
|
linux_arm64:
|
|
$(CGO) GOOS=linux GOARCH=arm64 go build $(BUILD_FLAGS) -o $(BUILD_PATTERN)-arm64/$(BINARY_NAME)
|
|
|
|
release: all
|
|
@echo Creating release tarballs...
|
|
tar -czvf $(BUILD_PATTERN)-amd64.tar.gz -C $(BUILD_PATTERN)-amd64 .
|
|
tar -czvf $(BUILD_PATTERN)-arm7.tar.gz -C $(BUILD_PATTERN)-arm7 .
|
|
tar -czvf $(BUILD_PATTERN)-arm64.tar.gz -C $(BUILD_PATTERN)-arm64 .
|
|
@echo Release tarballs created in $(BUILD_DIR)
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR)
|