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-11-11 01:01:43 +00:00
|
|
|
GO_LDFLAGS=-ldflags "-X `go list ./version`.Version=$(VERSION)"
|
2015-01-29 23:32:49 +00:00
|
|
|
|
2016-11-01 09:48:25 +00:00
|
|
|
.PHONY: all build binaries clean dep-restore dep-save dep-validate fmt lint test test-full vet
|
2016-02-22 20:56:23 +00:00
|
|
|
.DEFAULT: all
|
2016-03-18 21:07:13 +00:00
|
|
|
all: fmt vet 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 > $@
|
|
|
|
|
2016-03-18 21:07:13 +00:00
|
|
|
# Required for go 1.5 to build
|
|
|
|
GO15VENDOREXPERIMENT := 1
|
|
|
|
|
2016-10-11 00:30:47 +00:00
|
|
|
# Go files
|
|
|
|
GOFILES=$(shell find . -type f -name '*.go')
|
|
|
|
|
2016-03-18 21:07:13 +00:00
|
|
|
# Package list
|
2016-10-11 00:30:47 +00:00
|
|
|
PKGS=$(shell go list -tags "${DOCKER_BUILDTAGS}" ./... | grep -v ^github.com/docker/distribution/vendor/)
|
2016-03-18 21:07:13 +00:00
|
|
|
|
|
|
|
# Resolving binary dependencies for specific targets
|
2016-10-11 00:30:47 +00:00
|
|
|
GOLINT=$(shell which golint || echo '')
|
|
|
|
GODEP=$(shell which godep || echo '')
|
2016-03-21 19:08:47 +00:00
|
|
|
|
2016-10-11 00:30:47 +00:00
|
|
|
${PREFIX}/bin/registry: $(GOFILES)
|
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
|
|
|
|
2016-10-11 00:30:47 +00:00
|
|
|
${PREFIX}/bin/digest: $(GOFILES)
|
2015-08-20 19:39:50 +00:00
|
|
|
@echo "+ $@"
|
|
|
|
@go build -tags "${DOCKER_BUILDTAGS}" -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./cmd/digest
|
|
|
|
|
2016-10-11 00:30:47 +00:00
|
|
|
${PREFIX}/bin/registry-api-descriptor-template: $(GOFILES)
|
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
|
|
|
|
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 $< > $@
|
|
|
|
|
2016-03-18 21:07:13 +00:00
|
|
|
vet:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2016-03-18 21:07:13 +00:00
|
|
|
@go vet -tags "${DOCKER_BUILDTAGS}" $(PKGS)
|
2015-02-06 23:39:11 +00:00
|
|
|
|
|
|
|
fmt:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2016-03-18 21:07:13 +00:00
|
|
|
@test -z "$$(gofmt -s -l . 2>&1 | grep -v ^vendor/ | tee /dev/stderr)" || \
|
|
|
|
(echo >&2 "+ please format Go code with 'gofmt -s'" && false)
|
2015-02-06 23:39:11 +00:00
|
|
|
|
|
|
|
lint:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2016-03-18 21:07:13 +00:00
|
|
|
$(if $(GOLINT), , \
|
|
|
|
$(error Please install golint: `go get -u github.com/golang/lint/golint`))
|
|
|
|
@test -z "$$($(GOLINT) ./... 2>&1 | grep -v ^vendor/ | tee /dev/stderr)"
|
2015-02-06 23:39:11 +00:00
|
|
|
|
|
|
|
build:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2016-03-18 21:07:13 +00:00
|
|
|
@go build -tags "${DOCKER_BUILDTAGS}" -v ${GO_LDFLAGS} $(PKGS)
|
2015-02-06 23:39:11 +00:00
|
|
|
|
|
|
|
test:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2016-03-18 21:07:13 +00:00
|
|
|
@go test -test.short -tags "${DOCKER_BUILDTAGS}" $(PKGS)
|
2015-02-06 23:39:11 +00:00
|
|
|
|
|
|
|
test-full:
|
2015-02-16 22:25:17 +00:00
|
|
|
@echo "+ $@"
|
2016-03-18 21:07:13 +00:00
|
|
|
@go test -tags "${DOCKER_BUILDTAGS}" $(PKGS)
|
2015-02-06 23:39:11 +00:00
|
|
|
|
2015-08-20 19:39:50 +00:00
|
|
|
binaries: ${PREFIX}/bin/registry ${PREFIX}/bin/digest ${PREFIX}/bin/registry-api-descriptor-template
|
2015-02-16 22:25:17 +00:00
|
|
|
@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 "+ $@"
|
2016-03-18 21:07:13 +00:00
|
|
|
@rm -rf "${PREFIX}/bin/registry" "${PREFIX}/bin/digest" "${PREFIX}/bin/registry-api-descriptor-template"
|
2016-03-21 19:08:47 +00:00
|
|
|
|
|
|
|
dep-save:
|
2016-03-22 01:04:27 +00:00
|
|
|
@echo "+ $@"
|
2016-03-21 19:08:47 +00:00
|
|
|
$(if $(GODEP), , \
|
|
|
|
$(error Please install godep: go get github.com/tools/godep))
|
2016-03-22 01:04:27 +00:00
|
|
|
@$(GODEP) save $(PKGS)
|
2016-03-21 19:08:47 +00:00
|
|
|
|
|
|
|
dep-restore:
|
2016-03-22 01:04:27 +00:00
|
|
|
@echo "+ $@"
|
2016-03-21 19:08:47 +00:00
|
|
|
$(if $(GODEP), , \
|
|
|
|
$(error Please install godep: go get github.com/tools/godep))
|
2016-03-22 01:04:27 +00:00
|
|
|
@$(GODEP) restore -v
|
|
|
|
|
|
|
|
dep-validate: dep-restore
|
|
|
|
@echo "+ $@"
|
|
|
|
@rm -Rf .vendor.bak
|
|
|
|
@mv vendor .vendor.bak
|
|
|
|
@rm -Rf Godeps
|
|
|
|
@$(GODEP) save ./...
|
|
|
|
@test -z "$$(diff -r vendor .vendor.bak 2>&1 | tee /dev/stderr)" || \
|
|
|
|
(echo >&2 "+ borked dependencies! what you have in Godeps/Godeps.json does not match with what you have in vendor" && false)
|
2016-03-22 17:42:33 +00:00
|
|
|
@rm -Rf .vendor.bak
|