diff options
author | Tobias Schmidt <ts@soundcloud.com> | 2014-04-09 19:20:52 -0400 |
---|---|---|
committer | Tobias Schmidt <ts@soundcloud.com> | 2014-04-09 19:30:49 -0400 |
commit | c18f7ecfc6fe82cd16505b9cb4de1214f6bbd885 (patch) | |
tree | 016a50fe9310bf53c25b22aaa4f324886931e070 /Makefile | |
parent | 0f7604c3cd91049782fd710a08723bbb66887dad (diff) | |
download | prometheus_node_collector-c18f7ecfc6fe82cd16505b9cb4de1214f6bbd885.tar.bz2 prometheus_node_collector-c18f7ecfc6fe82cd16505b9cb4de1214f6bbd885.tar.xz prometheus_node_collector-c18f7ecfc6fe82cd16505b9cb4de1214f6bbd885.zip |
Add Makefile with install and release targets
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8b47af2 --- /dev/null +++ b/Makefile | |||
@@ -0,0 +1,50 @@ | |||
1 | VERSION := 0.3.0 | ||
2 | |||
3 | SRC := $(wildcard *.go) | ||
4 | TARGET := node_exporter | ||
5 | |||
6 | OS := $(subst Darwin,darwin,$(subst Linux,linux,$(shell uname))) | ||
7 | ARCH := $(subst x86_64,amd64,$(shell uname -m)) | ||
8 | |||
9 | GOOS ?= $(OS) | ||
10 | GOARCH ?= $(ARCH) | ||
11 | GOPKG := go1.2.1.$(OS)-$(ARCH).tar.gz | ||
12 | GOROOT ?= $(CURDIR)/.deps/go | ||
13 | GOPATH ?= $(CURDIR)/.deps/gopath | ||
14 | GOCC := $(GOROOT)/bin/go | ||
15 | GOLIB := $(GOROOT)/pkg/$(GOOS)_$(GOARCH) | ||
16 | GO := GOROOT=$(GOROOT) GOPATH=$(GOPATH) $(GOCC) | ||
17 | |||
18 | SUFFIX := $(GOOS)-$(GOARCH) | ||
19 | BINARY := $(TARGET) | ||
20 | ARCHIVE := $(TARGET)-$(VERSION).$(SUFFIX).tar.gz | ||
21 | |||
22 | default: | ||
23 | go build $(GOFLAGS) | ||
24 | |||
25 | .deps/$(GOPKG): | ||
26 | mkdir -p .deps | ||
27 | curl -o .deps/$(GOPKG) http://go.googlecode.com/files/$(GOPKG) | ||
28 | |||
29 | $(GOCC): .deps/$(GOPKG) | ||
30 | tar -C .deps -xzf .deps/$(GOPKG) | ||
31 | touch $@ | ||
32 | |||
33 | dependencies: $(SRC) | ||
34 | $(GO) get -d | ||
35 | |||
36 | $(BINARY): $(GOCC) $(SRC) dependencies | ||
37 | $(GO) build $(GOFLAGS) -o $@ | ||
38 | |||
39 | $(ARCHIVE): $(BINARY) | ||
40 | tar -czf $@ $< | ||
41 | |||
42 | release: REMOTE ?= $(error "can't release, REMOTE not set") | ||
43 | release: REMOTE_DIR ?= $(error "can't release, REMOTE_DIR not set") | ||
44 | release: $(ARCHIVE) | ||
45 | scp $< $(REMOTE):$(REMOTE_DIR)/$(ARCHIVE) | ||
46 | |||
47 | clean: | ||
48 | rm -rf bin | ||
49 | |||
50 | .PHONY: dependencies clean release | ||