Debian Codegraph @

Makefile

raw symbols SCIP
1 FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH)))
2 PKGS := $(shell go list ./... | grep -v /tests | grep -v /xcpb | grep -v /gpb)
3 PKGSWIN := $(shell go list ./... | grep -v /tests | grep -v /xcpb | grep -v /gpb | grep -v "jsonapi")
4 GOFILES_NOVENDOR := $(shell find . -name vendor -prune -o -type f -name '*.go' -not -name '*.pb.go' -print)
5 GOFILES_BUILD := $(shell find . -type f -name '*.go' -not -name '*_test.go')
6 PROTOFILES := $(shell find . -name vendor -prune -o -type f -name '*.proto' -print)
7 GOPASS_VERSION ?= $(shell cat VERSION)
8 GOPASS_OUTPUT ?= gopass-hibp
9 GOPASS_REVISION := $(shell cat COMMIT 2>/dev/null || git rev-parse --short=8 HEAD)
10 # Support reproducible builds by embedding date according to SOURCE_DATE_EPOCH if present
11 DATE := $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" '+%FT%T%z' 2>/dev/null || date -u '+%FT%T%z')
12 BUILDFLAGS_NOPIE := -trimpath -ldflags="-s -w -X main.version=$(GOPASS_VERSION) -X main.commit=$(GOPASS_REVISION) -X main.date=$(DATE)" -gcflags="-trimpath=$(GOPATH)" -asmflags="-trimpath=$(GOPATH)"
13 BUILDFLAGS ?= $(BUILDFLAGS_NOPIE) -buildmode=pie
14 TESTFLAGS ?=
15 PWD := $(shell pwd)
16 PREFIX ?= $(GOPATH)
17 BINDIR ?= $(PREFIX)/bin
18 GO := GO111MODULE=on go
19 GOOS ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f1)
20 GOARCH ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f2)
21 TAGS ?= netgo
22 export GO111MODULE=on
23
24 OK := $(shell tput setaf 6; echo ' [OK]'; tput sgr0;)
25
26 all: build
27 build: $(GOPASS_OUTPUT)
28 gha-linux: sysinfo crosscompile build test
29 gha-osx: sysinfo build test
30 gha-windows: sysinfo build test
31
32 sysinfo:
33 @echo ">> SYSTEM INFORMATION"
34 @echo -n " PLATFORM: $(shell uname -a)"
35 @printf '%s\n' '$(OK)'
36 @echo -n " PWD: : $(shell pwd)"
37 @printf '%s\n' '$(OK)'
38 @echo -n " GO : $(shell go version)"
39 @printf '%s\n' '$(OK)'
40 @echo -n " BUILDFLAGS: $(BUILDFLAGS)"
41 @printf '%s\n' '$(OK)'
42 @echo -n " GIT : $(shell git version)"
43 @printf '%s\n' '$(OK)'
44 @echo -n " GPG1 : $(shell which gpg) $(shell gpg --version | head -1)"
45 @printf '%s\n' '$(OK)'
46 @echo -n " GPG2 : $(shell which gpg2) $(shell gpg2 --version | head -1)"
47 @printf '%s\n' '$(OK)'
48 @echo -n " GPG-Agent : $(shell which gpg-agent) $(shell gpg-agent --version | head -1)"
49 @printf '%s\n' '$(OK)'
50
51 clean:
52 @echo -n ">> CLEAN"
53 @$(GO) clean -i ./...
54 @rm -f ./coverage-all.html
55 @rm -f ./coverage-all.out
56 @rm -f ./coverage.out
57 @find . -type f -name "coverage.out" -delete
58 @rm -f gopass_*.deb
59 @rm -f gopass-*.pkg.tar.xz
60 @rm -f gopass-*.rpm
61 @rm -f gopass-*.tar.bz2
62 @rm -f gopass-*.tar.gz
63 @rm -f gopass-*-*
64 @rm -f tests/tests
65 @rm -f *.test
66 @rm -rf dist/*
67 @rm -f *.completion
68 @printf '%s\n' '$(OK)'
69
70 $(GOPASS_OUTPUT): $(GOFILES_BUILD)
71 @echo -n ">> BUILD, version = $(GOPASS_VERSION)/$(GOPASS_REVISION), output = $@"
72 @$(GO) build -o $@ $(BUILDFLAGS)
73 @printf '%s\n' '$(OK)'
74
75 install: all
76 @echo -n ">> INSTALL, version = $(GOPASS_VERSION)"
77 @install -m 0755 -d $(DESTDIR)$(BINDIR)
78 @install -m 0755 $(GOPASS_OUTPUT) $(DESTDIR)$(BINDIR)/$(GOPASS_OUTPUT)
79 @printf '%s\n' '$(OK)'
80
81 test: $(GOPASS_OUTPUT)
82 @echo ">> TEST, \"fast-mode\": race detector off"
83 @$(foreach pkg, $(PKGS),\
84 echo -n " ";\
85 $(GO) test -test.short -run '(Test|Example)' $(BUILDFLAGS) $(TESTFLAGS) $(pkg) || exit 1;)
86
87 crosscompile:
88 @echo -n ">> CROSSCOMPILE linux/amd64"
89 @GOOS=linux GOARCH=amd64 $(GO) build -o $(GOPASS_OUTPUT)-linux-amd64
90 @printf '%s\n' '$(OK)'
91 @echo -n ">> CROSSCOMPILE darwin/amd64"
92 @GOOS=darwin GOARCH=amd64 $(GO) build -o $(GOPASS_OUTPUT)-darwin-amd64
93 @printf '%s\n' '$(OK)'
94 @echo -n ">> CROSSCOMPILE windows/amd64"
95 @GOOS=windows GOARCH=amd64 $(GO) build -o $(GOPASS_OUTPUT)-windows-amd64
96 @printf '%s\n' '$(OK)'
97
98 full:
99 @echo -n ">> COMPILE linux/amd64 xc"
100 $(GO) build -o $(GOPASS_OUTPUT)-full
101
102 codequality:
103 @echo ">> CODE QUALITY"
104
105 @echo -n " GOLANGCI-LINT "
106 @which golangci-lint > /dev/null; if [ $$? -ne 0 ]; then \
107 $(GO) install github.com/golangci/golangci-lint/v2/cmd/[email protected]; \
108 fi
109 @golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 || exit 1
110
111 @printf '%s\n' '$(OK)'
112
113 gen:
114 @$(GO) generate ./...
115
116 fmt:
117 @gofumpt -s -l -w $(GOFILES_NOVENDOR)
118 @gci write $(GOFILES_NOVENDOR)
119 @$(GO) mod tidy
120
121 deps:
122 @$(GO) build -v ./...
123
124 upgrade: gen fmt
125 @$(GO) get -u ./...
126 @$(GO) mod tidy
127
128 .PHONY: clean build completion install sysinfo crosscompile test codequality release goreleaser debsign