mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-24 15:12:37 +00:00
Bring Makefiles into shape.
This borrows a lot of the latest changes to the node_exporter Makefile, as well as some tricks from the Prometheus one.
This commit is contained in:
parent
2a5dee15b0
commit
cbf5faaf8c
41
Makefile
41
Makefile
@ -1,6 +1,4 @@
|
||||
# -*- Mode: makefile -*-
|
||||
|
||||
# Copyright 2013 Prometheus Team
|
||||
# Copyright 2013 The Prometheus Authors
|
||||
# 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
|
||||
@ -15,10 +13,22 @@
|
||||
|
||||
include Makefile.INCLUDE
|
||||
|
||||
all: build test
|
||||
default: $(BINARY)
|
||||
|
||||
build: config web
|
||||
$(GO) build $(BUILDFLAGS)
|
||||
.deps/$(GOPKG):
|
||||
mkdir -p .deps
|
||||
curl -o .deps/$(GOPKG) -L $(GOURL)/$(GOPKG)
|
||||
|
||||
$(GOCC): .deps/$(GOPKG)
|
||||
tar -C .deps -xzf .deps/$(GOPKG)
|
||||
touch $@
|
||||
|
||||
$(SELFLINK):
|
||||
mkdir -p $(GOPATH)/src/github.com/prometheus
|
||||
ln -s $(CURDIR) $(SELFLINK)
|
||||
|
||||
dependencies: $(SELFLINK) web config
|
||||
$(GO) get -d
|
||||
|
||||
config:
|
||||
$(MAKE) -C config
|
||||
@ -26,11 +36,22 @@ config:
|
||||
web:
|
||||
$(MAKE) -C web
|
||||
|
||||
test: build
|
||||
$(GO) test -v ./...
|
||||
$(BINARY): $(GOCC) dependencies
|
||||
$(GO) build $(BUILDFLAGS) -o $@
|
||||
|
||||
$(ARCHIVE): $(BINARY)
|
||||
tar -czf $@ $<
|
||||
|
||||
release: REMOTE ?= $(error "can't release, REMOTE not set")
|
||||
release: REMOTE_DIR ?= $(error "can't release, REMOTE_DIR not set")
|
||||
release: $(ARCHIVE)
|
||||
scp $< $(REMOTE):$(REMOTE_DIR)/$(ARCHIVE)
|
||||
|
||||
test: $(GOCC) dependencies
|
||||
$(GO) test ./...
|
||||
|
||||
clean:
|
||||
$(MAKE) -C web clean
|
||||
-rm alertmanager
|
||||
-rm -rf alertmanager .deps
|
||||
|
||||
.PHONY: clean config web
|
||||
.PHONY: clean config default dependencies release test web
|
||||
|
@ -1,6 +1,4 @@
|
||||
# -*- Mode: makefile -*-
|
||||
|
||||
# Copyright 2013 Prometheus Team
|
||||
# Copyright 2013 The Prometheus Authors
|
||||
# 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
|
||||
@ -13,11 +11,39 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
.SUFFIXES:
|
||||
VERSION := 0.1.0
|
||||
|
||||
GO := $(GOROOT)/bin/go
|
||||
TARGET := alertmanager
|
||||
|
||||
OS := $(subst Darwin,darwin,$(subst Linux,linux,$(shell uname)))
|
||||
ARCH := $(subst x86_64,amd64,$(shell uname -m))
|
||||
|
||||
# The release engineers apparently need to key their binary artifacts to the
|
||||
# Mac OS X release family.
|
||||
MAC_OS_X_VERSION ?= 10.8
|
||||
|
||||
GOOS ?= $(OS)
|
||||
GOARCH ?= $(ARCH)
|
||||
|
||||
ifeq ($(GOOS),darwin)
|
||||
RELEASE_SUFFIX ?= -osx$(MAC_OS_X_VERSION)
|
||||
else
|
||||
RELEASE_SUFFIX ?=
|
||||
endif
|
||||
|
||||
GO_VERSION ?= 1.4.1
|
||||
GOURL ?= https://golang.org/dl
|
||||
GOPKG ?= go$(GO_VERSION).$(GOOS)-$(GOARCH)$(RELEASE_SUFFIX).tar.gz
|
||||
GOROOT := $(PWD)/.deps/go
|
||||
GOPATH := $(PWD)/.deps/gopath
|
||||
GOCC := $(GOROOT)/bin/go
|
||||
GO := GOROOT=$(GOROOT) GOPATH=$(GOPATH) $(GOCC)
|
||||
GOFMT := $(GOROOT)/bin/gofmt
|
||||
GO_VERSION := 1.1
|
||||
|
||||
SUFFIX := $(GOOS)-$(GOARCH)
|
||||
BINARY := $(TARGET)
|
||||
ARCHIVE := $(TARGET)-$(VERSION).$(SUFFIX).tar.gz
|
||||
SELFLINK := $(GOPATH)/src/github.com/prometheus/alertmanager
|
||||
|
||||
REV := $(shell git rev-parse --short HEAD)
|
||||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
||||
|
16
web/Makefile
16
web/Makefile
@ -1,4 +1,4 @@
|
||||
# Copyright 2013 Prometheus Team
|
||||
# Copyright 2013 The Prometheus Authors
|
||||
# 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
|
||||
@ -11,14 +11,16 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
all: blob-stamp
|
||||
include ../Makefile.INCLUDE
|
||||
|
||||
blob-stamp: templates/*
|
||||
$(MAKE) -C blob
|
||||
touch $@
|
||||
all: blob/files.go
|
||||
|
||||
SUFFIXES:
|
||||
|
||||
blob/files.go: $(shell find templates/ static/ -type f)
|
||||
./blob/embed-static.sh static templates | $(GOFMT) > $@
|
||||
|
||||
clean:
|
||||
$(MAKE) -C blob clean
|
||||
-rm -f *-stamp
|
||||
-rm -f blob/files.go
|
||||
|
||||
.PHONY: clean
|
||||
|
@ -1,25 +0,0 @@
|
||||
# Copyright 2013 Prometheus Team
|
||||
# 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.
|
||||
|
||||
all: files.go
|
||||
|
||||
SUFFIXES:
|
||||
|
||||
files.go: $(shell find ../templates/ ../static/ -type f)
|
||||
./embed-static.sh ../static ../templates | gofmt > $@
|
||||
|
||||
clean:
|
||||
-rm files.go
|
||||
-rm -rf generated
|
||||
|
||||
.PHONY: clean
|
Loading…
Reference in New Issue
Block a user