-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
68 lines (56 loc) · 1.79 KB
/
makefile
File metadata and controls
68 lines (56 loc) · 1.79 KB
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
65
66
67
68
BINARY_NAME=barghman
CONFIG_PATH=$(HOME)/.config/barghman
SYSTEMD_PATH=$(HOME)/.config/systemd/user
CACHE_PATH=$(HOME)/.cache/barghman
BIN_PATH=$(HOME)/.local/bin
MAN_PATH=$(HOME)/.local/share/man/man1
.PHONY: build
build:
go build -o $(BINARY_NAME) ./...
.PHONY: install
install: build
mkdir -p $(CONFIG_PATH)
mkdir -p $(SYSTEMD_PATH)
mkdir -p $(CACHE_PATH)
mkdir -p $(BIN_PATH)
mkdir -p $(MAN_PATH)
cp $(BINARY_NAME) $(BIN_PATH)
chmod +x $(BIN_PATH)/$(BINARY_NAME)
cp man/$(BINARY_NAME).1 $(MAN_PATH)/
gzip -f $(MAN_PATH)/$(BINARY_NAME).1
@if [ ! -f $(CONFIG_PATH)/config.toml ]; then \
echo "Config file not exists, creating it from example"; \
cp example.toml $(CONFIG_PATH)/config.toml; \
else \
echo "Config exists, skipping: $(CONFIG_PATH)/config.toml"; \
fi
@sed -e "s|{{INSTALL_PATH}}|$(BIN_PATH)|g" \
-e "s|{{CONFIG_PATH}}|$(CONFIG_PATH)|g" \
-e "s|{{CACHE_PATH}}|$(CACHE_PATH)|g" \
systemd/$(BINARY_NAME).service.template > $(SYSTEMD_PATH)/$(BINARY_NAME).service
@echo "barghman sucessfully installed on your computer!"
@echo "update your configuration on ${CONFIG_PATH}"
.PHONY: uninstall
uninstall:
systemctl --user disable $(BINARY_NAME).service || true
rm -f $(SYSTEMD_PATH)/$(BINARY_NAME).service
rm -f $(BIN_PATH)/$(BINARY_NAME)
rm -rf $(CONFIG_PATH)
rm -rf $(CACHE_PATH)
rm -f $(BINARY_NAME)
rm -f $(MAN_PATH)/$(BINARY_NAME).1.gz
.PHONY: clean
clean:
rm -f $(BINARY_NAME)
rm -rf $(CACHE_PATH)
.PHONY: releaser
releaser:
goreleaser release --snapshot --clean
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the binary"
@echo " install - Build and install the service"
@echo " uninstall - Remove the service, binary"
@echo " releaser - Generate release files"
@echo " clean - Remove build artifacts and cache"