This repository has been archived by the owner on Nov 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMakefile
75 lines (59 loc) · 1.75 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
PWD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GOPKG = github.com/bndw/pick
GOVENDOR = vendor
GOPATH = "$(CURDIR)/$(GOVENDOR)"
PICK_DIR = $(HOME)/.pick
BIN_DIR = /usr/local/bin
INSTALL = install
FOLDERS = $(shell find . -mindepth 1 -type d -not -path "*.git*" -not -path "./githooks*" -not -path "./$(GOVENDOR)*" -not -path "./Godeps*" -not -path "*bin*")
all: build
install_hooks:
@if test -d .git; then \
for HOOK in githooks/???*; do \
case $$HOOK in \
*.sample|*~|*.swp) continue;; \
esac; \
if test -x $$HOOK; then \
test ! -x .git/hooks/$${HOOK##*/} && echo "Installing git hook $${HOOK##*/}.."; \
$(INSTALL) -c $$HOOK .git/hooks; \
fi \
done \
fi
dependencies:
@$(shell \
cd $(GOVENDOR) ; \
rm -rf src ; \
find . -mindepth 2 -maxdepth 2 -path ./src -prune -o -type d -print | \
sed -e 's/.\///' | \
xargs -I{} sh -c ' \
mkdir -p "src/`dirname {}`" ; \
ln -sfn "../../{}" "src/{}" ; \
' \
)
@mkdir -p $(shell dirname $(GOVENDOR)/src/$(GOPKG))
@ln -sfn ../../../.. $(GOVENDOR)/src/$(GOPKG)
build: install_hooks dependencies
GOPATH=$(GOPATH) go build -o bin/pick .
test: dependencies
GOPATH=$(GOPATH) go test -v $(FOLDERS)
install:
@echo "Installing pick to $(BIN_DIR)/pick"
$(INSTALL) -c bin/pick $(BIN_DIR)/pick
uninstall:
rm -f $(BIN_DIR)/pick
fmt: gofmt
gofmt:
GOPATH=$(GOPATH) go fmt $(FOLDERS)
govet:
GOPATH=$(GOPATH) go tool vet $(FOLDERS)
config:
@if [ ! -f "$(PICK_DIR)/config.toml" ]; then \
OLD_UMASK=$(shell echo `umask`) ; \
umask 077 ; \
mkdir -p $(PICK_DIR) ; \
$(INSTALL) -c -m 0600 config.toml.in $(PICK_DIR)/config.toml ; \
umask $(OLD_UMASK) ; \
fi
clean:
rm -rf bin/
.PHONY: all install_hooks dependencies build test install uninstall fmt gofmt govet config clean