@@ -7,13 +7,19 @@ GFLAGS ?= --race --randomize-all --randomize-suites
77BIN = $(PWD ) /bin
88FINCH_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
1925linux :
@@ -23,15 +29,22 @@ endif
2329
2430.PHONY : start
2531start : linux build unlink
26- sudo bin/finch-daemon --debug --socket-owner $$ {UID}
32+ sudo $( BINARY ) --debug --socket-owner $$ {UID}
2733
2834DLV =$(BIN ) /dlv
2935$(DLV ) :
3036 GOBIN=$(BIN ) go install github.com/go-delve/delve/cmd/dlv@latest
3137
3238.PHONY : start-debug
3339start-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
0 commit comments