mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-27 14:39:53 -08:00
Update Makefile.COMMON
Go expects to build a project from a location like `.../src/github.com/prometheus/node_exporter`.
This commit is contained in:
parent
b30806ef41
commit
a05966a3a9
|
@ -45,20 +45,23 @@ GOOS ?= $(shell uname | tr A-Z a-z)
|
||||||
GOARCH ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m)))
|
GOARCH ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m)))
|
||||||
|
|
||||||
GO_VERSION ?= 1.5.3
|
GO_VERSION ?= 1.5.3
|
||||||
|
GOPATH ?= $(CURDIR)/.build/gopath
|
||||||
|
ROOTPKG ?= github.com/prometheus/$(TARGET)
|
||||||
|
SELFLINK ?= $(GOPATH)/src/$(ROOTPKG)
|
||||||
|
|
||||||
# Check for the correct version of go in the path. If we find it, use it.
|
# Check for the correct version of go in the path. If we find it, use it.
|
||||||
# Otherwise, prepare to build go locally.
|
# Otherwise, prepare to build go locally.
|
||||||
ifeq ($(shell command -v "go" >/dev/null && go version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/'), $(GO_VERSION))
|
ifeq ($(shell command -v "go" >/dev/null && go version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/'), $(GO_VERSION))
|
||||||
GOCC ?= $(shell command -v "go")
|
GOCC ?= $(shell command -v "go")
|
||||||
GOFMT ?= $(shell command -v "gofmt")
|
GOFMT ?= $(shell command -v "gofmt")
|
||||||
GO ?= $(GOCC)
|
GO ?= GOPATH=$(GOPATH) $(GOCC)
|
||||||
else
|
else
|
||||||
GOURL ?= https://golang.org/dl
|
GOURL ?= https://golang.org/dl
|
||||||
GOPKG ?= go$(GO_VERSION).$(GOOS)-$(GOARCH).tar.gz
|
GOPKG ?= go$(GO_VERSION).$(GOOS)-$(GOARCH).tar.gz
|
||||||
GOROOT ?= $(CURDIR)/.build/go$(GO_VERSION)
|
GOROOT ?= $(CURDIR)/.build/go$(GO_VERSION)
|
||||||
GOCC ?= $(GOROOT)/bin/go
|
GOCC ?= $(GOROOT)/bin/go
|
||||||
GOFMT ?= $(GOROOT)/bin/gofmt
|
GOFMT ?= $(GOROOT)/bin/gofmt
|
||||||
GO ?= GOROOT=$(GOROOT) $(GOCC)
|
GO ?= GOPATH=$(GOPATH) GOROOT=$(GOROOT) $(GOCC)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Use vendored dependencies if available. Otherwise try to download them.
|
# Use vendored dependencies if available. Otherwise try to download them.
|
||||||
|
@ -66,11 +69,7 @@ ifneq (,$(wildcard vendor))
|
||||||
DEPENDENCIES := $(shell find vendor/ -type f -iname '*.go')
|
DEPENDENCIES := $(shell find vendor/ -type f -iname '*.go')
|
||||||
GO := GO15VENDOREXPERIMENT=1 $(GO)
|
GO := GO15VENDOREXPERIMENT=1 $(GO)
|
||||||
else
|
else
|
||||||
GOPATH := $(CURDIR)/.build/gopath
|
|
||||||
ROOTPKG ?= github.com/prometheus/$(TARGET)
|
|
||||||
SELFLINK ?= $(GOPATH)/src/$(ROOTPKG)
|
|
||||||
DEPENDENCIES := dependencies-stamp
|
DEPENDENCIES := dependencies-stamp
|
||||||
GO := GOPATH=$(GOPATH) $(GO)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Never honor GOBIN, should it be set at all.
|
# Never honor GOBIN, should it be set at all.
|
||||||
|
@ -82,8 +81,8 @@ ARCHIVE ?= $(TARGET)-$(VERSION).$(SUFFIX).tar.gz
|
||||||
|
|
||||||
default: $(BINARY)
|
default: $(BINARY)
|
||||||
|
|
||||||
$(BINARY): $(GOCC) $(SRC) $(DEPENDENCIES) Makefile Makefile.COMMON
|
$(BINARY): $(GOCC) $(SRC) $(DEPENDENCIES) Makefile Makefile.COMMON | $(SELFLINK)
|
||||||
$(GO) build $(GOFLAGS) -o $@
|
cd $(SELFLINK) && $(GO) build $(GOFLAGS) -o $@
|
||||||
|
|
||||||
.PHONY: archive
|
.PHONY: archive
|
||||||
archive: $(ARCHIVE)
|
archive: $(ARCHIVE)
|
||||||
|
@ -97,8 +96,8 @@ tag:
|
||||||
git push --tags
|
git push --tags
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: $(GOCC) $(DEPENDENCIES)
|
test: $(GOCC) $(DEPENDENCIES) | $(SELFLINK)
|
||||||
$(GO) test $$($(GO) list ./... | grep -v /vendor/)
|
cd $(SELFLINK) && $(GO) test $$($(GO) list ./... | grep -v /vendor/)
|
||||||
|
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
format: $(GOCC)
|
format: $(GOCC)
|
||||||
|
|
Loading…
Reference in a new issue