2015-02-02 17:14:36 +03:00
|
|
|
# Copyright 2013 The Prometheus Authors
|
2013-03-29 00:03:01 +04:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2015-02-02 17:25:06 +03:00
|
|
|
VERSION=$(shell cat `git rev-parse --show-toplevel`/VERSION)
|
|
|
|
|
2013-07-21 19:09:48 +04:00
|
|
|
OS = $(shell uname)
|
|
|
|
ARCH = $(shell uname -m)
|
|
|
|
|
2014-05-07 22:08:33 +04:00
|
|
|
MAC_OS_X_VERSION ?= 10.8
|
|
|
|
|
2013-07-21 19:09:48 +04:00
|
|
|
BUILD_PATH = $(PWD)/.build
|
|
|
|
|
2015-03-04 14:41:07 +03:00
|
|
|
export GO_VERSION = 1.4.2
|
2015-02-05 19:12:37 +03:00
|
|
|
export GOOS = $(subst Darwin,darwin,$(subst Linux,linux,$(subst FreeBSD,freebsd,$(OS))))
|
2014-05-07 22:08:33 +04:00
|
|
|
|
|
|
|
ifeq ($(GOOS),darwin)
|
|
|
|
RELEASE_SUFFIX ?= -osx$(MAC_OS_X_VERSION)
|
|
|
|
else
|
|
|
|
RELEASE_SUFFIX ?=
|
|
|
|
endif
|
|
|
|
|
2015-02-02 17:14:36 +03:00
|
|
|
# Never honor GOBIN, should it be set at all.
|
|
|
|
unexport GOBIN
|
|
|
|
|
2015-08-03 21:34:44 +03:00
|
|
|
export GOARCH = $(subst x86_64,amd64,$(patsubst i%86,386,$(ARCH)))
|
|
|
|
export GOPKG = go$(GO_VERSION).$(GOOS)-$(GOARCH)$(RELEASE_SUFFIX).tar.gz
|
|
|
|
export GOURL = https://golang.org/dl
|
|
|
|
export GOROOT = $(BUILD_PATH)/root/go
|
|
|
|
export GOPATH = $(BUILD_PATH)/root/gopath
|
|
|
|
export GOCC = $(GOROOT)/bin/go
|
|
|
|
export TMPDIR = /tmp
|
|
|
|
export GOENV = TMPDIR=$(TMPDIR) GOROOT=$(GOROOT) GOPATH=$(GOPATH)
|
|
|
|
export GO = $(GOENV) $(GOCC)
|
|
|
|
export GOFMT = $(GOROOT)/bin/gofmt
|
|
|
|
export GODOC = $(GOENV) $(GOROOT)/bin/godoc
|
2013-07-21 19:09:48 +04:00
|
|
|
|
2014-04-14 20:45:16 +04:00
|
|
|
BENCHMARK_FILTER ?= .
|
|
|
|
|
2013-07-21 19:09:48 +04:00
|
|
|
FULL_GOPATH = $(GOPATH)/src/github.com/prometheus/client_golang
|
|
|
|
FULL_GOPATH_BASE = $(GOPATH)/src/github.com/prometheus
|
|
|
|
|
2015-01-26 03:19:15 +03:00
|
|
|
MAKE_ARTIFACTS = search_index $(BUILD_PATH) example_random example_simple
|
2013-03-29 00:03:01 +04:00
|
|
|
|
|
|
|
all: test
|
|
|
|
|
2013-07-21 19:09:48 +04:00
|
|
|
$(BUILD_PATH):
|
|
|
|
mkdir -vp $(BUILD_PATH)
|
|
|
|
|
|
|
|
$(BUILD_PATH)/cache: $(BUILD_PATH)
|
|
|
|
mkdir -vp $(BUILD_PATH)/cache
|
|
|
|
|
|
|
|
$(BUILD_PATH)/root: $(BUILD_PATH)
|
|
|
|
mkdir -vp $(BUILD_PATH)/root
|
|
|
|
|
|
|
|
$(BUILD_PATH)/cache/$(GOPKG): $(BUILD_PATH)/cache
|
2014-12-19 16:17:25 +03:00
|
|
|
curl -o $@ -L $(GOURL)/$(GOPKG)
|
2013-07-21 19:09:48 +04:00
|
|
|
|
|
|
|
$(GOCC): $(BUILD_PATH)/root $(BUILD_PATH)/cache/$(GOPKG)
|
|
|
|
tar -C $(BUILD_PATH)/root -xzf $(BUILD_PATH)/cache/$(GOPKG)
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
build: source_path dependencies
|
2014-05-07 22:08:33 +04:00
|
|
|
$(GO) build ./...
|
2013-03-29 00:03:01 +04:00
|
|
|
|
2013-07-21 19:09:48 +04:00
|
|
|
dependencies: source_path $(GOCC)
|
2015-02-27 18:12:59 +03:00
|
|
|
cp -a $(CURDIR)/Godeps/_workspace/src/* $(GOPATH)/src
|
2013-07-21 19:09:48 +04:00
|
|
|
|
2015-01-26 03:19:15 +03:00
|
|
|
example_random: source_path dependencies examples/random/main.go
|
|
|
|
$(GO) build -o example_random examples/random/main.go
|
|
|
|
|
|
|
|
example_simple: source_path dependencies examples/simple/main.go
|
|
|
|
$(GO) build -o example_simple examples/simple/main.go
|
|
|
|
|
2013-03-29 00:03:01 +04:00
|
|
|
test: build
|
2015-02-19 17:51:11 +03:00
|
|
|
$(GO) test -short ./...
|
2013-04-03 20:33:32 +04:00
|
|
|
|
2014-04-14 20:45:16 +04:00
|
|
|
benchmark: build
|
|
|
|
$(GO) test -benchmem -test.bench="$(BENCHMARK_FILTER)" ./...
|
|
|
|
|
2013-04-03 20:33:32 +04:00
|
|
|
advice: test
|
2014-05-07 22:08:33 +04:00
|
|
|
$(GO) vet ./...
|
2013-03-29 00:03:01 +04:00
|
|
|
|
|
|
|
format:
|
2015-02-26 02:36:30 +03:00
|
|
|
find . -iname '*.go' | grep -vE '^./(.build|Godeps)/' | xargs -n1 -P1 $(GOFMT) -w -s=true
|
2015-02-02 17:25:06 +03:00
|
|
|
|
|
|
|
tag:
|
|
|
|
git tag $(VERSION)
|
|
|
|
git push --tags
|
2013-03-29 00:03:01 +04:00
|
|
|
|
|
|
|
search_index:
|
2014-05-07 22:08:33 +04:00
|
|
|
$(GODOC) -index -write_index -index_files='search_index'
|
2013-03-29 00:03:01 +04:00
|
|
|
|
2013-07-21 19:09:48 +04:00
|
|
|
# source_path is responsible for ensuring that the builder has not done anything
|
|
|
|
# stupid like working on Prometheus outside of ${GOPATH}.
|
|
|
|
source_path:
|
|
|
|
-[ -d "$(FULL_GOPATH)" ] || { mkdir -vp $(FULL_GOPATH_BASE) ; ln -s "$(PWD)" "$(FULL_GOPATH)" ; }
|
|
|
|
[ -d "$(FULL_GOPATH)" ]
|
|
|
|
|
2013-03-29 00:03:01 +04:00
|
|
|
documentation: search_index
|
2014-05-07 22:08:33 +04:00
|
|
|
$(GODOC) -http=:6060 -index -index_files='search_index'
|
2013-03-29 00:03:01 +04:00
|
|
|
|
|
|
|
clean:
|
2013-07-21 19:09:48 +04:00
|
|
|
rm -rf $(MAKE_ARTIFACTS)
|
2013-04-03 20:33:32 +04:00
|
|
|
find . -iname '*~' -exec rm -f '{}' ';'
|
|
|
|
find . -iname '*#' -exec rm -f '{}' ';'
|
2013-03-29 00:03:01 +04:00
|
|
|
|
2013-07-21 19:09:48 +04:00
|
|
|
.PHONY: advice build clean documentation format source_path test
|