-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
58 lines (43 loc) · 1.87 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
GOVERSION=$(shell go version)
GOOS=$(word 1,$(subst /, ,$(lastword $(GOVERSION))))
GOARCH=$(word 2,$(subst /, ,$(lastword $(GOVERSION))))
RELEASE_DIR=bin
DEVTOOL_DIR=devtools
PACKAGE=github.com/moznion/resque_exporter
REVISION=$(shell git rev-parse --verify HEAD)
HAVE_GLIDE:=$(shell which glide > /dev/null 2>&1)
.PHONY: clean build build-linux-amd64 build-linux-386 build-darwin-amd64 build-darwin-386 build-windows-amd64 build-windows-386 $(RELEASE_DIR)/resque_exporter_$(GOOS)_$(GOARCH) all
all: installdeps clean build-linux-amd64 build-linux-386 build-darwin-amd64 build-darwin-386 build-windows-amd64 build-windows-386
build: $(RELEASE_DIR)/resque_exporter_$(GOOS)_$(GOARCH)
build-linux-amd64:
@$(MAKE) build GOOS=linux GOARCH=amd64
build-linux-386:
@$(MAKE) build GOOS=linux GOARCH=386
build-darwin-amd64:
@$(MAKE) build GOOS=darwin GOARCH=amd64
build-darwin-386:
@$(MAKE) build GOOS=darwin GOARCH=386
build-windows-amd64:
@$(MAKE) build GOOS=windows GOARCH=amd64
build-windows-386:
@$(MAKE) build GOOS=windows GOARCH=386
$(RELEASE_DIR)/resque_exporter_$(GOOS)_$(GOARCH):
ifndef VERSION
@echo '[ERROR] $$VERSION must be specified'
exit 255
endif
go build -ldflags "-X $(PACKAGE).rev=$(REVISION) -X $(PACKAGE).ver=$(VERSION)" \
-o $(RELEASE_DIR)/resque_exporter_$(GOOS)_$(GOARCH)_$(VERSION) cmd/resque_exporter/resque_exporter.go
$(DEVTOOL_DIR)/$(GOOS)/$(GOARCH)/glide:
ifndef HAVE_GLIDE
@echo "Installing glide for $(GOOS)/$(GOARCH)..."
mkdir -p $(DEVTOOL_DIR)/$(GOOS)/$(GOARCH)
wget -q -O - https://github.com/Masterminds/glide/releases/download/v0.12.3/glide-v0.12.3-$(GOOS)-$(GOARCH).tar.gz | tar xvz
mv $(GOOS)-$(GOARCH)/glide $(DEVTOOL_DIR)/$(GOOS)/$(GOARCH)/glide
rm -rf $(GOOS)-$(GOARCH)
endif
glide: $(DEVTOOL_DIR)/$(GOOS)/$(GOARCH)/glide
installdeps: glide
@PATH=$(DEVTOOL_DIR)/$(GOOS)/$(GOARCH):$(PATH) glide install
clean:
rm -rf $(RELEASE_DIR)/resque_exporter_*