-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
98 lines (74 loc) · 2.89 KB
/
Makefile
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
93
94
95
96
97
98
SSHPROXY_VERSION ?= 1.6.2
SSHPROXY_GIT_URL ?= github.com/cea-hpc/sshproxy
prefix ?= /usr
bindir ?= $(prefix)/bin
sbindir ?= $(prefix)/sbin
datarootdir ?= $(prefix)/share
mandir ?= $(datarootdir)/man
bashcompdir ?= /etc/bash_completion.d
GO ?= go
ASCIIDOC_OPTS = -asshproxy_version=$(SSHPROXY_VERSION)
GO_OPTS = $(GO_OPTS_EXTRA) -mod=vendor -ldflags "-X main.SshproxyVersion=$(SSHPROXY_VERSION)"
SSHPROXY_SRC = $(wildcard cmd/sshproxy/*.go)
SSHPROXY_DUMPD_SRC = $(wildcard cmd/sshproxy-dumpd/*.go)
SSHPROXY_REPLAY_SRC = $(wildcard cmd/sshproxy-replay/*.go)
SSHPROXYCTL_SRC = $(wildcard cmd/sshproxyctl/*.go)
RECORD_SRC = $(wildcard pkg/record/*.go)
UTILS_SRC = $(wildcard pkg/utils/*.go)
PKGS = $(shell $(GO) list ./... | grep -v /vendor/)
TEST = test/fedora-image/sshproxy_test.go
EXE = $(addprefix bin/, sshproxy sshproxy-dumpd sshproxy-replay sshproxyctl)
MANDOC = doc/sshproxy.yaml.5 doc/sshproxy.8 doc/sshproxy-dumpd.8 doc/sshproxy-replay.8 doc/sshproxyctl.8
PACKAGE = sshproxy_$(SSHPROXY_VERSION)_$(shell uname -s)_$(shell uname -p)
all: exe doc
exe: $(EXE)
doc: $(MANDOC)
%.5: %.txt
a2x $(ASCIIDOC_OPTS) -f manpage $<
%.8: %.txt
a2x $(ASCIIDOC_OPTS) -f manpage $<
bin/sshproxy: $(SSHPROXY_SRC) $(RECORD_SRC) $(UTILS_SRC)
$(GO) build $(GO_OPTS) -o $@ $(SSHPROXY_GIT_URL)/cmd/sshproxy
bin/sshproxy-dumpd: $(SSHPROXY_DUMPD_SRC) $(RECORD_SRC) $(UTILS_SRC)
$(GO) build $(GO_OPTS) -o $@ $(SSHPROXY_GIT_URL)/cmd/sshproxy-dumpd
bin/sshproxy-replay: $(SSHPROXY_REPLAY_SRC) $(RECORD_SRC)
$(GO) build $(GO_OPTS) -o $@ $(SSHPROXY_GIT_URL)/cmd/sshproxy-replay
bin/sshproxyctl: $(SSHPROXYCTL_SRC) $(UTILS_SRC)
$(GO) build $(GO_OPTS) -o $@ $(SSHPROXY_GIT_URL)/cmd/sshproxyctl
install: install-binaries install-doc-man
install-doc-man: $(MANDOC)
install -d $(DESTDIR)$(mandir)/man5
install -p -m 0644 doc/*.5 $(DESTDIR)$(mandir)/man5
install -d $(DESTDIR)$(mandir)/man8
install -p -m 0644 doc/*.8 $(DESTDIR)$(mandir)/man8
install-binaries: $(EXE)
install -d $(DESTDIR)$(sbindir)
install -p -m 0755 bin/sshproxy $(DESTDIR)$(sbindir)
install -p -m 0755 bin/sshproxy-dumpd $(DESTDIR)$(sbindir)
install -d $(DESTDIR)$(bindir)
install -p -m 0755 bin/sshproxy-replay $(DESTDIR)$(bindir)
install -p -m 0755 bin/sshproxyctl $(DESTDIR)$(bindir)
install -d $(DESTDIR)$(bashcompdir)
install -p -m 0644 misc/sshproxyctl-completion.bash $(DESTDIR)$(bashcompdir)
package: $(EXE)
mkdir $(PACKAGE)
cp $(EXE) $(PACKAGE)
tar cfz $(PACKAGE).tar.gz $(PACKAGE)
rm -f $(PACKAGE)/*
rmdir $(PACKAGE)
fmt:
$(GO) fmt $(PKGS)
$(GO) fmt $(TEST)
get-deps:
$(GO) install honnef.co/go/tools/cmd/staticcheck@latest
check:
$(GO) vet ./...
$(GO) vet $(TEST)
staticcheck ./...
staticcheck $(TEST)
$(GO) test -failfast -race -count=1 -timeout=10s ./...
test:
cd test && bash ./run.sh
clean:
rm -f $(EXE) $(MANDOC) doc/*.xml sshproxy_*.tar.gz
.PHONY: all exe doc install install-doc-man install-binaries package fmt get-deps check test clean