Debian Codegraph @

Makefile

raw symbols SCIP
1 PREFIX ?= $(DESTDIR)/usr
2 BINDIR ?= $(DESTDIR)/usr/bin
3
4 COMMIT=$(shell git rev-parse HEAD 2> /dev/null || true)
5 EPOCH_TEST_COMMIT ?= $(shell git tag | tail -1)
6
7 default: all
8
9 help:
10 @echo "Usage: make <target>"
11 @echo
12 @echo " * 'all' - Build the oci tool and manual pages"
13 @echo " * 'tool' - Build the oci tool"
14 @echo " * 'install' - Install binaries and manual pages"
15 @echo " * 'install.tools' - Install tool needed for building this project"
16 @echo " * 'uninstall' - Remove the oci tool and manual pages"
17 @echo " * 'man' - Build the oci image manual pages"
18 @echo " * 'check-license' - Check license headers in source files"
19 @echo " * 'lint' - Execute the source code linter"
20 @echo " * 'test' - Execute the unit tests"
21 @echo " * 'update-deps' - Update vendored dependencies"
22 @echo " * 'clean' - clean existing build artifacts"
23
24 check-license:
25 @echo "checking license headers"
26 @./.tool/check-license
27
28 .PHONY: tool
29 tool:
30 go build -ldflags "-X main.gitCommit=${COMMIT}" -o oci-image-tool ./cmd/oci-image-tool
31
32
33 all: tool man
34
35 .PHONY: man
36 man:
37 go-md2man -in "man/oci-image-tool.1.md" -out "oci-image-tool.1"
38 go-md2man -in "man/oci-image-tool-create.1.md" -out "oci-image-tool-create.1"
39 go-md2man -in "man/oci-image-tool-unpack.1.md" -out "oci-image-tool-unpack.1"
40 go-md2man -in "man/oci-image-tool-validate.1.md" -out "oci-image-tool-validate.1"
41
42
43 install: man
44 install -d -m 755 $(BINDIR)
45 install -m 755 oci-image-tool $(BINDIR)
46 install -d -m 755 $(PREFIX)/share/man/man1
47 install -m 644 *.1 $(PREFIX)/share/man/man1
48 install -d -m 755 $(PREFIX)/share/bash-completion/completions
49 install -m 644 completions/bash/oci-image-tool $(PREFIX)/share/bash-completion/completions
50
51 uninstall:
52 rm -f $(BINDIR)/oci-image-tool
53 rm -f $(PREFIX)/share/man/man1/oci-image-tool*.1
54 rm -f $(PREFIX)/share/bash-completion/completions/oci-image-tool
55
56 lint:
57 @echo "checking lint"
58 @./.tool/lint
59
60 .PHONY: .gofmt .govet .gotest
61
62 PACKAGES = $(shell go list ./... | grep -v /vendor/)
63 test: .gofmt .govet .gotest
64
65 FILES = $(shell find ./ -name *.go | grep -v vendor)
66 .gofmt:
67 OUT=$$(gofmt -s -d $(FILES)); if test -n "$${OUT}"; then echo "$${OUT}" && exit 1; fi
68
69 .govet:
70 go vet -x $(PACKAGES)
71
72 .gotest:
73 go test -v -race -cover $(PACKAGES)
74
75
76 ## this uses https://github.com/Masterminds/glide and https://github.com/sgotti/glide-vc
77 update-deps:
78 @which glide > /dev/null 2>/dev/null || (echo "ERROR: glide not found. Consider 'make install.tools' target" && false)
79 glide update --strip-vcs --strip-vendor --update-vendored --delete
80 glide-vc --only-code --no-tests
81 # see http://sed.sourceforge.net/sed1line.txt
82 find vendor -type f -exec sed -i -e :a -e '/^\n*$$/{$$d;N;ba' -e '}' "{}" \;
83
84 .PHONY: .gitvalidation
85
86 # When this is running in travis, it will only check the travis commit range
87 .gitvalidation:
88 @which git-validation > /dev/null 2>/dev/null || (echo "ERROR: git-validation not found. Consider 'make install.tools' target" && false)
89 ifeq ($(TRAVIS),true)
90 git-validation -q -run DCO,short-subject,dangling-whitespace
91 else
92 git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
93 endif
94
95 .PHONY: install.tools
96
97 install.tools: .install.gitvalidation .install.glide .install.glide-vc .install.gometalinter .install.go-md2man
98
99 .install.gitvalidation:
100 go get github.com/vbatts/git-validation
101
102 .install.glide:
103 go get github.com/Masterminds/glide
104
105 .install.glide-vc:
106 go get github.com/sgotti/glide-vc
107
108 .install.gometalinter:
109 go get github.com/alecthomas/gometalinter
110 gometalinter --install --update
111
112 .install.go-md2man:
113 go get github.com/cpuguy83/go-md2man
114
115 clean:
116 rm -rf oci-image-tool *.1
117
118 .PHONY: \
119 all \
120 tool \
121 man \
122 install \
123 uninstall \
124 check-license \
125 clean \
126 lint \
127 test