Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (70 loc) · 2.25 KB
/
Copy pathMakefile
File metadata and controls
92 lines (70 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
export GOPROXY=https://proxy.golang.org
GOBIN := $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN := $(shell go env GOPATH)/bin
endif
# when cross compiling _for_ a Darwin or windows host, then we must use openpgp
BUILD_TAGS_WINDOWS_CROSS = containers_image_openpgp
BUILD_TAGS_DARWIN_CROSS = containers_image_openpgp
SEQUOIA_SONAME_DIR =
BUILDTAGS =
BUILDFLAGS := -tags "$(BUILDTAGS)" -ldflags '-X go.podman.io/image/v5/signature/internal/sequoia.sequoiaLibraryDir='"$(SEQUOIA_SONAME_DIR)"
# Extra flags passed to go test
TESTFLAGS :=
TEST_PACKAGES := ./...
PACKAGES := $(shell go list $(BUILDFLAGS) ./...)
SOURCE_DIRS = $(shell echo $(PACKAGES) | awk 'BEGIN{FS="/"; RS=" "}{print $$4}' | uniq)
PREFIX ?= ${DESTDIR}/usr
MANINSTALLDIR=${PREFIX}/share/man
GOMD2MAN ?= $(shell command -v go-md2man || echo '$(GOBIN)/go-md2man')
MANPAGES_MD = $(wildcard docs/*.5.md)
MANPAGES ?= $(MANPAGES_MD:%.md=%)
ifeq ($(shell uname -s),FreeBSD)
CONTAINERSCONFDIR ?= /usr/local/share/containers
else
CONTAINERSCONFDIR ?= /usr/share/containers
endif
REGISTRIESDDIR ?= ${CONTAINERSCONFDIR}/registries.d
export PATH := $(PATH):${GOBIN}
.PHONY: all
all: test lint
.PHONY: build
build:
go build $(BUILDFLAGS) ./...
$(MANPAGES): %: %.md
$(GOMD2MAN) -in $< -out $@
docs: $(MANPAGES)
.PHONY: install-docs
install-docs: docs
install -d -m 755 ${MANINSTALLDIR}/man5
install -m 644 docs/*.5 ${MANINSTALLDIR}/man5/
.PHONY: install
install: install-docs
install -d -m 755 ${DESTDIR}${CONTAINERSCONFDIR}
install -m 644 default-policy.json ${DESTDIR}${CONTAINERSCONFDIR}/policy.json
install -d -m 755 ${DESTDIR}${REGISTRIESDDIR}
install -m 644 default.yaml ${DESTDIR}${REGISTRIESDDIR}/default.yaml
.PHONY: cross
cross:
GOOS=windows $(MAKE) build BUILDTAGS="$(BUILDTAGS) $(BUILD_TAGS_WINDOWS_CROSS)"
GOOS=darwin $(MAKE) build BUILDTAGS="$(BUILDTAGS) $(BUILD_TAGS_DARWIN_CROSS)"
.PHONY: clean
clean:
rm -rf $(MANPAGES)
.PHONY: test
test:
@go test $(BUILDFLAGS) $(TESTFLAGS) -cover $(TEST_PACKAGES)
.PHONY: fmt
fmt:
golangci-lint fmt
.PHONY: lint
lint:
golangci-lint run --build-tags "$(BUILDTAGS)"
.PHONY: tidy-in-container
tidy-in-container:
podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src golang make tidy
.PHONY: tidy
tidy:
go mod tidy
go mod verify
go mod edit -toolchain none