github.com/opencontainers/runtime-tools@v0.9.0/Makefile (about)

     1  PREFIX ?= $(DESTDIR)/usr
     2  BINDIR ?= $(DESTDIR)/usr/bin
     3  TAP ?= tap
     4  
     5  BUILDTAGS=
     6  RUNTIME ?= runc
     7  COMMIT=$(shell git rev-parse HEAD 2> /dev/null || true)
     8  VERSION := ${shell cat ./VERSION}
     9  VALIDATION_TESTS ?= $(patsubst %.go,%.t,$(shell find ./validation/ -name *.go | grep -v util))
    10  
    11  all: tool runtimetest validation-executables
    12  
    13  tool:
    14  	go build -tags "$(BUILDTAGS)" -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -o oci-runtime-tool ./cmd/oci-runtime-tool
    15  
    16  .PHONY: runtimetest
    17  runtimetest:
    18  	CGO_ENABLED=0 go build -installsuffix cgo -tags "$(BUILDTAGS)" -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -o runtimetest ./cmd/runtimetest
    19  
    20  .PHONY: man
    21  man:
    22  	go-md2man -in "man/oci-runtime-tool.1.md" -out "oci-runtime-tool.1"
    23  	go-md2man -in "man/oci-runtime-tool-generate.1.md" -out "oci-runtime-tool-generate.1"
    24  	go-md2man -in "man/oci-runtime-tool-validate.1.md" -out "oci-runtime-tool-validate.1"
    25  
    26  install: man
    27  	install -d -m 755 $(BINDIR)
    28  	install -m 755 oci-runtime-tool $(BINDIR)
    29  	install -d -m 755 $(PREFIX)/share/man/man1
    30  	install -m 644 *.1 $(PREFIX)/share/man/man1
    31  	install -d -m 755 $(PREFIX)/share/bash-completion/completions
    32  	install -m 644 completions/bash/oci-runtime-tool $(PREFIX)/share/bash-completion/completions
    33  
    34  uninstall:
    35  	rm -f $(BINDIR)/oci-runtime-tool
    36  	rm -f $(PREFIX)/share/man/man1/oci-runtime-tool*.1
    37  	rm -f $(PREFIX)/share/bash-completion/completions/oci-runtime-tool
    38  
    39  clean:
    40  	rm -f oci-runtime-tool runtimetest *.1 $(VALIDATION_TESTS)
    41  
    42  localvalidation:
    43  	@for EXECUTABLE in runtimetest $(VALIDATION_TESTS); \
    44  	do \
    45  		if test ! -x "$${EXECUTABLE}"; \
    46  		then \
    47  			echo "missing test executable $${EXECUTABLE}; run 'make runtimetest validation-executables'" >&2; \
    48  			exit 1; \
    49  		fi; \
    50  	done
    51  	RUNTIME=$(RUNTIME) $(TAP) $(VALIDATION_TESTS)
    52  
    53  .PHONY: validation-executables
    54  validation-executables: $(VALIDATION_TESTS)
    55  
    56  .PRECIOUS: $(VALIDATION_TESTS)
    57  .PHONY: $(VALIDATION_TESTS)
    58  $(VALIDATION_TESTS): %.t: %.go
    59  	go build -tags "$(BUILDTAGS)" ${TESTFLAGS} -o $@ $<
    60  
    61  print-validation-tests:
    62  	@echo $(VALIDATION_TESTS)
    63  
    64  .PHONY: test .gofmt .govet .golint print-validation-tests
    65  
    66  PACKAGES = $(shell go list ./... | grep -v vendor)
    67  test: .gofmt .govet .golint .gotest
    68  
    69  .gofmt:
    70  	OUT=$$(go fmt $(PACKAGES)); if test -n "$${OUT}"; then echo "$${OUT}" && exit 1; fi
    71  
    72  .govet:
    73  	go vet -x $(PACKAGES)
    74  
    75  .golint:
    76  	golint -set_exit_status $(PACKAGES)
    77  
    78  UTDIRS = ./filepath/... ./validate/... ./generate/...
    79  .gotest:
    80  	go test $(UTDIRS)