-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
64 lines (52 loc) · 1.84 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
BIN := yubikey-touch-detector
VERSION := $(shell sed -nr 's/const appVersion\s*=\s*"(.*)"/\1/p' main.go)
PREFIX ?= /usr
LIB_DIR = $(DESTDIR)$(PREFIX)/lib
BIN_DIR = $(DESTDIR)$(PREFIX)/bin
SHARE_DIR = $(DESTDIR)$(PREFIX)/share
export CGO_CPPFLAGS := ${CPPFLAGS}
export CGO_CFLAGS := ${CFLAGS}
export CGO_CXXFLAGS := ${CXXFLAGS}
export CGO_LDFLAGS := ${LDFLAGS}
export GOFLAGS := -buildmode=pie -trimpath -ldflags=-linkmode=external
.PHONY: run
run: build
./$(BIN)
.PHONY: build
build: main.go detector/ notifier/
go build -o $(BIN) main.go
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
.PHONY: clean
clean:
rm -f "$(BIN)"
rm -rf dist
rm -rf vendor
.PHONY: dist
dist: clean vendor build
$(eval TMP := $(shell mktemp -d))
mkdir "$(TMP)/$(BIN)-$(VERSION)"
cp -r * "$(TMP)/$(BIN)-$(VERSION)"
(cd "$(TMP)" && tar -cvzf "$(BIN)-$(VERSION)-src.tar.gz" "$(BIN)-$(VERSION)")
mkdir "$(TMP)/$(BIN)-$(VERSION)-linux64"
cp "$(BIN)" "$(BIN).service" "$(BIN).socket" LICENSE README.md "$(TMP)/$(BIN)-$(VERSION)-linux64"
(cd "$(TMP)" && tar -cvzf "$(BIN)-$(VERSION)-linux64.tar.gz" "$(BIN)-$(VERSION)-linux64")
mkdir -p dist
mv "$(TMP)/$(BIN)-$(VERSION)"-*.tar.gz dist
git archive -o "dist/$(BIN)-$(VERSION).tar.gz" --format tar.gz --prefix "$(BIN)-$(VERSION)/" "$(VERSION)"
for file in dist/*; do \
gpg --detach-sign --armor "$$file"; \
done
rm -rf "$(TMP)"
rm -f "dist/$(BIN)-$(VERSION).tar.gz"
.PHONY: install
install:
install -Dm755 -t "$(BIN_DIR)/" $(BIN)
install -Dm644 -t "$(LIB_DIR)/systemd/user" "$(BIN).service"
install -Dm644 -t "$(LIB_DIR)/systemd/user" "$(BIN).socket"
install -Dm644 -t "$(SHARE_DIR)/icons/hicolor/128x128/apps/" yubikey-touch-detector.png
install -Dm644 -t "$(SHARE_DIR)/licenses/$(BIN)/" LICENSE
install -Dm644 -t "$(SHARE_DIR)/doc/$(BIN)/" README.md
install -Dm644 -t "$(SHARE_DIR)/doc/$(BIN)/" service.conf.example