forked from chakrit/go-scratch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (36 loc) · 848 Bytes
/
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
#!/usr/bin/make
SHELL := /bin/bash
PWD = $(shell pwd)
PKG = . # $(dir $(wildcard ./*)) # uncomment for implicit submodules
BIN = $(shell basename $(PWD))
GO := $(realpath ./go)
FIND_STD_DEPS = $(GO) list std | sort | uniq
FIND_PKG_DEPS = $(GO) list -f '{{join .Deps "\n"}}' $(PKG) | sort | uniq | grep -v "^_"
DEPS = $(shell comm -23 <($(FIND_PKG_DEPS)) <($(FIND_STD_DEPS)))
.PHONY: %
default: test
all: build
build: deps
$(GO) build $(PKG)
lint: vet
vet: deps
$(GO) get code.google.com/p/go.tools/cmd/vet
$(GO) vet $(PKG)
fmt:
$(GO) fmt $(PKG)
test: test-deps
$(GO) test $(PKG)
cover: test-deps
$(GO) test -cover $(PKG)
clean:
$(GO) clean -i $(PKG)
clean-all:
$(GO) clean -i -r $(PKG)
deps:
$(GO) get -d $(PKG)
$(GO) install $(DEPS)
test-deps: deps
$(GO) get -d -t $(PKG)
$(GO) test -i $(PKG)
run: all
./$(BIN)