-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMakefile
64 lines (53 loc) · 1.67 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
GO = /usr/bin/go
INSTALLPATH ?= /usr/local/bin
SERVICEPATH ?= $(HOME)/.config/systemd/user
CONFIGPATH ?= $(HOME)/.config/mouseless
service = mouseless.service
config = config.yaml
example_config = ./example_configs/config_full.yaml
binary = mouseless
clean:
-rm --force $(binary)
debug:
@echo "# Stopping the service"
-systemctl --user stop $(service)
@echo ""
@echo "# Run $(binary)"
@echo "# config path: $(CONFIGPATH)/$(config)"
$(GO) run . --config $(CONFIGPATH)/$(config) --debug
@echo "################"
install:
@echo "# Stopping and disabling the service"
-systemctl --user disable --now $(service)
@echo ""
@echo "# Copying application to $(INSTALLPATH)"
@echo "# This action requires sudo."
@echo 'go build -ldflags="-s -w"'
$(GO) build -ldflags="-s -w" .
sudo cp --force $(binary) $(INSTALLPATH)
sudo chmod u+s $(INSTALLPATH)/$(binary)
@echo ""
@echo "# Copying service file to $(SERVICEPATH)"
mkdir --parents $(SERVICEPATH)
cp --force $(service) $(SERVICEPATH)
@echo ""
@echo "# Copying default configuration file to $(CONFIGPATH)/$(config)"
mkdir --parents $(CONFIGPATH)
-cp --no-clobber $(example_config) $(CONFIGPATH)/$(config)
@echo ""
@echo "# Enabling and starting the service"
systemctl --user daemon-reload
systemctl --user enable --now $(service)
uninstall:
@echo "# Stopping and disabling the service"
-systemctl --user disable --now $(service)
systemctl --user daemon-reload
@echo ""
@echo "# Removing service file from $(SERVICEPATH)"
-rm $(SERVICEPATH)/$(service)
-rm --dir $(SERVICEPATH)
@echo ""
@echo "# Removing application from $(INSTALLPATH)"
@echo "# This action requires sudo."
-sudo rm $(INSTALLPATH)/$(binary)
@echo ""