github.com/mika/distribution@v2.2.2-0.20160108133430-a75790e3d8e0+incompatible/Makefile (about)

     1  # Set an output prefix, which is the local directory if not specified
     2  PREFIX?=$(shell pwd)
     3  
     4  
     5  # Used to populate version variable in main package.
     6  VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
     7  
     8  # Allow turning off function inlining and variable registerization
     9  ifeq (${DISABLE_OPTIMIZATION},true)
    10  	GO_GCFLAGS=-gcflags "-N -l"
    11  	VERSION:="$(VERSION)-noopt"
    12  endif
    13  
    14  GO_LDFLAGS=-ldflags "-X `go list ./version`.Version=$(VERSION)"
    15  
    16  .PHONY: clean all fmt vet lint build test binaries
    17  .DEFAULT: default
    18  all: AUTHORS clean fmt vet fmt lint build test binaries
    19  
    20  AUTHORS: .mailmap .git/HEAD
    21  	 git log --format='%aN <%aE>' | sort -fu > $@
    22  
    23  # This only needs to be generated by hand when cutting full releases.
    24  version/version.go:
    25  	./version/version.sh > $@
    26  
    27  ${PREFIX}/bin/registry: version/version.go $(shell find . -type f -name '*.go')
    28  	@echo "+ $@"
    29  	@go build -tags "${DOCKER_BUILDTAGS}" -o $@ ${GO_LDFLAGS}  ${GO_GCFLAGS} ./cmd/registry
    30  
    31  ${PREFIX}/bin/digest: version/version.go $(shell find . -type f -name '*.go')
    32  	@echo "+ $@"
    33  	@go build -tags "${DOCKER_BUILDTAGS}" -o $@ ${GO_LDFLAGS}  ${GO_GCFLAGS} ./cmd/digest
    34  
    35  ${PREFIX}/bin/registry-api-descriptor-template: version/version.go $(shell find . -type f -name '*.go')
    36  	@echo "+ $@"
    37  	@go build -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./cmd/registry-api-descriptor-template
    38  
    39  docs/spec/api.md: docs/spec/api.md.tmpl ${PREFIX}/bin/registry-api-descriptor-template
    40  	./bin/registry-api-descriptor-template $< > $@
    41  
    42  # Depends on binaries because vet will silently fail if it can't load compiled
    43  # imports
    44  vet: binaries
    45  	@echo "+ $@"
    46  	@go vet ./...
    47  
    48  fmt:
    49  	@echo "+ $@"
    50  	@test -z "$$(gofmt -s -l . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" || \
    51  		echo "+ please format Go code with 'gofmt -s'"
    52  
    53  lint:
    54  	@echo "+ $@"
    55  	@test -z "$$(golint ./... | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
    56  
    57  build:
    58  	@echo "+ $@"
    59  	@go build -tags "${DOCKER_BUILDTAGS}" -v ${GO_LDFLAGS} ./...
    60  
    61  test:
    62  	@echo "+ $@"
    63  	@go test -test.short -tags "${DOCKER_BUILDTAGS}" ./...
    64  
    65  test-full:
    66  	@echo "+ $@"
    67  	@go test ./...
    68  
    69  binaries: ${PREFIX}/bin/registry ${PREFIX}/bin/digest ${PREFIX}/bin/registry-api-descriptor-template
    70  	@echo "+ $@"
    71  
    72  clean:
    73  	@echo "+ $@"
    74  	@rm -rf "${PREFIX}/bin/registry" "${PREFIX}/bin/registry-api-descriptor-template"