-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
48 lines (33 loc) · 1.1 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
BINARY = gojekyll
PACKAGE = github.com/osteele/gojekyll
SOURCEDIR = .
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
COMMIT_HASH = `git rev-parse --short HEAD 2>/dev/null`
BUILD_DATE = `date +%FT%T%z`
VERSION := $(COMMIT_HASH)
OS := $(shell uname)
LDFLAGS=-ldflags "-X ${PACKAGE}/version.Version=${VERSION} -X ${PACKAGE}/version.BuildDate=${BUILD_DATE}"
.DEFAULT_GOAL: build
.PHONY: build clean deps setup install lint release test help
$(BINARY): $(SOURCES)
go build ${LDFLAGS} -o ${BINARY} ${PACKAGE}
build: $(BINARY) ## compile the package
clean:
rm -f ${BINARY}
imports:
go list -f '{{join .Imports "\n"}}' ./... | grep -v `go list -f '{{.ImportPath}}'` | grep '\.' | sort | uniq
deps:
go list -f '{{join .Deps "\n"}}' ./... | grep -v `go list -f '{{.ImportPath}}'` | grep '\.' | sort | uniq
race:
go build -race ${LDFLAGS} -o ${BINARY}-race ${PACKAGE}
release: build
mkdir -p dist
tar -cvzf dist/$(BINARY)_$(VERSION)_$(OS:GNU/%=%)_$(shell uname -m).tar.gz $(BINARY) LICENSE README.md
setup:
go get -t ./...
install:
go install ${LDFLAGS} ${PACKAGE}
lint:
golangci-lint run
test:
go test ./...