diff --git a/Makefile b/Makefile index b00d85820f..8bebc90087 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,10 @@ STATICCHECK_IGNORE = \ DOCKER_IMAGE_NAME ?= prometheus +# Go modules needs the bzr binary because of the dependency on launchpad.net/gocheck. +$(eval $(call PRECHECK_COMMAND_template,bzr)) +PRECHECK_OPTIONS_bzr = version + .PHONY: assets assets: @echo ">> writing assets" diff --git a/Makefile.common b/Makefile.common index 8f62b47495..e391a9f23e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -68,7 +68,7 @@ DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) DOCKER_REPO ?= prom .PHONY: all -all: style staticcheck unused build test +all: precheck style staticcheck unused build test # This rule is used to forward a target like "build" to "common-build". This # allows a new "build" target to be defined in a Makefile which includes this @@ -195,3 +195,19 @@ ifdef GOVENDOR $(GOVENDOR): GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor endif + +.PHONY: precheck +precheck:: + +define PRECHECK_COMMAND_template = +precheck:: $(1)_precheck + + +PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1))) +.PHONE: $(1)_precheck +$(1)_precheck: + @if ! $$(PRECHECK_COMMAND_$(1)) 1>/dev/null 2>&1; then \ + echo "Execution of '$$(PRECHECK_COMMAND_$(1))' command failed. Is $(1) installed?"; \ + exit 1; \ + fi +endef