-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
37 lines (32 loc) · 912 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
35
36
37
# Binary name
BINARY_NAME=aptos-metrics-exporter
# Compressed binary name
COMPRESSED_NAME=ame-linux-amd64
# Output directories
BUILD_DIR=build
BIN_DIR=$(BUILD_DIR)/bin
# Commands
GO_BUILD=go build
GO_GET=go get
TAR=tar
GZIP=gzip
# Install required Go dependencies
.PHONY: deps
deps:
@echo "Installing dependencies..."
$(GO_GET) github.com/prometheus/client_golang/prometheus
$(GO_GET) github.com/prometheus/client_golang/prometheus/promhttp
# Build binary for Linux amd64
.PHONY: build
build: deps
@echo "Building the binary for Linux amd64..."
mkdir -p $(BIN_DIR)
GOOS=linux GOARCH=amd64 $(GO_BUILD) -o $(BIN_DIR)/$(BINARY_NAME) ./cmd/$(BINARY_NAME)
# Compress the binary with gzip
.PHONY: compress-gzip
compress-gzip: build
@echo "Compressing the binary with gzip..."
$(TAR) -cvzf $(BUILD_DIR)/$(COMPRESSED_NAME).tar.gz -C $(BIN_DIR) $(BINARY_NAME)
# Default target (build)
.PHONY: all
all: build