-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGNUmakefile
More file actions
50 lines (41 loc) · 1.56 KB
/
GNUmakefile
File metadata and controls
50 lines (41 loc) · 1.56 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
SHELL = sh
PROJECT_ROOT := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
GO_LDFLAGS ?= -s -w
CGO_ENABLED ?= 1
GO_TAGS := osusergo
INSTALLATION_PATH ?= /usr/local/bin
default: clean bin/seashell
bin/seashell: $(SOURCE_FILES) ## Build seashell CLI executable
@echo "==> Building the seashell CLI executable..."
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 \
go build \
-trimpath \
-tags "$(GO_TAGS)" \
-ldflags "$(GO_LDFLAGS)" \
-o "$@"
release: GO_LDFLAGS := "-linkmode external -extldflags '-static' -s -w"
release: $(SOURCE_FILES) ## Build release version of the seashell CLI executable
@echo "==> Building the release version of the seashell CLI executable..."
@$(MAKE) GO_LDFLAGS=$(GO_LDFLAGS)
.PHONY: install
install: $(SOURCE_FILES) ## Build and install the seashell CLI executable on the system
@echo "==> Installing CLI executable at $(INSTALLATION_PATH)/seashell..."
@sudo cp $(PROJECT_ROOT)/bin/seashell $(INSTALLATION_PATH)/seashell
.PHONY: clean
clean: ## Remove build artifacts
@echo "==> Cleaning build artifacts from $(PROJECT_ROOT)/bin/..."
@go mod tidy
@rm -rf "$(PROJECT_ROOT)/bin/"
HELP_FORMAT=" \033[36m%-25s\033[0m %s\n"
EG_FORMAT=" \033[36m%s\033[0m %s\n"
.PHONY: help
help: ## Display this usage information
@echo "Valid targets:"
@grep -E '^[^ ]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; \
{printf $(HELP_FORMAT), $$1, $$2}'
@echo ""
@echo "Examples:"
@printf $(EG_FORMAT) "~${PWD}" "$$ make bin/seashell"
@printf $(EG_FORMAT) "~${PWD}" "$$ make install"