-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (42 loc) · 1.44 KB
/
Makefile
File metadata and controls
52 lines (42 loc) · 1.44 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
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man/man1
SHELL_PATH = $(BINDIR)/zish
.PHONY: all build install uninstall add-shell remove-shell clean test test-verbose
all: build
build:
zig build --release=safe
install: build
install -d $(DESTDIR)$(BINDIR)
install -d $(DESTDIR)$(MANDIR)
install -m 755 zig-out/bin/zish $(DESTDIR)$(SHELL_PATH)
install -m 644 zish.1 $(DESTDIR)$(MANDIR)/zish.1
@echo "installed zish to $(SHELL_PATH)"
@echo "installed man page to $(MANDIR)/zish.1"
@echo "run 'sudo make add-shell' to add to /etc/shells"
add-shell:
@if ! grep -q "^$(SHELL_PATH)$$" /etc/shells; then \
echo "$(SHELL_PATH)" >> /etc/shells; \
echo "added $(SHELL_PATH) to /etc/shells"; \
else \
echo "$(SHELL_PATH) already in /etc/shells"; \
fi
remove-shell:
@if grep -q "^$(SHELL_PATH)$$" /etc/shells; then \
sed -i "\|^$(SHELL_PATH)$$|d" /etc/shells; \
echo "removed $(SHELL_PATH) from /etc/shells"; \
else \
echo "$(SHELL_PATH) not in /etc/shells"; \
fi
uninstall: remove-shell
rm -f $(DESTDIR)$(SHELL_PATH)
rm -f $(DESTDIR)$(MANDIR)/zish.1
@echo "uninstalled zish"
clean:
rm -rf zig-out .zig-cache
test: build
@command -v shellspec >/dev/null 2>&1 || { echo "shellspec not found. install from: https://shellspec.info"; exit 1; }
shellspec
test-verbose: build
@command -v shellspec >/dev/null 2>&1 || { echo "shellspec not found. install from: https://shellspec.info"; exit 1; }
shellspec --format documentation