forked from vaz-ar/goxxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
43 lines (31 loc) · 1.09 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
VERSION=0.0.4
BINARY=goxxx
# -----------------------------------------------------------------------------------------
# This will only work while go version is < 2
GO_GTE_15=$(shell [ $$(go version | sed -r 's/^.*[0-9]\.([0-9])\.[0-9].*$$/\1/') -ge 5 ] && echo true || echo false)
ifeq ($(GO_GTE_15), true)
LDFLAGS=-ldflags "-X main.GlobalVersion=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
else
LDFLAGS=-ldflags "-X main.GlobalVersion $(VERSION) -X main.BuildTime $(BUILD_TIME)"
endif
BUILD_TIME=`date +%FT%T%z`
SOURCEDIR=.
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
# -----------------------------------------------------------------------------------------
.DEFAULT_GOAL := $(BINARY)
$(BINARY): $(SOURCES)
go build $(LDFLAGS) -o $(BINARY) goxxx.go
.PHONY: install
install: $(SOURCES)
go install $(LDFLAGS) goxxx.go
.PHONY: clean
clean:
if [ -f $(BINARY) ] ; then rm $(BINARY) ; fi
go clean
.PHONY: test
test:
go test -v ./... | sed -e /PASS/s//$$(printf "\033[32mPASS\033[0m")/ -e /FAIL/s//$$(printf "\033[31mFAIL\033[0m")/
.PHONY: format
format:
gofmt -s -w ./*.go
gofmt -s -w ./*/*.go