-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (49 loc) · 1.8 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
PKGS := $(shell go list ./... | grep -v /vendor)
SYSTEMD_FILENAME := [email protected]
SYSTEMD_SOURCE_DIR := systemd/
SYSTEMD_SOURCE_PATH := $(SYSTEMD_SOURCE_DIR)$(SYSTEMD_FILENAME)
SYSTEMD_TARGET_DIR := /usr/lib/systemd/system/
SYSTEMD_TARGET_PATH := $(SYSTEMD_TARGET_DIR)$(SYSTEMD_FILENAME)
BIN_FILENAME := skbl
BIN_SOURCE_DIR := bin/
BIN_SOURCE_PATH := $(BIN_SOURCE_DIR)$(BIN_FILENAME)
BIN_TARGET_DIR := /usr/bin/
BIN_TARGET_PATH := $(BIN_TARGET_DIR)$(BIN_FILENAME)
CONFIG_FILENAME := config.toml
CONFIG_SOURCE_DIR := ./
CONFIG_SOURCE_PATH := $(CONFIG_SOURCE_DIR)$(CONFIG_FILENAME)
CONFIG_TARGET_DIR := /etc/skbl/
CONFIG_TARGET_PATH := $(CONFIG_TARGET_DIR)$(CONFIG_FILENAME)
CONFIG_HOME_TARGET_DIR := $(HOME)/.skbl/
CONFIG_HOME_TARGET_PATH := $(CONFIG_HOME_TARGET_DIR)$(CONFIG_FILENAME)
.PHONY: test
test:
go test $(PKGS)
.PHONY: build
build:
go build -o $(BIN_SOURCE_PATH)
.PHONY: clean
clean:
rm -rf bin/
.PHONY: install
install: $(BIN_TARGET_PATH) $(SYSTEMD_TARGET_PATH) config_dir $(CONFIG_TARGET_PATH)
sudo usermod -aG input $(USER)
sudo systemctl daemon-reload
$(BIN_TARGET_PATH): build
sudo cp -f $(BIN_SOURCE_PATH) $(BIN_TARGET_DIR)
$(SYSTEMD_TARGET_PATH): $(SYSTEMD_SOURCE_PATH)
sudo cp -f $(SYSTEMD_SOURCE_PATH) $(SYSTEMD_TARGET_DIR)
.PHONY: config-dir
config_dir:
sudo mkdir -p $(CONFIG_TARGET_DIR)
mkdir -p $(CONFIG_HOME_TARGET_DIR)
test -f $(CONFIG_HOME_TARGET_PATH) || cp $(CONFIG_SOURCE_PATH) $(CONFIG_HOME_TARGET_DIR)
$(CONFIG_TARGET_PATH): $(CONFIG_SOURCE_PATH)
sudo cp -f $(CONFIG_SOURCE_PATH) $(CONFIG_TARGET_DIR)
sudo chmod 664 $(SYSTEMD_TARGET_PATH)
.PHONY: uninstall
uninstall:
test -f $(SYSTEMD_TARGET_PATH) && sudo rm $(SYSTEMD_TARGET_PATH)
test -d $(CONFIG_TARGET_DIR) && sudo rm -r $(CONFIG_TARGET_DIR)
test -f $(BIN_TARGET_PATH) && sudo rm $(BIN_TARGET_PATH)
sudo systemctl daemon-reload