2015-01-29 23:32:49 +00:00
|
|
|
# Set an output prefix, which is the local directory if not specified
|
|
|
|
PREFIX?=$(shell pwd)
|
2015-01-15 00:25:27 +00:00
|
|
|
|
2015-06-10 17:48:33 +00:00
|
|
|
|
2015-01-29 23:32:49 +00:00
|
|
|
# Used to populate version variable in main package.
|
2015-04-01 18:28:34 +00:00
|
|
|
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
|
2015-06-10 17:48:33 +00:00
|
|
|
|
|
|
|
# Allow turning off function inlining and variable registerization
|
|
|
|
ifeq (${DISABLE_OPTIMIZATION},true)
|
|
|
|
GO_GCFLAGS=-gcflags "-N -l"
|
|
|
|
VERSION:="$(VERSION)-noopt"
|
|
|
|
endif
|
|
|
|
|
2015-04-01 18:28:34 +00:00
|
|
|
GO_LDFLAGS=-ldflags "-X `go list ./version`.Version $(VERSION)"
|
2015-01-29 23:32:49 +00:00
|
|
|
|
2015-02-06 23:39:11 +00:00
|
|
|
.PHONY: clean all fmt vet lint build test binaries
|
2015-01-15 00:25:27 +00:00
|
|
|
.DEFAULT: default
|
2015-02-07 01:49:50 +00:00
|
|
|
all: AUTHORS clean fmt vet fmt lint build test binaries
|
2015-01-15 00:25:27 +00:00
|
|
|
|
2015-02-23 23:11:04 +00:00
|
|
|
AUTHORS: .mailmap .git/HEAD
|
2015-02-07 01:49:50 +00:00
|
|
|
git log --format='%aN <%aE>' | sort -fu > $@
|
2015-01-15 00:25:27 +00:00
|
|
|
|
2015-01-29 23:32:49 +00:00
|
|
|
# This only needs to be generated by hand when cutting full releases.
|
|
|
|
version/version.go:
|
|
|
|
./version/version.sh > $@
|
|
|
|
|
|
|
|
${PREFIX}/bin/registry: version/version.go $(shell find . -type f -name '*.go')
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2015-06-10 17:48:33 +00:00
|
|
|
@go build -tags "${DOCKER_BUILDTAGS}" -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./cmd/registry
|
2015-01-29 23:32:49 +00:00
|
|
|
|
2015-02-07 01:49:50 +00:00
|
|
|
${PREFIX}/bin/registry-api-descriptor-template: version/version.go $(shell find . -type f -name '*.go')
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2015-06-10 17:48:33 +00:00
|
|
|
@go build -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./cmd/registry-api-descriptor-template
|
2015-02-16 22:25:17 +00:00
|
|
|
|
|
|
|
${PREFIX}/bin/dist: version/version.go $(shell find . -type f -name '*.go')
|
|
|
|
@echo "+ $@"
|
2015-06-10 17:48:33 +00:00
|
|
|
@go build -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./cmd/dist
|
2015-02-07 01:49:50 +00:00
|
|
|
|
2015-04-16 00:55:15 +00:00
|
|
|
docs/spec/api.md: docs/spec/api.md.tmpl ${PREFIX}/bin/registry-api-descriptor-template
|
2015-02-07 01:49:50 +00:00
|
|
|
./bin/registry-api-descriptor-template $< > $@
|
|
|
|
|
2015-02-06 23:39:11 +00:00
|
|
|
vet:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
|
|
|
@go vet ./...
|
2015-02-06 23:39:11 +00:00
|
|
|
|
|
|
|
fmt:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
|
|
|
@test -z "$$(gofmt -s -l . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" || \
|
2015-02-06 23:39:11 +00:00
|
|
|
echo "+ please format Go code with 'gofmt -s'"
|
|
|
|
|
|
|
|
lint:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
|
|
|
@test -z "$$(golint ./... | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
|
2015-02-06 23:39:11 +00:00
|
|
|
|
|
|
|
build:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2015-04-23 16:13:52 +00:00
|
|
|
@go build -tags "${DOCKER_BUILDTAGS}" -v ${GO_LDFLAGS} ./...
|
2015-02-06 23:39:11 +00:00
|
|
|
|
|
|
|
test:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2015-04-23 16:13:52 +00:00
|
|
|
@go test -test.short -tags "${DOCKER_BUILDTAGS}" ./...
|
2015-02-06 23:39:11 +00:00
|
|
|
|
|
|
|
test-full:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
|
|
|
@go test ./...
|
2015-02-06 23:39:11 +00:00
|
|
|
|
2015-02-16 22:25:17 +00:00
|
|
|
binaries: ${PREFIX}/bin/registry ${PREFIX}/bin/registry-api-descriptor-template ${PREFIX}/bin/dist
|
|
|
|
@echo "+ $@"
|
2015-01-29 23:32:49 +00:00
|
|
|
|
2015-01-15 00:25:27 +00:00
|
|
|
clean:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
|
|
|
@rm -rf "${PREFIX}/bin/registry" "${PREFIX}/bin/registry-api-descriptor-template"
|
2015-04-01 18:28:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Use the existing docs build cmds from docker/docker
|
|
|
|
# Later, we will move this into an import
|
|
|
|
DOCS_MOUNT := $(if $(DOCSDIR),-v $(CURDIR)/$(DOCSDIR):/$(DOCSDIR))
|
|
|
|
DOCSPORT := 8000
|
|
|
|
DOCKER_DOCS_IMAGE := docker-docs-$(VERSION)
|
|
|
|
DOCKER_RUN_DOCS := docker run --rm -it $(DOCS_MOUNT) -e AWS_S3_BUCKET -e NOCACHE
|
|
|
|
|
|
|
|
docs: docs-build
|
|
|
|
$(DOCKER_RUN_DOCS) -p $(DOCSPORT):8000 "$(DOCKER_DOCS_IMAGE)" mkdocs serve
|
|
|
|
|
|
|
|
docs-shell: docs-build
|
|
|
|
$(DOCKER_RUN_DOCS) -p $(DOCSPORT):8000 "$(DOCKER_DOCS_IMAGE)" bash
|
|
|
|
|
|
|
|
docs-build:
|
|
|
|
docker build -t "$(DOCKER_DOCS_IMAGE)" -f docs/Dockerfile .
|