-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
81 lines (61 loc) · 1.92 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
78
79
80
81
#
# Makefile
#
# The kickoff point for all project management commands.
#
# Program version
VERSION := $(shell grep "const Version " version.go | sed -E 's/.*"(.+)"$$/\1/')
# Binary name for bintray
BIN_NAME=mock-ec2-metadata
# Project owner for bintray
OWNER=NYTimes
# Project name for bintray
PROJECT_NAME=mock-ec2-metadata
# Project url used for builds
# examples: github.com, bitbucket.org
REPO_HOST_URL=github.com
# Grab the current commit
GIT_COMMIT=$(shell git rev-parse HEAD)
# Check if there are uncommited changes
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
# Use a local vendor directory for any dependencies; comment this out to
# use the global GOPATH instead
GOPATH=$(PWD)/.vendor
INSTALL_PATH=$(GOPATH)/src/github.com/NYTimes/mock-ec2-metadata
default: build
help:
@echo 'Management commands for mock-ec2-metadata:'
@echo
@echo 'Usage:'
@echo ' make build Compile the project.'
@echo ' make link Symlink this project into the GOPATH.'
@echo ' make test Run tests on a compiled project.'
@echo ' make fmt Reformat the source tree with gofmt.'
@echo ' make clean Clean the directory tree.'
@echo
build: .git $(GOPATH)/bin/gogpm $(INSTALL_PATH)
@echo "building ${OWNER} ${BIN_NAME} ${VERSION}"
@echo "GOPATH=${GOPATH}"
$(GOPATH)/bin/gogpm install &&\
go build -ldflags "-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}" -o bin/${BIN_NAME} main.go
clean:
@test ! -e bin/${BIN_NAME} || rm bin/${BIN_NAME}
.git:
git init
git add -A .
git commit -m 'Initial scaffolding.'
link:
# relink into the go path
if [ ! $(INSTALL_PATH) -ef . ]; then \
mkdir -p `dirname $(INSTALL_PATH)`; \
ln -s $(PWD) $(INSTALL_PATH); \
fi
$(INSTALL_PATH):
make link
$(GOPATH)/bin/gogpm:
go get github.com/mtibben/gogpm
test:
go test ./...
fmt:
find . -name '*.go' -not -path './.vendor/*' -exec gofmt -w=true {} ';'
.PHONY: build dist clean test help default link fmt