forked from GitLab-Red-Team/gitrob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (58 loc) · 1.32 KB
/
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
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
#
# Copyright (c) 2015, Matt Jones <[email protected]>
# All rights reserved.
# MIT License
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
#
# version 0.1.24
#
SHELL = /bin/bash
.PHONY: all build clean coverage help install package pretty test
# The name of the binary to build
#
ifndef pkg
pkg := $(shell pwd | awk -F/ '{print $$NF}')
endif
# Set the target OS
# Ex: windows, darwin, linux
#
ifndef target_os
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
target_os = linux
endif
ifeq ($(UNAME_S),Darwin)
target_os = darwin
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
target_arch = amd64
endif
endif
ifeq ($(target_os),windows)
target_ext = .exe
endif
ifndef target_arch
target_arch = amd64
endif
all: pretty clean build
build: prep
@GOOS=$(target_os) GOARCH=$(target_arch) go build -o ./bin/$(pkg)-$(target_os)
release: prep
@GOOS=$(target_os) GOARCH=$(target_arch) go build -ldflags="-s -w" -o ./bin/$(pkg)$(target_ext)
clean:
@rm -rf ./bin ./rules
# TODO: write help command for Makefile
# TODO: documentation
help:
install: pretty
@GOOS=$(target_os) GOARCH=$(target_arch) go install
package: test clean build
prep:
@go get -u
pretty:
@golint ./...
@go fmt ./...
@go vet ./...
test: pretty
@cd ./...$(pkg) && go test -cover