-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Makefile
73 lines (62 loc) · 1.88 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
65
66
67
68
69
70
71
72
73
prog := angryoxide
bash_completion_script := completions/bash_angryoxide_completions
zsh_completion_script := completions/zsh_angryoxide_completions
debug ?=
ifdef debug
release :=
target := debug
extension := debug
else
release := --release
target := release
extension :=
endif
BASH_COMPLETION_DIR := /etc/bash_completion.d
ZSH_COMPLETION_DIR := /home
build:
cargo build $(release)
check-root:
@if [ "$$(id -u)" -ne 0 ]; then \
echo "This operation must be run as root. Please use sudo." >&2; \
exit 1; \
fi
install-binary: check-root
cp target/$(target)/$(prog) /usr/bin/$(prog)
install-bash: check-root
@if [ -x "$$(command -v bash)" ]; then \
echo "Installing bash completion for $(prog)..."; \
mkdir -p $(BASH_COMPLETION_DIR); \
cp $(bash_completion_script) $(BASH_COMPLETION_DIR)/$(prog); \
echo "Bash completion installed successfully."; \
else \
echo "Bash not found, skipping Bash completion installation."; \
fi
install-zsh: check-root
@if [ -x "$$(command -v zsh)" ]; then \
echo "Installing zsh completion for $(prog) for all users..."; \
for dir in $(ZSH_COMPLETION_DIR)/*; do \
if [ -d "$$dir" ]; then \
user=$$(basename $$dir); \
zsh_dir="$$dir/.zsh/completion"; \
echo "Installing for user $$user..."; \
mkdir -p $$zsh_dir; \
cp $(zsh_completion_script) $$zsh_dir/_$(prog); \
chown $$user:$$user $$zsh_dir/_$(prog); \
fi \
done; \
echo "Zsh completion installed successfully for all users."; \
else \
echo "Zsh not found, skipping Zsh completion installation."; \
fi
install: install-binary install-bash install-zsh
help:
@echo "usage: make [debug=1]"
uninstall:
rm -f /usr/bin/$(prog)
@rm -f $(BASH_COMPLETION_DIR)/$(prog)
@for dir in $(ZSH_COMPLETION_DIR)/*; do \
if [ -d "$$dir" ]; then \
rm -f "$$dir/.zsh/completion/_$(prog)"; \
fi \
done; \
echo "Cleaned installed binary and completion scripts."