-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
47 lines (38 loc) · 1.23 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
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
LIBDIR := $(PREFIX)/lib
SHRDIR := $(PREFIX)/share
BINS = $(notdir $(wildcard cmd/*))
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
TAG = $(shell git describe --abbrev=0 --tags)
all: build
build: $(BINS)
$(addprefix bin/,$(BINS)): $(SRC)
go build -buildmode=pie -trimpath -o $@ ./cmd/$(@F)
# TODO: Needs to be better written
$(BINS): $(addprefix bin/,$(BINS))
.PHONY: install
install: $(BINS)
@for bin in $(BINS); do \
install -Dm755 "bin/$$bin" -t '$(DESTDIR)$(BINDIR)'; \
done;
@install -dm755 $(DESTDIR)$(LIBDIR)/systemd/system
@install -dm755 $(DESTDIR)$(LIBDIR)/systemd/user
@DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) bin/ssh-tpm-hostkeys --install-system-units
@TEMPLATE_BINARY=$(BINDIR)/ssh-tpm-agent DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) bin/ssh-tpm-agent --install-user-units --install-system
.PHONY: lint
lint:
go vet ./...
staticcheck ./...
.PHONY: test
test:
go test -v ./...
.PHONY: clean
clean:
rm -rf bin/
sign-release:
gh release download $(TAG)
gpg --sign ssh-tpm-agent-$(TAG)-linux-amd64.tar.gz
gpg --sign ssh-tpm-agent-$(TAG)-linux-arm64.tar.gz
gpg --sign ssh-tpm-agent-$(TAG)-linux-arm.tar.gz
bash -c "gh release upload $(TAG) ssh-tpm-agent-$(TAG)*.gpg"