-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (61 loc) · 2.98 KB
/
Makefile
File metadata and controls
87 lines (61 loc) · 2.98 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
##----------------------------------------------------------------------------##
## Variables ##
##----------------------------------------------------------------------------##
OUTPUT = ./bin/
INSTALL = /usr/local/bin/
BINARY = systags
##----------------------------------------------------------------------------##
## Help ##
##----------------------------------------------------------------------------##
.PHONY: help
help:
@echo
@echo "WELCOME TO SYSTAGS"
@echo "------------------"
@echo
@echo "MAKE"
@echo " $$ make help - Prints out these help instructions"
@echo " $$ make build - Builds main binary in release mode"
@echo " $$ make debug - Builds main binary in debug mode"
@echo " $$ make clean - Cleans and removes generated files"
@echo " $$ make install - Builds and installs binary on system"
@echo " $$ make remove - Removes installed binary from system"
@echo " $$ make publish - Builds artifacts for a new release"
@echo
@echo "DOCS"
@echo " Visit https://github.com/StackAdapt/systags for more"
@echo
##----------------------------------------------------------------------------##
## Build ##
##----------------------------------------------------------------------------##
.PHONY: build debug clean
build:
go build -ldflags "-s -w" -o "$(OUTPUT)$(BINARY)"
debug:
# Include -gcflags to improve the experience with GDB
# particularly when needing to print variable values.
# Also try to detect race conditions using -race flag.
go build -o "$(OUTPUT)$(BINARY)" -gcflags="all=-N -l" -race
clean:
rm -rf "$(OUTPUT)"
##----------------------------------------------------------------------------##
## Install ##
##----------------------------------------------------------------------------##
.PHONY: install remove
install: build
mkdir -p "$(INSTALL)" # In case directory is missing
install -p -m 0755 "$(OUTPUT)$(BINARY)" "$(INSTALL)"
remove:
# Remove installed binary
rm -f "$(INSTALL)$(BINARY)"
##----------------------------------------------------------------------------##
## Publish ##
##----------------------------------------------------------------------------##
.PHONY: _publish_linux_amd64 _publish_linux_arm64 publish
_publish_linux_amd64: clean
env GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "$(OUTPUT)$(BINARY)_linux_amd64/$(BINARY)"
tar -czf "$(OUTPUT)$(BINARY)_linux_amd64.tar.gz" -C "$(OUTPUT)" "$(BINARY)_linux_amd64"
_publish_linux_arm64: clean
env GOOS=linux GOARCH=arm64 go build -ldflags "-s -w" -o "$(OUTPUT)$(BINARY)_linux_arm64/$(BINARY)"
tar -czf "$(OUTPUT)$(BINARY)_linux_arm64.tar.gz" -C "$(OUTPUT)" "$(BINARY)_linux_arm64"
publish: _publish_linux_amd64 _publish_linux_arm64