Skip to content

Commit 3017cf4

Browse files
authored
chore: add make install (#52)
chore: make install Signed-off-by: Henry Wang <[email protected]>
1 parent e282c25 commit 3017cf4

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

Makefile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@ GFLAGS ?= --race --randomize-all --randomize-suites
77
BIN = $(PWD)/bin
88
FINCH_DAEMON_PROJECT_ROOT ?= $(shell pwd)
99

10+
# Base path used to install.
11+
PREFIX ?= /usr/local
12+
BINDIR ?= $(PREFIX)/bin
13+
14+
BINARY = $(addprefix bin/,finch-daemon)
15+
1016
.PHONY: build
11-
build::
17+
build:
1218
$(eval PACKAGE := github.com/runfinch/finch-daemon)
1319
$(eval VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags))
1420
$(eval GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi))
1521
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT)")
16-
GOOS=linux go build -ldflags $(LDFLAGS) -v -o bin/finch-daemon $(PACKAGE)/cmd/finch-daemon
22+
GOOS=linux go build -ldflags $(LDFLAGS) -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon
1723

1824
.PHONY: linux
1925
linux:
@@ -23,15 +29,22 @@ endif
2329

2430
.PHONY: start
2531
start: linux build unlink
26-
sudo bin/finch-daemon --debug --socket-owner $${UID}
32+
sudo $(BINARY) --debug --socket-owner $${UID}
2733

2834
DLV=$(BIN)/dlv
2935
$(DLV):
3036
GOBIN=$(BIN) go install github.com/go-delve/delve/cmd/dlv@latest
3137

3238
.PHONY: start-debug
3339
start-debug: linux build $(DLV) unlink
34-
sudo $(DLV) --listen=:2345 --headless=true --api-version=2 exec ./bin/finch-daemon -- --debug --socket-owner $${UID}
40+
sudo $(DLV) --listen=:2345 --headless=true --api-version=2 exec $(BINARY) -- --debug --socket-owner $${UID}
41+
42+
install: linux
43+
install -d $(DESTDIR)$(BINDIR)
44+
install $(BINARY) $(DESTDIR)$(BINDIR)
45+
46+
uninstall:
47+
@rm -f $(addprefix $(DESTDIR)$(BINDIR)/,$(notdir $(BINARY)))
3548

3649
# Unlink the unix socket if the link does not get cleaned up properly (or if finch-daemon is already running)
3750
.PHONY: unlink

finch.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[Unit]
2-
Description=finch daemon %I
2+
Description=finch daemon
33
Documentation=https://runfinch.com
44
After=network.target local-fs.target containerd.service
55
Wants=network.target containerd.service
66

77
[Service]
8-
ExecStart=/usr/local/bin/finch-daemon --debug --socket-owner %i
8+
ExecStart=/usr/local/bin/finch-daemon --debug
99

1010
Type=notify
1111
Delegate=yes

0 commit comments

Comments
 (0)